From a78865c91fd84912f4664dc736bfbcfa04fff328 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Fri, 15 Mar 2024 21:07:54 +0000 Subject: [PATCH 01/90] Prepare migration --- .gitignore | 3 +++ .../todo}/grib_accessor_class_abstract_long_vector.cc | 0 src/{ => accessor/todo}/grib_accessor_class_abstract_vector.cc | 0 src/{ => accessor/todo}/grib_accessor_class_ascii.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bit.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bitmap.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bits.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bits_per_value.cc | 0 src/{ => accessor/todo}/grib_accessor_class_blob.cc | 0 src/{ => accessor/todo}/grib_accessor_class_budgdate.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bufr_data_array.cc | 0 .../todo}/grib_accessor_class_bufr_data_element.cc | 0 .../todo}/grib_accessor_class_bufr_elements_table.cc | 0 .../todo}/grib_accessor_class_bufr_extract_area_subsets.cc | 0 .../todo}/grib_accessor_class_bufr_extract_datetime_subsets.cc | 0 .../todo}/grib_accessor_class_bufr_extract_subsets.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bufr_group.cc | 0 .../todo}/grib_accessor_class_bufr_simple_thinning.cc | 0 .../todo}/grib_accessor_class_bufr_string_values.cc | 0 .../todo}/grib_accessor_class_bufrdc_expanded_descriptors.cc | 0 src/{ => accessor/todo}/grib_accessor_class_bytes.cc | 0 .../grib_accessor_class_change_alternative_row_scanning.cc | 0 .../todo}/grib_accessor_class_change_scanning_direction.cc | 0 .../todo}/grib_accessor_class_check_internal_version.cc | 0 src/{ => accessor/todo}/grib_accessor_class_closest_date.cc | 0 src/{ => accessor/todo}/grib_accessor_class_codeflag.cc | 0 src/{ => accessor/todo}/grib_accessor_class_codetable.cc | 0 src/{ => accessor/todo}/grib_accessor_class_codetable_title.cc | 0 src/{ => accessor/todo}/grib_accessor_class_codetable_units.cc | 0 src/{ => accessor/todo}/grib_accessor_class_concept.cc | 0 src/{ => accessor/todo}/grib_accessor_class_constant.cc | 0 src/{ => accessor/todo}/grib_accessor_class_count_file.cc | 0 src/{ => accessor/todo}/grib_accessor_class_count_missing.cc | 0 src/{ => accessor/todo}/grib_accessor_class_count_total.cc | 0 .../todo}/grib_accessor_class_data_apply_bitmap.cc | 0 .../todo}/grib_accessor_class_data_apply_boustrophedonic.cc | 0 .../grib_accessor_class_data_apply_boustrophedonic_bitmap.cc | 0 .../todo}/grib_accessor_class_data_ccsds_packing.cc | 0 .../todo}/grib_accessor_class_data_complex_packing.cc | 0 .../todo}/grib_accessor_class_data_dummy_field.cc | 0 .../todo}/grib_accessor_class_data_g1complex_packing.cc | 0 ...ccessor_class_data_g1second_order_constant_width_packing.cc | 0 ...essor_class_data_g1second_order_general_extended_packing.cc | 0 .../grib_accessor_class_data_g1second_order_general_packing.cc | 0 ...ib_accessor_class_data_g1second_order_row_by_row_packing.cc | 0 .../todo}/grib_accessor_class_data_g1secondary_bitmap.cc | 0 .../todo}/grib_accessor_class_data_g1shsimple_packing.cc | 0 .../todo}/grib_accessor_class_data_g1simple_packing.cc | 0 .../todo}/grib_accessor_class_data_g22order_packing.cc | 0 .../todo}/grib_accessor_class_data_g2bifourier_packing.cc | 0 .../todo}/grib_accessor_class_data_g2complex_packing.cc | 0 .../todo}/grib_accessor_class_data_g2secondary_bitmap.cc | 0 .../todo}/grib_accessor_class_data_g2shsimple_packing.cc | 0 .../todo}/grib_accessor_class_data_g2simple_packing.cc | 0 ..._accessor_class_data_g2simple_packing_with_preprocessing.cc | 0 .../todo}/grib_accessor_class_data_jpeg2000_packing.cc | 0 .../todo}/grib_accessor_class_data_png_packing.cc | 0 .../todo}/grib_accessor_class_data_raw_packing.cc | 0 .../todo}/grib_accessor_class_data_run_length_packing.cc | 0 .../todo}/grib_accessor_class_data_secondary_bitmap.cc | 0 src/{ => accessor/todo}/grib_accessor_class_data_sh_packed.cc | 0 .../todo}/grib_accessor_class_data_sh_unpacked.cc | 0 .../todo}/grib_accessor_class_data_shsimple_packing.cc | 0 .../todo}/grib_accessor_class_data_simple_packing.cc | 0 .../todo}/grib_accessor_class_decimal_precision.cc | 0 src/{ => accessor/todo}/grib_accessor_class_dictionary.cc | 0 src/{ => accessor/todo}/grib_accessor_class_dirty.cc | 0 src/{ => accessor/todo}/grib_accessor_class_divdouble.cc | 0 src/{ => accessor/todo}/grib_accessor_class_double.cc | 0 src/{ => accessor/todo}/grib_accessor_class_element.cc | 0 src/{ => accessor/todo}/grib_accessor_class_evaluate.cc | 0 .../todo}/grib_accessor_class_expanded_descriptors.cc | 0 .../grib_accessor_class_from_scale_factor_scaled_value.cc | 0 .../todo}/grib_accessor_class_g1_half_byte_codeflag.cc | 0 .../todo}/grib_accessor_class_g1_message_length.cc | 0 .../todo}/grib_accessor_class_g1_section4_length.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1bitmap.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1date.cc | 0 .../todo}/grib_accessor_class_g1day_of_the_year_date.cc | 0 .../todo}/grib_accessor_class_g1end_of_interval_monthly.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1fcperiod.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1forecastmonth.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1monthlydate.cc | 0 .../grib_accessor_class_g1number_of_coded_values_sh_complex.cc | 0 .../grib_accessor_class_g1number_of_coded_values_sh_simple.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g1step_range.cc | 0 .../todo}/grib_accessor_class_g1verificationdate.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2_aerosol.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2_chemical.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2_eps.cc | 0 .../todo}/grib_accessor_class_g2_mars_labeling.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2bitmap.cc | 0 .../todo}/grib_accessor_class_g2bitmap_present.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2date.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2end_step.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2grid.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2latlon.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2level.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2lon.cc | 0 src/{ => accessor/todo}/grib_accessor_class_g2step_range.cc | 0 .../todo}/grib_accessor_class_gaussian_grid_name.cc | 0 src/{ => accessor/todo}/grib_accessor_class_gds_is_present.cc | 0 .../todo}/grib_accessor_class_gds_not_present_bitmap.cc | 0 src/{ => accessor/todo}/grib_accessor_class_gen.cc | 0 src/{ => accessor/todo}/grib_accessor_class_getenv.cc | 0 src/{ => accessor/todo}/grib_accessor_class_global_gaussian.cc | 0 src/{ => accessor/todo}/grib_accessor_class_group.cc | 0 src/{ => accessor/todo}/grib_accessor_class_gts_header.cc | 0 src/{ => accessor/todo}/grib_accessor_class_hash_array.cc | 0 src/{ => accessor/todo}/grib_accessor_class_headers_only.cc | 0 src/{ => accessor/todo}/grib_accessor_class_ibmfloat.cc | 0 src/{ => accessor/todo}/grib_accessor_class_ieeefloat.cc | 0 src/{ => accessor/todo}/grib_accessor_class_ifs_param.cc | 0 src/{ => accessor/todo}/grib_accessor_class_iterator.cc | 0 src/{ => accessor/todo}/grib_accessor_class_julian_date.cc | 0 src/{ => accessor/todo}/grib_accessor_class_julian_day.cc | 0 src/{ => accessor/todo}/grib_accessor_class_ksec1expver.cc | 0 src/{ => accessor/todo}/grib_accessor_class_label.cc | 0 src/{ => accessor/todo}/grib_accessor_class_latitudes.cc | 0 .../todo}/grib_accessor_class_latlon_increment.cc | 0 src/{ => accessor/todo}/grib_accessor_class_latlonvalues.cc | 0 src/{ => accessor/todo}/grib_accessor_class_library_version.cc | 0 .../todo}/grib_accessor_class_local_definition.cc | 0 src/{ => accessor/todo}/grib_accessor_class_long.cc | 0 src/{ => accessor/todo}/grib_accessor_class_long_vector.cc | 0 src/{ => accessor/todo}/grib_accessor_class_longitudes.cc | 0 src/{ => accessor/todo}/grib_accessor_class_lookup.cc | 0 src/{ => accessor/todo}/grib_accessor_class_mars_param.cc | 0 src/{ => accessor/todo}/grib_accessor_class_mars_step.cc | 0 src/{ => accessor/todo}/grib_accessor_class_md5.cc | 0 src/{ => accessor/todo}/grib_accessor_class_message.cc | 0 src/{ => accessor/todo}/grib_accessor_class_message_copy.cc | 0 src/{ => accessor/todo}/grib_accessor_class_multdouble.cc | 0 src/{ => accessor/todo}/grib_accessor_class_nearest.cc | 0 src/{ => accessor/todo}/grib_accessor_class_non_alpha.cc | 0 .../todo}/grib_accessor_class_number_of_coded_values.cc | 0 .../todo}/grib_accessor_class_number_of_points.cc | 0 .../todo}/grib_accessor_class_number_of_points_gaussian.cc | 0 .../todo}/grib_accessor_class_number_of_values.cc | 0 .../grib_accessor_class_number_of_values_data_raw_packing.cc | 0 .../todo}/grib_accessor_class_octahedral_gaussian.cc | 0 src/{ => accessor/todo}/grib_accessor_class_octet_number.cc | 0 src/{ => accessor/todo}/grib_accessor_class_offset_file.cc | 0 src/{ => accessor/todo}/grib_accessor_class_offset_values.cc | 0 .../todo}/grib_accessor_class_optimal_step_units.cc | 0 .../todo}/grib_accessor_class_pack_bufr_values.cc | 0 src/{ => accessor/todo}/grib_accessor_class_packing_type.cc | 0 src/{ => accessor/todo}/grib_accessor_class_pad.cc | 0 src/{ => accessor/todo}/grib_accessor_class_padding.cc | 0 src/{ => accessor/todo}/grib_accessor_class_padto.cc | 0 src/{ => accessor/todo}/grib_accessor_class_padtoeven.cc | 0 src/{ => accessor/todo}/grib_accessor_class_padtomultiple.cc | 0 src/{ => accessor/todo}/grib_accessor_class_position.cc | 0 src/{ => accessor/todo}/grib_accessor_class_proj_string.cc | 0 src/{ => accessor/todo}/grib_accessor_class_raw.cc | 0 .../todo}/grib_accessor_class_rdbtime_guess_date.cc | 0 .../todo}/grib_accessor_class_reference_value_error.cc | 0 src/{ => accessor/todo}/grib_accessor_class_round.cc | 0 src/{ => accessor/todo}/grib_accessor_class_scale.cc | 0 src/{ => accessor/todo}/grib_accessor_class_scale_values.cc | 0 .../todo}/grib_accessor_class_second_order_bits_per_value.cc | 0 src/{ => accessor/todo}/grib_accessor_class_section.cc | 0 src/{ => accessor/todo}/grib_accessor_class_section_length.cc | 0 src/{ => accessor/todo}/grib_accessor_class_section_padding.cc | 0 src/{ => accessor/todo}/grib_accessor_class_section_pointer.cc | 0 .../todo}/grib_accessor_class_select_step_template.cc | 0 .../todo}/grib_accessor_class_sexagesimal2decimal.cc | 0 src/{ => accessor/todo}/grib_accessor_class_signed.cc | 0 src/{ => accessor/todo}/grib_accessor_class_signed_bits.cc | 0 .../todo}/grib_accessor_class_simple_packing_error.cc | 0 src/{ => accessor/todo}/grib_accessor_class_size.cc | 0 src/{ => accessor/todo}/grib_accessor_class_smart_table.cc | 0 .../todo}/grib_accessor_class_smart_table_column.cc | 0 src/{ => accessor/todo}/grib_accessor_class_spd.cc | 0 .../todo}/grib_accessor_class_spectral_truncation.cc | 0 src/{ => accessor/todo}/grib_accessor_class_sprintf.cc | 0 src/{ => accessor/todo}/grib_accessor_class_statistics.cc | 0 .../todo}/grib_accessor_class_statistics_spectral.cc | 0 .../todo}/grib_accessor_class_step_human_readable.cc | 0 src/{ => accessor/todo}/grib_accessor_class_step_in_units.cc | 0 src/{ => accessor/todo}/grib_accessor_class_sum.cc | 0 src/{ => accessor/todo}/grib_accessor_class_suppressed.cc | 0 src/{ => accessor/todo}/grib_accessor_class_time.cc | 0 src/{ => accessor/todo}/grib_accessor_class_to_double.cc | 0 src/{ => accessor/todo}/grib_accessor_class_to_integer.cc | 0 src/{ => accessor/todo}/grib_accessor_class_to_string.cc | 0 src/{ => accessor/todo}/grib_accessor_class_transient.cc | 0 .../todo}/grib_accessor_class_transient_darray.cc | 0 src/{ => accessor/todo}/grib_accessor_class_trim.cc | 0 src/{ => accessor/todo}/grib_accessor_class_uint16.cc | 0 src/{ => accessor/todo}/grib_accessor_class_uint32.cc | 0 .../todo}/grib_accessor_class_uint32_little_endian.cc | 0 src/{ => accessor/todo}/grib_accessor_class_uint64.cc | 0 .../todo}/grib_accessor_class_uint64_little_endian.cc | 0 src/{ => accessor/todo}/grib_accessor_class_uint8.cc | 0 .../todo}/grib_accessor_class_unexpanded_descriptors.cc | 0 .../todo}/grib_accessor_class_unpack_bufr_values.cc | 0 src/{ => accessor/todo}/grib_accessor_class_unsigned.cc | 0 src/{ => accessor/todo}/grib_accessor_class_unsigned_bits.cc | 0 src/{ => accessor/todo}/grib_accessor_class_validity_date.cc | 0 src/{ => accessor/todo}/grib_accessor_class_validity_time.cc | 0 src/{ => accessor/todo}/grib_accessor_class_values.cc | 0 src/{ => accessor/todo}/grib_accessor_class_variable.cc | 0 src/{ => accessor/todo}/grib_accessor_class_vector.cc | 0 src/{ => accessor/todo}/grib_accessor_class_when.cc | 0 205 files changed, 3 insertions(+) rename src/{ => accessor/todo}/grib_accessor_class_abstract_long_vector.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_abstract_vector.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_ascii.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bit.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bits.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bits_per_value.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_blob.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_budgdate.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_data_array.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_data_element.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_elements_table.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_extract_area_subsets.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_extract_datetime_subsets.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_extract_subsets.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_group.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_simple_thinning.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufr_string_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bufrdc_expanded_descriptors.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_bytes.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_change_alternative_row_scanning.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_change_scanning_direction.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_check_internal_version.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_closest_date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_codeflag.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_codetable.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_codetable_title.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_codetable_units.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_concept.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_constant.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_count_file.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_count_missing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_count_total.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_apply_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_apply_boustrophedonic.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_ccsds_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_complex_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_dummy_field.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1complex_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1second_order_constant_width_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1second_order_general_extended_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1second_order_general_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1second_order_row_by_row_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1secondary_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1shsimple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g1simple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g22order_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2bifourier_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2complex_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2secondary_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2shsimple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2simple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_jpeg2000_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_png_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_raw_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_run_length_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_secondary_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_sh_packed.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_sh_unpacked.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_shsimple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_data_simple_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_decimal_precision.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_dictionary.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_dirty.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_divdouble.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_double.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_element.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_evaluate.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_expanded_descriptors.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_from_scale_factor_scaled_value.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1_half_byte_codeflag.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1_message_length.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1_section4_length.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1day_of_the_year_date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1end_of_interval_monthly.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1fcperiod.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1forecastmonth.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1monthlydate.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1number_of_coded_values_sh_complex.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1number_of_coded_values_sh_simple.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1step_range.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g1verificationdate.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2_aerosol.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2_chemical.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2_eps.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2_mars_labeling.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2bitmap_present.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2end_step.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2grid.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2latlon.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2level.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2lon.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_g2step_range.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_gaussian_grid_name.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_gds_is_present.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_gds_not_present_bitmap.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_gen.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_getenv.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_global_gaussian.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_group.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_gts_header.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_hash_array.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_headers_only.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_ibmfloat.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_ieeefloat.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_ifs_param.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_iterator.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_julian_date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_julian_day.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_ksec1expver.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_label.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_latitudes.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_latlon_increment.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_latlonvalues.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_library_version.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_local_definition.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_long.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_long_vector.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_longitudes.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_lookup.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_mars_param.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_mars_step.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_md5.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_message.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_message_copy.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_multdouble.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_nearest.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_non_alpha.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_number_of_coded_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_number_of_points.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_number_of_points_gaussian.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_number_of_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_number_of_values_data_raw_packing.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_octahedral_gaussian.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_octet_number.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_offset_file.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_offset_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_optimal_step_units.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_pack_bufr_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_packing_type.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_pad.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_padding.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_padto.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_padtoeven.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_padtomultiple.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_position.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_proj_string.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_raw.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_rdbtime_guess_date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_reference_value_error.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_round.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_scale.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_scale_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_second_order_bits_per_value.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_section.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_section_length.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_section_padding.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_section_pointer.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_select_step_template.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_sexagesimal2decimal.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_signed.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_signed_bits.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_simple_packing_error.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_size.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_smart_table.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_smart_table_column.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_spd.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_spectral_truncation.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_sprintf.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_statistics.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_statistics_spectral.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_step_human_readable.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_step_in_units.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_sum.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_suppressed.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_time.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_to_double.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_to_integer.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_to_string.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_transient.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_transient_darray.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_trim.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint16.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint32.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint32_little_endian.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint64.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint64_little_endian.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_uint8.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_unexpanded_descriptors.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_unpack_bufr_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_unsigned.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_unsigned_bits.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_validity_date.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_validity_time.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_values.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_variable.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_vector.cc (100%) rename src/{ => accessor/todo}/grib_accessor_class_when.cc (100%) diff --git a/.gitignore b/.gitignore index bfdfd9434..8791994fc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ grib_api.pc grib_api_f90.pc *.analyzerinfo *.snalyzerinfo +tags +src/convert_*.sh # compiled source # ################### @@ -72,3 +74,4 @@ data/bufr/*test build/ *.back +trash diff --git a/src/grib_accessor_class_abstract_long_vector.cc b/src/accessor/todo/grib_accessor_class_abstract_long_vector.cc similarity index 100% rename from src/grib_accessor_class_abstract_long_vector.cc rename to src/accessor/todo/grib_accessor_class_abstract_long_vector.cc diff --git a/src/grib_accessor_class_abstract_vector.cc b/src/accessor/todo/grib_accessor_class_abstract_vector.cc similarity index 100% rename from src/grib_accessor_class_abstract_vector.cc rename to src/accessor/todo/grib_accessor_class_abstract_vector.cc diff --git a/src/grib_accessor_class_ascii.cc b/src/accessor/todo/grib_accessor_class_ascii.cc similarity index 100% rename from src/grib_accessor_class_ascii.cc rename to src/accessor/todo/grib_accessor_class_ascii.cc diff --git a/src/grib_accessor_class_bit.cc b/src/accessor/todo/grib_accessor_class_bit.cc similarity index 100% rename from src/grib_accessor_class_bit.cc rename to src/accessor/todo/grib_accessor_class_bit.cc diff --git a/src/grib_accessor_class_bitmap.cc b/src/accessor/todo/grib_accessor_class_bitmap.cc similarity index 100% rename from src/grib_accessor_class_bitmap.cc rename to src/accessor/todo/grib_accessor_class_bitmap.cc diff --git a/src/grib_accessor_class_bits.cc b/src/accessor/todo/grib_accessor_class_bits.cc similarity index 100% rename from src/grib_accessor_class_bits.cc rename to src/accessor/todo/grib_accessor_class_bits.cc diff --git a/src/grib_accessor_class_bits_per_value.cc b/src/accessor/todo/grib_accessor_class_bits_per_value.cc similarity index 100% rename from src/grib_accessor_class_bits_per_value.cc rename to src/accessor/todo/grib_accessor_class_bits_per_value.cc diff --git a/src/grib_accessor_class_blob.cc b/src/accessor/todo/grib_accessor_class_blob.cc similarity index 100% rename from src/grib_accessor_class_blob.cc rename to src/accessor/todo/grib_accessor_class_blob.cc diff --git a/src/grib_accessor_class_budgdate.cc b/src/accessor/todo/grib_accessor_class_budgdate.cc similarity index 100% rename from src/grib_accessor_class_budgdate.cc rename to src/accessor/todo/grib_accessor_class_budgdate.cc diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/accessor/todo/grib_accessor_class_bufr_data_array.cc similarity index 100% rename from src/grib_accessor_class_bufr_data_array.cc rename to src/accessor/todo/grib_accessor_class_bufr_data_array.cc diff --git a/src/grib_accessor_class_bufr_data_element.cc b/src/accessor/todo/grib_accessor_class_bufr_data_element.cc similarity index 100% rename from src/grib_accessor_class_bufr_data_element.cc rename to src/accessor/todo/grib_accessor_class_bufr_data_element.cc diff --git a/src/grib_accessor_class_bufr_elements_table.cc b/src/accessor/todo/grib_accessor_class_bufr_elements_table.cc similarity index 100% rename from src/grib_accessor_class_bufr_elements_table.cc rename to src/accessor/todo/grib_accessor_class_bufr_elements_table.cc diff --git a/src/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/todo/grib_accessor_class_bufr_extract_area_subsets.cc similarity index 100% rename from src/grib_accessor_class_bufr_extract_area_subsets.cc rename to src/accessor/todo/grib_accessor_class_bufr_extract_area_subsets.cc diff --git a/src/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/todo/grib_accessor_class_bufr_extract_datetime_subsets.cc similarity index 100% rename from src/grib_accessor_class_bufr_extract_datetime_subsets.cc rename to src/accessor/todo/grib_accessor_class_bufr_extract_datetime_subsets.cc diff --git a/src/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc similarity index 100% rename from src/grib_accessor_class_bufr_extract_subsets.cc rename to src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc diff --git a/src/grib_accessor_class_bufr_group.cc b/src/accessor/todo/grib_accessor_class_bufr_group.cc similarity index 100% rename from src/grib_accessor_class_bufr_group.cc rename to src/accessor/todo/grib_accessor_class_bufr_group.cc diff --git a/src/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc similarity index 100% rename from src/grib_accessor_class_bufr_simple_thinning.cc rename to src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc diff --git a/src/grib_accessor_class_bufr_string_values.cc b/src/accessor/todo/grib_accessor_class_bufr_string_values.cc similarity index 100% rename from src/grib_accessor_class_bufr_string_values.cc rename to src/accessor/todo/grib_accessor_class_bufr_string_values.cc diff --git a/src/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc similarity index 100% rename from src/grib_accessor_class_bufrdc_expanded_descriptors.cc rename to src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc diff --git a/src/grib_accessor_class_bytes.cc b/src/accessor/todo/grib_accessor_class_bytes.cc similarity index 100% rename from src/grib_accessor_class_bytes.cc rename to src/accessor/todo/grib_accessor_class_bytes.cc diff --git a/src/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc similarity index 100% rename from src/grib_accessor_class_change_alternative_row_scanning.cc rename to src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc diff --git a/src/grib_accessor_class_change_scanning_direction.cc b/src/accessor/todo/grib_accessor_class_change_scanning_direction.cc similarity index 100% rename from src/grib_accessor_class_change_scanning_direction.cc rename to src/accessor/todo/grib_accessor_class_change_scanning_direction.cc diff --git a/src/grib_accessor_class_check_internal_version.cc b/src/accessor/todo/grib_accessor_class_check_internal_version.cc similarity index 100% rename from src/grib_accessor_class_check_internal_version.cc rename to src/accessor/todo/grib_accessor_class_check_internal_version.cc diff --git a/src/grib_accessor_class_closest_date.cc b/src/accessor/todo/grib_accessor_class_closest_date.cc similarity index 100% rename from src/grib_accessor_class_closest_date.cc rename to src/accessor/todo/grib_accessor_class_closest_date.cc diff --git a/src/grib_accessor_class_codeflag.cc b/src/accessor/todo/grib_accessor_class_codeflag.cc similarity index 100% rename from src/grib_accessor_class_codeflag.cc rename to src/accessor/todo/grib_accessor_class_codeflag.cc diff --git a/src/grib_accessor_class_codetable.cc b/src/accessor/todo/grib_accessor_class_codetable.cc similarity index 100% rename from src/grib_accessor_class_codetable.cc rename to src/accessor/todo/grib_accessor_class_codetable.cc diff --git a/src/grib_accessor_class_codetable_title.cc b/src/accessor/todo/grib_accessor_class_codetable_title.cc similarity index 100% rename from src/grib_accessor_class_codetable_title.cc rename to src/accessor/todo/grib_accessor_class_codetable_title.cc diff --git a/src/grib_accessor_class_codetable_units.cc b/src/accessor/todo/grib_accessor_class_codetable_units.cc similarity index 100% rename from src/grib_accessor_class_codetable_units.cc rename to src/accessor/todo/grib_accessor_class_codetable_units.cc diff --git a/src/grib_accessor_class_concept.cc b/src/accessor/todo/grib_accessor_class_concept.cc similarity index 100% rename from src/grib_accessor_class_concept.cc rename to src/accessor/todo/grib_accessor_class_concept.cc diff --git a/src/grib_accessor_class_constant.cc b/src/accessor/todo/grib_accessor_class_constant.cc similarity index 100% rename from src/grib_accessor_class_constant.cc rename to src/accessor/todo/grib_accessor_class_constant.cc diff --git a/src/grib_accessor_class_count_file.cc b/src/accessor/todo/grib_accessor_class_count_file.cc similarity index 100% rename from src/grib_accessor_class_count_file.cc rename to src/accessor/todo/grib_accessor_class_count_file.cc diff --git a/src/grib_accessor_class_count_missing.cc b/src/accessor/todo/grib_accessor_class_count_missing.cc similarity index 100% rename from src/grib_accessor_class_count_missing.cc rename to src/accessor/todo/grib_accessor_class_count_missing.cc diff --git a/src/grib_accessor_class_count_total.cc b/src/accessor/todo/grib_accessor_class_count_total.cc similarity index 100% rename from src/grib_accessor_class_count_total.cc rename to src/accessor/todo/grib_accessor_class_count_total.cc diff --git a/src/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_apply_bitmap.cc similarity index 100% rename from src/grib_accessor_class_data_apply_bitmap.cc rename to src/accessor/todo/grib_accessor_class_data_apply_bitmap.cc diff --git a/src/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic.cc similarity index 100% rename from src/grib_accessor_class_data_apply_boustrophedonic.cc rename to src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic.cc diff --git a/src/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc similarity index 100% rename from src/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc rename to src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc diff --git a/src/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/todo/grib_accessor_class_data_ccsds_packing.cc similarity index 100% rename from src/grib_accessor_class_data_ccsds_packing.cc rename to src/accessor/todo/grib_accessor_class_data_ccsds_packing.cc diff --git a/src/grib_accessor_class_data_complex_packing.cc b/src/accessor/todo/grib_accessor_class_data_complex_packing.cc similarity index 100% rename from src/grib_accessor_class_data_complex_packing.cc rename to src/accessor/todo/grib_accessor_class_data_complex_packing.cc diff --git a/src/grib_accessor_class_data_dummy_field.cc b/src/accessor/todo/grib_accessor_class_data_dummy_field.cc similarity index 100% rename from src/grib_accessor_class_data_dummy_field.cc rename to src/accessor/todo/grib_accessor_class_data_dummy_field.cc diff --git a/src/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1complex_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc diff --git a/src/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1second_order_constant_width_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1second_order_constant_width_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1second_order_constant_width_packing.cc diff --git a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1second_order_general_extended_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1second_order_general_extended_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1second_order_general_extended_packing.cc diff --git a/src/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1second_order_general_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1second_order_general_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1second_order_general_packing.cc diff --git a/src/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1second_order_row_by_row_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1second_order_row_by_row_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1second_order_row_by_row_packing.cc diff --git a/src/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc similarity index 100% rename from src/grib_accessor_class_data_g1secondary_bitmap.cc rename to src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc diff --git a/src/grib_accessor_class_data_g1shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1shsimple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc diff --git a/src/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1simple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g1simple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g1simple_packing.cc diff --git a/src/grib_accessor_class_data_g22order_packing.cc b/src/accessor/todo/grib_accessor_class_data_g22order_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g22order_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g22order_packing.cc diff --git a/src/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2bifourier_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g2bifourier_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g2bifourier_packing.cc diff --git a/src/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g2complex_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc diff --git a/src/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc similarity index 100% rename from src/grib_accessor_class_data_g2secondary_bitmap.cc rename to src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc diff --git a/src/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g2shsimple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc diff --git a/src/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2simple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_g2simple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_g2simple_packing.cc diff --git a/src/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc similarity index 100% rename from src/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc rename to src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc diff --git a/src/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/todo/grib_accessor_class_data_jpeg2000_packing.cc similarity index 100% rename from src/grib_accessor_class_data_jpeg2000_packing.cc rename to src/accessor/todo/grib_accessor_class_data_jpeg2000_packing.cc diff --git a/src/grib_accessor_class_data_png_packing.cc b/src/accessor/todo/grib_accessor_class_data_png_packing.cc similarity index 100% rename from src/grib_accessor_class_data_png_packing.cc rename to src/accessor/todo/grib_accessor_class_data_png_packing.cc diff --git a/src/grib_accessor_class_data_raw_packing.cc b/src/accessor/todo/grib_accessor_class_data_raw_packing.cc similarity index 100% rename from src/grib_accessor_class_data_raw_packing.cc rename to src/accessor/todo/grib_accessor_class_data_raw_packing.cc diff --git a/src/grib_accessor_class_data_run_length_packing.cc b/src/accessor/todo/grib_accessor_class_data_run_length_packing.cc similarity index 100% rename from src/grib_accessor_class_data_run_length_packing.cc rename to src/accessor/todo/grib_accessor_class_data_run_length_packing.cc diff --git a/src/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_secondary_bitmap.cc similarity index 100% rename from src/grib_accessor_class_data_secondary_bitmap.cc rename to src/accessor/todo/grib_accessor_class_data_secondary_bitmap.cc diff --git a/src/grib_accessor_class_data_sh_packed.cc b/src/accessor/todo/grib_accessor_class_data_sh_packed.cc similarity index 100% rename from src/grib_accessor_class_data_sh_packed.cc rename to src/accessor/todo/grib_accessor_class_data_sh_packed.cc diff --git a/src/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/todo/grib_accessor_class_data_sh_unpacked.cc similarity index 100% rename from src/grib_accessor_class_data_sh_unpacked.cc rename to src/accessor/todo/grib_accessor_class_data_sh_unpacked.cc diff --git a/src/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_shsimple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc diff --git a/src/grib_accessor_class_data_simple_packing.cc b/src/accessor/todo/grib_accessor_class_data_simple_packing.cc similarity index 100% rename from src/grib_accessor_class_data_simple_packing.cc rename to src/accessor/todo/grib_accessor_class_data_simple_packing.cc diff --git a/src/grib_accessor_class_decimal_precision.cc b/src/accessor/todo/grib_accessor_class_decimal_precision.cc similarity index 100% rename from src/grib_accessor_class_decimal_precision.cc rename to src/accessor/todo/grib_accessor_class_decimal_precision.cc diff --git a/src/grib_accessor_class_dictionary.cc b/src/accessor/todo/grib_accessor_class_dictionary.cc similarity index 100% rename from src/grib_accessor_class_dictionary.cc rename to src/accessor/todo/grib_accessor_class_dictionary.cc diff --git a/src/grib_accessor_class_dirty.cc b/src/accessor/todo/grib_accessor_class_dirty.cc similarity index 100% rename from src/grib_accessor_class_dirty.cc rename to src/accessor/todo/grib_accessor_class_dirty.cc diff --git a/src/grib_accessor_class_divdouble.cc b/src/accessor/todo/grib_accessor_class_divdouble.cc similarity index 100% rename from src/grib_accessor_class_divdouble.cc rename to src/accessor/todo/grib_accessor_class_divdouble.cc diff --git a/src/grib_accessor_class_double.cc b/src/accessor/todo/grib_accessor_class_double.cc similarity index 100% rename from src/grib_accessor_class_double.cc rename to src/accessor/todo/grib_accessor_class_double.cc diff --git a/src/grib_accessor_class_element.cc b/src/accessor/todo/grib_accessor_class_element.cc similarity index 100% rename from src/grib_accessor_class_element.cc rename to src/accessor/todo/grib_accessor_class_element.cc diff --git a/src/grib_accessor_class_evaluate.cc b/src/accessor/todo/grib_accessor_class_evaluate.cc similarity index 100% rename from src/grib_accessor_class_evaluate.cc rename to src/accessor/todo/grib_accessor_class_evaluate.cc diff --git a/src/grib_accessor_class_expanded_descriptors.cc b/src/accessor/todo/grib_accessor_class_expanded_descriptors.cc similarity index 100% rename from src/grib_accessor_class_expanded_descriptors.cc rename to src/accessor/todo/grib_accessor_class_expanded_descriptors.cc diff --git a/src/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/todo/grib_accessor_class_from_scale_factor_scaled_value.cc similarity index 100% rename from src/grib_accessor_class_from_scale_factor_scaled_value.cc rename to src/accessor/todo/grib_accessor_class_from_scale_factor_scaled_value.cc diff --git a/src/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc similarity index 100% rename from src/grib_accessor_class_g1_half_byte_codeflag.cc rename to src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc diff --git a/src/grib_accessor_class_g1_message_length.cc b/src/accessor/todo/grib_accessor_class_g1_message_length.cc similarity index 100% rename from src/grib_accessor_class_g1_message_length.cc rename to src/accessor/todo/grib_accessor_class_g1_message_length.cc diff --git a/src/grib_accessor_class_g1_section4_length.cc b/src/accessor/todo/grib_accessor_class_g1_section4_length.cc similarity index 100% rename from src/grib_accessor_class_g1_section4_length.cc rename to src/accessor/todo/grib_accessor_class_g1_section4_length.cc diff --git a/src/grib_accessor_class_g1bitmap.cc b/src/accessor/todo/grib_accessor_class_g1bitmap.cc similarity index 100% rename from src/grib_accessor_class_g1bitmap.cc rename to src/accessor/todo/grib_accessor_class_g1bitmap.cc diff --git a/src/grib_accessor_class_g1date.cc b/src/accessor/todo/grib_accessor_class_g1date.cc similarity index 100% rename from src/grib_accessor_class_g1date.cc rename to src/accessor/todo/grib_accessor_class_g1date.cc diff --git a/src/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc similarity index 100% rename from src/grib_accessor_class_g1day_of_the_year_date.cc rename to src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc diff --git a/src/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc similarity index 100% rename from src/grib_accessor_class_g1end_of_interval_monthly.cc rename to src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc diff --git a/src/grib_accessor_class_g1fcperiod.cc b/src/accessor/todo/grib_accessor_class_g1fcperiod.cc similarity index 100% rename from src/grib_accessor_class_g1fcperiod.cc rename to src/accessor/todo/grib_accessor_class_g1fcperiod.cc diff --git a/src/grib_accessor_class_g1forecastmonth.cc b/src/accessor/todo/grib_accessor_class_g1forecastmonth.cc similarity index 100% rename from src/grib_accessor_class_g1forecastmonth.cc rename to src/accessor/todo/grib_accessor_class_g1forecastmonth.cc diff --git a/src/grib_accessor_class_g1monthlydate.cc b/src/accessor/todo/grib_accessor_class_g1monthlydate.cc similarity index 100% rename from src/grib_accessor_class_g1monthlydate.cc rename to src/accessor/todo/grib_accessor_class_g1monthlydate.cc diff --git a/src/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc similarity index 100% rename from src/grib_accessor_class_g1number_of_coded_values_sh_complex.cc rename to src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc diff --git a/src/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc similarity index 100% rename from src/grib_accessor_class_g1number_of_coded_values_sh_simple.cc rename to src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc diff --git a/src/grib_accessor_class_g1step_range.cc b/src/accessor/todo/grib_accessor_class_g1step_range.cc similarity index 100% rename from src/grib_accessor_class_g1step_range.cc rename to src/accessor/todo/grib_accessor_class_g1step_range.cc diff --git a/src/grib_accessor_class_g1verificationdate.cc b/src/accessor/todo/grib_accessor_class_g1verificationdate.cc similarity index 100% rename from src/grib_accessor_class_g1verificationdate.cc rename to src/accessor/todo/grib_accessor_class_g1verificationdate.cc diff --git a/src/grib_accessor_class_g2_aerosol.cc b/src/accessor/todo/grib_accessor_class_g2_aerosol.cc similarity index 100% rename from src/grib_accessor_class_g2_aerosol.cc rename to src/accessor/todo/grib_accessor_class_g2_aerosol.cc diff --git a/src/grib_accessor_class_g2_chemical.cc b/src/accessor/todo/grib_accessor_class_g2_chemical.cc similarity index 100% rename from src/grib_accessor_class_g2_chemical.cc rename to src/accessor/todo/grib_accessor_class_g2_chemical.cc diff --git a/src/grib_accessor_class_g2_eps.cc b/src/accessor/todo/grib_accessor_class_g2_eps.cc similarity index 100% rename from src/grib_accessor_class_g2_eps.cc rename to src/accessor/todo/grib_accessor_class_g2_eps.cc diff --git a/src/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/todo/grib_accessor_class_g2_mars_labeling.cc similarity index 100% rename from src/grib_accessor_class_g2_mars_labeling.cc rename to src/accessor/todo/grib_accessor_class_g2_mars_labeling.cc diff --git a/src/grib_accessor_class_g2bitmap.cc b/src/accessor/todo/grib_accessor_class_g2bitmap.cc similarity index 100% rename from src/grib_accessor_class_g2bitmap.cc rename to src/accessor/todo/grib_accessor_class_g2bitmap.cc diff --git a/src/grib_accessor_class_g2bitmap_present.cc b/src/accessor/todo/grib_accessor_class_g2bitmap_present.cc similarity index 100% rename from src/grib_accessor_class_g2bitmap_present.cc rename to src/accessor/todo/grib_accessor_class_g2bitmap_present.cc diff --git a/src/grib_accessor_class_g2date.cc b/src/accessor/todo/grib_accessor_class_g2date.cc similarity index 100% rename from src/grib_accessor_class_g2date.cc rename to src/accessor/todo/grib_accessor_class_g2date.cc diff --git a/src/grib_accessor_class_g2end_step.cc b/src/accessor/todo/grib_accessor_class_g2end_step.cc similarity index 100% rename from src/grib_accessor_class_g2end_step.cc rename to src/accessor/todo/grib_accessor_class_g2end_step.cc diff --git a/src/grib_accessor_class_g2grid.cc b/src/accessor/todo/grib_accessor_class_g2grid.cc similarity index 100% rename from src/grib_accessor_class_g2grid.cc rename to src/accessor/todo/grib_accessor_class_g2grid.cc diff --git a/src/grib_accessor_class_g2latlon.cc b/src/accessor/todo/grib_accessor_class_g2latlon.cc similarity index 100% rename from src/grib_accessor_class_g2latlon.cc rename to src/accessor/todo/grib_accessor_class_g2latlon.cc diff --git a/src/grib_accessor_class_g2level.cc b/src/accessor/todo/grib_accessor_class_g2level.cc similarity index 100% rename from src/grib_accessor_class_g2level.cc rename to src/accessor/todo/grib_accessor_class_g2level.cc diff --git a/src/grib_accessor_class_g2lon.cc b/src/accessor/todo/grib_accessor_class_g2lon.cc similarity index 100% rename from src/grib_accessor_class_g2lon.cc rename to src/accessor/todo/grib_accessor_class_g2lon.cc diff --git a/src/grib_accessor_class_g2step_range.cc b/src/accessor/todo/grib_accessor_class_g2step_range.cc similarity index 100% rename from src/grib_accessor_class_g2step_range.cc rename to src/accessor/todo/grib_accessor_class_g2step_range.cc diff --git a/src/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc similarity index 100% rename from src/grib_accessor_class_gaussian_grid_name.cc rename to src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc diff --git a/src/grib_accessor_class_gds_is_present.cc b/src/accessor/todo/grib_accessor_class_gds_is_present.cc similarity index 100% rename from src/grib_accessor_class_gds_is_present.cc rename to src/accessor/todo/grib_accessor_class_gds_is_present.cc diff --git a/src/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc similarity index 100% rename from src/grib_accessor_class_gds_not_present_bitmap.cc rename to src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc diff --git a/src/grib_accessor_class_gen.cc b/src/accessor/todo/grib_accessor_class_gen.cc similarity index 100% rename from src/grib_accessor_class_gen.cc rename to src/accessor/todo/grib_accessor_class_gen.cc diff --git a/src/grib_accessor_class_getenv.cc b/src/accessor/todo/grib_accessor_class_getenv.cc similarity index 100% rename from src/grib_accessor_class_getenv.cc rename to src/accessor/todo/grib_accessor_class_getenv.cc diff --git a/src/grib_accessor_class_global_gaussian.cc b/src/accessor/todo/grib_accessor_class_global_gaussian.cc similarity index 100% rename from src/grib_accessor_class_global_gaussian.cc rename to src/accessor/todo/grib_accessor_class_global_gaussian.cc diff --git a/src/grib_accessor_class_group.cc b/src/accessor/todo/grib_accessor_class_group.cc similarity index 100% rename from src/grib_accessor_class_group.cc rename to src/accessor/todo/grib_accessor_class_group.cc diff --git a/src/grib_accessor_class_gts_header.cc b/src/accessor/todo/grib_accessor_class_gts_header.cc similarity index 100% rename from src/grib_accessor_class_gts_header.cc rename to src/accessor/todo/grib_accessor_class_gts_header.cc diff --git a/src/grib_accessor_class_hash_array.cc b/src/accessor/todo/grib_accessor_class_hash_array.cc similarity index 100% rename from src/grib_accessor_class_hash_array.cc rename to src/accessor/todo/grib_accessor_class_hash_array.cc diff --git a/src/grib_accessor_class_headers_only.cc b/src/accessor/todo/grib_accessor_class_headers_only.cc similarity index 100% rename from src/grib_accessor_class_headers_only.cc rename to src/accessor/todo/grib_accessor_class_headers_only.cc diff --git a/src/grib_accessor_class_ibmfloat.cc b/src/accessor/todo/grib_accessor_class_ibmfloat.cc similarity index 100% rename from src/grib_accessor_class_ibmfloat.cc rename to src/accessor/todo/grib_accessor_class_ibmfloat.cc diff --git a/src/grib_accessor_class_ieeefloat.cc b/src/accessor/todo/grib_accessor_class_ieeefloat.cc similarity index 100% rename from src/grib_accessor_class_ieeefloat.cc rename to src/accessor/todo/grib_accessor_class_ieeefloat.cc diff --git a/src/grib_accessor_class_ifs_param.cc b/src/accessor/todo/grib_accessor_class_ifs_param.cc similarity index 100% rename from src/grib_accessor_class_ifs_param.cc rename to src/accessor/todo/grib_accessor_class_ifs_param.cc diff --git a/src/grib_accessor_class_iterator.cc b/src/accessor/todo/grib_accessor_class_iterator.cc similarity index 100% rename from src/grib_accessor_class_iterator.cc rename to src/accessor/todo/grib_accessor_class_iterator.cc diff --git a/src/grib_accessor_class_julian_date.cc b/src/accessor/todo/grib_accessor_class_julian_date.cc similarity index 100% rename from src/grib_accessor_class_julian_date.cc rename to src/accessor/todo/grib_accessor_class_julian_date.cc diff --git a/src/grib_accessor_class_julian_day.cc b/src/accessor/todo/grib_accessor_class_julian_day.cc similarity index 100% rename from src/grib_accessor_class_julian_day.cc rename to src/accessor/todo/grib_accessor_class_julian_day.cc diff --git a/src/grib_accessor_class_ksec1expver.cc b/src/accessor/todo/grib_accessor_class_ksec1expver.cc similarity index 100% rename from src/grib_accessor_class_ksec1expver.cc rename to src/accessor/todo/grib_accessor_class_ksec1expver.cc diff --git a/src/grib_accessor_class_label.cc b/src/accessor/todo/grib_accessor_class_label.cc similarity index 100% rename from src/grib_accessor_class_label.cc rename to src/accessor/todo/grib_accessor_class_label.cc diff --git a/src/grib_accessor_class_latitudes.cc b/src/accessor/todo/grib_accessor_class_latitudes.cc similarity index 100% rename from src/grib_accessor_class_latitudes.cc rename to src/accessor/todo/grib_accessor_class_latitudes.cc diff --git a/src/grib_accessor_class_latlon_increment.cc b/src/accessor/todo/grib_accessor_class_latlon_increment.cc similarity index 100% rename from src/grib_accessor_class_latlon_increment.cc rename to src/accessor/todo/grib_accessor_class_latlon_increment.cc diff --git a/src/grib_accessor_class_latlonvalues.cc b/src/accessor/todo/grib_accessor_class_latlonvalues.cc similarity index 100% rename from src/grib_accessor_class_latlonvalues.cc rename to src/accessor/todo/grib_accessor_class_latlonvalues.cc diff --git a/src/grib_accessor_class_library_version.cc b/src/accessor/todo/grib_accessor_class_library_version.cc similarity index 100% rename from src/grib_accessor_class_library_version.cc rename to src/accessor/todo/grib_accessor_class_library_version.cc diff --git a/src/grib_accessor_class_local_definition.cc b/src/accessor/todo/grib_accessor_class_local_definition.cc similarity index 100% rename from src/grib_accessor_class_local_definition.cc rename to src/accessor/todo/grib_accessor_class_local_definition.cc diff --git a/src/grib_accessor_class_long.cc b/src/accessor/todo/grib_accessor_class_long.cc similarity index 100% rename from src/grib_accessor_class_long.cc rename to src/accessor/todo/grib_accessor_class_long.cc diff --git a/src/grib_accessor_class_long_vector.cc b/src/accessor/todo/grib_accessor_class_long_vector.cc similarity index 100% rename from src/grib_accessor_class_long_vector.cc rename to src/accessor/todo/grib_accessor_class_long_vector.cc diff --git a/src/grib_accessor_class_longitudes.cc b/src/accessor/todo/grib_accessor_class_longitudes.cc similarity index 100% rename from src/grib_accessor_class_longitudes.cc rename to src/accessor/todo/grib_accessor_class_longitudes.cc diff --git a/src/grib_accessor_class_lookup.cc b/src/accessor/todo/grib_accessor_class_lookup.cc similarity index 100% rename from src/grib_accessor_class_lookup.cc rename to src/accessor/todo/grib_accessor_class_lookup.cc diff --git a/src/grib_accessor_class_mars_param.cc b/src/accessor/todo/grib_accessor_class_mars_param.cc similarity index 100% rename from src/grib_accessor_class_mars_param.cc rename to src/accessor/todo/grib_accessor_class_mars_param.cc diff --git a/src/grib_accessor_class_mars_step.cc b/src/accessor/todo/grib_accessor_class_mars_step.cc similarity index 100% rename from src/grib_accessor_class_mars_step.cc rename to src/accessor/todo/grib_accessor_class_mars_step.cc diff --git a/src/grib_accessor_class_md5.cc b/src/accessor/todo/grib_accessor_class_md5.cc similarity index 100% rename from src/grib_accessor_class_md5.cc rename to src/accessor/todo/grib_accessor_class_md5.cc diff --git a/src/grib_accessor_class_message.cc b/src/accessor/todo/grib_accessor_class_message.cc similarity index 100% rename from src/grib_accessor_class_message.cc rename to src/accessor/todo/grib_accessor_class_message.cc diff --git a/src/grib_accessor_class_message_copy.cc b/src/accessor/todo/grib_accessor_class_message_copy.cc similarity index 100% rename from src/grib_accessor_class_message_copy.cc rename to src/accessor/todo/grib_accessor_class_message_copy.cc diff --git a/src/grib_accessor_class_multdouble.cc b/src/accessor/todo/grib_accessor_class_multdouble.cc similarity index 100% rename from src/grib_accessor_class_multdouble.cc rename to src/accessor/todo/grib_accessor_class_multdouble.cc diff --git a/src/grib_accessor_class_nearest.cc b/src/accessor/todo/grib_accessor_class_nearest.cc similarity index 100% rename from src/grib_accessor_class_nearest.cc rename to src/accessor/todo/grib_accessor_class_nearest.cc diff --git a/src/grib_accessor_class_non_alpha.cc b/src/accessor/todo/grib_accessor_class_non_alpha.cc similarity index 100% rename from src/grib_accessor_class_non_alpha.cc rename to src/accessor/todo/grib_accessor_class_non_alpha.cc diff --git a/src/grib_accessor_class_number_of_coded_values.cc b/src/accessor/todo/grib_accessor_class_number_of_coded_values.cc similarity index 100% rename from src/grib_accessor_class_number_of_coded_values.cc rename to src/accessor/todo/grib_accessor_class_number_of_coded_values.cc diff --git a/src/grib_accessor_class_number_of_points.cc b/src/accessor/todo/grib_accessor_class_number_of_points.cc similarity index 100% rename from src/grib_accessor_class_number_of_points.cc rename to src/accessor/todo/grib_accessor_class_number_of_points.cc diff --git a/src/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/todo/grib_accessor_class_number_of_points_gaussian.cc similarity index 100% rename from src/grib_accessor_class_number_of_points_gaussian.cc rename to src/accessor/todo/grib_accessor_class_number_of_points_gaussian.cc diff --git a/src/grib_accessor_class_number_of_values.cc b/src/accessor/todo/grib_accessor_class_number_of_values.cc similarity index 100% rename from src/grib_accessor_class_number_of_values.cc rename to src/accessor/todo/grib_accessor_class_number_of_values.cc diff --git a/src/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc similarity index 100% rename from src/grib_accessor_class_number_of_values_data_raw_packing.cc rename to src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc diff --git a/src/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc similarity index 100% rename from src/grib_accessor_class_octahedral_gaussian.cc rename to src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc diff --git a/src/grib_accessor_class_octet_number.cc b/src/accessor/todo/grib_accessor_class_octet_number.cc similarity index 100% rename from src/grib_accessor_class_octet_number.cc rename to src/accessor/todo/grib_accessor_class_octet_number.cc diff --git a/src/grib_accessor_class_offset_file.cc b/src/accessor/todo/grib_accessor_class_offset_file.cc similarity index 100% rename from src/grib_accessor_class_offset_file.cc rename to src/accessor/todo/grib_accessor_class_offset_file.cc diff --git a/src/grib_accessor_class_offset_values.cc b/src/accessor/todo/grib_accessor_class_offset_values.cc similarity index 100% rename from src/grib_accessor_class_offset_values.cc rename to src/accessor/todo/grib_accessor_class_offset_values.cc diff --git a/src/grib_accessor_class_optimal_step_units.cc b/src/accessor/todo/grib_accessor_class_optimal_step_units.cc similarity index 100% rename from src/grib_accessor_class_optimal_step_units.cc rename to src/accessor/todo/grib_accessor_class_optimal_step_units.cc diff --git a/src/grib_accessor_class_pack_bufr_values.cc b/src/accessor/todo/grib_accessor_class_pack_bufr_values.cc similarity index 100% rename from src/grib_accessor_class_pack_bufr_values.cc rename to src/accessor/todo/grib_accessor_class_pack_bufr_values.cc diff --git a/src/grib_accessor_class_packing_type.cc b/src/accessor/todo/grib_accessor_class_packing_type.cc similarity index 100% rename from src/grib_accessor_class_packing_type.cc rename to src/accessor/todo/grib_accessor_class_packing_type.cc diff --git a/src/grib_accessor_class_pad.cc b/src/accessor/todo/grib_accessor_class_pad.cc similarity index 100% rename from src/grib_accessor_class_pad.cc rename to src/accessor/todo/grib_accessor_class_pad.cc diff --git a/src/grib_accessor_class_padding.cc b/src/accessor/todo/grib_accessor_class_padding.cc similarity index 100% rename from src/grib_accessor_class_padding.cc rename to src/accessor/todo/grib_accessor_class_padding.cc diff --git a/src/grib_accessor_class_padto.cc b/src/accessor/todo/grib_accessor_class_padto.cc similarity index 100% rename from src/grib_accessor_class_padto.cc rename to src/accessor/todo/grib_accessor_class_padto.cc diff --git a/src/grib_accessor_class_padtoeven.cc b/src/accessor/todo/grib_accessor_class_padtoeven.cc similarity index 100% rename from src/grib_accessor_class_padtoeven.cc rename to src/accessor/todo/grib_accessor_class_padtoeven.cc diff --git a/src/grib_accessor_class_padtomultiple.cc b/src/accessor/todo/grib_accessor_class_padtomultiple.cc similarity index 100% rename from src/grib_accessor_class_padtomultiple.cc rename to src/accessor/todo/grib_accessor_class_padtomultiple.cc diff --git a/src/grib_accessor_class_position.cc b/src/accessor/todo/grib_accessor_class_position.cc similarity index 100% rename from src/grib_accessor_class_position.cc rename to src/accessor/todo/grib_accessor_class_position.cc diff --git a/src/grib_accessor_class_proj_string.cc b/src/accessor/todo/grib_accessor_class_proj_string.cc similarity index 100% rename from src/grib_accessor_class_proj_string.cc rename to src/accessor/todo/grib_accessor_class_proj_string.cc diff --git a/src/grib_accessor_class_raw.cc b/src/accessor/todo/grib_accessor_class_raw.cc similarity index 100% rename from src/grib_accessor_class_raw.cc rename to src/accessor/todo/grib_accessor_class_raw.cc diff --git a/src/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc similarity index 100% rename from src/grib_accessor_class_rdbtime_guess_date.cc rename to src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc diff --git a/src/grib_accessor_class_reference_value_error.cc b/src/accessor/todo/grib_accessor_class_reference_value_error.cc similarity index 100% rename from src/grib_accessor_class_reference_value_error.cc rename to src/accessor/todo/grib_accessor_class_reference_value_error.cc diff --git a/src/grib_accessor_class_round.cc b/src/accessor/todo/grib_accessor_class_round.cc similarity index 100% rename from src/grib_accessor_class_round.cc rename to src/accessor/todo/grib_accessor_class_round.cc diff --git a/src/grib_accessor_class_scale.cc b/src/accessor/todo/grib_accessor_class_scale.cc similarity index 100% rename from src/grib_accessor_class_scale.cc rename to src/accessor/todo/grib_accessor_class_scale.cc diff --git a/src/grib_accessor_class_scale_values.cc b/src/accessor/todo/grib_accessor_class_scale_values.cc similarity index 100% rename from src/grib_accessor_class_scale_values.cc rename to src/accessor/todo/grib_accessor_class_scale_values.cc diff --git a/src/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/todo/grib_accessor_class_second_order_bits_per_value.cc similarity index 100% rename from src/grib_accessor_class_second_order_bits_per_value.cc rename to src/accessor/todo/grib_accessor_class_second_order_bits_per_value.cc diff --git a/src/grib_accessor_class_section.cc b/src/accessor/todo/grib_accessor_class_section.cc similarity index 100% rename from src/grib_accessor_class_section.cc rename to src/accessor/todo/grib_accessor_class_section.cc diff --git a/src/grib_accessor_class_section_length.cc b/src/accessor/todo/grib_accessor_class_section_length.cc similarity index 100% rename from src/grib_accessor_class_section_length.cc rename to src/accessor/todo/grib_accessor_class_section_length.cc diff --git a/src/grib_accessor_class_section_padding.cc b/src/accessor/todo/grib_accessor_class_section_padding.cc similarity index 100% rename from src/grib_accessor_class_section_padding.cc rename to src/accessor/todo/grib_accessor_class_section_padding.cc diff --git a/src/grib_accessor_class_section_pointer.cc b/src/accessor/todo/grib_accessor_class_section_pointer.cc similarity index 100% rename from src/grib_accessor_class_section_pointer.cc rename to src/accessor/todo/grib_accessor_class_section_pointer.cc diff --git a/src/grib_accessor_class_select_step_template.cc b/src/accessor/todo/grib_accessor_class_select_step_template.cc similarity index 100% rename from src/grib_accessor_class_select_step_template.cc rename to src/accessor/todo/grib_accessor_class_select_step_template.cc diff --git a/src/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc similarity index 100% rename from src/grib_accessor_class_sexagesimal2decimal.cc rename to src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc diff --git a/src/grib_accessor_class_signed.cc b/src/accessor/todo/grib_accessor_class_signed.cc similarity index 100% rename from src/grib_accessor_class_signed.cc rename to src/accessor/todo/grib_accessor_class_signed.cc diff --git a/src/grib_accessor_class_signed_bits.cc b/src/accessor/todo/grib_accessor_class_signed_bits.cc similarity index 100% rename from src/grib_accessor_class_signed_bits.cc rename to src/accessor/todo/grib_accessor_class_signed_bits.cc diff --git a/src/grib_accessor_class_simple_packing_error.cc b/src/accessor/todo/grib_accessor_class_simple_packing_error.cc similarity index 100% rename from src/grib_accessor_class_simple_packing_error.cc rename to src/accessor/todo/grib_accessor_class_simple_packing_error.cc diff --git a/src/grib_accessor_class_size.cc b/src/accessor/todo/grib_accessor_class_size.cc similarity index 100% rename from src/grib_accessor_class_size.cc rename to src/accessor/todo/grib_accessor_class_size.cc diff --git a/src/grib_accessor_class_smart_table.cc b/src/accessor/todo/grib_accessor_class_smart_table.cc similarity index 100% rename from src/grib_accessor_class_smart_table.cc rename to src/accessor/todo/grib_accessor_class_smart_table.cc diff --git a/src/grib_accessor_class_smart_table_column.cc b/src/accessor/todo/grib_accessor_class_smart_table_column.cc similarity index 100% rename from src/grib_accessor_class_smart_table_column.cc rename to src/accessor/todo/grib_accessor_class_smart_table_column.cc diff --git a/src/grib_accessor_class_spd.cc b/src/accessor/todo/grib_accessor_class_spd.cc similarity index 100% rename from src/grib_accessor_class_spd.cc rename to src/accessor/todo/grib_accessor_class_spd.cc diff --git a/src/grib_accessor_class_spectral_truncation.cc b/src/accessor/todo/grib_accessor_class_spectral_truncation.cc similarity index 100% rename from src/grib_accessor_class_spectral_truncation.cc rename to src/accessor/todo/grib_accessor_class_spectral_truncation.cc diff --git a/src/grib_accessor_class_sprintf.cc b/src/accessor/todo/grib_accessor_class_sprintf.cc similarity index 100% rename from src/grib_accessor_class_sprintf.cc rename to src/accessor/todo/grib_accessor_class_sprintf.cc diff --git a/src/grib_accessor_class_statistics.cc b/src/accessor/todo/grib_accessor_class_statistics.cc similarity index 100% rename from src/grib_accessor_class_statistics.cc rename to src/accessor/todo/grib_accessor_class_statistics.cc diff --git a/src/grib_accessor_class_statistics_spectral.cc b/src/accessor/todo/grib_accessor_class_statistics_spectral.cc similarity index 100% rename from src/grib_accessor_class_statistics_spectral.cc rename to src/accessor/todo/grib_accessor_class_statistics_spectral.cc diff --git a/src/grib_accessor_class_step_human_readable.cc b/src/accessor/todo/grib_accessor_class_step_human_readable.cc similarity index 100% rename from src/grib_accessor_class_step_human_readable.cc rename to src/accessor/todo/grib_accessor_class_step_human_readable.cc diff --git a/src/grib_accessor_class_step_in_units.cc b/src/accessor/todo/grib_accessor_class_step_in_units.cc similarity index 100% rename from src/grib_accessor_class_step_in_units.cc rename to src/accessor/todo/grib_accessor_class_step_in_units.cc diff --git a/src/grib_accessor_class_sum.cc b/src/accessor/todo/grib_accessor_class_sum.cc similarity index 100% rename from src/grib_accessor_class_sum.cc rename to src/accessor/todo/grib_accessor_class_sum.cc diff --git a/src/grib_accessor_class_suppressed.cc b/src/accessor/todo/grib_accessor_class_suppressed.cc similarity index 100% rename from src/grib_accessor_class_suppressed.cc rename to src/accessor/todo/grib_accessor_class_suppressed.cc diff --git a/src/grib_accessor_class_time.cc b/src/accessor/todo/grib_accessor_class_time.cc similarity index 100% rename from src/grib_accessor_class_time.cc rename to src/accessor/todo/grib_accessor_class_time.cc diff --git a/src/grib_accessor_class_to_double.cc b/src/accessor/todo/grib_accessor_class_to_double.cc similarity index 100% rename from src/grib_accessor_class_to_double.cc rename to src/accessor/todo/grib_accessor_class_to_double.cc diff --git a/src/grib_accessor_class_to_integer.cc b/src/accessor/todo/grib_accessor_class_to_integer.cc similarity index 100% rename from src/grib_accessor_class_to_integer.cc rename to src/accessor/todo/grib_accessor_class_to_integer.cc diff --git a/src/grib_accessor_class_to_string.cc b/src/accessor/todo/grib_accessor_class_to_string.cc similarity index 100% rename from src/grib_accessor_class_to_string.cc rename to src/accessor/todo/grib_accessor_class_to_string.cc diff --git a/src/grib_accessor_class_transient.cc b/src/accessor/todo/grib_accessor_class_transient.cc similarity index 100% rename from src/grib_accessor_class_transient.cc rename to src/accessor/todo/grib_accessor_class_transient.cc diff --git a/src/grib_accessor_class_transient_darray.cc b/src/accessor/todo/grib_accessor_class_transient_darray.cc similarity index 100% rename from src/grib_accessor_class_transient_darray.cc rename to src/accessor/todo/grib_accessor_class_transient_darray.cc diff --git a/src/grib_accessor_class_trim.cc b/src/accessor/todo/grib_accessor_class_trim.cc similarity index 100% rename from src/grib_accessor_class_trim.cc rename to src/accessor/todo/grib_accessor_class_trim.cc diff --git a/src/grib_accessor_class_uint16.cc b/src/accessor/todo/grib_accessor_class_uint16.cc similarity index 100% rename from src/grib_accessor_class_uint16.cc rename to src/accessor/todo/grib_accessor_class_uint16.cc diff --git a/src/grib_accessor_class_uint32.cc b/src/accessor/todo/grib_accessor_class_uint32.cc similarity index 100% rename from src/grib_accessor_class_uint32.cc rename to src/accessor/todo/grib_accessor_class_uint32.cc diff --git a/src/grib_accessor_class_uint32_little_endian.cc b/src/accessor/todo/grib_accessor_class_uint32_little_endian.cc similarity index 100% rename from src/grib_accessor_class_uint32_little_endian.cc rename to src/accessor/todo/grib_accessor_class_uint32_little_endian.cc diff --git a/src/grib_accessor_class_uint64.cc b/src/accessor/todo/grib_accessor_class_uint64.cc similarity index 100% rename from src/grib_accessor_class_uint64.cc rename to src/accessor/todo/grib_accessor_class_uint64.cc diff --git a/src/grib_accessor_class_uint64_little_endian.cc b/src/accessor/todo/grib_accessor_class_uint64_little_endian.cc similarity index 100% rename from src/grib_accessor_class_uint64_little_endian.cc rename to src/accessor/todo/grib_accessor_class_uint64_little_endian.cc diff --git a/src/grib_accessor_class_uint8.cc b/src/accessor/todo/grib_accessor_class_uint8.cc similarity index 100% rename from src/grib_accessor_class_uint8.cc rename to src/accessor/todo/grib_accessor_class_uint8.cc diff --git a/src/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc similarity index 100% rename from src/grib_accessor_class_unexpanded_descriptors.cc rename to src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc diff --git a/src/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc similarity index 100% rename from src/grib_accessor_class_unpack_bufr_values.cc rename to src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc diff --git a/src/grib_accessor_class_unsigned.cc b/src/accessor/todo/grib_accessor_class_unsigned.cc similarity index 100% rename from src/grib_accessor_class_unsigned.cc rename to src/accessor/todo/grib_accessor_class_unsigned.cc diff --git a/src/grib_accessor_class_unsigned_bits.cc b/src/accessor/todo/grib_accessor_class_unsigned_bits.cc similarity index 100% rename from src/grib_accessor_class_unsigned_bits.cc rename to src/accessor/todo/grib_accessor_class_unsigned_bits.cc diff --git a/src/grib_accessor_class_validity_date.cc b/src/accessor/todo/grib_accessor_class_validity_date.cc similarity index 100% rename from src/grib_accessor_class_validity_date.cc rename to src/accessor/todo/grib_accessor_class_validity_date.cc diff --git a/src/grib_accessor_class_validity_time.cc b/src/accessor/todo/grib_accessor_class_validity_time.cc similarity index 100% rename from src/grib_accessor_class_validity_time.cc rename to src/accessor/todo/grib_accessor_class_validity_time.cc diff --git a/src/grib_accessor_class_values.cc b/src/accessor/todo/grib_accessor_class_values.cc similarity index 100% rename from src/grib_accessor_class_values.cc rename to src/accessor/todo/grib_accessor_class_values.cc diff --git a/src/grib_accessor_class_variable.cc b/src/accessor/todo/grib_accessor_class_variable.cc similarity index 100% rename from src/grib_accessor_class_variable.cc rename to src/accessor/todo/grib_accessor_class_variable.cc diff --git a/src/grib_accessor_class_vector.cc b/src/accessor/todo/grib_accessor_class_vector.cc similarity index 100% rename from src/grib_accessor_class_vector.cc rename to src/accessor/todo/grib_accessor_class_vector.cc diff --git a/src/grib_accessor_class_when.cc b/src/accessor/todo/grib_accessor_class_when.cc similarity index 100% rename from src/grib_accessor_class_when.cc rename to src/accessor/todo/grib_accessor_class_when.cc From 6647a213999fc2e4d6158555273be54072537774 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Sun, 17 Mar 2024 12:57:53 +0000 Subject: [PATCH 02/90] Create a todo list --- src/{ => accessor}/grib_accessor.cc | 0 src/{ => accessor}/grib_accessor.h | 0 src/accessor/{todo => }/grib_accessor_class_codetable.cc | 0 src/accessor/{todo => }/grib_accessor_class_constant.cc | 0 src/accessor/{todo => }/grib_accessor_class_iterator.cc | 0 src/accessor/{todo => }/grib_accessor_class_long.cc | 0 src/accessor/{todo => }/grib_accessor_class_nearest.cc | 0 src/accessor/{todo => }/grib_accessor_class_smart_table.cc | 0 src/accessor/{todo => }/grib_accessor_class_transient.cc | 0 src/accessor/{todo => }/grib_accessor_class_unsigned.cc | 0 src/accessor/{todo => }/grib_accessor_class_variable.cc | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => accessor}/grib_accessor.cc (100%) rename src/{ => accessor}/grib_accessor.h (100%) rename src/accessor/{todo => }/grib_accessor_class_codetable.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_constant.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_iterator.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_long.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_nearest.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_smart_table.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_transient.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_unsigned.cc (100%) rename src/accessor/{todo => }/grib_accessor_class_variable.cc (100%) diff --git a/src/grib_accessor.cc b/src/accessor/grib_accessor.cc similarity index 100% rename from src/grib_accessor.cc rename to src/accessor/grib_accessor.cc diff --git a/src/grib_accessor.h b/src/accessor/grib_accessor.h similarity index 100% rename from src/grib_accessor.h rename to src/accessor/grib_accessor.h diff --git a/src/accessor/todo/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_codetable.cc rename to src/accessor/grib_accessor_class_codetable.cc diff --git a/src/accessor/todo/grib_accessor_class_constant.cc b/src/accessor/grib_accessor_class_constant.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_constant.cc rename to src/accessor/grib_accessor_class_constant.cc diff --git a/src/accessor/todo/grib_accessor_class_iterator.cc b/src/accessor/grib_accessor_class_iterator.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_iterator.cc rename to src/accessor/grib_accessor_class_iterator.cc diff --git a/src/accessor/todo/grib_accessor_class_long.cc b/src/accessor/grib_accessor_class_long.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_long.cc rename to src/accessor/grib_accessor_class_long.cc diff --git a/src/accessor/todo/grib_accessor_class_nearest.cc b/src/accessor/grib_accessor_class_nearest.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_nearest.cc rename to src/accessor/grib_accessor_class_nearest.cc diff --git a/src/accessor/todo/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_smart_table.cc rename to src/accessor/grib_accessor_class_smart_table.cc diff --git a/src/accessor/todo/grib_accessor_class_transient.cc b/src/accessor/grib_accessor_class_transient.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_transient.cc rename to src/accessor/grib_accessor_class_transient.cc diff --git a/src/accessor/todo/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_unsigned.cc rename to src/accessor/grib_accessor_class_unsigned.cc diff --git a/src/accessor/todo/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc similarity index 100% rename from src/accessor/todo/grib_accessor_class_variable.cc rename to src/accessor/grib_accessor_class_variable.cc From be71970aa85b593d9ddfdc75b32804988115e8fb Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Sun, 17 Mar 2024 15:04:53 +0000 Subject: [PATCH 03/90] Abstract grib_accessor and grib_accessor_class --- src/accessor/grib_accessor_class_codetable.h | 47 ++ src/accessor/grib_accessor_class_constant.h | 27 + src/accessor/grib_accessor_class_gen.cc | 767 ++++++++++++++++++ src/accessor/grib_accessor_class_gen.h | 142 ++++ src/accessor/grib_accessor_class_iterator.h | 36 + src/accessor/grib_accessor_class_long.h | 22 + src/accessor/grib_accessor_class_nearest.h | 33 + .../grib_accessor_class_smart_table.h | 52 ++ src/accessor/grib_accessor_class_transient.h | 26 + src/accessor/grib_accessor_class_unsigned.h | 40 + src/accessor/grib_accessor_class_variable.h | 50 ++ src/accessor/grib_accessors_list.cc | 143 ++++ src/accessor/grib_accessors_list.h | 28 + 13 files changed, 1413 insertions(+) create mode 100644 src/accessor/grib_accessor_class_codetable.h create mode 100644 src/accessor/grib_accessor_class_constant.h create mode 100644 src/accessor/grib_accessor_class_gen.cc create mode 100644 src/accessor/grib_accessor_class_gen.h create mode 100644 src/accessor/grib_accessor_class_iterator.h create mode 100644 src/accessor/grib_accessor_class_long.h create mode 100644 src/accessor/grib_accessor_class_nearest.h create mode 100644 src/accessor/grib_accessor_class_smart_table.h create mode 100644 src/accessor/grib_accessor_class_transient.h create mode 100644 src/accessor/grib_accessor_class_unsigned.h create mode 100644 src/accessor/grib_accessor_class_variable.h create mode 100644 src/accessor/grib_accessors_list.cc create mode 100644 src/accessor/grib_accessors_list.h diff --git a/src/accessor/grib_accessor_class_codetable.h b/src/accessor/grib_accessor_class_codetable.h new file mode 100644 index 000000000..c77c6f72d --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable.h @@ -0,0 +1,47 @@ +/* + * (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. + */ + +/***************************************** + * Enrico Fucile + ****************************************/ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" +#include + + +class grib_accessor_codetable_t : public grib_accessor_unsigned_t +{ +public: + const char* tablename; + const char* masterDir; + const char* localDir; + grib_codetable* table; + int table_loaded; +}; + +class grib_accessor_class_codetable_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_t{}; } + grib_accessor_class_codetable_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_constant.h b/src/accessor/grib_accessor_class_constant.h new file mode 100644 index 000000000..0c4944c68 --- /dev/null +++ b/src/accessor/grib_accessor_class_constant.h @@ -0,0 +1,27 @@ +/* + * (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. + */ + + +/************************************* + * Enrico Fucile + **************************************/ + +#include "../grib_api_internal.h" +#include "grib_accessor_class_variable.h" + +class grib_accessor_constant_t : public grib_accessor_variable_t {}; + +class grib_accessor_class_constant_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_constant_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_constant_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc new file mode 100644 index 000000000..fb885700b --- /dev/null +++ b/src/accessor/grib_accessor_class_gen.cc @@ -0,0 +1,767 @@ +#include "grib_accessor.h" +#include "grib_accessor_class_gen.h" +#include + +// ======================== grib_accessor_gen ======================== + + + +void grib_accessor_gen_t::dump(grib_dumper* f) +{ + return cclass->dump(this, f); +} +int grib_accessor_gen_t::pack_missing() +{ + // grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); + return cclass->pack_missing(this); +} +// int grib_accessor_gen_t::pack_zero(grib_accessor* a) +// { +// return cclass->clear(a); +// } + +int grib_accessor_gen_t::is_missing_internal() +{ + return cclass->is_missing(this); +} + +int grib_accessor_gen_t::pack_double(const double* v, size_t* len) +{ + return cclass->pack_double(this, v, len); +} + +int grib_accessor_gen_t::pack_float(const float* v, size_t* len) +{ + return cclass->pack_float(this, v, len); +} + +int grib_accessor_gen_t::pack_expression(grib_expression* e) +{ + return cclass->pack_expression(this, e); +} + +int grib_accessor_gen_t::pack_string(const char* v, size_t* len) +{ + return cclass->pack_string(this, v, len); +} + +int grib_accessor_gen_t::pack_string_array(const char** v, size_t* len) +{ + return cclass->pack_string_array(this, v, len); +} + +int grib_accessor_gen_t::pack_long(const long* v, size_t* len) +{ + return cclass->pack_long(this, v, len); +} + +int grib_accessor_gen_t::pack_bytes(const unsigned char* v, size_t* len) +{ + return cclass->pack_bytes(this, v, len); +} + +int grib_accessor_gen_t::unpack_bytes(unsigned char* v, size_t* len) +{ + return cclass->unpack_bytes(this, v, len); +} + +int grib_accessor_gen_t::unpack_double_subarray(double* v, size_t start, size_t len) +{ + return cclass->unpack_double_subarray(this, v, start, len); +} + +int grib_accessor_gen_t::unpack_double(double* v, size_t* len) +{ + return cclass->unpack_double(this, v, len); +} + +int grib_accessor_gen_t::unpack_float(float* v, size_t* len) +{ + // return cclass->unpack_float(this, v, len); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_gen_t::unpack_double_element(size_t i, double* v) +{ + return cclass->unpack_double_element(this, i, v); +} + +int grib_accessor_gen_t::unpack_float_element(size_t i, float* v) +{ + // return cclass->unpack_float_element(this, i, v); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_gen_t::unpack_long(long* v, size_t* len) +{ + return cclass->unpack_long(this, v, len); +} + +long grib_accessor_gen_t::get_native_type() +{ + return cclass->get_native_type(this); +} + +long grib_accessor_gen_t::get_next_position_offset() +{ + return cclass->next_offset(this); +} + +long grib_accessor_gen_t::string_length() +{ + return cclass->string_length(this); +} + +long grib_accessor_gen_t::byte_offset() +{ + return cclass->byte_offset(this); +} + +long grib_accessor_gen_t::byte_count() +{ + return cclass->byte_count(this); +} + +int grib_accessor_gen_t::value_count(long* count) +{ + return cclass->value_count(this, count); +} + +int grib_accessor_gen_t::notify_change(grib_accessor* changed) +{ + return cclass->notify_change(this, changed); +} + +// Get the values for the indices passed in. +// The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements +int grib_accessor_gen_t::unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) +{ + return cclass->unpack_double_element_set(this, index_array, len, val_array); +} +int grib_accessor_gen_t::unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) +{ + throw std::runtime_error("grib_unpack_float_element_set not implemented"); +} +int grib_accessor_gen_t::unpack_string(char* v, size_t* len) +{ + return cclass->unpack_string(this, v, len); +} +int grib_accessor_gen_t::unpack_string_array(char** v, size_t* len) +{ + return cclass->unpack_string_array(this, v, len); +} + +void grib_accessor_gen_t::init_accessor(const long len, grib_arguments* args) +{ + this->cclass->init(this, len, args); +} + +grib_accessor* grib_accessor_gen_t::clone(grib_section* s, int* err) +{ + grib_context* ct = this->context; + grib_context_log(ct, GRIB_LOG_DEBUG, "clone %s ==> %s", cclass->name, this->name); + return cclass->make_clone(this, s, err); +} + +void grib_accessor_gen_t::update_size(size_t len) +{ + cclass->update_size(this, len); +} + +int grib_accessor_gen_t::nearest_smaller_value(double val, double* nearest) +{ + return cclass->nearest_smaller_value(this, val, nearest); +} + +size_t grib_accessor_gen_t::preferred_size(int from_handle) +{ + return cclass->preferred_size(this, from_handle); +} + +grib_accessor* grib_accessor_gen_t::next_accessor() +{ + return cclass->next(this, 0); +} + +void grib_accessor_gen_t::resize(size_t new_size) +{ + cclass->resize(this, new_size); +} + +// For this one, ALL destroy are called +void grib_accessor_delete(grib_context* ct, grib_accessor* a) +{ + free(a); +} + + + + +// ======================== grib_accessor_class_gen ======================== + + +grib_accessor_class_gen_t _grib_accessor_class_gen = grib_accessor_class_gen_t("gen"); +grib_accessor_class_gen_t* grib_accessor_class_gen = &_grib_accessor_class_gen; + +void grib_accessor_class_gen_t::init(grib_accessor* a, const long len, grib_arguments* param) +{ + grib_action* act = (grib_action*)(a->creator); + if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { + a->length = 0; + if (!a->vvalue) + a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); + a->vvalue->type = a->get_native_type(); + a->vvalue->length = len; + if (act->default_value != NULL) { + const char* p = 0; + size_t s_len = 1; + long l; + int ret = 0; + double d; + char tmp[1024]; + grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); + int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); + switch (type) { + case GRIB_TYPE_DOUBLE: + grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); + a->pack_double(&d, &s_len); + break; + + case GRIB_TYPE_LONG: + grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); + a->pack_long(&l, &s_len); + break; + + default: + s_len = sizeof(tmp); + p = grib_expression_evaluate_string(grib_handle_of_accessor(a), expression, tmp, &s_len, &ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to evaluate %s as string", a->name); + Assert(0); + } + s_len = strlen(p) + 1; + a->pack_string(p, &s_len); + break; + } + } + } + else { + a->length = len; + } +} + +void grib_accessor_class_gen_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + const int type = a->get_native_type(); + switch (type) { + case GRIB_TYPE_STRING: + grib_dump_string(dumper, a, NULL); + break; + case GRIB_TYPE_DOUBLE: + grib_dump_double(dumper, a, NULL); + break; + case GRIB_TYPE_LONG: + grib_dump_long(dumper, a, NULL); + break; + default: + grib_dump_bytes(dumper, a, NULL); + } +} + +long grib_accessor_class_gen_t::next_offset(grib_accessor* a) +{ + return a->offset + a->length; +} + +int grib_accessor_class_gen_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_gen_t::string_length(grib_accessor* a) +{ + return 1024; +} + +long grib_accessor_class_gen_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_gen_t::get_native_type(grib_accessor* a) +{ + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s [%s] must implement 'get_native_type'", a->name, a->cclass->name); + return GRIB_TYPE_UNDEFINED; +} + +long grib_accessor_class_gen_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +int grib_accessor_class_gen_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) +{ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const long length = a->byte_count(); + const long offset = a->byte_offset(); + + if (*len < length) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", a->name, length); + *len = length; + return GRIB_ARRAY_TOO_SMALL; + } + + memcpy(val, buf + offset, length); + *len = length; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::clear(grib_accessor* a) +{ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const long length = a->byte_count(); + const long offset = a->byte_offset(); + + memset(buf + offset, 0, length); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ + int type = GRIB_TYPE_UNDEFINED; + //if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { + try { + double val = 0.0; + size_t l = 1; + a->unpack_double(&val, &l); + if (val == GRIB_MISSING_DOUBLE) + *v = GRIB_MISSING_LONG; + else + *v = (long)val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); + return GRIB_SUCCESS; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { + try { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + + *v = strtol(val, &last, 10); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", a->name); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ + return unpack_helper(a, v, len); +} + +int grib_accessor_class_gen_t::unpack_float(grib_accessor* a, float* v, size_t* len) +{ + return unpack_helper(a, v, len); +} + +int grib_accessor_class_gen_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ + int err = 0; + //if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { + try { + double val = 0.0; + size_t l = 1; + err = a->unpack_double(&val, &l); + if (err) return err; + snprintf(v, 64, "%g", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); + return GRIB_SUCCESS; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { + try { + long val = 0; + size_t l = 1; + err = a->unpack_long(&val, &l); + if (err) return err; + snprintf(v, 64, "%ld", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); + return GRIB_SUCCESS; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_string_array(grib_accessor* a, char** v, size_t* len) +{ + size_t length = 0; + + int err = grib_get_string_length_acc(a, &length); + if (err) + return err; + v[0] = (char*)grib_context_malloc_clear(a->context, length); + a->unpack_string(v[0], &length); // TODO(masn): check return value + *len = 1; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::pack_expression(grib_accessor* a, grib_expression* e) +{ + size_t len = 1; + long lval = 0; + double dval = 0; + const char* cval = NULL; + int ret = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + // Use the native type of the expression not the accessor + switch (grib_expression_native_type(hand, e)) { + case GRIB_TYPE_LONG: { + len = 1; + ret = grib_expression_evaluate_long(hand, e, &lval); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as long (from %s)", + a->name, e->cclass->name); + return ret; + } + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %ld\n", a->name,lval);*/ + return a->pack_long(&lval, &len); + } + + case GRIB_TYPE_DOUBLE: { + len = 1; + ret = grib_expression_evaluate_double(hand, e, &dval); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as double (from %s)", + a->name, e->cclass->name); + return ret; + } + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %g\n", a->name, dval);*/ + return a->pack_double(&dval, &len); + } + + case GRIB_TYPE_STRING: { + char tmp[1024]; + len = sizeof(tmp); + cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as string (from %s)", + a->name, e->cclass->name); + return ret; + } + len = strlen(cval); + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %s\n", a->name, cval);*/ + return a->pack_string(cval, &len); + } + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ + grib_context* c = a->context; + //if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { + try { + double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); + if (!val) { + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double))); + return GRIB_OUT_OF_MEMORY; + } + for (size_t i = 0; i < *len; i++) + val[i] = v[i]; + int ret = a->pack_double(val, len); + grib_context_free(c, val); + return ret; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", a->name); + //if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { + try { + grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + return GRIB_NOT_IMPLEMENTED; +} + +int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) +{ + grib_context* c = a->context; + int ret = GRIB_SUCCESS; + size_t numBytes = *len * (sizeof(long)); + long* lValues = (long*)grib_context_malloc(c, numBytes); + if (!lValues) { + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes); + return GRIB_OUT_OF_MEMORY; + } + for (size_t i = 0; i < *len; i++) + lValues[i] = (long)v[i]; /* convert from double to long */ + ret = a->pack_long(lValues, len); + grib_context_free(c, lValues); + return ret; +} + +int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, size_t* len) +{ + int do_pack_as_long = 0; + grib_context* c = a->context; + //if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { + try { + do_pack_as_long = 1; + } + //else { + catch (std::runtime_error& e) { + /* ECC-648: Special case of codetable */ + if (strcmp(a->cclass->name, "codetable") == 0) { + do_pack_as_long = 1; + } + // TODO(maee): replace try-catch logic + } + if (do_pack_as_long) { + return pack_double_array_as_long(a, v, len); + } + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); + //if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { + try { + grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); + } + catch (std::runtime_error& e) { + // TODO(maee): replace try-catch logic + } + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_string_array(grib_accessor* a, const char** v, size_t* len) +{ + int err = 0; + size_t length = 0; + grib_accessor* as = 0; + + as = a; + long i = (long)*len - 1; + while (as && i >= 0) { + length = strlen(v[i]); + err = as->pack_string(v[i], &length); + if (err) + return err; + --i; + as = as->same; + } + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::pack_string(grib_accessor* a, const char* v, size_t* len) +{ + //if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { + try { + size_t l = 1; + char* endPtr = NULL; /* for error handling */ + double val = strtod(v, &endPtr); + if (*endPtr) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Invalid value (%s) for key '%s'. String cannot be converted to a double", + __func__, v, a->name); + return GRIB_WRONG_TYPE; + } + return a->pack_double(&val, &l); + } + catch (std::runtime_error& e) { + // TODO(maee): replace try-catch logic + } + + //if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { + try { + size_t l = 1; + long val = atol(v); + return a->pack_long(&val, &l); + } + catch (std::runtime_error& e) { + // TODO(maee): replace try-catch logic + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) +{ + const size_t length = *len; + if (length != a->length) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long", + length, a->name, a->length); + return GRIB_BUFFER_TOO_SMALL; + } + grib_buffer_replace(a, val, length, 1, 1); + return GRIB_SUCCESS; +} + +void grib_accessor_class_gen_t::destroy(grib_context* ct, grib_accessor* a) +{ + grib_dependency_remove_observed(a); + grib_dependency_remove_observer(a); + if (a->vvalue != NULL) { + grib_context_free(ct, a->vvalue); + a->vvalue = NULL; + } + /*grib_context_log(ct,GRIB_LOG_DEBUG,"address=%p",a);*/ +} + +grib_section* grib_accessor_class_gen_t::sub_section(grib_accessor* a) +{ + return NULL; +} + +int grib_accessor_class_gen_t::notify_change(grib_accessor* self, grib_accessor* observed) +{ + /* Default behaviour is to notify creator */ + return grib_action_notify_change(self->creator, self, observed); +} + +void grib_accessor_class_gen_t::update_size(grib_accessor* a, size_t s) +{ + grib_context_log(a->context, GRIB_LOG_FATAL, + "Accessor %s [%s] must implement 'update_size'", a->name, a->cclass->name); +} + +grib_accessor* grib_accessor_class_gen_t::next(grib_accessor* a, int mod) +{ + grib_accessor* next = NULL; + if (a->next) { + next = a->next; + } + else { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} + +int grib_accessor_class_gen_t::compare(grib_accessor* a, grib_accessor* b) +{ + return GRIB_NOT_IMPLEMENTED; +} + +/* Redefined in all padding */ + +size_t grib_accessor_class_gen_t::preferred_size(grib_accessor* a, int from_handle) +{ + return a->length; +} + +int grib_accessor_class_gen_t::is_missing(grib_accessor* a) +{ + int i = 0; + int is_missing = 1; + unsigned char ones = 0xff; + unsigned char* v = NULL; + + if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { + if (a->vvalue == NULL) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", a->name, a->flags); + Assert(!"grib_accessor_class_gen_t::is_missing(): a->vvalue == NULL"); + return 0; + } + return a->vvalue->missing; + } + Assert(a->length >= 0); + + v = grib_handle_of_accessor(a)->buffer->data + a->offset; + + for (i = 0; i < a->length; i++) { + if (*v != ones) { + is_missing = 0; + break; + } + v++; + } + + return is_missing; +} + +int grib_accessor_class_gen_t::unpack_double_element(grib_accessor* a, size_t i, double* val) +{ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) +{ + return GRIB_NOT_IMPLEMENTED; +} + +grib_accessor* grib_accessor_class_gen_t::make_clone(grib_accessor* a, grib_section* s, int* err) +{ + *err = GRIB_NOT_IMPLEMENTED; + return NULL; +} + + + + +grib_accessor_class_gen_t::~grib_accessor_class_gen_t(){}; + +void grib_accessor_class_gen_t::post_init(grib_accessor*){ + return; +}; +int grib_accessor_class_gen_t::pack_missing(grib_accessor*) { + throw std::runtime_error("grib_accessor_class_gen_t::pack_missing not implemented"); +}; +int grib_accessor_class_gen_t::pack_float(grib_accessor*, const float*, size_t* len) { + throw std::runtime_error("grib_accessor_class_gen_t::pack_float not implemented"); +}; +void grib_accessor_class_gen_t::resize(grib_accessor*, size_t) { + throw std::runtime_error("grib_accessor_class_gen_t::resize not implemented"); +}; +int grib_accessor_class_gen_t::nearest_smaller_value(grib_accessor*, double, double*) { + throw std::runtime_error("grib_accessor_class_gen_t::nearest_smaller_value not implemented"); +}; +int grib_accessor_class_gen_t::unpack_float_element(grib_accessor*, size_t, float*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_float_element not implemented"); +}; +int unpack_element_set(grib_accessor*, const size_t*, size_t, double*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_element_set not implemented"); +}; +int grib_accessor_class_gen_t::unpack_float_element_set(grib_accessor*, const size_t*, size_t, float*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_float_element_set not implemented"); +}; diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h new file mode 100644 index 000000000..df85efab8 --- /dev/null +++ b/src/accessor/grib_accessor_class_gen.h @@ -0,0 +1,142 @@ +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor.h" + +class grib_accessor_gen_t : public grib_accessor { + void init_accessor(const long, grib_arguments*) override; + void dump(grib_dumper* f) override; + int pack_missing() override; + //int grib_pack_zero(grib_accessor* a) override; + int is_missing_internal() override; + int pack_double(const double* v, size_t* len) override; + int pack_float(const float* v, size_t* len) override; + int pack_expression(grib_expression* e) override; + int pack_string(const char* v, size_t* len) override; + int pack_string_array(const char** v, size_t* len) override; + int pack_long(const long* v, size_t* len) override; + int pack_bytes(const unsigned char* v, size_t* len) override; + int unpack_bytes(unsigned char* v, size_t* len) override; + int unpack_double_subarray(double* v, size_t start, size_t len) override; + int unpack_double(double* v, size_t* len) override; + int unpack_float(float* v, size_t* len) override; + int unpack_double_element(size_t i, double* v) override; + int unpack_float_element(size_t i, float* v) override; + int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) override; + int unpack_string(char* v, size_t* len) override; + int unpack_string_array(char** v, size_t* len) override; + int unpack_long(long* v, size_t* len) override; + long get_native_type() override; + long get_next_position_offset() override; + long string_length() override; + long byte_offset() override; + long byte_count() override; + int value_count(long* count) override; + int notify_change(grib_accessor* changed) override; + grib_accessor* clone(grib_section* s, int* err) override; + void update_size(size_t len) override; + int nearest_smaller_value(double val, double* nearest) override; + size_t preferred_size(int from_handle) override; + grib_accessor* next_accessor() override; + void resize(size_t new_size) override; + //int compare_accessors(grib_accessor* a2, int compare_flags) override; + //int add_attribute(grib_accessor* attr, int nest_if_clash) override; + //grib_accessor* get_attribute_index(const char* name, int* index) override; + //int has_attributes() override; + //grib_accessor* get_attribute(const char* name) override; +}; + +class grib_accessor_class_gen_t : public grib_accessor_class +{ +public: + grib_accessor_class_gen_t(const char* name) : grib_accessor_class{name} {} + ~grib_accessor_class_gen_t(); + + grib_accessor* create_empty_accessor() override{ return new grib_accessor_gen_t(); } + grib_section* sub_section(grib_accessor* a) override; + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; + void update_size(grib_accessor*, size_t) override; + size_t preferred_size(grib_accessor*, int) override; + void resize(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; + grib_accessor* next(grib_accessor*, int) override; + int compare(grib_accessor*, grib_accessor*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_float_element(grib_accessor*, size_t i, float* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; + int clear(grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; + + +template +int unpack_helper(grib_accessor* a, T* v, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + int type = GRIB_TYPE_UNDEFINED; + const char* Tname = type_to_string(*v); + //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { + try { + long val = 0; + size_t l = 1; + a->unpack_long(&val, &l); + *v = val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { + try { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + + *v = strtod(val, &last); + if (*last == 0) { /* conversion of string to double worked */ + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_iterator.h b/src/accessor/grib_accessor_class_iterator.h new file mode 100644 index 000000000..7288fa205 --- /dev/null +++ b/src/accessor/grib_accessor_class_iterator.h @@ -0,0 +1,36 @@ +/* + * (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. + */ + +/*************************** + * Enrico Fucile + *************************/ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_iterator_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + +class grib_accessor_class_iterator_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_iterator_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_iterator_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + + +//grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) diff --git a/src/accessor/grib_accessor_class_long.h b/src/accessor/grib_accessor_class_long.h new file mode 100644 index 000000000..a0b01f9ae --- /dev/null +++ b/src/accessor/grib_accessor_class_long.h @@ -0,0 +1,22 @@ +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_long_t : public grib_accessor_gen_t +{}; + +class grib_accessor_class_long_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_long_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + int get_native_type(grib_accessor* a) override; + int pack_missing(grib_accessor* a) override; + int pack_string(grib_accessor* a, const char*, size_t* len) override; + int unpack_double(grib_accessor* a, double* val, size_t* len) override; + int unpack_string(grib_accessor* a, char*, size_t* len) override; + void dump(grib_accessor* a, grib_dumper*) override; + int compare(grib_accessor* a, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_nearest.h b/src/accessor/grib_accessor_class_nearest.h new file mode 100644 index 000000000..831afea60 --- /dev/null +++ b/src/accessor/grib_accessor_class_nearest.h @@ -0,0 +1,33 @@ +/* + * (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. + */ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_nearest_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + + +class grib_accessor_class_nearest_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_nearest_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_nearest_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + + +//grib_nearest* grib_nearest_new(const grib_handle* ch, int* error); diff --git a/src/accessor/grib_accessor_class_smart_table.h b/src/accessor/grib_accessor_class_smart_table.h new file mode 100644 index 000000000..b6146a981 --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table.h @@ -0,0 +1,52 @@ +/* + * (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. + */ + +/***************************************** + * Enrico Fucile + ****************************************/ + + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" +#include + + +class grib_accessor_smart_table_t : public grib_accessor_unsigned_t +{ +public: + const char* values; + const char* tablename; + const char* masterDir; + const char* localDir; + const char* extraDir; + const char* extraTable; + int widthOfCode; + long* tableCodes; + size_t tableCodesSize; + grib_smart_table* table; + int dirty; +}; + + +class grib_accessor_class_smart_table_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_smart_table_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_transient.h b/src/accessor/grib_accessor_class_transient.h new file mode 100644 index 000000000..fa6771ecd --- /dev/null +++ b/src/accessor/grib_accessor_class_transient.h @@ -0,0 +1,26 @@ +/* + * (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. + */ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_variable.h" + +class grib_accessor_transient_t : public grib_accessor_variable_t { +public: +}; + +class grib_accessor_class_transient_t : public grib_accessor_class_variable_t { +public: + void init(grib_accessor* a, const long l, grib_arguments* args) override; + grib_accessor_class_transient_t(const char* name) : grib_accessor_class_variable_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_t{}; } +}; + diff --git a/src/accessor/grib_accessor_class_unsigned.h b/src/accessor/grib_accessor_class_unsigned.h new file mode 100644 index 000000000..99aadb93a --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned.h @@ -0,0 +1,40 @@ +/* + * (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. + */ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_t : public grib_accessor_long_t +{ +public: + long nbytes; + grib_arguments* arg; +}; + + +class grib_accessor_class_unsigned_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; + int unpack_long(grib_accessor* a, long* val, size_t* len) override; + int pack_long(grib_accessor* a, const long* val, size_t* len) override; + long byte_count(grib_accessor* a) override; + int value_count(grib_accessor* a, long* len) override; + long byte_offset(grib_accessor* a) override; + void update_size(grib_accessor* a, size_t s) override; + long next_offset(grib_accessor* a) override; + int is_missing(grib_accessor* a) override; + void destroy(grib_context* context, grib_accessor* a) override; +}; diff --git a/src/accessor/grib_accessor_class_variable.h b/src/accessor/grib_accessor_class_variable.h new file mode 100644 index 000000000..91c7f815d --- /dev/null +++ b/src/accessor/grib_accessor_class_variable.h @@ -0,0 +1,50 @@ +/* + * (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. + */ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor.h" +#include "grib_accessor_class_gen.h" + + +class grib_accessor_variable_t : public grib_accessor_gen_t +{ +public: + double dval; + float fval; + char* cval; + char* cname; + int type; +}; + +class grib_accessor_class_variable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_variable_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_variable_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc new file mode 100644 index 000000000..29d8b1f0d --- /dev/null +++ b/src/accessor/grib_accessors_list.cc @@ -0,0 +1,143 @@ + +#include "grib_accessors_list.h" + +grib_accessors_list* grib_accessors_list_create(grib_context* c) +{ + return (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); +} + +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) { + grib_accessors_list* tmp; + while (al) { + tmp = al->next_; + grib_context_free(c, al); + al = tmp; + } +} + + + + +int grib_accessors_list::value_count(size_t* count) +{ + long lcount = 0; + *count = 0; + grib_accessors_list* al = this; + while (al) { + al->accessor->value_count(&lcount); + *count += lcount; + al = al->next_; + } + return 0; +} + +void grib_accessors_list::push(grib_accessor* a, int rank) +{ + grib_accessors_list* last; + const grib_context* c = a->context; + + last = this->last(); + if (last && last->accessor) { + last->next_ = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); + last->next_->accessor = a; + last->next_->prev_ = last; + last->next_->rank = rank; + this->last_ = last->next_; + } + else { + this->accessor = a; + this->rank = rank; + this->last_ = this; + } +} + +grib_accessors_list* grib_accessors_list::last() +{ + return last_; +} + +grib_accessors_list::~grib_accessors_list() +{ + grib_accessors_list* tmp; + grib_context* c = grib_context_get_default(); + + grib_accessors_list* al = this; + while (al) { + tmp = al->next_; + //grib_accessor_delete(c, al->accessor); + grib_context_free(c, al); + al = tmp; + } +} + +int grib_accessors_list::unpack_long(long* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_long(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_double(double* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_double(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_float(float* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_float(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_string(char** val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_string_array(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h new file mode 100644 index 000000000..f088414f5 --- /dev/null +++ b/src/accessor/grib_accessors_list.h @@ -0,0 +1,28 @@ +#pragma once + +#include "grib_accessor.h" + +struct grib_accessors_list +{ +public: + grib_accessors_list(); + ~grib_accessors_list(); + + int value_count(size_t* count); + void push(grib_accessor* a, int rank); + grib_accessors_list* last(); + int unpack_long(long* val, size_t* buffer_len); + int unpack_double(double* val, size_t* buffer_len); + int unpack_float(float* val, size_t* buffer_len); + int unpack_string(char** val, size_t* buffer_len); + + grib_accessor* accessor; + int rank; + grib_accessors_list* next_; + grib_accessors_list* prev_; + grib_accessors_list* last_; +}; + +//grib_accessors_list* grib_accessors_list_create(grib_context* c); +//void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); + From 35b689a4d8a371be79fee7481979299bdec8011a Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Sun, 17 Mar 2024 16:44:07 +0000 Subject: [PATCH 04/90] Accessor backend ready for running accessors --- examples/C/grib_pthreads.c | 13 +- src/CMakeLists.txt | 414 ++++----- src/accessor/grib_accessor.cc | 788 +----------------- src/accessor/grib_accessor.h | 180 +++- src/accessor/grib_accessor_class_codetable.cc | 195 ++--- src/accessor/grib_accessor_class_constant.cc | 99 +-- src/accessor/grib_accessor_class_gen.cc | 5 +- src/accessor/grib_accessor_class_gen.h | 51 +- src/accessor/grib_accessor_class_iterator.cc | 98 +-- src/accessor/grib_accessor_class_long.cc | 141 +--- src/accessor/grib_accessor_class_nearest.cc | 98 +-- .../grib_accessor_class_smart_table.cc | 161 +--- src/accessor/grib_accessor_class_transient.cc | 94 +-- src/accessor/grib_accessor_class_unsigned.cc | 149 +--- src/accessor/grib_accessor_class_variable.cc | 201 +---- src/action_class_gen.cc | 2 +- src/action_class_remove.cc | 2 +- src/action_class_transient_darray.cc | 2 +- src/bufr_keys_iterator.cc | 4 +- src/eccodes_prototypes.h | 68 +- src/grib_accessor_class.cc | 38 +- src/grib_accessor_class.h | 404 ++++----- src/grib_accessor_classes_hash.cc | 625 ++------------ src/grib_accessor_factory.h | 390 ++++----- src/grib_accessor_factory_hash_list | 390 ++++----- src/grib_api_internal.h | 157 +--- src/grib_buffer.cc | 18 +- src/grib_bufr_descriptor.cc | 6 +- src/grib_dependency.cc | 4 +- src/grib_dumper_class.cc | 10 +- src/grib_dumper_class_bufr_decode_C.cc | 26 +- src/grib_dumper_class_bufr_decode_filter.cc | 20 +- src/grib_dumper_class_bufr_decode_fortran.cc | 24 +- src/grib_dumper_class_bufr_decode_python.cc | 24 +- src/grib_dumper_class_bufr_encode_C.cc | 34 +- src/grib_dumper_class_bufr_encode_filter.cc | 34 +- src/grib_dumper_class_bufr_encode_fortran.cc | 34 +- src/grib_dumper_class_bufr_encode_python.cc | 34 +- src/grib_dumper_class_bufr_simple.cc | 36 +- src/grib_dumper_class_debug.cc | 34 +- src/grib_dumper_class_default.cc | 38 +- src/grib_dumper_class_grib_encode_C.cc | 16 +- src/grib_dumper_class_json.cc | 22 +- src/grib_dumper_class_serialize.cc | 14 +- src/grib_dumper_class_wmo.cc | 32 +- src/grib_handle.cc | 2 +- src/grib_keys_iterator.cc | 16 +- src/grib_loader_from_handle.cc | 28 +- src/grib_parse_utils.cc | 34 +- src/grib_query.cc | 49 +- src/grib_value.cc | 107 +-- tests/grib_unpack_subarray.cc | 4 +- tools/bufr_dump.cc | 5 +- 53 files changed, 1678 insertions(+), 3796 deletions(-) diff --git a/examples/C/grib_pthreads.c b/examples/C/grib_pthreads.c index 2dce9a4cd..d9b23344c 100644 --- a/examples/C/grib_pthreads.c +++ b/examples/C/grib_pthreads.c @@ -9,11 +9,22 @@ */ #include -#include "grib_api_internal.h" +#include +#include +/*#include "grib_api_internal.h"*/ #include "eccodes.h" #define NUM_THREADS 4 +void Assert(int condition) +{ + if (!condition) { + printf("Assertion failed\n"); + exit(1); + } +} + + /* Return 0 if numbers considered equal, otherwise 1 */ static int compare_doubles(double a, double b, double tolerance) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97cd81dfc..21548a39c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,9 @@ # nor does it submit to any jurisdiction. # list( APPEND eccodes_src_files + ./accessor/grib_accessor.cc + ./accessor/grib_accessors_list.cc + ./grib_accessor_class.cc step_unit.cc step.cc step_utilities.cc @@ -20,9 +23,9 @@ list( APPEND eccodes_src_files action_class_gen.cc action_class_if.cc action_class_switch.cc - grib_accessor_class_g1fcperiod.cc - grib_accessor_class_g1end_of_interval_monthly.cc - grib_accessor_class_mars_param.cc + #grib_accessor_class_g1fcperiod.cc + #grib_accessor_class_g1end_of_interval_monthly.cc + #grib_accessor_class_mars_param.cc action_class_section.cc action_class_list.cc action_class_while.cc @@ -47,7 +50,6 @@ list( APPEND eccodes_src_files action_class_modify.cc action_class_transient_darray.cc eccodes.cc - grib_accessor.cc grib_concept.cc grib_hash_array.cc grib_bufr_descriptor.cc @@ -60,208 +62,208 @@ list( APPEND eccodes_src_files grib_iarray.cc grib_viarray.cc codes_memfs.cc - grib_accessor_class_ascii.cc - grib_accessor_class_bit.cc - grib_accessor_class_bitmap.cc - grib_accessor_class_bits.cc - grib_accessor_class_bits_per_value.cc - grib_accessor_class_bufr_elements_table.cc - grib_accessor_class_bufr_data_array.cc - grib_accessor_class_bufr_data_element.cc - grib_accessor_class_bufr_group.cc - grib_accessor_class_bufr_string_values.cc - grib_accessor_class_pack_bufr_values.cc - grib_accessor_class_unpack_bufr_values.cc - grib_accessor_class_group.cc - grib_accessor_class_non_alpha.cc - grib_accessor_class_g1bitmap.cc - grib_accessor_class_g2bitmap.cc - grib_accessor_class_concept.cc - grib_accessor_class_hash_array.cc - grib_accessor_class_decimal_precision.cc - grib_accessor_class_divdouble.cc - grib_accessor_class_multdouble.cc - grib_accessor_class_budgdate.cc - grib_accessor_class_validity_date.cc - grib_accessor_class_validity_time.cc - grib_accessor_class_bytes.cc - grib_accessor_class.cc - grib_accessor_class_change_alternative_row_scanning.cc - grib_accessor_class_change_scanning_direction.cc - grib_accessor_class_check_internal_version.cc - grib_accessor_class_codeflag.cc - grib_accessor_class_smart_table.cc - grib_accessor_class_smart_table_column.cc - grib_accessor_class_codetable.cc - grib_accessor_class_codetable_units.cc - grib_accessor_class_codetable_title.cc - grib_accessor_class_step_human_readable.cc - grib_accessor_class_count_file.cc - grib_accessor_class_count_total.cc - grib_accessor_class_double.cc - grib_accessor_class_element.cc - grib_accessor_class_evaluate.cc - grib_accessor_class_g1date.cc - grib_accessor_class_g1monthlydate.cc - grib_accessor_class_library_version.cc - grib_accessor_class_when.cc - grib_accessor_class_g1verificationdate.cc - grib_accessor_class_g1day_of_the_year_date.cc - grib_accessor_class_g1_half_byte_codeflag.cc - grib_accessor_class_g1forecastmonth.cc - grib_accessor_class_g1step_range.cc - grib_accessor_class_g2step_range.cc - grib_accessor_class_data_g22order_packing.cc - grib_accessor_class_mars_step.cc - grib_accessor_class_message_copy.cc - grib_accessor_class_dictionary.cc - grib_accessor_class_latlon_increment.cc - grib_accessor_class_g2date.cc - grib_accessor_class_g2level.cc - grib_accessor_class_g2end_step.cc - grib_accessor_class_g2latlon.cc - grib_accessor_class_g2lon.cc - grib_accessor_class_global_gaussian.cc - grib_accessor_class_gaussian_grid_name.cc - grib_accessor_class_gen.cc - grib_accessor_class_getenv.cc - grib_accessor_class_gts_header.cc - grib_accessor_class_ifs_param.cc - grib_accessor_class_julian_day.cc - grib_accessor_class_julian_date.cc - grib_accessor_class_closest_date.cc - grib_accessor_class_latlonvalues.cc - grib_accessor_class_latitudes.cc - grib_accessor_class_longitudes.cc - grib_accessor_class_offset_file.cc - grib_accessor_class_scale.cc - grib_accessor_class_from_scale_factor_scaled_value.cc - grib_accessor_class_g2bitmap_present.cc - grib_accessor_class_ibmfloat.cc - grib_accessor_class_ieeefloat.cc - grib_accessor_class_constant.cc - grib_accessor_class_iterator.cc - grib_accessor_class_message.cc - grib_accessor_class_nearest.cc - grib_accessor_class_ksec1expver.cc - grib_accessor_class_label.cc - grib_accessor_class_long.cc - grib_accessor_class_lookup.cc - grib_accessor_class_octahedral_gaussian.cc - grib_accessor_class_octet_number.cc - grib_accessor_class_headers_only.cc - grib_accessor_class_padding.cc - grib_accessor_class_pad.cc - grib_accessor_class_padto.cc - grib_accessor_class_padtoeven.cc - grib_accessor_class_padtomultiple.cc - grib_accessor_class_section_padding.cc - grib_accessor_class_packing_type.cc - grib_accessor_class_section_pointer.cc - grib_accessor_class_position.cc - grib_accessor_class_signed.cc - grib_accessor_class_signed_bits.cc - grib_accessor_class_section.cc - grib_accessor_class_step_in_units.cc - grib_accessor_class_optimal_step_units.cc - grib_accessor_class_section_length.cc - grib_accessor_class_g1_message_length.cc - grib_accessor_class_g1_section4_length.cc - grib_accessor_class_size.cc - grib_accessor_class_rdbtime_guess_date.cc - grib_accessor_class_scale_values.cc - grib_accessor_class_offset_values.cc - grib_accessor_class_sprintf.cc - grib_accessor_class_round.cc - grib_accessor_class_spectral_truncation.cc - grib_accessor_class_time.cc - grib_accessor_class_transient.cc - grib_accessor_class_trim.cc - grib_accessor_class_transient_darray.cc - grib_accessor_class_values.cc - grib_accessor_class_simple_packing_error.cc - grib_accessor_class_data_simple_packing.cc - grib_accessor_class_count_missing.cc - grib_accessor_class_data_sh_packed.cc - grib_accessor_class_data_sh_unpacked.cc - grib_accessor_class_number_of_values_data_raw_packing.cc - grib_accessor_class_data_g1simple_packing.cc - grib_accessor_class_data_g1shsimple_packing.cc - grib_accessor_class_data_shsimple_packing.cc - grib_accessor_class_data_dummy_field.cc - grib_accessor_class_variable.cc - grib_accessor_class_second_order_bits_per_value.cc - grib_accessor_class_data_g2simple_packing.cc - grib_accessor_class_data_g2simple_packing_with_preprocessing.cc - grib_accessor_class_data_g2shsimple_packing.cc - grib_accessor_class_data_g2complex_packing.cc - grib_accessor_class_data_g1second_order_row_by_row_packing.cc - grib_accessor_class_data_g1second_order_constant_width_packing.cc - grib_accessor_class_data_g1second_order_general_packing.cc - grib_accessor_class_data_g1second_order_general_extended_packing.cc - grib_accessor_class_g2grid.cc - grib_accessor_class_unexpanded_descriptors.cc - grib_accessor_class_expanded_descriptors.cc - grib_accessor_class_bufrdc_expanded_descriptors.cc - grib_accessor_class_data_apply_bitmap.cc - grib_accessor_class_data_apply_boustrophedonic.cc - grib_accessor_class_data_apply_boustrophedonic_bitmap.cc - grib_accessor_class_data_secondary_bitmap.cc - grib_accessor_class_data_g1secondary_bitmap.cc - grib_accessor_class_data_g2secondary_bitmap.cc - grib_accessor_class_data_jpeg2000_packing.cc - grib_accessor_class_data_png_packing.cc - grib_accessor_class_data_ccsds_packing.cc - grib_accessor_class_data_raw_packing.cc - grib_accessor_class_data_complex_packing.cc - grib_accessor_class_data_g1complex_packing.cc - grib_accessor_class_gds_not_present_bitmap.cc - grib_accessor_class_gds_is_present.cc - grib_accessor_class_select_step_template.cc - grib_accessor_class_local_definition.cc - grib_accessor_class_g2_eps.cc - grib_accessor_class_g2_aerosol.cc - grib_accessor_class_g2_chemical.cc - grib_accessor_class_g2_mars_labeling.cc - grib_accessor_class_md5.cc - grib_accessor_class_proj_string.cc + accessor/grib_accessor_class_gen.cc + #grib_accessor_class_ascii.cc + #grib_accessor_class_bit.cc + #grib_accessor_class_bitmap.cc + #grib_accessor_class_bits.cc + #grib_accessor_class_bits_per_value.cc + #grib_accessor_class_bufr_elements_table.cc + #grib_accessor_class_bufr_data_array.cc + #grib_accessor_class_bufr_data_element.cc + #grib_accessor_class_bufr_group.cc + #grib_accessor_class_bufr_string_values.cc + #grib_accessor_class_pack_bufr_values.cc + #grib_accessor_class_unpack_bufr_values.cc + #grib_accessor_class_group.cc + #grib_accessor_class_non_alpha.cc + #grib_accessor_class_g1bitmap.cc + #grib_accessor_class_g2bitmap.cc + #grib_accessor_class_concept.cc + #grib_accessor_class_hash_array.cc + #grib_accessor_class_decimal_precision.cc + #grib_accessor_class_divdouble.cc + #grib_accessor_class_multdouble.cc + #grib_accessor_class_budgdate.cc + #grib_accessor_class_validity_date.cc + #grib_accessor_class_validity_time.cc + #grib_accessor_class_bytes.cc + #grib_accessor_class_change_alternative_row_scanning.cc + #grib_accessor_class_change_scanning_direction.cc + #grib_accessor_class_check_internal_version.cc + #grib_accessor_class_codeflag.cc + accessor/grib_accessor_class_smart_table.cc + #grib_accessor_class_smart_table_column.cc + accessor/grib_accessor_class_codetable.cc + #grib_accessor_class_codetable_units.cc + #grib_accessor_class_codetable_title.cc + #grib_accessor_class_step_human_readable.cc + #grib_accessor_class_count_file.cc + #grib_accessor_class_count_total.cc + #grib_accessor_class_double.cc + #grib_accessor_class_element.cc + #grib_accessor_class_evaluate.cc + #grib_accessor_class_g1date.cc + #grib_accessor_class_g1monthlydate.cc + #grib_accessor_class_library_version.cc + #grib_accessor_class_when.cc + #grib_accessor_class_g1verificationdate.cc + #grib_accessor_class_g1day_of_the_year_date.cc + #grib_accessor_class_g1_half_byte_codeflag.cc + #grib_accessor_class_g1forecastmonth.cc + #grib_accessor_class_g1step_range.cc + #grib_accessor_class_g2step_range.cc + #grib_accessor_class_data_g22order_packing.cc + #grib_accessor_class_mars_step.cc + #grib_accessor_class_message_copy.cc + #grib_accessor_class_dictionary.cc + #grib_accessor_class_latlon_increment.cc + #grib_accessor_class_g2date.cc + #grib_accessor_class_g2level.cc + #grib_accessor_class_g2end_step.cc + #grib_accessor_class_g2latlon.cc + #grib_accessor_class_g2lon.cc + #grib_accessor_class_global_gaussian.cc + #grib_accessor_class_gaussian_grid_name.cc + #grib_accessor_class_gen.cc + #grib_accessor_class_getenv.cc + #grib_accessor_class_gts_header.cc + #grib_accessor_class_ifs_param.cc + #grib_accessor_class_julian_day.cc + #grib_accessor_class_julian_date.cc + #grib_accessor_class_closest_date.cc + #grib_accessor_class_latlonvalues.cc + #grib_accessor_class_latitudes.cc + #grib_accessor_class_longitudes.cc + #grib_accessor_class_offset_file.cc + #grib_accessor_class_scale.cc + #grib_accessor_class_from_scale_factor_scaled_value.cc + #grib_accessor_class_g2bitmap_present.cc + #grib_accessor_class_ibmfloat.cc + #grib_accessor_class_ieeefloat.cc + accessor/grib_accessor_class_constant.cc + accessor/grib_accessor_class_iterator.cc + #grib_accessor_class_message.cc + accessor/grib_accessor_class_nearest.cc + #grib_accessor_class_ksec1expver.cc + #grib_accessor_class_label.cc + accessor/grib_accessor_class_long.cc + #grib_accessor_class_lookup.cc + #grib_accessor_class_octahedral_gaussian.cc + #grib_accessor_class_octet_number.cc + #grib_accessor_class_headers_only.cc + #grib_accessor_class_padding.cc + #grib_accessor_class_pad.cc + #grib_accessor_class_padto.cc + #grib_accessor_class_padtoeven.cc + #grib_accessor_class_padtomultiple.cc + #grib_accessor_class_section_padding.cc + #grib_accessor_class_packing_type.cc + #grib_accessor_class_section_pointer.cc + #grib_accessor_class_position.cc + #grib_accessor_class_signed.cc + #grib_accessor_class_signed_bits.cc + #grib_accessor_class_section.cc + #grib_accessor_class_step_in_units.cc + #grib_accessor_class_optimal_step_units.cc + #grib_accessor_class_section_length.cc + #grib_accessor_class_g1_message_length.cc + #grib_accessor_class_g1_section4_length.cc + #grib_accessor_class_size.cc + #grib_accessor_class_rdbtime_guess_date.cc + #grib_accessor_class_scale_values.cc + #grib_accessor_class_offset_values.cc + #grib_accessor_class_sprintf.cc + #grib_accessor_class_round.cc + #grib_accessor_class_spectral_truncation.cc + #grib_accessor_class_time.cc + accessor/grib_accessor_class_transient.cc + #grib_accessor_class_trim.cc + #grib_accessor_class_transient_darray.cc + #grib_accessor_class_values.cc + #grib_accessor_class_simple_packing_error.cc + #grib_accessor_class_data_simple_packing.cc + #grib_accessor_class_count_missing.cc + #grib_accessor_class_data_sh_packed.cc + #grib_accessor_class_data_sh_unpacked.cc + #grib_accessor_class_number_of_values_data_raw_packing.cc + #grib_accessor_class_data_g1simple_packing.cc + #grib_accessor_class_data_g1shsimple_packing.cc + #grib_accessor_class_data_shsimple_packing.cc + #grib_accessor_class_data_dummy_field.cc + accessor/grib_accessor_class_variable.cc + #grib_accessor_class_second_order_bits_per_value.cc + #grib_accessor_class_data_g2simple_packing.cc + #grib_accessor_class_data_g2simple_packing_with_preprocessing.cc + #grib_accessor_class_data_g2shsimple_packing.cc + #grib_accessor_class_data_g2complex_packing.cc + #grib_accessor_class_data_g1second_order_row_by_row_packing.cc + #grib_accessor_class_data_g1second_order_constant_width_packing.cc + #grib_accessor_class_data_g1second_order_general_packing.cc + #grib_accessor_class_data_g1second_order_general_extended_packing.cc + #grib_accessor_class_g2grid.cc + #grib_accessor_class_unexpanded_descriptors.cc + #grib_accessor_class_expanded_descriptors.cc + #grib_accessor_class_bufrdc_expanded_descriptors.cc + #grib_accessor_class_data_apply_bitmap.cc + #grib_accessor_class_data_apply_boustrophedonic.cc + #grib_accessor_class_data_apply_boustrophedonic_bitmap.cc + #grib_accessor_class_data_secondary_bitmap.cc + #grib_accessor_class_data_g1secondary_bitmap.cc + #grib_accessor_class_data_g2secondary_bitmap.cc + #grib_accessor_class_data_jpeg2000_packing.cc + #grib_accessor_class_data_png_packing.cc + #grib_accessor_class_data_ccsds_packing.cc + #grib_accessor_class_data_raw_packing.cc + #grib_accessor_class_data_complex_packing.cc + #grib_accessor_class_data_g1complex_packing.cc + #grib_accessor_class_gds_not_present_bitmap.cc + #grib_accessor_class_gds_is_present.cc + #grib_accessor_class_select_step_template.cc + #grib_accessor_class_local_definition.cc + #grib_accessor_class_g2_eps.cc + #grib_accessor_class_g2_aerosol.cc + #grib_accessor_class_g2_chemical.cc + #grib_accessor_class_g2_mars_labeling.cc + #grib_accessor_class_md5.cc + #grib_accessor_class_proj_string.cc grib_jasper_encoding.cc grib_openjpeg_encoding.cc action_class_set_missing.cc - grib_accessor_class_number_of_points.cc - grib_accessor_class_suppressed.cc + #grib_accessor_class_number_of_points.cc + #grib_accessor_class_suppressed.cc grib_index.cc - grib_accessor_class_number_of_points_gaussian.cc - grib_accessor_class_number_of_values.cc - grib_accessor_class_number_of_coded_values.cc - grib_accessor_class_g1number_of_coded_values_sh_complex.cc - grib_accessor_class_g1number_of_coded_values_sh_simple.cc - grib_accessor_class_dirty.cc - grib_accessor_class_statistics.cc - grib_accessor_class_statistics_spectral.cc - grib_accessor_class_unsigned.cc - grib_accessor_class_unsigned_bits.cc - grib_accessor_class_raw.cc - grib_accessor_class_bufr_simple_thinning.cc - grib_accessor_class_bufr_extract_subsets.cc - grib_accessor_class_bufr_extract_area_subsets.cc - grib_accessor_class_bufr_extract_datetime_subsets.cc - grib_accessor_class_spd.cc - grib_accessor_class_sum.cc - grib_accessor_class_to_integer.cc - grib_accessor_class_to_double.cc - grib_accessor_class_to_string.cc - grib_accessor_class_sexagesimal2decimal.cc - grib_accessor_class_vector.cc - grib_accessor_class_long_vector.cc + #grib_accessor_class_number_of_points_gaussian.cc + #grib_accessor_class_number_of_values.cc + #grib_accessor_class_number_of_coded_values.cc + #grib_accessor_class_g1number_of_coded_values_sh_complex.cc + #grib_accessor_class_g1number_of_coded_values_sh_simple.cc + #grib_accessor_class_dirty.cc + #grib_accessor_class_statistics.cc + #grib_accessor_class_statistics_spectral.cc + accessor/grib_accessor_class_unsigned.cc + #grib_accessor_class_unsigned_bits.cc + #grib_accessor_class_raw.cc + #grib_accessor_class_bufr_simple_thinning.cc + #grib_accessor_class_bufr_extract_subsets.cc + #grib_accessor_class_bufr_extract_area_subsets.cc + #grib_accessor_class_bufr_extract_datetime_subsets.cc + #grib_accessor_class_spd.cc + #grib_accessor_class_sum.cc + #grib_accessor_class_to_integer.cc + #grib_accessor_class_to_double.cc + #grib_accessor_class_to_string.cc + #grib_accessor_class_sexagesimal2decimal.cc + #grib_accessor_class_vector.cc + #grib_accessor_class_long_vector.cc grib_gaussian_reduced.cc - grib_accessor_class_abstract_vector.cc - grib_accessor_class_abstract_long_vector.cc + #grib_accessor_class_abstract_vector.cc + #grib_accessor_class_abstract_long_vector.cc grib_loader_from_handle.cc grib_bits.cc grib_ibmfloat.cc grib_ieeefloat.cc - grib_accessor_class_reference_value_error.cc + #grib_accessor_class_reference_value_error.cc grib_memory.cc grib_buffer.cc grib_dumper.cc @@ -364,16 +366,16 @@ list( APPEND eccodes_src_files grib_yacc.h md5.h md5.cc - grib_accessor_class_uint16.cc - grib_accessor_class_uint32.cc - grib_accessor_class_uint32_little_endian.cc - grib_accessor_class_uint64.cc - grib_accessor_class_uint64_little_endian.cc - grib_accessor_class_uint8.cc - grib_accessor_class_blob.cc + #grib_accessor_class_uint16.cc + #grib_accessor_class_uint32.cc + #grib_accessor_class_uint32_little_endian.cc + #grib_accessor_class_uint64.cc + #grib_accessor_class_uint64_little_endian.cc + #grib_accessor_class_uint8.cc + #grib_accessor_class_blob.cc grib_optimize_decimal_factor.cc - grib_accessor_class_data_g2bifourier_packing.cc - grib_accessor_class_data_run_length_packing.cc + #grib_accessor_class_data_g2bifourier_packing.cc + #grib_accessor_class_data_run_length_packing.cc eccodes_windef.h # We ship our own generated lex/yacc C files grib_yacc.cc grib_lex.cc ) diff --git a/src/accessor/grib_accessor.cc b/src/accessor/grib_accessor.cc index a08f5348e..da14833bd 100644 --- a/src/accessor/grib_accessor.cc +++ b/src/accessor/grib_accessor.cc @@ -13,6 +13,7 @@ ***************************************************************************/ #include "grib_accessor.h" +#include // Note: A fast cut-down version of strcmp which does NOT return -1 // 0 means input strings are equal and 1 means not equal @@ -27,657 +28,40 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } -void grib_accessor_dump(grib_accessor* a, grib_dumper* f) +template <> +int grib_accessor::unpack(double* v, size_t* len) { - grib_accessor_class* c = a->cclass; - while (c) { - if (c->dump) { - c->dump(a, f); - return; - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); -} - -int grib_pack_missing(grib_accessor* a) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->pack_missing) { - return c->pack_missing(a); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -// int grib_pack_zero(grib_accessor* a) -// { -// grib_accessor_class* c = a->cclass; -// while (c) { -// if (c->clear) { -// return c->clear(a); -// } -// c = c->super ? *(c->super) : NULL; -// } -// DEBUG_ASSERT(0); -// return 0; -// } - -int grib_is_missing_internal(grib_accessor* a) -{ - grib_accessor_class* c = a->cclass; - // grib_context_log(a->context, GRIB_LOG_DEBUG, - // "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->is_missing) { - return c->is_missing(a); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_double(grib_accessor* a, const double* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->pack_double) { - return c->pack_double(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_float(grib_accessor* a, const float* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->pack_float) { - return c->pack_float(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_expression(grib_accessor* a, grib_expression* e) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->pack_expression) { - return c->pack_expression(a, e); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_string(grib_accessor* a, const char* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)"); - while (c) { - if (c->pack_string) { - return c->pack_string(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (string) %s",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?v:"(null)"); - while (c) { - if (c->pack_string_array) { - return c->pack_string_array(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->pack_long) { - return c->pack_long(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (bytes) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->pack_bytes) { - return c->pack_bytes(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (bytes)",(a->parent->owner)?(a->parent->owner->name):"root", a->name); - while (c) { - if (c->unpack_bytes) { - return c->unpack_bytes(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_t len) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->unpack_double_subarray) { - return c->unpack_double_subarray(a, v, start, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_unpack_double(grib_accessor* a, double* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (double)",(a->parent->owner)?(a->parent->owner->name):"root", a->name); - while (c) { - if (c->unpack_double) { - return c->unpack_double(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_unpack_float(grib_accessor* a, float* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - while (c) { - //printf("grib_accessor.c grib_unpack_float:: c->name=%s\n",c->name); - if (c->unpack_float) { - return c->unpack_float(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; + return unpack_double(v, len); } template <> -int grib_unpack(grib_accessor* a, double* v, size_t* len) +int grib_accessor::unpack(float* v, size_t* len) { - return grib_unpack_double(a, v, len); + return unpack_float(v, len); } -template <> -int grib_unpack(grib_accessor* a, float* v, size_t* len) -{ - return grib_unpack_float(a, v, len); -} - -int grib_unpack_double_element(grib_accessor* a, size_t i, double* v) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->unpack_double_element) { - return c->unpack_double_element(a, i, v); - } - c = c->super ? *(c->super) : NULL; - } - return GRIB_NOT_IMPLEMENTED; -} -int grib_unpack_float_element(grib_accessor* a, size_t i, float* v) -{ - // grib_accessor_class* c = a->cclass; - // while (c) { - // if (c->unpack_float_element) { - // return c->unpack_float_element(a, i, v); - // } - // c = c->super ? *(c->super) : NULL; - //} - - return GRIB_NOT_IMPLEMENTED; -} - -// Get the values for the indices passed in. -// The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements -int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_class* c = a->cclass; - DEBUG_ASSERT(len > 0); - while (c) { - if (c->unpack_double_element_set) { - return c->unpack_double_element_set(a, index_array, len, val_array); - } - c = c->super ? *(c->super) : NULL; - } - return GRIB_NOT_IMPLEMENTED; -} -int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, size_t len, float* val_array) -{ - // grib_accessor_class* c = a->cclass; - // DEBUG_ASSERT(len > 0); - // while (c) { - // if (c->unpack_float_element_set) { - // return c->unpack_float_element_set(a, index_array, len, val_array); - // } - // c = c->super ? *(c->super) : NULL; - // } - - return GRIB_NOT_IMPLEMENTED; -} - -int grib_unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (string)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); - while (c) { - if (c->unpack_string) { - return c->unpack_string(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->unpack_string_array) { - return c->unpack_string_array(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_accessors_list_unpack_long(grib_accessors_list* al, long* val, size_t* buffer_len) -{ - int err = GRIB_SUCCESS; - size_t unpacked_len = 0; - size_t len = 0; - - while (al && err == GRIB_SUCCESS) { - len = *buffer_len - unpacked_len; - err = grib_unpack_long(al->accessor, val + unpacked_len, &len); - unpacked_len += len; - al = al->next; - } - - *buffer_len = unpacked_len; - return err; -} - -int grib_accessors_list_unpack_double(grib_accessors_list* al, double* val, size_t* buffer_len) -{ - int err = GRIB_SUCCESS; - size_t unpacked_len = 0; - size_t len = 0; - - while (al && err == GRIB_SUCCESS) { - len = *buffer_len - unpacked_len; - err = grib_unpack_double(al->accessor, val + unpacked_len, &len); - unpacked_len += len; - al = al->next; - } - - *buffer_len = unpacked_len; - return err; -} - -int grib_accessors_list_unpack_float(grib_accessors_list* al, float* val, size_t* buffer_len) -{ - int err = GRIB_SUCCESS; - size_t unpacked_len = 0; - size_t len = 0; - - while (al && err == GRIB_SUCCESS) { - len = *buffer_len - unpacked_len; - err = grib_unpack_float(al->accessor, val + unpacked_len, &len); - unpacked_len += len; - al = al->next; - } - - *buffer_len = unpacked_len; - return err; -} - -int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_t* buffer_len) -{ - int err = GRIB_SUCCESS; - size_t unpacked_len = 0; - size_t len = 0; - - while (al && err == GRIB_SUCCESS) { - len = *buffer_len - unpacked_len; - err = grib_unpack_string_array(al->accessor, val + unpacked_len, &len); - unpacked_len += len; - al = al->next; - } - - *buffer_len = unpacked_len; - return err; -} - -int grib_unpack_long(grib_accessor* a, long* v, size_t* len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is unpacking (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); - while (c) { - if (c->unpack_long) { - return c->unpack_long(a, v, len); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -long grib_accessor_get_native_type(grib_accessor* a) -{ - grib_accessor_class* c = NULL; - if (a) - c = a->cclass; - - while (c) { - if (c->get_native_type) - return c->get_native_type(a); - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -long grib_get_next_position_offset(grib_accessor* a) -{ - grib_accessor_class* c = NULL; - //grib_context_log(a->context, GRIB_LOG_DEBUG, - // "(%s)%s is checking next (long)",(a->parent->owner)?(a->parent->owner->name):"root", a->name ); - if (a) - c = a->cclass; - - while (c) { - if (c->next_offset) - return c->next_offset(a); - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -long grib_string_length(grib_accessor* a) -{ - grib_accessor_class* c = NULL; - if (a) - c = a->cclass; - - while (c) { - if (c->string_length) - return c->string_length(a); - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -long grib_byte_offset(grib_accessor* a) -{ - grib_accessor_class* c = NULL; - if (a) - c = a->cclass; - - while (c) { - if (c->byte_offset) - return c->byte_offset(a); - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -long grib_byte_count(grib_accessor* a) -{ - grib_accessor_class* c = NULL; - if (a) - c = a->cclass; - - while (c) { - if (c->byte_count) - return c->byte_count(a); - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_value_count(grib_accessor* a, long* count) -{ - grib_accessor_class* c = NULL; - int err = 0; - if (a) - c = a->cclass; - - while (c) { - if (c->value_count) { - err = c->value_count(a, count); - return err; - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -int grib_accessors_list_value_count(grib_accessors_list* al, size_t* count) -{ - long lcount = 0; - *count = 0; - while (al) { - grib_value_count(al->accessor, &lcount); - *count += lcount; - al = al->next; - } - return 0; -} - -int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed) -{ - grib_accessor_class* c = NULL; - if (a) - c = a->cclass; - - while (c) { - if (c->notify_change) - return c->notify_change(a, changed); - c = c->super ? *(c->super) : NULL; - } - if (a && a->cclass) - fprintf(stderr, "Error: notify_change not implemented for %s %s\n", a->cclass->name, a->name); - DEBUG_ASSERT(0); - return 0; -} - -// For this one, ALL init are called -static void init_accessor(grib_accessor_class* c, grib_accessor* a, const long len, grib_arguments* args) -{ - if (c) { - grib_accessor_class* s = c->super ? *(c->super) : NULL; - init_accessor(s, a, len, args); - if (c->init) - c->init(a, len, args); - } -} - -void grib_init_accessor(grib_accessor* a, const long len, grib_arguments* args) -{ - init_accessor(a->cclass, a, len, args); -} - -// For this one, ALL destroy are called -void grib_accessor_delete(grib_context* ct, grib_accessor* a) -{ - grib_accessor_class* c = a->cclass; - while (c) { - grib_accessor_class* s = c->super ? *(c->super) : NULL; - //printf("grib_accessor_delete: before destroy a=%p c->name=%s ==> a->name=%s\n", (void*)a, c->name, a->name); - if (c->destroy) { - c->destroy(ct, a); - } - c = s; - } - // printf("grib_accessor_delete before free a=%p\n", (void*)a); - grib_context_free(ct, a); -} - -grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err) -{ - grib_accessor_class* c = a->cclass; - const grib_context* ct = a->context; - while (c) { - grib_accessor_class* super = c->super ? *(c->super) : NULL; - grib_context_log(ct, GRIB_LOG_DEBUG, "clone %s ==> %s", c->name, a->name); - if (c->make_clone) { - return c->make_clone(a, s, err); - } - c = super; - } - return 0; -} - -void grib_update_size(grib_accessor* a, size_t len) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, - // "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->update_size) { - c->update_size(a, len); - return; - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); -} - -int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->nearest_smaller_value) { - return c->nearest_smaller_value(a, val, nearest); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - - -size_t grib_preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_class* c = a->cclass; - // grib_context_log(a->context, GRIB_LOG_DEBUG, - // "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->preferred_size) { - return c->preferred_size(a, from_handle); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -grib_accessor* grib_next_accessor(grib_accessor* a) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->next) { - return c->next(a, 1); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} - -void grib_resize(grib_accessor* a, size_t new_size) -{ - grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, - // "(%s)%s is packing (long) %d",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); - while (c) { - if (c->resize) { - c->resize(a, new_size); - return; - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return; -} - -int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_flags) +int grib_accessor::compare_accessors(grib_accessor* a2, int compare_flags) { int ret = 0; long type1 = 0; long type2 = 0; int type_mismatch = 0; grib_accessor_class* c1 = NULL; + grib_accessor* a1 = this; if ((compare_flags & GRIB_COMPARE_NAMES) && grib_inline_strcmp(a1->name, a2->name)) return GRIB_NAME_MISMATCH; if (compare_flags & GRIB_COMPARE_TYPES) { - type1 = grib_accessor_get_native_type(a1); - type2 = grib_accessor_get_native_type(a2); + type1 = a1->get_native_type(); + type2 = a2->get_native_type(); type_mismatch = type1 != type2 ? 1 : 0; } - ret = GRIB_UNABLE_TO_COMPARE_ACCESSORS; + // ret = GRIB_UNABLE_TO_COMPARE_ACCESSORS; c1 = a1->cclass; - while (c1) { - if (c1->compare) { - ret = c1->compare(a1, a2); - break; - } - c1 = c1->super ? *(c1->super) : NULL; - } + ret = c1->compare(a1, a2); if (ret == GRIB_VALUE_MISMATCH && type_mismatch) ret = GRIB_TYPE_AND_VALUE_MISMATCH; @@ -685,24 +69,15 @@ int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_fla return ret; } -// int grib_accessor_clear_attributes(grib_accessor* a) -// { -// int id; -// for (id=0;idattributes[id]=NULL; -// } -// return 0; -// } - -int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_if_clash) +int grib_accessor::add_attribute(grib_accessor* attr, int nest_if_clash) { int id = 0; int idx = 0; grib_accessor* same = NULL; - grib_accessor* aloc = a; + grib_accessor* aloc = this; - if (grib_accessor_has_attributes(a)) { - same = grib_accessor_get_attribute_index(a, attr->name, &id); + if (this->has_attributes()) { + same = this->get_attribute_index(attr->name, &id); } if (same) { @@ -717,76 +92,34 @@ int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_ aloc->attributes[id] = attr; attr->parent_as_attribute = aloc; if (aloc->same) - attr->same = grib_accessor_get_attribute_index(aloc->same, attr->name, &idx); + attr->same = aloc->same->get_attribute_index(attr->name, &idx); - grib_context_log(a->context, GRIB_LOG_DEBUG, "added attribute %s->%s", a->name, attr->name); + grib_context_log(this->context, GRIB_LOG_DEBUG, "added attribute %s->%s", this->name, attr->name); return GRIB_SUCCESS; } } return GRIB_TOO_MANY_ATTRIBUTES; } -// int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr) -// { -// int id = 0; -// int idx = 0; -// if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) { -// grib_accessor_delete(a->context, a->attributes[id]); -// a->attributes[id] = attr; -// attr->parent_as_attribute = a; -// if (a->same) -// attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx); -// } -// else { -// grib_accessor_add_attribute(a, attr, 0); -// } -// return GRIB_SUCCESS; -// } - -// int grib_accessor_delete_attribute(grib_accessor* a, const char* name) -// { -// int id = 0; -// if (grib_accessor_get_attribute_index(a, name, &id) != NULL) { -// grib_accessor_delete(a->context, a->attributes[id]); -// a->attributes[id] = NULL; -// return GRIB_SUCCESS; -// } -// else { -// return GRIB_NOT_FOUND; -// } -// } - -// grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index) -// { -// if (index < MAX_ACCESSOR_ATTRIBUTES) -// return a->attributes[index]; -// return NULL; -// } - -// const char* grib_accessor_get_name(grib_accessor* a) -// { -// return a->name; -// } - -grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index) +grib_accessor* grib_accessor::get_attribute_index(const char* name, int* index) { int i = 0; - while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { - if (!grib_inline_strcmp(a->attributes[i]->name, name)) { + while (i < MAX_ACCESSOR_ATTRIBUTES && this->attributes[i]) { + if (!grib_inline_strcmp(this->attributes[i]->name, name)) { *index = i; - return a->attributes[i]; + return this->attributes[i]; } i++; } return NULL; } -int grib_accessor_has_attributes(grib_accessor* a) +int grib_accessor::has_attributes() { - return a->attributes[0] ? 1 : 0; + return this->attributes[0] ? 1 : 0; } -grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name) +grib_accessor* grib_accessor::get_attribute(const char* name) { int index = 0; const char* p = 0; @@ -797,79 +130,18 @@ grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name) while (*(p + 1) != '\0' && (*p != '-' || *(p + 1) != '>')) p++; if (*(p + 1) == '\0') { - return grib_accessor_get_attribute_index(a, name, &index); + return this->get_attribute_index(name, &index); } else { size_t size = p - name; attribute_name = p + 2; - basename = (char*)grib_context_malloc_clear(a->context, size + 1); + basename = (char*)grib_context_malloc_clear(this->context, size + 1); basename = (char*)memcpy(basename, name, size); - acc = grib_accessor_get_attribute_index(a, basename, &index); - grib_context_free(a->context, basename); + acc = this->get_attribute_index(basename, &index); + grib_context_free(this->context, basename); if (acc) - return grib_accessor_get_attribute(acc, attribute_name); + return acc->get_attribute(attribute_name); else return NULL; } } - -grib_accessors_list* grib_accessors_list_create(grib_context* c) -{ - return (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); -} - -void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank) -{ - grib_accessors_list* last; - const grib_context* c = a->context; - - last = grib_accessors_list_last(al); - if (last && last->accessor) { - last->next = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); - last->next->accessor = a; - last->next->prev = last; - last->next->rank = rank; - al->last = last->next; - } - else { - al->accessor = a; - al->rank = rank; - al->last = al; - } -} - -grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al) -{ - // grib_accessors_list* last=al; - // grib_accessors_list* next=al->next; - // while(next) { - // last=next; - // next=last->next; - // } - return al->last; -} - -// grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a) -// { -// grib_accessors_list* last = al; -// grib_accessors_list* next = al->next; -// while (next) { -// if (last->accessor == a) -// return last; -// last = next; -// next = last->next; -// } -// return NULL; -// } - -void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) -{ - grib_accessors_list* tmp; - - while (al) { - tmp = al->next; - //grib_accessor_delete(c, al->accessor); - grib_context_free(c, al); - al = tmp; - } -} diff --git a/src/accessor/grib_accessor.h b/src/accessor/grib_accessor.h index 10fa228f7..d79e30111 100644 --- a/src/accessor/grib_accessor.h +++ b/src/accessor/grib_accessor.h @@ -10,6 +10,182 @@ #pragma once -#include "grib_api_internal.h" +#include "../grib_api_internal.h" +#include "../grib_value.h" +#include + +class grib_accessor +{ +public: + grib_accessor() : name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), length(0), offset(0), parent(nullptr), next(nullptr), previous(nullptr), cclass(nullptr), flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), set(nullptr), parent_as_attribute(nullptr) {} + virtual ~grib_accessor() {} + + template int unpack(T* v, size_t* len); + + virtual void init_accessor(const long, grib_arguments*) = 0; + virtual void dump(grib_dumper* f) = 0; + virtual int pack_missing() = 0; + //virtual int grib_pack_zero(grib_accessor* a) = 0; + virtual int is_missing_internal() = 0; + virtual int pack_double(const double* v, size_t* len) = 0; + virtual int pack_float(const float* v, size_t* len) = 0; + virtual int pack_expression(grib_expression* e) = 0; + virtual int pack_string(const char* v, size_t* len) = 0; + virtual int pack_string_array(const char** v, size_t* len) = 0; + virtual int pack_long(const long* v, size_t* len) = 0; + virtual int pack_bytes(const unsigned char* v, size_t* len) = 0; + virtual int unpack_bytes(unsigned char* v, size_t* len) = 0; + virtual int unpack_double_subarray(double* v, size_t start, size_t len) = 0; + virtual int unpack_double(double* v, size_t* len) = 0; + virtual int unpack_float(float* v, size_t* len) = 0; + virtual int unpack_double_element(size_t i, double* v) = 0; + virtual int unpack_float_element(size_t i, float* v) = 0; + virtual int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) = 0; + virtual int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) = 0; + virtual int unpack_string(char* v, size_t* len) = 0; + virtual int unpack_string_array(char** v, size_t* len) = 0; + virtual int unpack_long(long* v, size_t* len) = 0; + virtual long get_native_type() = 0; + virtual long get_next_position_offset() = 0; + virtual long string_length() = 0; + virtual long byte_offset() = 0; + virtual long byte_count() = 0; + virtual int value_count(long* count) = 0; + virtual int notify_change(grib_accessor* changed) = 0; + virtual grib_accessor* clone(grib_section* s, int* err) = 0; + virtual void update_size(size_t len) = 0; + virtual int nearest_smaller_value(double val, double* nearest) = 0; + virtual size_t preferred_size(int from_handle) = 0; + virtual grib_accessor* next_accessor() = 0; + virtual void resize(size_t new_size) = 0; + virtual void destroy(grib_context* ct) = 0; + + virtual int compare_accessors(grib_accessor* a2, int compare_flags); + virtual int add_attribute(grib_accessor* attr, int nest_if_clash); + virtual grib_accessor* get_attribute_index(const char* name, int* index); + virtual int has_attributes(); + virtual grib_accessor* get_attribute(const char* name); + + + const char* name; /** < name of the accessor */ + const char* name_space; /** < namespace to which the accessor belongs */ + grib_context* context; + grib_handle* h; + grib_action* creator; /** < action that created the accessor */ + long length; /** < byte length of the accessor */ + long offset; /** < offset of the data in the buffer */ + grib_section* parent; /** < section to which the accessor is attached */ + grib_accessor* next; /** < next accessor in list */ + grib_accessor* previous; /** < next accessor in list */ + grib_accessor_class* cclass; /** < behaviour of the accessor */ + unsigned long flags; /** < Various flags */ + grib_section* sub_section; + + const char* all_names[MAX_ACCESSOR_NAMES]; /** < name of the accessor */ + const char* all_name_spaces[MAX_ACCESSOR_NAMES]; /** < namespace to which the accessor belongs */ + int dirty; + + grib_accessor* same; /** < accessors with the same name */ + long loop; /** < used in lists */ + grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ + const char* set; + grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES]; /** < attributes are accessors */ + grib_accessor* parent_as_attribute; +}; + +class grib_accessor_class +{ +public: + const char* name; + + grib_accessor_class(const char* name) : name(name){} + virtual ~grib_accessor_class(){} + + virtual grib_accessor* create_empty_accessor() = 0; + virtual grib_section* sub_section(grib_accessor* a) = 0; + virtual int get_native_type(grib_accessor*) = 0; + virtual int pack_missing(grib_accessor*) = 0; + virtual int is_missing(grib_accessor*) = 0; + virtual int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) = 0; + virtual int pack_double(grib_accessor*, const double* val, size_t* len) = 0; + virtual int pack_float(grib_accessor*, const float* val, size_t* len) = 0; + virtual int pack_long(grib_accessor*, const long* val, size_t* len) = 0; + virtual int pack_string(grib_accessor*, const char*, size_t* len) = 0; + virtual int pack_string_array(grib_accessor*, const char**, size_t* len) = 0; + virtual int pack_expression(grib_accessor*, grib_expression*) = 0; + virtual int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) = 0; + virtual int unpack_double(grib_accessor*, double* val, size_t* len) = 0; + virtual int unpack_float(grib_accessor*, float* val, size_t* len) = 0; + virtual int unpack_long(grib_accessor*, long* val, size_t* len) = 0; + virtual int unpack_string(grib_accessor*, char*, size_t* len) = 0; + virtual int unpack_string_array(grib_accessor*, char**, size_t* len) = 0; + virtual size_t string_length(grib_accessor*) = 0; + virtual long byte_count(grib_accessor*) = 0; + virtual long byte_offset(grib_accessor*) = 0; + virtual long next_offset(grib_accessor*) = 0; + virtual int value_count(grib_accessor*, long*) = 0; + virtual void destroy(grib_context*, grib_accessor*) = 0; + virtual void dump(grib_accessor*, grib_dumper*) = 0; + virtual void init(grib_accessor*, const long, grib_arguments*) = 0; + virtual void post_init(grib_accessor*) = 0; + virtual int notify_change(grib_accessor*, grib_accessor*) = 0; + virtual void update_size(grib_accessor*, size_t) = 0; + virtual size_t preferred_size(grib_accessor*, int) = 0; + virtual void resize(grib_accessor*,size_t) = 0; + virtual int nearest_smaller_value (grib_accessor*, double, double*) = 0; + virtual grib_accessor* next(grib_accessor*, int) = 0; + virtual int compare(grib_accessor*, grib_accessor*) = 0; + virtual int unpack_double_element(grib_accessor*, size_t i, double* val) = 0; + virtual int unpack_float_element(grib_accessor*, size_t i, float* val) = 0; + virtual int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) = 0; + virtual int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) = 0; + virtual int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) = 0; + virtual int clear(grib_accessor*) = 0; + virtual grib_accessor* make_clone(grib_accessor*, grib_section*, int*) = 0; +}; + + +template +int unpack_helper(grib_accessor* a, T* v, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + int type = GRIB_TYPE_UNDEFINED; + const char* Tname = type_to_string(*v); + //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { + try { + long val = 0; + size_t l = 1; + a->unpack_long(&val, &l); + *v = val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { + try { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + + *v = strtod(val, &last); + if (*last == 0) { /* conversion of string to double worked */ + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + catch (std::runtime_error& e) { + // TODO(maee): log error + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + + return GRIB_NOT_IMPLEMENTED; +} -template int grib_unpack(grib_accessor* a, T* v, size_t* len); diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index 9e39ed633..696370ba9 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -12,14 +12,19 @@ * Enrico Fucile ****************************************/ -#include "grib_api_internal.h" +#include "grib_accessor_class_codetable.h" #include + +grib_accessor_class_codetable_t _grib_accessor_class_codetable("codetable"); +grib_accessor_class* grib_accessor_class_codetable = &_grib_accessor_class_codetable; + + #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; -static void thread_init() +void thread_init() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -31,7 +36,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex1; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_codetable_c) { @@ -43,123 +48,19 @@ static void thread_init() } #endif -/* - This is used by make_class.pl - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump;unpack_string;pack_expression;unpack_long - IMPLEMENTS = value_count;pack_string; destroy; get_native_type;pack_missing - MEMBERS = const char* tablename - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - MEMBERS = grib_codetable* table - MEMBERS = int table_loaded - END_CLASS_DEF - */ -/* START_CLASS_IMP */ +int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t); -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable +void grib_accessor_class_codetable_t::init(grib_accessor* a, const long len, grib_arguments* params) { - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; - int table_loaded; -} grib_accessor_codetable; + grib_accessor_class_unsigned_t::init(a, len, params); -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_codetable = { - &grib_accessor_class_unsigned, /* super */ - "codetable", /* name */ - sizeof(grib_accessor_codetable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable = &_grib_accessor_class_codetable; - -/* END_CLASS_IMP */ - -static int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t); - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ int n = 0; long new_len = len; grib_handle* hand = grib_handle_of_accessor(a); - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_action* act = (grib_action*)(a->creator); DEBUG_ASSERT(len == self->nbytes); @@ -195,7 +96,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) a->length = 0; if (!a->vvalue) a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); - a->vvalue->type = grib_accessor_get_native_type(a); + a->vvalue->type = a->get_native_type(); a->vvalue->length = new_len; if (act->default_value != NULL) { const char* p = 0; @@ -209,12 +110,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) switch (type) { case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(hand, expression, &d); - grib_pack_double(a, &d, &s_len); + a->pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); + a->pack_long(&l, &s_len); break; default: @@ -271,7 +172,7 @@ static void dump_codetable(grib_codetable* atable) #endif static grib_codetable* load_table(grib_accessor* a) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; size_t size = 0; grib_handle* h = ((grib_accessor*)self)->parent->h; grib_context* c = h->context; @@ -342,7 +243,7 @@ static grib_codetable* load_table(grib_accessor* a) size = a->vvalue->length * 8; } else { - size = grib_byte_count((grib_accessor*)self) * 8; + size = ((grib_accessor*)self)->byte_count() * 8; } size = (1ULL << size); /* 2^size - 64bits */ @@ -370,7 +271,7 @@ the_end: return t; } -static int grib_load_codetable(grib_context* c, const char* filename, +int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t) { char line[1024]; @@ -538,10 +439,10 @@ int codes_codetable_get_contents_malloc(const grib_handle* h, const char* key, c return GRIB_INVALID_ARGUMENT; // key is not a codetable } - const grib_accessor_codetable* ca = (const grib_accessor_codetable*)aa; // could be dynamic_cast + const grib_accessor_codetable_t* ca = (const grib_accessor_codetable_t*)aa; // could be dynamic_cast // Decode the key itself. This will either fetch it from the cache or place it there - if ((err = grib_unpack_long(aa, &lvalue, &size)) != GRIB_SUCCESS) { + if ((err = aa->unpack_long(&lvalue, &size)) != GRIB_SUCCESS) { return err; } @@ -612,9 +513,9 @@ int codes_codetable_check_abbreviation(const grib_handle* h, const char* key, co return err; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_codetable_t::dump(grib_accessor* a, grib_dumper* dumper) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; char comment[2048]; grib_codetable* table; @@ -627,7 +528,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } table = self->table; - grib_unpack_long(a, &value, &llen); + a->unpack_long(&value, &llen); if (value == GRIB_MISSING_LONG) { if (a->length < 4) { @@ -670,9 +571,9 @@ static void dump(grib_accessor* a, grib_dumper* dumper) grib_dump_long(dumper, a, comment); } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) +int grib_accessor_class_codetable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_codetable* table = NULL; size_t size = 1; @@ -681,7 +582,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) char tmp[1024]; size_t l = 0; - if ((err = grib_unpack_long(a, &value, &size)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&value, &size)) != GRIB_SUCCESS) return err; if (!self->table_loaded) { @@ -714,14 +615,14 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_codetable_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } // Return true if the input is an integer (non-negative) -static bool is_number(const char* s) +bool is_number(const char* s) { while (*s) { if (!isdigit(*s)) @@ -731,27 +632,27 @@ static bool is_number(const char* s) return true; } -static bool strings_equal(const char* s1, const char* s2, bool case_sensitive) +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) +int grib_accessor_class_codetable_t::pack_string(grib_accessor* a, const char* buffer, size_t* len) { long lValue = 0; Assert(buffer); if (is_number(buffer) && string_to_long(buffer, &lValue, 1) == GRIB_SUCCESS) { // ECC-1654: If value is a pure number, just pack as long size_t l = 1; - return grib_pack_long(a, &lValue, &l); + return a->pack_long(&lValue, &l); } if (STR_EQUAL_NOCASE(buffer, "missing")) { return pack_missing(a); } - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_codetable* table = NULL; long i = 0; size_t size = 1; @@ -779,7 +680,7 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) 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 a->pack_long(&i, &size); } } } @@ -798,12 +699,12 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) switch (type) { case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); - grib_pack_double(a, &d, &s_len); + a->pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); + a->pack_long(&l, &s_len); break; default: @@ -837,7 +738,7 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) return GRIB_ENCODING_ERROR; } -static int pack_expression(grib_accessor* a, grib_expression* e) +int grib_accessor_class_codetable_t::pack_expression(grib_accessor* a, grib_expression* e) { const char* cval = NULL; int ret = 0; @@ -848,7 +749,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e) if (strcmp(e->cclass->name, "long") == 0) { grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ //if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %ld\n", a->name,lval); - ret = grib_pack_long(a, &lval, &len); + ret = a->pack_long(&lval, &len); } else { char tmp[1024]; @@ -863,12 +764,12 @@ static int pack_expression(grib_accessor* a, grib_expression* e) len = strlen(cval) + 1; //if (hand->context->debug) // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval); - ret = grib_pack_string(a, cval, &len); + ret = a->pack_string(cval, &len); } return ret; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_codetable_t::destroy(grib_context* context, grib_accessor* a) { if (a->vvalue != NULL) { grib_context_free(context, a->vvalue); @@ -876,7 +777,7 @@ static void destroy(grib_context* context, grib_accessor* a) } } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_codetable_t::get_native_type(grib_accessor* a) { int type = GRIB_TYPE_LONG; /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", @@ -886,16 +787,16 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_codetable_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; long rlen = 0, i = 0; long pos = a->offset * 8; grib_handle* hand = NULL; #ifdef DEBUG { - int err = grib_value_count(a, &rlen); + int err = a->value_count(&rlen); Assert(!err); Assert(rlen == 1); } @@ -908,9 +809,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values", *len, a->name, rlen); - *len = rlen; + *len = 0; return GRIB_ARRAY_TOO_SMALL; } @@ -934,12 +835,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_missing(grib_accessor* a) +int grib_accessor_class_codetable_t::pack_missing(grib_accessor* a) { // Many of the code tables do have a 'Missing' entry (all bits = 1) // So it is more user-friendly to allow setting codetable keys to // missing. For tables that do not have such an entry, an error is issued - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_handle* h = grib_handle_of_accessor(a); const long nbytes = a->length; @@ -949,7 +850,7 @@ static int pack_missing(grib_accessor* a) int err = codes_codetable_check_code_figure(h, a->name, maxVal); if (!err) { size_t l = 1; - return grib_pack_long(a, &maxVal, &l); + return a->pack_long(&maxVal, &l); } grib_context_log(a->context, GRIB_LOG_ERROR, "There is no 'missing' entry in Code Table %s (%s)", diff --git a/src/accessor/grib_accessor_class_constant.cc b/src/accessor/grib_accessor_class_constant.cc index b54de5b88..ed30a6365 100644 --- a/src/accessor/grib_accessor_class_constant.cc +++ b/src/accessor/grib_accessor_class_constant.cc @@ -8,104 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_constant.h" -/************************************* - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_constant -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in constant */ -} grib_accessor_constant; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_constant = { - &grib_accessor_class_variable, /* super */ - "constant", /* name */ - sizeof(grib_accessor_constant), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_constant_t _grib_accessor_class_constant{"constant"}; grib_accessor_class* grib_accessor_class_constant = &_grib_accessor_class_constant; -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_constant_t::init(grib_accessor* a, const long len, grib_arguments* arg) { + grib_accessor_class_variable_t::init(a, len, arg); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index fb885700b..08f2f1bba 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -189,9 +189,10 @@ void grib_accessor_gen_t::resize(size_t new_size) } // For this one, ALL destroy are called -void grib_accessor_delete(grib_context* ct, grib_accessor* a) +void grib_accessor_gen_t::destroy(grib_context* ct) { - free(a); + cclass->destroy(ct, this); + delete this; } diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h index df85efab8..d68ad4320 100644 --- a/src/accessor/grib_accessor_class_gen.h +++ b/src/accessor/grib_accessor_class_gen.h @@ -40,11 +40,7 @@ class grib_accessor_gen_t : public grib_accessor { size_t preferred_size(int from_handle) override; grib_accessor* next_accessor() override; void resize(size_t new_size) override; - //int compare_accessors(grib_accessor* a2, int compare_flags) override; - //int add_attribute(grib_accessor* attr, int nest_if_clash) override; - //grib_accessor* get_attribute_index(const char* name, int* index) override; - //int has_attributes() override; - //grib_accessor* get_attribute(const char* name) override; + void destroy(grib_context* ct) override; }; class grib_accessor_class_gen_t : public grib_accessor_class @@ -95,48 +91,3 @@ public: int clear(grib_accessor*) override; grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; }; - - -template -int unpack_helper(grib_accessor* a, T* v, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - int type = GRIB_TYPE_UNDEFINED; - const char* Tname = type_to_string(*v); - //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - try { - long val = 0; - size_t l = 1; - a->unpack_long(&val, &l); - *v = val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - catch (std::runtime_error& e) { - // TODO(maee): log error - } - - //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - try { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - a->unpack_string(val, &l); - - *v = strtod(val, &last); - if (*last == 0) { /* conversion of string to double worked */ - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - catch (std::runtime_error& e) { - // TODO(maee): log error - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/accessor/grib_accessor_class_iterator.cc b/src/accessor/grib_accessor_class_iterator.cc index 2a5fc815b..138146747 100644 --- a/src/accessor/grib_accessor_class_iterator.cc +++ b/src/accessor/grib_accessor_class_iterator.cc @@ -13,101 +13,19 @@ *************************/ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - MEMBERS=grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_iterator -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in iterator */ - grib_arguments* args; -} grib_accessor_iterator; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_iterator = { - &grib_accessor_class_gen, /* super */ - "iterator", /* name */ - sizeof(grib_accessor_iterator), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_iterator.h" +grib_accessor_class_iterator_t _grib_accessor_class_iterator{"iterator"}; grib_accessor_class* grib_accessor_class_iterator = &_grib_accessor_class_iterator; -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) +void grib_accessor_class_iterator_t::init(grib_accessor* a, const long l, grib_arguments* args) { - grib_accessor_iterator* self = (grib_accessor_iterator*)a; + grib_accessor_class_gen_t::init(a, l, args); + grib_accessor_iterator_t* self = (grib_accessor_iterator_t*)a; self->args = args; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_iterator_t::dump(grib_accessor* a, grib_dumper* dumper) { /* TODO: pass args */ grib_dump_label(dumper, a, NULL); @@ -117,11 +35,11 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int { grib_handle* h = (grib_handle*)ch; grib_accessor* a = NULL; - grib_accessor_iterator* ita = NULL; + grib_accessor_iterator_t* ita = NULL; grib_iterator* iter = NULL; *error = GRIB_NOT_IMPLEMENTED; a = grib_find_accessor(h, "ITERATOR"); - ita = (grib_accessor_iterator*)a; + ita = (grib_accessor_iterator_t*)a; if (!a) return NULL; diff --git a/src/accessor/grib_accessor_class_long.cc b/src/accessor/grib_accessor_class_long.cc index 5eb10fec5..a1f125f25 100644 --- a/src/accessor/grib_accessor_class_long.cc +++ b/src/accessor/grib_accessor_class_long.cc @@ -1,120 +1,23 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;pack_missing; - IMPLEMENTS = unpack_string; pack_string - IMPLEMENTS = unpack_double - IMPLEMENTS = dump - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_long -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ -} grib_accessor_long; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_long = { - &grib_accessor_class_gen, /* super */ - "long", /* name */ - sizeof(grib_accessor_long), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_long.h" +grib_accessor_class_long_t _grib_accessor_class_long{"long"}; grib_accessor_class* grib_accessor_class_long = &_grib_accessor_class_long; -/* END_CLASS_IMP */ +void grib_accessor_class_long_t::init(grib_accessor* a, const long len, grib_arguments* arg) { + grib_accessor_class_gen_t::init(a, len, arg); +} -static int get_native_type(grib_accessor* a) +int grib_accessor_class_long_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_LONG; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_long_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_long(dumper, a, NULL); } -static int unpack_string(grib_accessor* a, char* v, size_t* len) +int grib_accessor_class_long_t::unpack_string(grib_accessor* a, char* v, size_t* len) { long val = 0; size_t l = 1; @@ -122,7 +25,7 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) char format[32] = "%ld"; grib_handle* h = grib_handle_of_accessor(a); - grib_unpack_long(a, &val, &l); + a->unpack_long(&val, &l); /* TODO: We should catch all errors but in this case the test ERA_Gen.sh will fail * as the output from grib_ls will be different */ @@ -152,18 +55,18 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) return GRIB_SUCCESS; } -static int pack_missing(grib_accessor* a) +int grib_accessor_class_long_t::pack_missing(grib_accessor* a) { size_t len = 1; long value = GRIB_MISSING_LONG; if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_pack_long(a, &value, &len); + return a->pack_long(&value, &len); return GRIB_VALUE_CANNOT_BE_MISSING; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_long_t::unpack_double(grib_accessor* a, double* val, size_t* len) { size_t rlen = 0; long count = 0; @@ -172,7 +75,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) long oneval = 0; int ret = GRIB_SUCCESS; - ret = grib_value_count(a, &count); + ret = a->value_count(&count); if (ret) return ret; rlen = count; @@ -184,7 +87,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } if (rlen == 1) { - ret = grib_unpack_long(a, &oneval, &rlen); + ret = a->unpack_long(&oneval, &rlen); if (ret != GRIB_SUCCESS) return ret; *val = oneval; @@ -196,7 +99,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) if (!values) return GRIB_OUT_OF_MEMORY; - ret = grib_unpack_long(a, values, &rlen); + ret = a->unpack_long(values, &rlen); if (ret != GRIB_SUCCESS) { grib_context_free(a->context, values); return ret; @@ -210,7 +113,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static int compare(grib_accessor* a, grib_accessor* b) +int grib_accessor_class_long_t::compare(grib_accessor* a, grib_accessor* b) { int retval = 0; long* aval = 0; @@ -221,12 +124,12 @@ static int compare(grib_accessor* a, grib_accessor* b) size_t blen = 0; int err = 0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); + err = a->value_count(&count); if (err) return err; blen = count; @@ -237,8 +140,8 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (long*)grib_context_malloc(a->context, alen * sizeof(long)); bval = (long*)grib_context_malloc(b->context, blen * sizeof(long)); - grib_unpack_long(a, aval, &alen); - grib_unpack_long(b, bval, &blen); + a->unpack_long(aval, &alen); + b->unpack_long(bval, &blen); retval = GRIB_SUCCESS; for (size_t i=0; ipack_long(&v, len); } diff --git a/src/accessor/grib_accessor_class_nearest.cc b/src/accessor/grib_accessor_class_nearest.cc index b1a3138d3..6dbac1722 100644 --- a/src/accessor/grib_accessor_class_nearest.cc +++ b/src/accessor/grib_accessor_class_nearest.cc @@ -8,102 +8,20 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - MEMBERS=grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_nearest -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in nearest */ - grib_arguments* args; -} grib_accessor_nearest; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_nearest = { - &grib_accessor_class_gen, /* super */ - "nearest", /* name */ - sizeof(grib_accessor_nearest), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_nearest.h" +grib_accessor_class_nearest_t _grib_accessor_class_nearest{"nearest"}; grib_accessor_class* grib_accessor_class_nearest = &_grib_accessor_class_nearest; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* args) +void grib_accessor_class_nearest_t::init(grib_accessor* a, const long l, grib_arguments* args) { - grib_accessor_nearest* self = (grib_accessor_nearest*)a; + grib_accessor_class_gen_t::init(a, l, args); + grib_accessor_nearest_t* self = (grib_accessor_nearest_t*)a; self->args = args; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_nearest_t::dump(grib_accessor* a, grib_dumper* dumper) { /* TODO: pass args */ grib_dump_label(dumper, a, NULL); @@ -113,11 +31,11 @@ grib_nearest* grib_nearest_new(const grib_handle* ch, int* error) { grib_handle* h = (grib_handle*)ch; grib_accessor* a = NULL; - grib_accessor_nearest* na = NULL; + grib_accessor_nearest_t* na = NULL; grib_nearest* n = NULL; *error = GRIB_NOT_IMPLEMENTED; a = grib_find_accessor(h, "NEAREST"); - na = (grib_accessor_nearest*)a; + na = (grib_accessor_nearest_t*)a; if (!a) return NULL; diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index 70f964c7d..4d1997854 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -12,127 +12,12 @@ * Enrico Fucile ****************************************/ -#include "grib_api_internal.h" +#include "grib_accessor_class_smart_table.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump;unpack_string;unpack_long - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = const char* values - 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 - MEMBERS = grib_smart_table* table - MEMBERS = int dirty - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_smart_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in smart_table */ - const char* values; - const char* tablename; - const char* masterDir; - const char* localDir; - const char* extraDir; - const char* extraTable; - int widthOfCode; - long* tableCodes; - size_t tableCodesSize; - grib_smart_table* table; - int dirty; -} grib_accessor_smart_table; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_smart_table = { - &grib_accessor_class_unsigned, /* super */ - "smart_table", /* name */ - sizeof(grib_accessor_smart_table), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_smart_table_t _grib_accessor_class_smart_table{"smart_table"}; grib_accessor_class* grib_accessor_class_smart_table = &_grib_accessor_class_smart_table; -/* END_CLASS_IMP */ - #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -149,7 +34,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_smart_table_c) { @@ -161,12 +46,14 @@ static void thread_init() } #endif -static int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t); +int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t); -static void init(grib_accessor* a, const long len, grib_arguments* params) +void grib_accessor_class_smart_table_t::init(grib_accessor* a, const long len, grib_arguments* params) { + grib_accessor_class_unsigned_t::init(a, len, params); + int n = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->values = grib_arguments_get_name(hand, params, n++); @@ -184,9 +71,9 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) self->tableCodes = 0; } -static grib_smart_table* load_table(grib_accessor* a) +grib_smart_table* load_table(grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; size_t size = 0; grib_handle* h = ((grib_accessor*)self)->parent->h; grib_context* c = h->context; @@ -279,7 +166,7 @@ static grib_smart_table* load_table(grib_accessor* a) return t; } -static int grib_load_smart_table(grib_context* c, const char* filename, +int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t) { char line[1024] = {0,}; @@ -397,14 +284,14 @@ void grib_smart_table_delete(grib_context* c) } } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_smart_table_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_long(dumper, a, NULL); } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) +int grib_accessor_class_smart_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; grib_smart_table* table = NULL; size_t size = 1; @@ -413,7 +300,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) char tmp[1024]; size_t l = 0; - if ((err = grib_unpack_long(a, &value, &size)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&value, &size)) != GRIB_SUCCESS) return err; if (!self->table) @@ -441,9 +328,9 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) return GRIB_SUCCESS; } -static int get_table_codes(grib_accessor* a) +int get_table_codes(grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; size_t size = 0; long* v = 0; int err = 0; @@ -493,10 +380,10 @@ static int get_table_codes(grib_accessor* a) return 0; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_smart_table_t::value_count(grib_accessor* a, long* count) { int err = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; *count = 0; if (!self->values) @@ -509,9 +396,9 @@ static int value_count(grib_accessor* a, long* count) return GRIB_SUCCESS; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_smart_table_t::destroy(grib_context* context, grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; if (a->vvalue != NULL) { grib_context_free(context, a->vvalue); a->vvalue = NULL; @@ -520,7 +407,7 @@ static void destroy(grib_context* context, grib_accessor* a) grib_context_free(a->context, self->tableCodes); } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_smart_table_t::get_native_type(grib_accessor* a) { int type = GRIB_TYPE_LONG; /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", @@ -530,10 +417,10 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_smart_table_t::unpack_long(grib_accessor* a, long* val, size_t* len) { int err = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; size_t i; if (!self->values) diff --git a/src/accessor/grib_accessor_class_transient.cc b/src/accessor/grib_accessor_class_transient.cc index c51886c20..0cda763d0 100644 --- a/src/accessor/grib_accessor_class_transient.cc +++ b/src/accessor/grib_accessor_class_transient.cc @@ -8,93 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_transient -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in transient */ -} grib_accessor_transient; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_transient = { - &grib_accessor_class_variable, /* super */ - "transient", /* name */ - sizeof(grib_accessor_transient), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_transient.h" +grib_accessor_class_transient_t _grib_accessor_class_transient{"transient"}; grib_accessor_class* grib_accessor_class_transient = &_grib_accessor_class_transient; -/* END_CLASS_IMP */ + +void grib_accessor_class_transient_t::init(grib_accessor* a, const long l, grib_arguments* args) { + grib_accessor_class_variable_t::init(a, l, args); +} + diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index f1202b0d0..b5615ac37 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -8,117 +8,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump;is_missing - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size; destroy - MEMBERS = long nbytes - MEMBERS = grib_arguments* arg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unsigned -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; -} grib_accessor_unsigned; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unsigned = { - &grib_accessor_class_long, /* super */ - "unsigned", /* name */ - sizeof(grib_accessor_unsigned), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; +#include "grib_accessor_class_unsigned.h" +grib_accessor_class_unsigned_t _grib_accessor_class_unsigned("unsigned"); grib_accessor_class* grib_accessor_class_unsigned = &_grib_accessor_class_unsigned; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_unsigned_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; - self->arg = NULL; + grib_accessor_class_long_t::init(a, len, arg); + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; self->arg = arg; self->nbytes = len; @@ -131,17 +31,17 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) } else { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); a->length = len * count; a->vvalue = NULL; } } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_unsigned_t::dump(grib_accessor* a, grib_dumper* dumper) { long rlen = 0; - grib_value_count(a, &rlen); + a->value_count(&rlen); if (rlen == 1) grib_dump_long(dumper, a, NULL); else @@ -158,14 +58,15 @@ static const unsigned long ones[] = { /* See GRIB-490 */ static const unsigned long all_ones = -1; -static int value_is_missing(long val) + +int value_is_missing(long val) { return (val == GRIB_MISSING_LONG || val == all_ones); } int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, int check) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; int ret = 0; long off = 0; long rlen = 0; @@ -176,7 +77,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in unsigned long i = 0; unsigned long missing = 0; - err = grib_value_count(a, &rlen); + err = a->value_count(&rlen); if (err) return err; @@ -260,9 +161,9 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; long rlen = 0; unsigned long i = 0; unsigned long missing = 0; @@ -271,7 +172,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) long pos = a->offset * 8; grib_handle* hand = grib_handle_of_accessor(a); - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; rlen = count; @@ -304,20 +205,20 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_unsigned_t::pack_long(grib_accessor* a, const long* val, size_t* len) { /* See GRIB-262 as example of why we do the checks */ return pack_long_unsigned_helper(a, val, len, /*check=*/1); } -static long byte_count(grib_accessor* a) +long grib_accessor_class_unsigned_t::byte_count(grib_accessor* a) { return a->length; } -static int value_count(grib_accessor* a, long* len) +int grib_accessor_class_unsigned_t::value_count(grib_accessor* a, long* len) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; if (!self->arg) { *len = 1; return 0; @@ -325,22 +226,22 @@ static int value_count(grib_accessor* a, long* len) return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -static long byte_offset(grib_accessor* a) +long grib_accessor_class_unsigned_t::byte_offset(grib_accessor* a) { return a->offset; } -static void update_size(grib_accessor* a, size_t s) +void grib_accessor_class_unsigned_t::update_size(grib_accessor* a, size_t s) { a->length = s; } -static long next_offset(grib_accessor* a) +long grib_accessor_class_unsigned_t::next_offset(grib_accessor* a) { - return grib_byte_offset(a) + grib_byte_count(a); + return a->byte_offset() + a->byte_count(); } -static int is_missing(grib_accessor* a) +int grib_accessor_class_unsigned_t::is_missing(grib_accessor* a) { int i = 0; unsigned char ff = 0xff; @@ -361,7 +262,7 @@ static int is_missing(grib_accessor* a) return 1; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_unsigned_t::destroy(grib_context* context, grib_accessor* a) { if (a->vvalue != NULL) grib_context_free(context, a->vvalue); diff --git a/src/accessor/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc index 8c5bbe7b0..879da527b 100644 --- a/src/accessor/grib_accessor_class_variable.cc +++ b/src/accessor/grib_accessor_class_variable.cc @@ -8,124 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_accessor_class_variable.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float; pack_float - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy;byte_count - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare; make_clone - MEMBERS=double dval - MEMBERS=float fval - MEMBERS=char* cval - MEMBERS=char* cname - MEMBERS=int type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_float(grib_accessor*, const float* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_variable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; -} grib_accessor_variable; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_variable = { - &grib_accessor_class_gen, /* super */ - "variable", /* name */ - sizeof(grib_accessor_variable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - &pack_float, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - &make_clone, /* clone accessor */ -}; +grib_accessor_class_variable_t _grib_accessor_class_variable{"variable"}; grib_accessor_class* grib_accessor_class_variable = &_grib_accessor_class_variable; -/* END_CLASS_IMP */ - // // This accessor is used for: // constant @@ -134,9 +23,11 @@ grib_accessor_class* grib_accessor_class_variable = &_grib_accessor_class_variab #define MAX_VARIABLE_STRING_LENGTH 255 -static void init(grib_accessor* a, const long length, grib_arguments* args) +void grib_accessor_class_variable_t::init(grib_accessor* a, const long length, grib_arguments* args) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_class_gen_t::init(a, length, args); + + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; grib_handle* hand = grib_handle_of_accessor(a); grib_expression* expression = grib_arguments_get_expression(hand, args, 0); const char* p = 0; @@ -153,12 +44,12 @@ static void init(grib_accessor* a, const long length, grib_arguments* args) switch (self->type) { case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(hand, expression, &d); - pack_double(a, &d, &len); + a->pack_double(&d, &len); break; case GRIB_TYPE_LONG: grib_expression_evaluate_long(hand, expression, &l); - pack_long(a, &l, &len); + a->pack_long(&l, &len); break; default: { @@ -171,7 +62,7 @@ static void init(grib_accessor* a, const long length, grib_arguments* args) return; } len = strlen(p) + 1; - pack_string(a, p, &len); + a->pack_string(p, &len); break; } } @@ -180,13 +71,13 @@ static void init(grib_accessor* a, const long length, grib_arguments* args) void accessor_variable_set_type(grib_accessor* a, int type) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; self->type = type; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_variable_t::dump(grib_accessor* a, grib_dumper* dumper) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; switch (self->type) { case GRIB_TYPE_DOUBLE: grib_dump_double(dumper, a, NULL); @@ -202,9 +93,9 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_variable_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; const double dval = *val; if (*len != 1) { @@ -227,9 +118,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int pack_float(grib_accessor* a, const float* val, size_t* len) +int grib_accessor_class_variable_t::pack_float(grib_accessor* a, const float* val, size_t* len) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; const double fval = *val; if (*len != 1) { @@ -247,9 +138,9 @@ static int pack_float(grib_accessor* a, const float* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_variable_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; if (*len != 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains 1 value", a->name); @@ -264,9 +155,9 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_variable_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); @@ -278,9 +169,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_variable_t::unpack_float(grib_accessor* a, float* val, size_t* len) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); @@ -292,9 +183,9 @@ static int unpack_float(grib_accessor* a, float* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_variable_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); @@ -306,15 +197,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_variable_t::get_native_type(grib_accessor* a) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; return self->type; } -static void destroy(grib_context* c, grib_accessor* a) +void grib_accessor_class_variable_t::destroy(grib_context* c, grib_accessor* a) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; int i = 0; grib_context_free(c, self->cval); @@ -323,15 +214,15 @@ static void destroy(grib_context* c, grib_accessor* a) /* Note: BUFR operator descriptors are variables and have attributes so need to free them */ while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { - grib_accessor_delete(c, a->attributes[i]); + a->attributes[i]->destroy(c); a->attributes[i] = NULL; ++i; } } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_variable_t::unpack_string(grib_accessor* a, char* val, size_t* len) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; char buf[80]; char* p = buf; @@ -358,9 +249,9 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_variable_t::pack_string(grib_accessor* a, const char* val, size_t* len) { - grib_accessor_variable* self = (grib_accessor_variable*)a; + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; const grib_context* c = a->context; grib_context_free(c, self->cval); @@ -372,27 +263,27 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_variable_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } -static size_t string_length(grib_accessor* a) +size_t grib_accessor_class_variable_t::string_length(grib_accessor* a) { - const grib_accessor_variable* self = (grib_accessor_variable*)a; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; if (self->type == GRIB_TYPE_STRING) return strlen(self->cval); else return MAX_VARIABLE_STRING_LENGTH; } -static long byte_count(grib_accessor* a) +long grib_accessor_class_variable_t::byte_count(grib_accessor* a) { return a->length; } -static int compare(grib_accessor* a, grib_accessor* b) +int grib_accessor_class_variable_t::compare(grib_accessor* a, grib_accessor* b) { int retval = GRIB_SUCCESS; double* aval = 0; @@ -403,12 +294,12 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); + err = b->value_count(&count); if (err) return err; blen = count; @@ -419,8 +310,8 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; retval = GRIB_SUCCESS; @@ -434,11 +325,11 @@ static int compare(grib_accessor* a, grib_accessor* b) return retval; } -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) +grib_accessor* grib_accessor_class_variable_t::make_clone(grib_accessor* a, grib_section* s, int* err) { grib_accessor* the_clone = NULL; - const grib_accessor_variable* self = (grib_accessor_variable*)a; - grib_accessor_variable* variableAccessor = NULL; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + grib_accessor_variable_t* variableAccessor = NULL; grib_action creator = {0,}; creator.op = (char*)"variable"; creator.name_space = (char*)""; @@ -449,7 +340,7 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) the_clone->parent = NULL; the_clone->h = s->h; the_clone->flags = a->flags; - variableAccessor = (grib_accessor_variable*)the_clone; + variableAccessor = (grib_accessor_variable_t*)the_clone; variableAccessor->cname = creator.name; /* ECC-765: Store for later freeing memory */ *err = 0; diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index 641aa3c92..722391c7f 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -152,7 +152,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* loade static int notify_change(grib_action* act, grib_accessor* notified, grib_accessor* changed) { if (act->default_value) - return grib_pack_expression(notified, grib_arguments_get_expression(grib_handle_of_accessor(notified), act->default_value, 0)); + return notified->pack_expression(grib_arguments_get_expression(grib_handle_of_accessor(notified), act->default_value, 0)); return GRIB_SUCCESS; } diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index 40f5079a7..a334a79f1 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -110,7 +110,7 @@ static void remove_accessor(grib_accessor* a) a->next->previous = a->previous; - grib_accessor_delete(s->h->context, a); + a->destroy(s->h->context); } static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) diff --git a/src/action_class_transient_darray.cc b/src/action_class_transient_darray.cc index 673f83502..276dcf3fa 100644 --- a/src/action_class_transient_darray.cc +++ b/src/action_class_transient_darray.cc @@ -117,7 +117,7 @@ static int execute(grib_action* act, grib_handle* h) if (a->flags & GRIB_ACCESSOR_FLAG_CONSTRAINT) grib_dependency_observe_arguments(a, act->default_value); - return grib_pack_double(a, self->darray->v, &len); + return a->pack_double(self->darray->v, &len); } static void dump(grib_action* act, FILE* f, int lvl) diff --git a/src/bufr_keys_iterator.cc b/src/bufr_keys_iterator.cc index e1ab89697..d22b0349b 100644 --- a/src/bufr_keys_iterator.cc +++ b/src/bufr_keys_iterator.cc @@ -176,7 +176,7 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter) return 1; } else { - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); kiter->attributes = 0; if (kiter->prefix) { grib_context_free(kiter->current->context, kiter->prefix); @@ -187,7 +187,7 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter) } while (kiter->current && skip(kiter)) - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); return kiter->current != NULL; } diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 7905f7978..30fcd82b0 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1,13 +1,3 @@ -/* - * (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. - */ - #pragma once #ifdef ECCODES_ON_WINDOWS @@ -116,52 +106,6 @@ grib_action* grib_action_create_modify(grib_context* context, const char* name, grib_action* grib_action_create_transient_darray(grib_context* context, const char* name, grib_darray* darray, int flags); /* grib_accessor.cc*/ -void grib_accessor_dump(grib_accessor* a, grib_dumper* f); -int grib_pack_missing(grib_accessor* a); -int grib_is_missing_internal(grib_accessor* a); -int grib_pack_double(grib_accessor* a, const double* v, size_t* len); -int grib_pack_float(grib_accessor* a, const float* v, size_t* len); -int grib_pack_expression(grib_accessor* a, grib_expression* e); -int grib_pack_string(grib_accessor* a, const char* v, size_t* len); -int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len); -int grib_pack_long(grib_accessor* a, const long* v, size_t* len); -int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len); -int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len); -int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_t len); -int grib_unpack_double(grib_accessor* a, double* v, size_t* len); -int grib_unpack_float(grib_accessor* a, float* v, size_t* len); -int grib_unpack_double_element(grib_accessor* a, size_t i, double* v); -int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array); -int grib_unpack_float_element(grib_accessor* a, size_t i, float* v); -int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, size_t len, float* val_array); -int grib_unpack_string(grib_accessor* a, char* v, size_t* len); -int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len); -int grib_accessors_list_unpack_long(grib_accessors_list* al, long* val, size_t* buffer_len); -int grib_accessors_list_unpack_double(grib_accessors_list* al, double* val, size_t* buffer_len); -int grib_accessors_list_unpack_float(grib_accessors_list* al, float* val, size_t* buffer_len); -int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_t* buffer_len); -int grib_unpack_long(grib_accessor* a, long* v, size_t* len); -long grib_accessor_get_native_type(grib_accessor* a); -long grib_get_next_position_offset(grib_accessor* a); -long grib_string_length(grib_accessor* a); -long grib_byte_offset(grib_accessor* a); -long grib_byte_count(grib_accessor* a); -int grib_value_count(grib_accessor* a, long* count); -int grib_accessors_list_value_count(grib_accessors_list* al, size_t* count); -int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed); -void grib_init_accessor(grib_accessor* a, const long len, grib_arguments* args); -void grib_accessor_delete(grib_context* ct, grib_accessor* a); -grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err); -void grib_update_size(grib_accessor* a, size_t len); -int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest); -size_t grib_preferred_size(grib_accessor* a, int from_handle); -grib_accessor* grib_next_accessor(grib_accessor* a); -void grib_resize(grib_accessor* a, size_t new_size); -int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_flags); -int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_if_clash); -grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index); -int grib_accessor_has_attributes(grib_accessor* a); -grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name); grib_accessors_list* grib_accessors_list_create(grib_context* c); void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank); grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al); @@ -262,10 +206,13 @@ void grib_viarray_delete_content(grib_context* c, grib_viarray* v); /* grib_accessor_class_bits_per_value.cc*/ /* grib_accessor_class_bufr_data_array.cc*/ -grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); -grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); -grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); -void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); +// ===== TODO(maee): Reenable these functions ===== +//grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); +//grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); +//grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); +//void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); +// ===== END ===== + /* grib_accessor_class_bufr_data_element.cc*/ void accessor_bufr_data_element_set_index(grib_accessor* a, long index); @@ -928,6 +875,7 @@ grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err); /* grib_filepool.cc*/ void grib_file_pool_clean(void); +grib_file* grib_file_pool_get_files(void); grib_file* grib_file_open(const char* filename, const char* mode, int* err); void grib_file_pool_delete_file(grib_file* file); void grib_file_close(const char* filename, int force, int* err); diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc index 9cdd04b97..63c2fede6 100644 --- a/src/grib_accessor_class.cc +++ b/src/grib_accessor_class.cc @@ -15,7 +15,7 @@ /* This file is generated by ./make_class.pl */ -#include "grib_accessor_class.h" +#include "accessor/grib_accessor.h" #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; @@ -139,7 +139,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, c = *((grib_accessor_classes_hash(creator->op, strlen(creator->op)))->cclass); #endif - a = (grib_accessor*)grib_context_malloc_clear(p->h->context, c->size); + a = c->create_empty_accessor(); a->name = creator->name; a->name_space = creator->name_space; @@ -159,7 +159,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->set = creator->set; if (p->block->last) { - a->offset = grib_get_next_position_offset(p->block->last); + a->offset = p->block->last->get_next_position_offset(); //printf("offset: p->block->last %s %s %ld %ld\n", // p->block->last->cclass->name, @@ -176,8 +176,8 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->cclass = c; - grib_init_accessor(a, len, params); - size = grib_get_next_position_offset(a); + a->init_accessor(len, params); + size = a->get_next_position_offset(); if (size > p->h->buffer->ulength) { if (!p->h->buffer->growable) { @@ -189,7 +189,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->offset + a->length, p->h->buffer->ulength); - grib_accessor_delete(p->h->context, a); + a->destroy(p->h->context); return NULL; } else { @@ -223,10 +223,10 @@ static void link_same_attributes(grib_accessor* a, grib_accessor* b) grib_accessor* bAttribute = NULL; if (a == NULL || b == NULL) return; - if (!grib_accessor_has_attributes(b)) + if (!b->has_attributes()) return; while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { - bAttribute = grib_accessor_get_attribute_index(b, a->attributes[i]->name, &idx); + bAttribute = b->get_attribute_index(a->attributes[i]->name, &idx); if (bAttribute) a->attributes[i]->same = bAttribute; i++; @@ -270,8 +270,10 @@ void grib_section_post_init(grib_section* s) while (a) { grib_accessor_class* c = a->cclass; - if (c->post_init) - c->post_init(a); + //if (c->post_init) + // c->post_init(a); + c->post_init(a); + if (a->sub_section) grib_section_post_init(a->sub_section); a = a->next; @@ -313,13 +315,13 @@ int grib_section_adjust_sizes(grib_section* s, int update, int depth) if (s->aclength) { size_t len = 1; long plen = 0; - int lret = grib_unpack_long(s->aclength, &plen, &len); + int lret = s->aclength->unpack_long(&plen, &len); Assert(lret == GRIB_SUCCESS); /* This happens when there is some padding */ if ((plen != length) || force_update) { if (update) { plen = length; - lret = grib_pack_long(s->aclength, &plen, &len); + lret = s->aclength->pack_long(&plen, &len); if (lret != GRIB_SUCCESS) return lret; s->padding = 0; @@ -358,7 +360,7 @@ int grib_get_block_length(grib_section* s, size_t* l) // if(s->aclength) { // size_t len = 1; // long plen = 0; -// int ret = grib_unpack_long(s->aclength, &plen, &len); +// int ret = s->aclength->unpack_long(&plen, &len); // if(ret == GRIB_SUCCESS && plen != 0) // { // *l = plen; @@ -371,13 +373,13 @@ int grib_get_block_length(grib_section* s, size_t* l) // return GRIB_SUCCESS; // } // // no accessor for block length -// if(s->owner) *l = grib_get_next_position_offset(s->block->last) - s->owner->offset; -// else *l = grib_get_next_position_offset(s->block->last); +// if(s->owner) *l = s->block->last->get_next_position_offset() - s->owner->offset; +// else *l = s->block->last->get_next_position_offset(); // if(s->aclength) { // size_t len = 1; // long plen = *l; -// int ret = grib_pack_long(s->aclength, &plen, &len); +// int ret = s->aclength->pack_long(&plen, &len); // if(ret != GRIB_SUCCESS) // ; // if(s->h->context->debug) @@ -397,7 +399,7 @@ grib_accessor* find_paddings(grib_section* s) if (p) return p; - if (grib_preferred_size(a, 0) != a->length) + if (a->preferred_size(0) != a->length) return a; a = a->next; @@ -414,7 +416,7 @@ void grib_update_paddings(grib_section* s) /* while((changed = find_paddings(s)) != NULL) */ while ((changed = find_paddings(s->h->root)) != NULL) { Assert(changed != last); - grib_resize(changed, grib_preferred_size(changed, 0)); + changed->resize(changed->preferred_size(0)); last = changed; } } diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index 0c569decd..fd0370719 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -1,206 +1,216 @@ -/* This file is automatically generated by ./make_class.pl, do not edit */ -extern grib_accessor_class* grib_accessor_class_abstract_long_vector; -extern grib_accessor_class* grib_accessor_class_abstract_vector; -extern grib_accessor_class* grib_accessor_class_ascii; -extern grib_accessor_class* grib_accessor_class_bit; -extern grib_accessor_class* grib_accessor_class_bitmap; -extern grib_accessor_class* grib_accessor_class_bits; -extern grib_accessor_class* grib_accessor_class_bits_per_value; -extern grib_accessor_class* grib_accessor_class_blob; -extern grib_accessor_class* grib_accessor_class_budgdate; -extern grib_accessor_class* grib_accessor_class_bufr_data_array; -extern grib_accessor_class* grib_accessor_class_bufr_data_element; -extern grib_accessor_class* grib_accessor_class_bufr_elements_table; -extern grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets; -extern grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets; -extern grib_accessor_class* grib_accessor_class_bufr_extract_subsets; -extern grib_accessor_class* grib_accessor_class_bufr_group; -extern grib_accessor_class* grib_accessor_class_bufr_simple_thinning; -extern grib_accessor_class* grib_accessor_class_bufr_string_values; -extern grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors; -extern grib_accessor_class* grib_accessor_class_bytes; -extern grib_accessor_class* grib_accessor_class_change_alternative_row_scanning; -extern grib_accessor_class* grib_accessor_class_change_scanning_direction; -extern grib_accessor_class* grib_accessor_class_check_internal_version; -extern grib_accessor_class* grib_accessor_class_closest_date; -extern grib_accessor_class* grib_accessor_class_codeflag; +#include "grib_api_internal.h" + +//extern grib_accessor_class* grib_accessor_class_abstract_long_vector; +//extern grib_accessor_class* grib_accessor_class_abstract_vector; +//extern grib_accessor_class* grib_accessor_class_ascii; +//extern grib_accessor_class* grib_accessor_class_bit; +//extern grib_accessor_class* grib_accessor_class_bitmap; +//extern grib_accessor_class* grib_accessor_class_bits; +//extern grib_accessor_class* grib_accessor_class_bits_per_value; +//extern grib_accessor_class* grib_accessor_class_blob; +//extern grib_accessor_class* grib_accessor_class_budgdate; +//extern grib_accessor_class* grib_accessor_class_bufr_data_array; +//extern grib_accessor_class* grib_accessor_class_bufr_data_element; +//extern grib_accessor_class* grib_accessor_class_bufr_elements_table; +//extern grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets; +//extern grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets; +//extern grib_accessor_class* grib_accessor_class_bufr_extract_subsets; +//extern grib_accessor_class* grib_accessor_class_bufr_group; +//extern grib_accessor_class* grib_accessor_class_bufr_simple_thinning; +//extern grib_accessor_class* grib_accessor_class_bufr_string_values; +//extern grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors; +//extern grib_accessor_class* grib_accessor_class_bytes; +//extern grib_accessor_class* grib_accessor_class_change_alternative_row_scanning; +//extern grib_accessor_class* grib_accessor_class_change_scanning_direction; +//extern grib_accessor_class* grib_accessor_class_check_internal_version; +//extern grib_accessor_class* grib_accessor_class_closest_date; +//extern grib_accessor_class* grib_accessor_class_codeflag; +#include "accessor/grib_accessor_class_codetable.h" extern grib_accessor_class* grib_accessor_class_codetable; -extern grib_accessor_class* grib_accessor_class_codetable_title; -extern grib_accessor_class* grib_accessor_class_codetable_units; -extern grib_accessor_class* grib_accessor_class_concept; +//extern grib_accessor_class* grib_accessor_class_codetable_title; +//extern grib_accessor_class* grib_accessor_class_codetable_units; +//extern grib_accessor_class* grib_accessor_class_concept; +#include "accessor/grib_accessor_class_constant.h" extern grib_accessor_class* grib_accessor_class_constant; -extern grib_accessor_class* grib_accessor_class_count_file; -extern grib_accessor_class* grib_accessor_class_count_missing; -extern grib_accessor_class* grib_accessor_class_count_total; -extern grib_accessor_class* grib_accessor_class_data_apply_bitmap; -extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic; -extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap; -extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; -extern grib_accessor_class* grib_accessor_class_data_complex_packing; -extern grib_accessor_class* grib_accessor_class_data_dummy_field; -extern grib_accessor_class* grib_accessor_class_data_g1complex_packing; -extern grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing; -extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing; -extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing; -extern grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing; -extern grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap; -extern grib_accessor_class* grib_accessor_class_data_g1shsimple_packing; -extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; -extern grib_accessor_class* grib_accessor_class_data_g22order_packing; -extern grib_accessor_class* grib_accessor_class_data_g2bifourier_packing; -extern grib_accessor_class* grib_accessor_class_data_g2complex_packing; -extern grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap; -extern grib_accessor_class* grib_accessor_class_data_g2shsimple_packing; -extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; -extern grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing; -extern grib_accessor_class* grib_accessor_class_data_jpeg2000_packing; -extern grib_accessor_class* grib_accessor_class_data_png_packing; -extern grib_accessor_class* grib_accessor_class_data_raw_packing; -extern grib_accessor_class* grib_accessor_class_data_run_length_packing; -extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; -extern grib_accessor_class* grib_accessor_class_data_sh_packed; -extern grib_accessor_class* grib_accessor_class_data_sh_unpacked; -extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; -extern grib_accessor_class* grib_accessor_class_data_simple_packing; -extern grib_accessor_class* grib_accessor_class_decimal_precision; -extern grib_accessor_class* grib_accessor_class_dictionary; -extern grib_accessor_class* grib_accessor_class_dirty; -extern grib_accessor_class* grib_accessor_class_divdouble; -extern grib_accessor_class* grib_accessor_class_double; -extern grib_accessor_class* grib_accessor_class_element; -extern grib_accessor_class* grib_accessor_class_evaluate; -extern grib_accessor_class* grib_accessor_class_expanded_descriptors; -extern grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value; -extern grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag; -extern grib_accessor_class* grib_accessor_class_g1_message_length; -extern grib_accessor_class* grib_accessor_class_g1_section4_length; -extern grib_accessor_class* grib_accessor_class_g1bitmap; -extern grib_accessor_class* grib_accessor_class_g1date; -extern grib_accessor_class* grib_accessor_class_g1day_of_the_year_date; -extern grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly; -extern grib_accessor_class* grib_accessor_class_g1fcperiod; -extern grib_accessor_class* grib_accessor_class_g1forecastmonth; -extern grib_accessor_class* grib_accessor_class_g1monthlydate; -extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex; -extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple; -extern grib_accessor_class* grib_accessor_class_g1step_range; -extern grib_accessor_class* grib_accessor_class_g1verificationdate; -extern grib_accessor_class* grib_accessor_class_g2_aerosol; -extern grib_accessor_class* grib_accessor_class_g2_chemical; -extern grib_accessor_class* grib_accessor_class_g2_eps; -extern grib_accessor_class* grib_accessor_class_g2_mars_labeling; -extern grib_accessor_class* grib_accessor_class_g2bitmap; -extern grib_accessor_class* grib_accessor_class_g2bitmap_present; -extern grib_accessor_class* grib_accessor_class_g2date; -extern grib_accessor_class* grib_accessor_class_g2end_step; -extern grib_accessor_class* grib_accessor_class_g2grid; -extern grib_accessor_class* grib_accessor_class_g2latlon; -extern grib_accessor_class* grib_accessor_class_g2level; -extern grib_accessor_class* grib_accessor_class_g2lon; -extern grib_accessor_class* grib_accessor_class_g2step_range; -extern grib_accessor_class* grib_accessor_class_gaussian_grid_name; -extern grib_accessor_class* grib_accessor_class_gds_is_present; -extern grib_accessor_class* grib_accessor_class_gds_not_present_bitmap; -extern grib_accessor_class* grib_accessor_class_gen; -extern grib_accessor_class* grib_accessor_class_getenv; -extern grib_accessor_class* grib_accessor_class_global_gaussian; -extern grib_accessor_class* grib_accessor_class_group; -extern grib_accessor_class* grib_accessor_class_group_copy; -extern grib_accessor_class* grib_accessor_class_gts_header; -extern grib_accessor_class* grib_accessor_class_hash_array; -extern grib_accessor_class* grib_accessor_class_headers_only; -extern grib_accessor_class* grib_accessor_class_ibmfloat; -extern grib_accessor_class* grib_accessor_class_ieeefloat; -extern grib_accessor_class* grib_accessor_class_ifs_param; +//extern grib_accessor_class* grib_accessor_class_count_file; +//extern grib_accessor_class* grib_accessor_class_count_missing; +//extern grib_accessor_class* grib_accessor_class_count_total; +//extern grib_accessor_class* grib_accessor_class_data_apply_bitmap; +//extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic; +//extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap; +//extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; +//extern grib_accessor_class* grib_accessor_class_data_complex_packing; +//extern grib_accessor_class* grib_accessor_class_data_dummy_field; +//extern grib_accessor_class* grib_accessor_class_data_g1complex_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap; +//extern grib_accessor_class* grib_accessor_class_data_g1shsimple_packing; +//extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; +//extern grib_accessor_class* grib_accessor_class_data_g22order_packing; +//extern grib_accessor_class* grib_accessor_class_data_g2bifourier_packing; +//extern grib_accessor_class* grib_accessor_class_data_g2complex_packing; +//extern grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap; +//extern grib_accessor_class* grib_accessor_class_data_g2shsimple_packing; +//extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; +//extern grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing; +//extern grib_accessor_class* grib_accessor_class_data_jpeg2000_packing; +//extern grib_accessor_class* grib_accessor_class_data_png_packing; +//extern grib_accessor_class* grib_accessor_class_data_raw_packing; +//extern grib_accessor_class* grib_accessor_class_data_run_length_packing; +//extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; +//extern grib_accessor_class* grib_accessor_class_data_sh_packed; +//extern grib_accessor_class* grib_accessor_class_data_sh_unpacked; +//extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; +//extern grib_accessor_class* grib_accessor_class_data_simple_packing; +//extern grib_accessor_class* grib_accessor_class_decimal_precision; +//extern grib_accessor_class* grib_accessor_class_dictionary; +//extern grib_accessor_class* grib_accessor_class_dirty; +//extern grib_accessor_class* grib_accessor_class_divdouble; +//extern grib_accessor_class* grib_accessor_class_double; +//extern grib_accessor_class* grib_accessor_class_element; +//extern grib_accessor_class* grib_accessor_class_evaluate; +//extern grib_accessor_class* grib_accessor_class_expanded_descriptors; +//extern grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value; +//extern grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag; +//extern grib_accessor_class* grib_accessor_class_g1_message_length; +//extern grib_accessor_class* grib_accessor_class_g1_section4_length; +//extern grib_accessor_class* grib_accessor_class_g1bitmap; +//extern grib_accessor_class* grib_accessor_class_g1date; +//extern grib_accessor_class* grib_accessor_class_g1day_of_the_year_date; +//extern grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly; +//extern grib_accessor_class* grib_accessor_class_g1fcperiod; +//extern grib_accessor_class* grib_accessor_class_g1forecastmonth; +//extern grib_accessor_class* grib_accessor_class_g1monthlydate; +//extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex; +//extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple; +//extern grib_accessor_class* grib_accessor_class_g1step_range; +//extern grib_accessor_class* grib_accessor_class_g1verificationdate; +//extern grib_accessor_class* grib_accessor_class_g2_aerosol; +//extern grib_accessor_class* grib_accessor_class_g2_chemical; +//extern grib_accessor_class* grib_accessor_class_g2_eps; +//extern grib_accessor_class* grib_accessor_class_g2_mars_labeling; +//extern grib_accessor_class* grib_accessor_class_g2bitmap; +//extern grib_accessor_class* grib_accessor_class_g2bitmap_present; +//extern grib_accessor_class* grib_accessor_class_g2date; +//extern grib_accessor_class* grib_accessor_class_g2end_step; +//extern grib_accessor_class* grib_accessor_class_g2grid; +//extern grib_accessor_class* grib_accessor_class_g2latlon; +//extern grib_accessor_class* grib_accessor_class_g2level; +//extern grib_accessor_class* grib_accessor_class_g2lon; +//extern grib_accessor_class* grib_accessor_class_g2step_range; +//extern grib_accessor_class* grib_accessor_class_gaussian_grid_name; +//extern grib_accessor_class* grib_accessor_class_gds_is_present; +//extern grib_accessor_class* grib_accessor_class_gds_not_present_bitmap; +//extern grib_accessor_class* grib_accessor_class_gen; +//extern grib_accessor_class* grib_accessor_class_getenv; +//extern grib_accessor_class* grib_accessor_class_global_gaussian; +//extern grib_accessor_class* grib_accessor_class_group; +//extern grib_accessor_class* grib_accessor_class_group_copy; +//extern grib_accessor_class* grib_accessor_class_gts_header; +//extern grib_accessor_class* grib_accessor_class_hash_array; +//extern grib_accessor_class* grib_accessor_class_headers_only; +//extern grib_accessor_class* grib_accessor_class_ibmfloat; +//extern grib_accessor_class* grib_accessor_class_ieeefloat; +//extern grib_accessor_class* grib_accessor_class_ifs_param; +#include "accessor/grib_accessor_class_iterator.h" extern grib_accessor_class* grib_accessor_class_iterator; -extern grib_accessor_class* grib_accessor_class_julian_date; -extern grib_accessor_class* grib_accessor_class_julian_day; -extern grib_accessor_class* grib_accessor_class_ksec1expver; -extern grib_accessor_class* grib_accessor_class_label; -extern grib_accessor_class* grib_accessor_class_latitudes; -extern grib_accessor_class* grib_accessor_class_latlon_increment; -extern grib_accessor_class* grib_accessor_class_latlonvalues; -extern grib_accessor_class* grib_accessor_class_library_version; -extern grib_accessor_class* grib_accessor_class_local_definition; +//extern grib_accessor_class* grib_accessor_class_julian_date; +//extern grib_accessor_class* grib_accessor_class_julian_day; +//extern grib_accessor_class* grib_accessor_class_ksec1expver; +//extern grib_accessor_class* grib_accessor_class_label; +//extern grib_accessor_class* grib_accessor_class_latitudes; +//extern grib_accessor_class* grib_accessor_class_latlon_increment; +//extern grib_accessor_class* grib_accessor_class_latlonvalues; +//extern grib_accessor_class* grib_accessor_class_library_version; +//extern grib_accessor_class* grib_accessor_class_local_definition; +#include "accessor/grib_accessor_class_long.h" extern grib_accessor_class* grib_accessor_class_long; -extern grib_accessor_class* grib_accessor_class_long_vector; -extern grib_accessor_class* grib_accessor_class_longitudes; -extern grib_accessor_class* grib_accessor_class_lookup; -extern grib_accessor_class* grib_accessor_class_mars_param; -extern grib_accessor_class* grib_accessor_class_mars_step; -extern grib_accessor_class* grib_accessor_class_md5; -extern grib_accessor_class* grib_accessor_class_message; -extern grib_accessor_class* grib_accessor_class_message_copy; -extern grib_accessor_class* grib_accessor_class_multdouble; +//extern grib_accessor_class* grib_accessor_class_long_vector; +//extern grib_accessor_class* grib_accessor_class_longitudes; +//extern grib_accessor_class* grib_accessor_class_lookup; +//extern grib_accessor_class* grib_accessor_class_mars_param; +//extern grib_accessor_class* grib_accessor_class_mars_step; +//extern grib_accessor_class* grib_accessor_class_md5; +//extern grib_accessor_class* grib_accessor_class_message; +//extern grib_accessor_class* grib_accessor_class_message_copy; +//extern grib_accessor_class* grib_accessor_class_multdouble; +#include "accessor/grib_accessor_class_nearest.h" extern grib_accessor_class* grib_accessor_class_nearest; -extern grib_accessor_class* grib_accessor_class_non_alpha; -extern grib_accessor_class* grib_accessor_class_number_of_coded_values; -extern grib_accessor_class* grib_accessor_class_number_of_points; -extern grib_accessor_class* grib_accessor_class_number_of_points_gaussian; -extern grib_accessor_class* grib_accessor_class_number_of_values; -extern grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing; -extern grib_accessor_class* grib_accessor_class_octahedral_gaussian; -extern grib_accessor_class* grib_accessor_class_octet_number; -extern grib_accessor_class* grib_accessor_class_offset_file; -extern grib_accessor_class* grib_accessor_class_offset_values; -extern grib_accessor_class* grib_accessor_class_optimal_step_units; -extern grib_accessor_class* grib_accessor_class_pack_bufr_values; -extern grib_accessor_class* grib_accessor_class_packing_type; -extern grib_accessor_class* grib_accessor_class_pad; -extern grib_accessor_class* grib_accessor_class_padding; -extern grib_accessor_class* grib_accessor_class_padto; -extern grib_accessor_class* grib_accessor_class_padtoeven; -extern grib_accessor_class* grib_accessor_class_padtomultiple; -extern grib_accessor_class* grib_accessor_class_position; -extern grib_accessor_class* grib_accessor_class_proj_string; -extern grib_accessor_class* grib_accessor_class_raw; -extern grib_accessor_class* grib_accessor_class_rdbtime_guess_date; -extern grib_accessor_class* grib_accessor_class_reference_value_error; -extern grib_accessor_class* grib_accessor_class_round; -extern grib_accessor_class* grib_accessor_class_scale; -extern grib_accessor_class* grib_accessor_class_scale_values; -extern grib_accessor_class* grib_accessor_class_second_order_bits_per_value; -extern grib_accessor_class* grib_accessor_class_section; -extern grib_accessor_class* grib_accessor_class_section_length; -extern grib_accessor_class* grib_accessor_class_section_padding; -extern grib_accessor_class* grib_accessor_class_section_pointer; -extern grib_accessor_class* grib_accessor_class_select_step_template; -extern grib_accessor_class* grib_accessor_class_sexagesimal2decimal; -extern grib_accessor_class* grib_accessor_class_signed; -extern grib_accessor_class* grib_accessor_class_signed_bits; -extern grib_accessor_class* grib_accessor_class_simple_packing_error; -extern grib_accessor_class* grib_accessor_class_size; +//extern grib_accessor_class* grib_accessor_class_non_alpha; +//extern grib_accessor_class* grib_accessor_class_number_of_coded_values; +//extern grib_accessor_class* grib_accessor_class_number_of_points; +//extern grib_accessor_class* grib_accessor_class_number_of_points_gaussian; +//extern grib_accessor_class* grib_accessor_class_number_of_values; +//extern grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing; +//extern grib_accessor_class* grib_accessor_class_octahedral_gaussian; +//extern grib_accessor_class* grib_accessor_class_octet_number; +//extern grib_accessor_class* grib_accessor_class_offset_file; +//extern grib_accessor_class* grib_accessor_class_offset_values; +//extern grib_accessor_class* grib_accessor_class_optimal_step_units; +//extern grib_accessor_class* grib_accessor_class_pack_bufr_values; +//extern grib_accessor_class* grib_accessor_class_packing_type; +//extern grib_accessor_class* grib_accessor_class_pad; +//extern grib_accessor_class* grib_accessor_class_padding; +//extern grib_accessor_class* grib_accessor_class_padto; +//extern grib_accessor_class* grib_accessor_class_padtoeven; +//extern grib_accessor_class* grib_accessor_class_padtomultiple; +//extern grib_accessor_class* grib_accessor_class_position; +//extern grib_accessor_class* grib_accessor_class_proj_string; +//extern grib_accessor_class* grib_accessor_class_raw; +//extern grib_accessor_class* grib_accessor_class_rdbtime_guess_date; +//extern grib_accessor_class* grib_accessor_class_reference_value_error; +//extern grib_accessor_class* grib_accessor_class_round; +//extern grib_accessor_class* grib_accessor_class_scale; +//extern grib_accessor_class* grib_accessor_class_scale_values; +//extern grib_accessor_class* grib_accessor_class_second_order_bits_per_value; +//extern grib_accessor_class* grib_accessor_class_section; +//extern grib_accessor_class* grib_accessor_class_section_length; +//extern grib_accessor_class* grib_accessor_class_section_padding; +//extern grib_accessor_class* grib_accessor_class_section_pointer; +//extern grib_accessor_class* grib_accessor_class_select_step_template; +//extern grib_accessor_class* grib_accessor_class_sexagesimal2decimal; +//extern grib_accessor_class* grib_accessor_class_signed; +//extern grib_accessor_class* grib_accessor_class_signed_bits; +//extern grib_accessor_class* grib_accessor_class_simple_packing_error; +//extern grib_accessor_class* grib_accessor_class_size; +#include "accessor/grib_accessor_class_smart_table.h" extern grib_accessor_class* grib_accessor_class_smart_table; -extern grib_accessor_class* grib_accessor_class_smart_table_column; -extern grib_accessor_class* grib_accessor_class_spd; -extern grib_accessor_class* grib_accessor_class_spectral_truncation; -extern grib_accessor_class* grib_accessor_class_sprintf; -extern grib_accessor_class* grib_accessor_class_statistics; -extern grib_accessor_class* grib_accessor_class_statistics_spectral; -extern grib_accessor_class* grib_accessor_class_step_human_readable; -extern grib_accessor_class* grib_accessor_class_step_in_units; -extern grib_accessor_class* grib_accessor_class_sum; -extern grib_accessor_class* grib_accessor_class_suppressed; -extern grib_accessor_class* grib_accessor_class_time; -extern grib_accessor_class* grib_accessor_class_to_double; -extern grib_accessor_class* grib_accessor_class_to_integer; -extern grib_accessor_class* grib_accessor_class_to_string; +//extern grib_accessor_class* grib_accessor_class_smart_table_column; +//extern grib_accessor_class* grib_accessor_class_spd; +//extern grib_accessor_class* grib_accessor_class_spectral_truncation; +//extern grib_accessor_class* grib_accessor_class_sprintf; +//extern grib_accessor_class* grib_accessor_class_statistics; +//extern grib_accessor_class* grib_accessor_class_statistics_spectral; +//extern grib_accessor_class* grib_accessor_class_step_human_readable; +//extern grib_accessor_class* grib_accessor_class_step_in_units; +//extern grib_accessor_class* grib_accessor_class_sum; +//extern grib_accessor_class* grib_accessor_class_suppressed; +//extern grib_accessor_class* grib_accessor_class_time; +//extern grib_accessor_class* grib_accessor_class_to_double; +//extern grib_accessor_class* grib_accessor_class_to_integer; +//extern grib_accessor_class* grib_accessor_class_to_string; +#include "accessor/grib_accessor_class_transient.h" extern grib_accessor_class* grib_accessor_class_transient; -extern grib_accessor_class* grib_accessor_class_transient_darray; -extern grib_accessor_class* grib_accessor_class_trim; -extern grib_accessor_class* grib_accessor_class_uint16; -extern grib_accessor_class* grib_accessor_class_uint32; -extern grib_accessor_class* grib_accessor_class_uint32_little_endian; -extern grib_accessor_class* grib_accessor_class_uint64; -extern grib_accessor_class* grib_accessor_class_uint64_little_endian; -extern grib_accessor_class* grib_accessor_class_uint8; -extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors; -extern grib_accessor_class* grib_accessor_class_unpack_bufr_values; +//extern grib_accessor_class* grib_accessor_class_transient_darray; +//extern grib_accessor_class* grib_accessor_class_trim; +//extern grib_accessor_class* grib_accessor_class_uint16; +//extern grib_accessor_class* grib_accessor_class_uint32; +//extern grib_accessor_class* grib_accessor_class_uint32_little_endian; +//extern grib_accessor_class* grib_accessor_class_uint64; +//extern grib_accessor_class* grib_accessor_class_uint64_little_endian; +//extern grib_accessor_class* grib_accessor_class_uint8; +//extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors; +//extern grib_accessor_class* grib_accessor_class_unpack_bufr_values; +#include "accessor/grib_accessor_class_unsigned.h" extern grib_accessor_class* grib_accessor_class_unsigned; -extern grib_accessor_class* grib_accessor_class_unsigned_bits; -extern grib_accessor_class* grib_accessor_class_validity_date; -extern grib_accessor_class* grib_accessor_class_validity_time; -extern grib_accessor_class* grib_accessor_class_values; +//extern grib_accessor_class* grib_accessor_class_unsigned_bits; +//extern grib_accessor_class* grib_accessor_class_validity_date; +//extern grib_accessor_class* grib_accessor_class_validity_time; +//extern grib_accessor_class* grib_accessor_class_values; +#include "accessor/grib_accessor_class_variable.h" extern grib_accessor_class* grib_accessor_class_variable; -extern grib_accessor_class* grib_accessor_class_vector; -extern grib_accessor_class* grib_accessor_class_when; +//extern grib_accessor_class* grib_accessor_class_vector; +//extern grib_accessor_class* grib_accessor_class_when; diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index 5617c9456..dd88339f7 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -1,6 +1,6 @@ /* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf -C -W classes -t -G -H grib_accessor_classes_get_id -N grib_accessor_classes_hash -m 1 -j 1 accessor_class_list.gperf */ -/* Computed positions: -k'1-2,5,7,11' */ +/* Computed positions: -k'1' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -37,12 +37,12 @@ #line 6 "accessor_class_list.gperf" struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; -#define TOTAL_KEYWORDS 205 +#define TOTAL_KEYWORDS 10 #define MIN_WORD_LENGTH 1 -#define MAX_WORD_LENGTH 44 +#define MAX_WORD_LENGTH 11 #define MIN_HASH_VALUE 1 -#define MAX_HASH_VALUE 506 -/* maximum key range = 506, duplicates = 0 */ +#define MAX_HASH_VALUE 14 +/* maximum key range = 14, duplicates = 0 */ #ifdef __GNUC__ @@ -51,64 +51,39 @@ struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; #endif #endif -static unsigned int grib_accessor_classes_get_id (const char *str, size_t len) +static unsigned int +grib_accessor_classes_get_id (const char *str, size_t len) { - static const unsigned short asso_values[] = + static const unsigned char asso_values[] = { - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 0, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 1, 145, - 23, 6, 2, 507, 4, 507, 1, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 0, 507, 0, 69, 84, - 0, 0, 161, 24, 187, 1, 8, 9, 87, 102, - 13, 51, 6, 507, 118, 1, 40, 59, 171, 0, - 4, 6, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - 507, 507, 507, 507, 507, 507 + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, + 15, 15, 15, 15, 15, 6, 15, 15, 0, 15, + 0, 15, 15, 15, 15, 2, 3, 3, 0, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15 }; - unsigned int hval = len; - - switch (hval) - { - default: - hval += asso_values[(unsigned char)str[10]]; - /*FALLTHROUGH*/ - case 10: - case 9: - case 8: - case 7: - hval += asso_values[(unsigned char)str[6]]; - /*FALLTHROUGH*/ - case 6: - case 5: - hval += asso_values[(unsigned char)str[4]]; - /*FALLTHROUGH*/ - case 4: - case 3: - case 2: - hval += asso_values[(unsigned char)str[1]]; - /*FALLTHROUGH*/ - case 1: - hval += asso_values[(unsigned char)str[0]]; - break; - } - return hval; + return len + asso_values[(unsigned char)str[0]]; } static const struct accessor_class_hash classes[] = @@ -116,524 +91,42 @@ static const struct accessor_class_hash classes[] = {""}, #line 9 "accessor_class_list.gperf" {" "}, - {""}, {""}, {""}, {""}, -#line 179 "accessor_class_list.gperf" - {"size", &grib_accessor_class_size}, -#line 12 "accessor_class_list.gperf" - {"ascii", &grib_accessor_class_ascii}, -#line 176 "accessor_class_list.gperf" - {"signed", &grib_accessor_class_signed}, -#line 156 "accessor_class_list.gperf" - {"pad", &grib_accessor_class_pad}, -#line 182 "accessor_class_list.gperf" - {"spd", &grib_accessor_class_spd}, - {""}, -#line 75 "accessor_class_list.gperf" - {"dirty", &grib_accessor_class_dirty}, - {""}, -#line 177 "accessor_class_list.gperf" - {"signed_bits", &grib_accessor_class_signed_bits}, - {""}, -#line 66 "accessor_class_list.gperf" - {"data_raw_packing", &grib_accessor_class_data_raw_packing}, - {""}, {""}, {""}, -#line 72 "accessor_class_list.gperf" - {"data_simple_packing", &grib_accessor_class_data_simple_packing}, -#line 68 "accessor_class_list.gperf" - {"data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap}, -#line 170 "accessor_class_list.gperf" - {"section", &grib_accessor_class_section}, -#line 43 "accessor_class_list.gperf" - {"data_apply_bitmap", &grib_accessor_class_data_apply_bitmap}, - {""}, -#line 74 "accessor_class_list.gperf" - {"dictionary", &grib_accessor_class_dictionary}, - {""}, -#line 112 "accessor_class_list.gperf" - {"gen", &grib_accessor_class_gen}, -#line 64 "accessor_class_list.gperf" - {"data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing}, -#line 65 "accessor_class_list.gperf" - {"data_png_packing", &grib_accessor_class_data_png_packing}, -#line 172 "accessor_class_list.gperf" - {"section_padding", &grib_accessor_class_section_padding}, -#line 173 "accessor_class_list.gperf" - {"section_pointer", &grib_accessor_class_section_pointer}, -#line 44 "accessor_class_list.gperf" - {"data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic}, - {""}, {""}, {""}, {""}, -#line 80 "accessor_class_list.gperf" - {"expanded_descriptors", &grib_accessor_class_expanded_descriptors}, -#line 157 "accessor_class_list.gperf" - {"padding", &grib_accessor_class_padding}, -#line 45 "accessor_class_list.gperf" - {"data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap}, -#line 110 "accessor_class_list.gperf" - {"gds_is_present", &grib_accessor_class_gds_is_present}, -#line 169 "accessor_class_list.gperf" - {"second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value}, -#line 171 "accessor_class_list.gperf" - {"section_length", &grib_accessor_class_section_length}, -#line 113 "accessor_class_list.gperf" - {"getenv", &grib_accessor_class_getenv}, -#line 57 "accessor_class_list.gperf" - {"data_g22order_packing", &grib_accessor_class_data_g22order_packing}, -#line 191 "accessor_class_list.gperf" - {"time", &grib_accessor_class_time}, - {""}, -#line 61 "accessor_class_list.gperf" - {"data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing}, - {""}, -#line 155 "accessor_class_list.gperf" - {"packing_type", &grib_accessor_class_packing_type}, -#line 62 "accessor_class_list.gperf" - {"data_g2simple_packing", &grib_accessor_class_data_g2simple_packing}, -#line 59 "accessor_class_list.gperf" - {"data_g2complex_packing", &grib_accessor_class_data_g2complex_packing}, {""}, {""}, -#line 104 "accessor_class_list.gperf" - {"g2grid", &grib_accessor_class_g2grid}, - {""}, {""}, {""}, -#line 103 "accessor_class_list.gperf" - {"g2end_step", &grib_accessor_class_g2end_step}, -#line 98 "accessor_class_list.gperf" - {"g2_eps", &grib_accessor_class_g2_eps}, -#line 142 "accessor_class_list.gperf" - {"nearest", &grib_accessor_class_nearest}, - {""}, -#line 158 "accessor_class_list.gperf" - {"padto", &grib_accessor_class_padto}, -#line 189 "accessor_class_list.gperf" - {"sum", &grib_accessor_class_sum}, - {""}, -#line 107 "accessor_class_list.gperf" - {"g2lon", &grib_accessor_class_g2lon}, -#line 203 "accessor_class_list.gperf" - {"uint8", &grib_accessor_class_uint8}, - {""}, -#line 188 "accessor_class_list.gperf" - {"step_in_units", &grib_accessor_class_step_in_units}, -#line 63 "accessor_class_list.gperf" - {"data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing}, -#line 201 "accessor_class_list.gperf" - {"uint64", &grib_accessor_class_uint64}, -#line 47 "accessor_class_list.gperf" - {"data_complex_packing", &grib_accessor_class_data_complex_packing}, -#line 199 "accessor_class_list.gperf" - {"uint32", &grib_accessor_class_uint32}, -#line 13 "accessor_class_list.gperf" - {"bit", &grib_accessor_class_bit}, -#line 15 "accessor_class_list.gperf" - {"bits", &grib_accessor_class_bits}, -#line 48 "accessor_class_list.gperf" - {"data_dummy_field", &grib_accessor_class_data_dummy_field}, -#line 14 "accessor_class_list.gperf" - {"bitmap", &grib_accessor_class_bitmap}, -#line 124 "accessor_class_list.gperf" - {"julian_day", &grib_accessor_class_julian_day}, -#line 123 "accessor_class_list.gperf" - {"julian_date", &grib_accessor_class_julian_date}, -#line 143 "accessor_class_list.gperf" - {"non_alpha", &grib_accessor_class_non_alpha}, - {""}, -#line 29 "accessor_class_list.gperf" - {"bytes", &grib_accessor_class_bytes}, -#line 67 "accessor_class_list.gperf" - {"data_run_length_packing", &grib_accessor_class_data_run_length_packing}, -#line 108 "accessor_class_list.gperf" - {"g2step_range", &grib_accessor_class_g2step_range}, -#line 16 "accessor_class_list.gperf" - {"bits_per_value", &grib_accessor_class_bits_per_value}, - {""}, {""}, {""}, {""}, {""}, -#line 167 "accessor_class_list.gperf" - {"scale", &grib_accessor_class_scale}, - {""}, -#line 185 "accessor_class_list.gperf" - {"statistics", &grib_accessor_class_statistics}, -#line 102 "accessor_class_list.gperf" - {"g2date", &grib_accessor_class_g2date}, -#line 145 "accessor_class_list.gperf" - {"number_of_points", &grib_accessor_class_number_of_points}, -#line 100 "accessor_class_list.gperf" - {"g2bitmap", &grib_accessor_class_g2bitmap}, - {""}, -#line 60 "accessor_class_list.gperf" - {"data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap}, -#line 58 "accessor_class_list.gperf" - {"data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing}, -#line 111 "accessor_class_list.gperf" - {"gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap}, -#line 122 "accessor_class_list.gperf" - {"iterator", &grib_accessor_class_iterator}, -#line 186 "accessor_class_list.gperf" - {"statistics_spectral", &grib_accessor_class_statistics_spectral}, -#line 46 "accessor_class_list.gperf" - {"data_ccsds_packing", &grib_accessor_class_data_ccsds_packing}, -#line 146 "accessor_class_list.gperf" - {"number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian}, -#line 206 "accessor_class_list.gperf" - {"unsigned", &grib_accessor_class_unsigned}, -#line 138 "accessor_class_list.gperf" - {"md5", &grib_accessor_class_md5}, - {""}, {""}, -#line 96 "accessor_class_list.gperf" - {"g2_aerosol", &grib_accessor_class_g2_aerosol}, -#line 139 "accessor_class_list.gperf" - {"message", &grib_accessor_class_message}, -#line 207 "accessor_class_list.gperf" - {"unsigned_bits", &grib_accessor_class_unsigned_bits}, -#line 174 "accessor_class_list.gperf" - {"select_step_template", &grib_accessor_class_select_step_template}, -#line 136 "accessor_class_list.gperf" - {"mars_param", &grib_accessor_class_mars_param}, -#line 204 "accessor_class_list.gperf" - {"unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors}, -#line 193 "accessor_class_list.gperf" - {"to_integer", &grib_accessor_class_to_integer}, - {""}, {""}, {""}, -#line 178 "accessor_class_list.gperf" - {"simple_packing_error", &grib_accessor_class_simple_packing_error}, -#line 187 "accessor_class_list.gperf" - {"step_human_readable", &grib_accessor_class_step_human_readable}, -#line 140 "accessor_class_list.gperf" - {"message_copy", &grib_accessor_class_message_copy}, -#line 163 "accessor_class_list.gperf" - {"raw", &grib_accessor_class_raw}, - {""}, {""}, -#line 202 "accessor_class_list.gperf" - {"uint64_little_endian", &grib_accessor_class_uint64_little_endian}, - {""}, -#line 200 "accessor_class_list.gperf" - {"uint32_little_endian", &grib_accessor_class_uint32_little_endian}, -#line 114 "accessor_class_list.gperf" - {"global_gaussian", &grib_accessor_class_global_gaussian}, - {""}, {""}, -#line 76 "accessor_class_list.gperf" - {"divdouble", &grib_accessor_class_divdouble}, - {""}, -#line 175 "accessor_class_list.gperf" - {"sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal}, -#line 99 "accessor_class_list.gperf" - {"g2_mars_labeling", &grib_accessor_class_g2_mars_labeling}, -#line 78 "accessor_class_list.gperf" - {"element", &grib_accessor_class_element}, -#line 160 "accessor_class_list.gperf" - {"padtomultiple", &grib_accessor_class_padtomultiple}, -#line 127 "accessor_class_list.gperf" - {"latitudes", &grib_accessor_class_latitudes}, -#line 164 "accessor_class_list.gperf" - {"rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date}, - {""}, {""}, {""}, -#line 194 "accessor_class_list.gperf" - {"to_string", &grib_accessor_class_to_string}, #line 132 "accessor_class_list.gperf" {"long", &grib_accessor_class_long}, -#line 19 "accessor_class_list.gperf" - {"bufr_data_array", &grib_accessor_class_bufr_data_array}, -#line 77 "accessor_class_list.gperf" - {"double", &grib_accessor_class_double}, -#line 20 "accessor_class_list.gperf" - {"bufr_data_element", &grib_accessor_class_bufr_data_element}, -#line 105 "accessor_class_list.gperf" - {"g2latlon", &grib_accessor_class_g2latlon}, {""}, {""}, -#line 26 "accessor_class_list.gperf" - {"bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning}, - {""}, -#line 137 "accessor_class_list.gperf" - {"mars_step", &grib_accessor_class_mars_step}, - {""}, -#line 115 "accessor_class_list.gperf" - {"group", &grib_accessor_class_group}, - {""}, -#line 28 "accessor_class_list.gperf" - {"bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors}, -#line 161 "accessor_class_list.gperf" - {"position", &grib_accessor_class_position}, - {""}, {""}, {""}, -#line 17 "accessor_class_list.gperf" - {"blob", &grib_accessor_class_blob}, -#line 109 "accessor_class_list.gperf" - {"gaussian_grid_name", &grib_accessor_class_gaussian_grid_name}, -#line 197 "accessor_class_list.gperf" - {"trim", &grib_accessor_class_trim}, - {""}, {""}, -#line 119 "accessor_class_list.gperf" - {"ibmfloat", &grib_accessor_class_ibmfloat}, - {""}, {""}, -#line 195 "accessor_class_list.gperf" - {"transient", &grib_accessor_class_transient}, -#line 55 "accessor_class_list.gperf" - {"data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing}, - {""}, {""}, -#line 56 "accessor_class_list.gperf" - {"data_g1simple_packing", &grib_accessor_class_data_g1simple_packing}, -#line 49 "accessor_class_list.gperf" - {"data_g1complex_packing", &grib_accessor_class_data_g1complex_packing}, -#line 166 "accessor_class_list.gperf" - {"round", &grib_accessor_class_round}, -#line 196 "accessor_class_list.gperf" - {"transient_darray", &grib_accessor_class_transient_darray}, -#line 18 "accessor_class_list.gperf" - {"budgdate", &grib_accessor_class_budgdate}, -#line 210 "accessor_class_list.gperf" - {"values", &grib_accessor_class_values}, -#line 144 "accessor_class_list.gperf" - {"number_of_coded_values", &grib_accessor_class_number_of_coded_values}, -#line 126 "accessor_class_list.gperf" - {"label", &grib_accessor_class_label}, - {""}, {""}, -#line 38 "accessor_class_list.gperf" - {"concept", &grib_accessor_class_concept}, - {""}, -#line 183 "accessor_class_list.gperf" - {"spectral_truncation", &grib_accessor_class_spectral_truncation}, - {""}, {""}, -#line 83 "accessor_class_list.gperf" - {"g1_message_length", &grib_accessor_class_g1_message_length}, -#line 184 "accessor_class_list.gperf" - {"sprintf", &grib_accessor_class_sprintf}, -#line 190 "accessor_class_list.gperf" - {"suppressed", &grib_accessor_class_suppressed}, - {""}, -#line 213 "accessor_class_list.gperf" - {"when", &grib_accessor_class_when}, - {""}, {""}, -#line 180 "accessor_class_list.gperf" - {"smart_table", &grib_accessor_class_smart_table}, - {""}, -#line 39 "accessor_class_list.gperf" - {"constant", &grib_accessor_class_constant}, - {""}, {""}, -#line 162 "accessor_class_list.gperf" - {"proj_string", &grib_accessor_class_proj_string}, -#line 150 "accessor_class_list.gperf" - {"octet_number", &grib_accessor_class_octet_number}, -#line 181 "accessor_class_list.gperf" - {"smart_table_column", &grib_accessor_class_smart_table_column}, - {""}, -#line 135 "accessor_class_list.gperf" - {"lookup", &grib_accessor_class_lookup}, - {""}, -#line 94 "accessor_class_list.gperf" - {"g1step_range", &grib_accessor_class_g1step_range}, -#line 73 "accessor_class_list.gperf" - {"decimal_precision", &grib_accessor_class_decimal_precision}, - {""}, -#line 134 "accessor_class_list.gperf" - {"longitudes", &grib_accessor_class_longitudes}, -#line 70 "accessor_class_list.gperf" - {"data_sh_unpacked", &grib_accessor_class_data_sh_unpacked}, -#line 27 "accessor_class_list.gperf" - {"bufr_string_values", &grib_accessor_class_bufr_string_values}, -#line 198 "accessor_class_list.gperf" - {"uint16", &grib_accessor_class_uint16}, - {""}, {""}, -#line 71 "accessor_class_list.gperf" - {"data_shsimple_packing", &grib_accessor_class_data_shsimple_packing}, -#line 86 "accessor_class_list.gperf" - {"g1date", &grib_accessor_class_g1date}, - {""}, -#line 85 "accessor_class_list.gperf" - {"g1bitmap", &grib_accessor_class_g1bitmap}, - {""}, -#line 54 "accessor_class_list.gperf" - {"data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap}, -#line 192 "accessor_class_list.gperf" - {"to_double", &grib_accessor_class_to_double}, -#line 101 "accessor_class_list.gperf" - {"g2bitmap_present", &grib_accessor_class_g2bitmap_present}, -#line 120 "accessor_class_list.gperf" - {"ieeefloat", &grib_accessor_class_ieeefloat}, -#line 151 "accessor_class_list.gperf" - {"offset_file", &grib_accessor_class_offset_file}, -#line 208 "accessor_class_list.gperf" - {"validity_date", &grib_accessor_class_validity_date}, -#line 209 "accessor_class_list.gperf" - {"validity_time", &grib_accessor_class_validity_time}, - {""}, -#line 130 "accessor_class_list.gperf" - {"library_version", &grib_accessor_class_library_version}, -#line 212 "accessor_class_list.gperf" - {"vector", &grib_accessor_class_vector}, -#line 84 "accessor_class_list.gperf" - {"g1_section4_length", &grib_accessor_class_g1_section4_length}, -#line 141 "accessor_class_list.gperf" - {"multdouble", &grib_accessor_class_multdouble}, -#line 52 "accessor_class_list.gperf" - {"data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing}, - {""}, {""}, -#line 53 "accessor_class_list.gperf" - {"data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing}, - {""}, -#line 24 "accessor_class_list.gperf" - {"bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets}, -#line 159 "accessor_class_list.gperf" - {"padtoeven", &grib_accessor_class_padtoeven}, -#line 50 "accessor_class_list.gperf" - {"data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing}, - {""}, -#line 51 "accessor_class_list.gperf" - {"data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing}, -#line 22 "accessor_class_list.gperf" - {"bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets}, - {""}, {""}, {""}, -#line 23 "accessor_class_list.gperf" - {"bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets}, - {""}, -#line 21 "accessor_class_list.gperf" - {"bufr_elements_table", &grib_accessor_class_bufr_elements_table}, - {""}, {""}, {""}, {""}, -#line 154 "accessor_class_list.gperf" - {"pack_bufr_values", &grib_accessor_class_pack_bufr_values}, -#line 35 "accessor_class_list.gperf" - {"codetable", &grib_accessor_class_codetable}, -#line 131 "accessor_class_list.gperf" - {"local_definition", &grib_accessor_class_local_definition}, - {""}, -#line 25 "accessor_class_list.gperf" - {"bufr_group", &grib_accessor_class_bufr_group}, - {""}, -#line 88 "accessor_class_list.gperf" - {"g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly}, -#line 147 "accessor_class_list.gperf" - {"number_of_values", &grib_accessor_class_number_of_values}, - {""}, -#line 116 "accessor_class_list.gperf" - {"gts_header", &grib_accessor_class_gts_header}, - {""}, -#line 33 "accessor_class_list.gperf" - {"closest_date", &grib_accessor_class_closest_date}, -#line 153 "accessor_class_list.gperf" - {"optimal_step_units", &grib_accessor_class_optimal_step_units}, - {""}, +#line 142 "accessor_class_list.gperf" + {"nearest", &grib_accessor_class_nearest}, #line 211 "accessor_class_list.gperf" {"variable", &grib_accessor_class_variable}, -#line 133 "accessor_class_list.gperf" - {"long_vector", &grib_accessor_class_long_vector}, -#line 168 "accessor_class_list.gperf" - {"scale_values", &grib_accessor_class_scale_values}, - {""}, {""}, {""}, -#line 128 "accessor_class_list.gperf" - {"latlon_increment", &grib_accessor_class_latlon_increment}, - {""}, {""}, {""}, -#line 148 "accessor_class_list.gperf" - {"number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing}, - {""}, -#line 79 "accessor_class_list.gperf" - {"evaluate", &grib_accessor_class_evaluate}, - {""}, {""}, {""}, {""}, {""}, -#line 152 "accessor_class_list.gperf" - {"offset_values", &grib_accessor_class_offset_values}, -#line 69 "accessor_class_list.gperf" - {"data_sh_packed", &grib_accessor_class_data_sh_packed}, -#line 11 "accessor_class_list.gperf" - {"abstract_vector", &grib_accessor_class_abstract_vector}, -#line 118 "accessor_class_list.gperf" - {"headers_only", &grib_accessor_class_headers_only}, -#line 125 "accessor_class_list.gperf" - {"ksec1expver", &grib_accessor_class_ksec1expver}, - {""}, {""}, -#line 41 "accessor_class_list.gperf" - {"count_missing", &grib_accessor_class_count_missing}, -#line 205 "accessor_class_list.gperf" - {"unpack_bufr_values", &grib_accessor_class_unpack_bufr_values}, - {""}, {""}, -#line 121 "accessor_class_list.gperf" - {"ifs_param", &grib_accessor_class_ifs_param}, - {""}, {""}, {""}, -#line 36 "accessor_class_list.gperf" - {"codetable_title", &grib_accessor_class_codetable_title}, - {""}, {""}, {""}, -#line 89 "accessor_class_list.gperf" - {"g1fcperiod", &grib_accessor_class_g1fcperiod}, -#line 34 "accessor_class_list.gperf" - {"codeflag", &grib_accessor_class_codeflag}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 106 "accessor_class_list.gperf" - {"g2level", &grib_accessor_class_g2level}, -#line 42 "accessor_class_list.gperf" - {"count_total", &grib_accessor_class_count_total}, - {""}, -#line 117 "accessor_class_list.gperf" - {"hash_array", &grib_accessor_class_hash_array}, - {""}, {""}, -#line 37 "accessor_class_list.gperf" - {"codetable_units", &grib_accessor_class_codetable_units}, - {""}, {""}, -#line 129 "accessor_class_list.gperf" - {"latlonvalues", &grib_accessor_class_latlonvalues}, - {""}, {""}, {""}, {""}, -#line 30 "accessor_class_list.gperf" - {"change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 31 "accessor_class_list.gperf" - {"change_scanning_direction", &grib_accessor_class_change_scanning_direction}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 149 "accessor_class_list.gperf" - {"octahedral_gaussian", &grib_accessor_class_octahedral_gaussian}, -#line 10 "accessor_class_list.gperf" - {"abstract_long_vector", &grib_accessor_class_abstract_long_vector}, - {""}, {""}, {""}, -#line 40 "accessor_class_list.gperf" - {"count_file", &grib_accessor_class_count_file}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 91 "accessor_class_list.gperf" - {"g1monthlydate", &grib_accessor_class_g1monthlydate}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 82 "accessor_class_list.gperf" - {"g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag}, - {""}, -#line 81 "accessor_class_list.gperf" - {"from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 32 "accessor_class_list.gperf" - {"check_internal_version", &grib_accessor_class_check_internal_version}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, -#line 97 "accessor_class_list.gperf" - {"g2_chemical", &grib_accessor_class_g2_chemical}, -#line 87 "accessor_class_list.gperf" - {"g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date}, - {""}, {""}, {""}, {""}, {""}, -#line 165 "accessor_class_list.gperf" - {"reference_value_error", &grib_accessor_class_reference_value_error}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 93 "accessor_class_list.gperf" - {"g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple}, -#line 92 "accessor_class_list.gperf" - {"g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, -#line 90 "accessor_class_list.gperf" - {"g1forecastmonth", &grib_accessor_class_g1forecastmonth}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 95 "accessor_class_list.gperf" - {"g1verificationdate", &grib_accessor_class_g1verificationdate} +#line 39 "accessor_class_list.gperf" + {"constant", &grib_accessor_class_constant}, +#line 35 "accessor_class_list.gperf" + {"codetable", &grib_accessor_class_codetable}, +#line 206 "accessor_class_list.gperf" + {"unsigned", &grib_accessor_class_unsigned}, +#line 195 "accessor_class_list.gperf" + {"transient", &grib_accessor_class_transient}, +#line 180 "accessor_class_list.gperf" + {"smart_table", &grib_accessor_class_smart_table}, +#line 122 "accessor_class_list.gperf" + {"iterator", &grib_accessor_class_iterator} }; -static const struct accessor_class_hash* grib_accessor_classes_hash(const char *str, size_t len) +const struct accessor_class_hash * +grib_accessor_classes_hash (const char *str, size_t len) +{ + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { unsigned int key = grib_accessor_classes_get_id (str, len); -#ifdef DEBUG + if (key <= MAX_HASH_VALUE) { - const char *s; - Assert( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH ); - Assert( key <= MAX_HASH_VALUE ); - s = classes[key].name; - Assert( *str == *s && strcmp(str + 1, s + 1)==0 ); - } -#endif + const char *s = classes[key].name; + if (*str == *s && !strcmp (str + 1, s + 1)) return &classes[key]; + } + } + return 0; } diff --git a/src/grib_accessor_factory.h b/src/grib_accessor_factory.h index 2f889a0c6..644d2e89b 100644 --- a/src/grib_accessor_factory.h +++ b/src/grib_accessor_factory.h @@ -1,205 +1,205 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ -{ "abstract_long_vector", &grib_accessor_class_abstract_long_vector, }, -{ "abstract_vector", &grib_accessor_class_abstract_vector, }, -{ "ascii", &grib_accessor_class_ascii, }, -{ "bit", &grib_accessor_class_bit, }, -{ "bitmap", &grib_accessor_class_bitmap, }, -{ "bits", &grib_accessor_class_bits, }, -{ "bits_per_value", &grib_accessor_class_bits_per_value, }, -{ "blob", &grib_accessor_class_blob, }, -{ "budgdate", &grib_accessor_class_budgdate, }, -{ "bufr_data_array", &grib_accessor_class_bufr_data_array, }, -{ "bufr_data_element", &grib_accessor_class_bufr_data_element, }, -{ "bufr_elements_table", &grib_accessor_class_bufr_elements_table, }, -{ "bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets, }, -{ "bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets, }, -{ "bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets, }, -{ "bufr_group", &grib_accessor_class_bufr_group, }, -{ "bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning, }, -{ "bufr_string_values", &grib_accessor_class_bufr_string_values, }, -{ "bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors, }, -{ "bytes", &grib_accessor_class_bytes, }, -{ "change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning, }, -{ "change_scanning_direction", &grib_accessor_class_change_scanning_direction, }, -{ "check_internal_version", &grib_accessor_class_check_internal_version, }, -{ "closest_date", &grib_accessor_class_closest_date, }, -{ "codeflag", &grib_accessor_class_codeflag, }, +//{ "abstract_long_vector", &grib_accessor_class_abstract_long_vector, }, +//{ "abstract_vector", &grib_accessor_class_abstract_vector, }, +//{ "ascii", &grib_accessor_class_ascii, }, +//{ "bit", &grib_accessor_class_bit, }, +//{ "bitmap", &grib_accessor_class_bitmap, }, +//{ "bits", &grib_accessor_class_bits, }, +//{ "bits_per_value", &grib_accessor_class_bits_per_value, }, +//{ "blob", &grib_accessor_class_blob, }, +//{ "budgdate", &grib_accessor_class_budgdate, }, +//{ "bufr_data_array", &grib_accessor_class_bufr_data_array, }, +//{ "bufr_data_element", &grib_accessor_class_bufr_data_element, }, +//{ "bufr_elements_table", &grib_accessor_class_bufr_elements_table, }, +//{ "bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets, }, +//{ "bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets, }, +//{ "bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets, }, +//{ "bufr_group", &grib_accessor_class_bufr_group, }, +//{ "bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning, }, +//{ "bufr_string_values", &grib_accessor_class_bufr_string_values, }, +//{ "bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors, }, +//{ "bytes", &grib_accessor_class_bytes, }, +//{ "change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning, }, +//{ "change_scanning_direction", &grib_accessor_class_change_scanning_direction, }, +//{ "check_internal_version", &grib_accessor_class_check_internal_version, }, +//{ "closest_date", &grib_accessor_class_closest_date, }, +//{ "codeflag", &grib_accessor_class_codeflag, }, { "codetable", &grib_accessor_class_codetable, }, -{ "codetable_title", &grib_accessor_class_codetable_title, }, -{ "codetable_units", &grib_accessor_class_codetable_units, }, -{ "concept", &grib_accessor_class_concept, }, +//{ "codetable_title", &grib_accessor_class_codetable_title, }, +//{ "codetable_units", &grib_accessor_class_codetable_units, }, +//{ "concept", &grib_accessor_class_concept, }, { "constant", &grib_accessor_class_constant, }, -{ "count_file", &grib_accessor_class_count_file, }, -{ "count_missing", &grib_accessor_class_count_missing, }, -{ "count_total", &grib_accessor_class_count_total, }, -{ "data_apply_bitmap", &grib_accessor_class_data_apply_bitmap, }, -{ "data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic, }, -{ "data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap, }, -{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, -{ "data_complex_packing", &grib_accessor_class_data_complex_packing, }, -{ "data_dummy_field", &grib_accessor_class_data_dummy_field, }, -{ "data_g1complex_packing", &grib_accessor_class_data_g1complex_packing, }, -{ "data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing, }, -{ "data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing, }, -{ "data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing, }, -{ "data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing, }, -{ "data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap, }, -{ "data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing, }, -{ "data_g1simple_packing", &grib_accessor_class_data_g1simple_packing, }, -{ "data_g22order_packing", &grib_accessor_class_data_g22order_packing, }, -{ "data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing, }, -{ "data_g2complex_packing", &grib_accessor_class_data_g2complex_packing, }, -{ "data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap, }, -{ "data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing, }, -{ "data_g2simple_packing", &grib_accessor_class_data_g2simple_packing, }, -{ "data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing, }, -{ "data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing, }, -{ "data_png_packing", &grib_accessor_class_data_png_packing, }, -{ "data_raw_packing", &grib_accessor_class_data_raw_packing, }, -{ "data_run_length_packing", &grib_accessor_class_data_run_length_packing, }, -{ "data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap, }, -{ "data_sh_packed", &grib_accessor_class_data_sh_packed, }, -{ "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, }, -{ "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, }, -{ "data_simple_packing", &grib_accessor_class_data_simple_packing, }, -{ "decimal_precision", &grib_accessor_class_decimal_precision, }, -{ "dictionary", &grib_accessor_class_dictionary, }, -{ "dirty", &grib_accessor_class_dirty, }, -{ "divdouble", &grib_accessor_class_divdouble, }, -{ "double", &grib_accessor_class_double, }, -{ "element", &grib_accessor_class_element, }, -{ "evaluate", &grib_accessor_class_evaluate, }, -{ "expanded_descriptors", &grib_accessor_class_expanded_descriptors, }, -{ "from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value, }, -{ "g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag, }, -{ "g1_message_length", &grib_accessor_class_g1_message_length, }, -{ "g1_section4_length", &grib_accessor_class_g1_section4_length, }, -{ "g1bitmap", &grib_accessor_class_g1bitmap, }, -{ "g1date", &grib_accessor_class_g1date, }, -{ "g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date, }, -{ "g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly, }, -{ "g1fcperiod", &grib_accessor_class_g1fcperiod, }, -{ "g1forecastmonth", &grib_accessor_class_g1forecastmonth, }, -{ "g1monthlydate", &grib_accessor_class_g1monthlydate, }, -{ "g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex, }, -{ "g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple, }, -{ "g1step_range", &grib_accessor_class_g1step_range, }, -{ "g1verificationdate", &grib_accessor_class_g1verificationdate, }, -{ "g2_aerosol", &grib_accessor_class_g2_aerosol, }, -{ "g2_chemical", &grib_accessor_class_g2_chemical, }, -{ "g2_eps", &grib_accessor_class_g2_eps, }, -{ "g2_mars_labeling", &grib_accessor_class_g2_mars_labeling, }, -{ "g2bitmap", &grib_accessor_class_g2bitmap, }, -{ "g2bitmap_present", &grib_accessor_class_g2bitmap_present, }, -{ "g2date", &grib_accessor_class_g2date, }, -{ "g2end_step", &grib_accessor_class_g2end_step, }, -{ "g2grid", &grib_accessor_class_g2grid, }, -{ "g2latlon", &grib_accessor_class_g2latlon, }, -{ "g2level", &grib_accessor_class_g2level, }, -{ "g2lon", &grib_accessor_class_g2lon, }, -{ "g2step_range", &grib_accessor_class_g2step_range, }, -{ "gaussian_grid_name", &grib_accessor_class_gaussian_grid_name, }, -{ "gds_is_present", &grib_accessor_class_gds_is_present, }, -{ "gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap, }, -{ "gen", &grib_accessor_class_gen, }, -{ "getenv", &grib_accessor_class_getenv, }, -{ "global_gaussian", &grib_accessor_class_global_gaussian, }, -{ "group", &grib_accessor_class_group, }, -{ "gts_header", &grib_accessor_class_gts_header, }, -{ "hash_array", &grib_accessor_class_hash_array, }, -{ "headers_only", &grib_accessor_class_headers_only, }, -{ "ibmfloat", &grib_accessor_class_ibmfloat, }, -{ "ieeefloat", &grib_accessor_class_ieeefloat, }, -{ "ifs_param", &grib_accessor_class_ifs_param, }, +//{ "count_file", &grib_accessor_class_count_file, }, +//{ "count_missing", &grib_accessor_class_count_missing, }, +//{ "count_total", &grib_accessor_class_count_total, }, +//{ "data_apply_bitmap", &grib_accessor_class_data_apply_bitmap, }, +//{ "data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic, }, +//{ "data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap, }, +//{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, +//{ "data_complex_packing", &grib_accessor_class_data_complex_packing, }, +//{ "data_dummy_field", &grib_accessor_class_data_dummy_field, }, +//{ "data_g1complex_packing", &grib_accessor_class_data_g1complex_packing, }, +//{ "data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing, }, +//{ "data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing, }, +//{ "data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing, }, +//{ "data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing, }, +//{ "data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap, }, +//{ "data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing, }, +//{ "data_g1simple_packing", &grib_accessor_class_data_g1simple_packing, }, +//{ "data_g22order_packing", &grib_accessor_class_data_g22order_packing, }, +//{ "data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing, }, +//{ "data_g2complex_packing", &grib_accessor_class_data_g2complex_packing, }, +//{ "data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap, }, +//{ "data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing, }, +//{ "data_g2simple_packing", &grib_accessor_class_data_g2simple_packing, }, +//{ "data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing, }, +//{ "data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing, }, +//{ "data_png_packing", &grib_accessor_class_data_png_packing, }, +//{ "data_raw_packing", &grib_accessor_class_data_raw_packing, }, +//{ "data_run_length_packing", &grib_accessor_class_data_run_length_packing, }, +//{ "data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap, }, +//{ "data_sh_packed", &grib_accessor_class_data_sh_packed, }, +//{ "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, }, +//{ "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, }, +//{ "data_simple_packing", &grib_accessor_class_data_simple_packing, }, +//{ "decimal_precision", &grib_accessor_class_decimal_precision, }, +//{ "dictionary", &grib_accessor_class_dictionary, }, +//{ "dirty", &grib_accessor_class_dirty, }, +//{ "divdouble", &grib_accessor_class_divdouble, }, +//{ "double", &grib_accessor_class_double, }, +//{ "element", &grib_accessor_class_element, }, +//{ "evaluate", &grib_accessor_class_evaluate, }, +//{ "expanded_descriptors", &grib_accessor_class_expanded_descriptors, }, +//{ "from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value, }, +//{ "g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag, }, +//{ "g1_message_length", &grib_accessor_class_g1_message_length, }, +//{ "g1_section4_length", &grib_accessor_class_g1_section4_length, }, +//{ "g1bitmap", &grib_accessor_class_g1bitmap, }, +//{ "g1date", &grib_accessor_class_g1date, }, +//{ "g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date, }, +//{ "g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly, }, +//{ "g1fcperiod", &grib_accessor_class_g1fcperiod, }, +//{ "g1forecastmonth", &grib_accessor_class_g1forecastmonth, }, +//{ "g1monthlydate", &grib_accessor_class_g1monthlydate, }, +//{ "g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex, }, +//{ "g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple, }, +//{ "g1step_range", &grib_accessor_class_g1step_range, }, +//{ "g1verificationdate", &grib_accessor_class_g1verificationdate, }, +//{ "g2_aerosol", &grib_accessor_class_g2_aerosol, }, +//{ "g2_chemical", &grib_accessor_class_g2_chemical, }, +//{ "g2_eps", &grib_accessor_class_g2_eps, }, +//{ "g2_mars_labeling", &grib_accessor_class_g2_mars_labeling, }, +//{ "g2bitmap", &grib_accessor_class_g2bitmap, }, +//{ "g2bitmap_present", &grib_accessor_class_g2bitmap_present, }, +//{ "g2date", &grib_accessor_class_g2date, }, +//{ "g2end_step", &grib_accessor_class_g2end_step, }, +//{ "g2grid", &grib_accessor_class_g2grid, }, +//{ "g2latlon", &grib_accessor_class_g2latlon, }, +//{ "g2level", &grib_accessor_class_g2level, }, +//{ "g2lon", &grib_accessor_class_g2lon, }, +//{ "g2step_range", &grib_accessor_class_g2step_range, }, +//{ "gaussian_grid_name", &grib_accessor_class_gaussian_grid_name, }, +//{ "gds_is_present", &grib_accessor_class_gds_is_present, }, +//{ "gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap, }, +//{ "gen", &grib_accessor_class_gen, }, +//{ "getenv", &grib_accessor_class_getenv, }, +//{ "global_gaussian", &grib_accessor_class_global_gaussian, }, +//{ "group", &grib_accessor_class_group, }, +//{ "gts_header", &grib_accessor_class_gts_header, }, +//{ "hash_array", &grib_accessor_class_hash_array, }, +//{ "headers_only", &grib_accessor_class_headers_only, }, +//{ "ibmfloat", &grib_accessor_class_ibmfloat, }, +//{ "ieeefloat", &grib_accessor_class_ieeefloat, }, +//{ "ifs_param", &grib_accessor_class_ifs_param, }, { "iterator", &grib_accessor_class_iterator, }, -{ "julian_date", &grib_accessor_class_julian_date, }, -{ "julian_day", &grib_accessor_class_julian_day, }, -{ "ksec1expver", &grib_accessor_class_ksec1expver, }, -{ "label", &grib_accessor_class_label, }, -{ "latitudes", &grib_accessor_class_latitudes, }, -{ "latlon_increment", &grib_accessor_class_latlon_increment, }, -{ "latlonvalues", &grib_accessor_class_latlonvalues, }, -{ "library_version", &grib_accessor_class_library_version, }, -{ "local_definition", &grib_accessor_class_local_definition, }, +//{ "julian_date", &grib_accessor_class_julian_date, }, +//{ "julian_day", &grib_accessor_class_julian_day, }, +//{ "ksec1expver", &grib_accessor_class_ksec1expver, }, +//{ "label", &grib_accessor_class_label, }, +//{ "latitudes", &grib_accessor_class_latitudes, }, +//{ "latlon_increment", &grib_accessor_class_latlon_increment, }, +//{ "latlonvalues", &grib_accessor_class_latlonvalues, }, +//{ "library_version", &grib_accessor_class_library_version, }, +//{ "local_definition", &grib_accessor_class_local_definition, }, { "long", &grib_accessor_class_long, }, -{ "long_vector", &grib_accessor_class_long_vector, }, -{ "longitudes", &grib_accessor_class_longitudes, }, -{ "lookup", &grib_accessor_class_lookup, }, -{ "mars_param", &grib_accessor_class_mars_param, }, -{ "mars_step", &grib_accessor_class_mars_step, }, -{ "md5", &grib_accessor_class_md5, }, -{ "message", &grib_accessor_class_message, }, -{ "message_copy", &grib_accessor_class_message_copy, }, -{ "multdouble", &grib_accessor_class_multdouble, }, +//{ "long_vector", &grib_accessor_class_long_vector, }, +//{ "longitudes", &grib_accessor_class_longitudes, }, +//{ "lookup", &grib_accessor_class_lookup, }, +//{ "mars_param", &grib_accessor_class_mars_param, }, +//{ "mars_step", &grib_accessor_class_mars_step, }, +//{ "md5", &grib_accessor_class_md5, }, +//{ "message", &grib_accessor_class_message, }, +//{ "message_copy", &grib_accessor_class_message_copy, }, +//{ "multdouble", &grib_accessor_class_multdouble, }, { "nearest", &grib_accessor_class_nearest, }, -{ "non_alpha", &grib_accessor_class_non_alpha, }, -{ "number_of_coded_values", &grib_accessor_class_number_of_coded_values, }, -{ "number_of_points", &grib_accessor_class_number_of_points, }, -{ "number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian, }, -{ "number_of_values", &grib_accessor_class_number_of_values, }, -{ "number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing, }, -{ "octahedral_gaussian", &grib_accessor_class_octahedral_gaussian, }, -{ "octet_number", &grib_accessor_class_octet_number, }, -{ "offset_file", &grib_accessor_class_offset_file, }, -{ "offset_values", &grib_accessor_class_offset_values, }, -{ "optimal_step_units", &grib_accessor_class_optimal_step_units, }, -{ "pack_bufr_values", &grib_accessor_class_pack_bufr_values, }, -{ "packing_type", &grib_accessor_class_packing_type, }, -{ "pad", &grib_accessor_class_pad, }, -{ "padding", &grib_accessor_class_padding, }, -{ "padto", &grib_accessor_class_padto, }, -{ "padtoeven", &grib_accessor_class_padtoeven, }, -{ "padtomultiple", &grib_accessor_class_padtomultiple, }, -{ "position", &grib_accessor_class_position, }, -{ "proj_string", &grib_accessor_class_proj_string, }, -{ "raw", &grib_accessor_class_raw, }, -{ "rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date, }, -{ "reference_value_error", &grib_accessor_class_reference_value_error, }, -{ "round", &grib_accessor_class_round, }, -{ "scale", &grib_accessor_class_scale, }, -{ "scale_values", &grib_accessor_class_scale_values, }, -{ "second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value, }, -{ "section", &grib_accessor_class_section, }, -{ "section_length", &grib_accessor_class_section_length, }, -{ "section_padding", &grib_accessor_class_section_padding, }, -{ "section_pointer", &grib_accessor_class_section_pointer, }, -{ "select_step_template", &grib_accessor_class_select_step_template, }, -{ "sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal, }, -{ "signed", &grib_accessor_class_signed, }, -{ "signed_bits", &grib_accessor_class_signed_bits, }, -{ "simple_packing_error", &grib_accessor_class_simple_packing_error, }, -{ "size", &grib_accessor_class_size, }, +//{ "non_alpha", &grib_accessor_class_non_alpha, }, +//{ "number_of_coded_values", &grib_accessor_class_number_of_coded_values, }, +//{ "number_of_points", &grib_accessor_class_number_of_points, }, +//{ "number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian, }, +//{ "number_of_values", &grib_accessor_class_number_of_values, }, +//{ "number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing, }, +//{ "octahedral_gaussian", &grib_accessor_class_octahedral_gaussian, }, +//{ "octet_number", &grib_accessor_class_octet_number, }, +//{ "offset_file", &grib_accessor_class_offset_file, }, +//{ "offset_values", &grib_accessor_class_offset_values, }, +//{ "optimal_step_units", &grib_accessor_class_optimal_step_units, }, +//{ "pack_bufr_values", &grib_accessor_class_pack_bufr_values, }, +//{ "packing_type", &grib_accessor_class_packing_type, }, +//{ "pad", &grib_accessor_class_pad, }, +//{ "padding", &grib_accessor_class_padding, }, +//{ "padto", &grib_accessor_class_padto, }, +//{ "padtoeven", &grib_accessor_class_padtoeven, }, +//{ "padtomultiple", &grib_accessor_class_padtomultiple, }, +//{ "position", &grib_accessor_class_position, }, +//{ "proj_string", &grib_accessor_class_proj_string, }, +//{ "raw", &grib_accessor_class_raw, }, +//{ "rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date, }, +//{ "reference_value_error", &grib_accessor_class_reference_value_error, }, +//{ "round", &grib_accessor_class_round, }, +//{ "scale", &grib_accessor_class_scale, }, +//{ "scale_values", &grib_accessor_class_scale_values, }, +//{ "second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value, }, +//{ "section", &grib_accessor_class_section, }, +//{ "section_length", &grib_accessor_class_section_length, }, +//{ "section_padding", &grib_accessor_class_section_padding, }, +//{ "section_pointer", &grib_accessor_class_section_pointer, }, +//{ "select_step_template", &grib_accessor_class_select_step_template, }, +//{ "sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal, }, +//{ "signed", &grib_accessor_class_signed, }, +//{ "signed_bits", &grib_accessor_class_signed_bits, }, +//{ "simple_packing_error", &grib_accessor_class_simple_packing_error, }, +//{ "size", &grib_accessor_class_size, }, { "smart_table", &grib_accessor_class_smart_table, }, -{ "smart_table_column", &grib_accessor_class_smart_table_column, }, -{ "spd", &grib_accessor_class_spd, }, -{ "spectral_truncation", &grib_accessor_class_spectral_truncation, }, -{ "sprintf", &grib_accessor_class_sprintf, }, -{ "statistics", &grib_accessor_class_statistics, }, -{ "statistics_spectral", &grib_accessor_class_statistics_spectral, }, -{ "step_human_readable", &grib_accessor_class_step_human_readable, }, -{ "step_in_units", &grib_accessor_class_step_in_units, }, -{ "sum", &grib_accessor_class_sum, }, -{ "suppressed", &grib_accessor_class_suppressed, }, -{ "time", &grib_accessor_class_time, }, -{ "to_double", &grib_accessor_class_to_double, }, -{ "to_integer", &grib_accessor_class_to_integer, }, -{ "to_string", &grib_accessor_class_to_string, }, +//{ "smart_table_column", &grib_accessor_class_smart_table_column, }, +//{ "spd", &grib_accessor_class_spd, }, +//{ "spectral_truncation", &grib_accessor_class_spectral_truncation, }, +//{ "sprintf", &grib_accessor_class_sprintf, }, +//{ "statistics", &grib_accessor_class_statistics, }, +//{ "statistics_spectral", &grib_accessor_class_statistics_spectral, }, +//{ "step_human_readable", &grib_accessor_class_step_human_readable, }, +//{ "step_in_units", &grib_accessor_class_step_in_units, }, +//{ "sum", &grib_accessor_class_sum, }, +//{ "suppressed", &grib_accessor_class_suppressed, }, +//{ "time", &grib_accessor_class_time, }, +//{ "to_double", &grib_accessor_class_to_double, }, +//{ "to_integer", &grib_accessor_class_to_integer, }, +//{ "to_string", &grib_accessor_class_to_string, }, { "transient", &grib_accessor_class_transient, }, -{ "transient_darray", &grib_accessor_class_transient_darray, }, -{ "trim", &grib_accessor_class_trim, }, -{ "uint16", &grib_accessor_class_uint16, }, -{ "uint32", &grib_accessor_class_uint32, }, -{ "uint32_little_endian", &grib_accessor_class_uint32_little_endian, }, -{ "uint64", &grib_accessor_class_uint64, }, -{ "uint64_little_endian", &grib_accessor_class_uint64_little_endian, }, -{ "uint8", &grib_accessor_class_uint8, }, -{ "unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors, }, -{ "unpack_bufr_values", &grib_accessor_class_unpack_bufr_values, }, +//{ "transient_darray", &grib_accessor_class_transient_darray, }, +//{ "trim", &grib_accessor_class_trim, }, +//{ "uint16", &grib_accessor_class_uint16, }, +//{ "uint32", &grib_accessor_class_uint32, }, +//{ "uint32_little_endian", &grib_accessor_class_uint32_little_endian, }, +//{ "uint64", &grib_accessor_class_uint64, }, +//{ "uint64_little_endian", &grib_accessor_class_uint64_little_endian, }, +//{ "uint8", &grib_accessor_class_uint8, }, +//{ "unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors, }, +//{ "unpack_bufr_values", &grib_accessor_class_unpack_bufr_values, }, { "unsigned", &grib_accessor_class_unsigned, }, -{ "unsigned_bits", &grib_accessor_class_unsigned_bits, }, -{ "validity_date", &grib_accessor_class_validity_date, }, -{ "validity_time", &grib_accessor_class_validity_time, }, -{ "values", &grib_accessor_class_values, }, +//{ "unsigned_bits", &grib_accessor_class_unsigned_bits, }, +//{ "validity_date", &grib_accessor_class_validity_date, }, +//{ "validity_time", &grib_accessor_class_validity_time, }, +//{ "values", &grib_accessor_class_values, }, { "variable", &grib_accessor_class_variable, }, -{ "vector", &grib_accessor_class_vector, }, -{ "when", &grib_accessor_class_when, }, +//{ "vector", &grib_accessor_class_vector, }, +//{ "when", &grib_accessor_class_when, }, diff --git a/src/grib_accessor_factory_hash_list b/src/grib_accessor_factory_hash_list index 1f7687f38..136aedc43 100644 --- a/src/grib_accessor_factory_hash_list +++ b/src/grib_accessor_factory_hash_list @@ -1,206 +1,206 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ -abstract_long_vector, &grib_accessor_class_abstract_long_vector -abstract_vector, &grib_accessor_class_abstract_vector -ascii, &grib_accessor_class_ascii -bit, &grib_accessor_class_bit -bitmap, &grib_accessor_class_bitmap -bits, &grib_accessor_class_bits -bits_per_value, &grib_accessor_class_bits_per_value -blob, &grib_accessor_class_blob -budgdate, &grib_accessor_class_budgdate -bufr_data_array, &grib_accessor_class_bufr_data_array -bufr_data_element, &grib_accessor_class_bufr_data_element -bufr_elements_table, &grib_accessor_class_bufr_elements_table -bufr_extract_area_subsets, &grib_accessor_class_bufr_extract_area_subsets -bufr_extract_datetime_subsets, &grib_accessor_class_bufr_extract_datetime_subsets -bufr_extract_subsets, &grib_accessor_class_bufr_extract_subsets -bufr_group, &grib_accessor_class_bufr_group -bufr_simple_thinning, &grib_accessor_class_bufr_simple_thinning -bufr_string_values, &grib_accessor_class_bufr_string_values -bufrdc_expanded_descriptors, &grib_accessor_class_bufrdc_expanded_descriptors -bytes, &grib_accessor_class_bytes -change_alternative_row_scanning, &grib_accessor_class_change_alternative_row_scanning -change_scanning_direction, &grib_accessor_class_change_scanning_direction -check_internal_version, &grib_accessor_class_check_internal_version -closest_date, &grib_accessor_class_closest_date -codeflag, &grib_accessor_class_codeflag +#abstract_long_vector, &grib_accessor_class_abstract_long_vector +#abstract_vector, &grib_accessor_class_abstract_vector +#ascii, &grib_accessor_class_ascii +#bit, &grib_accessor_class_bit +#bitmap, &grib_accessor_class_bitmap +#bits, &grib_accessor_class_bits +#bits_per_value, &grib_accessor_class_bits_per_value +#blob, &grib_accessor_class_blob +#budgdate, &grib_accessor_class_budgdate +#bufr_data_array, &grib_accessor_class_bufr_data_array +#bufr_data_element, &grib_accessor_class_bufr_data_element +#bufr_elements_table, &grib_accessor_class_bufr_elements_table +#bufr_extract_area_subsets, &grib_accessor_class_bufr_extract_area_subsets +#bufr_extract_datetime_subsets, &grib_accessor_class_bufr_extract_datetime_subsets +#bufr_extract_subsets, &grib_accessor_class_bufr_extract_subsets +#bufr_group, &grib_accessor_class_bufr_group +#bufr_simple_thinning, &grib_accessor_class_bufr_simple_thinning +#bufr_string_values, &grib_accessor_class_bufr_string_values +#bufrdc_expanded_descriptors, &grib_accessor_class_bufrdc_expanded_descriptors +#bytes, &grib_accessor_class_bytes +#change_alternative_row_scanning, &grib_accessor_class_change_alternative_row_scanning +#change_scanning_direction, &grib_accessor_class_change_scanning_direction +#check_internal_version, &grib_accessor_class_check_internal_version +#closest_date, &grib_accessor_class_closest_date +#codeflag, &grib_accessor_class_codeflag codetable, &grib_accessor_class_codetable -codetable_title, &grib_accessor_class_codetable_title -codetable_units, &grib_accessor_class_codetable_units -concept, &grib_accessor_class_concept +#codetable_title, &grib_accessor_class_codetable_title +#codetable_units, &grib_accessor_class_codetable_units +#concept, &grib_accessor_class_concept constant, &grib_accessor_class_constant -count_file, &grib_accessor_class_count_file -count_missing, &grib_accessor_class_count_missing -count_total, &grib_accessor_class_count_total -data_apply_bitmap, &grib_accessor_class_data_apply_bitmap -data_apply_boustrophedonic, &grib_accessor_class_data_apply_boustrophedonic -data_apply_boustrophedonic_bitmap, &grib_accessor_class_data_apply_boustrophedonic_bitmap -data_ccsds_packing, &grib_accessor_class_data_ccsds_packing -data_complex_packing, &grib_accessor_class_data_complex_packing -data_dummy_field, &grib_accessor_class_data_dummy_field -data_g1complex_packing, &grib_accessor_class_data_g1complex_packing -data_g1second_order_constant_width_packing, &grib_accessor_class_data_g1second_order_constant_width_packing -data_g1second_order_general_extended_packing, &grib_accessor_class_data_g1second_order_general_extended_packing -data_g1second_order_general_packing, &grib_accessor_class_data_g1second_order_general_packing -data_g1second_order_row_by_row_packing, &grib_accessor_class_data_g1second_order_row_by_row_packing -data_g1secondary_bitmap, &grib_accessor_class_data_g1secondary_bitmap -data_g1shsimple_packing, &grib_accessor_class_data_g1shsimple_packing -data_g1simple_packing, &grib_accessor_class_data_g1simple_packing -data_g22order_packing, &grib_accessor_class_data_g22order_packing -data_g2bifourier_packing, &grib_accessor_class_data_g2bifourier_packing -data_g2complex_packing, &grib_accessor_class_data_g2complex_packing -data_g2secondary_bitmap, &grib_accessor_class_data_g2secondary_bitmap -data_g2shsimple_packing, &grib_accessor_class_data_g2shsimple_packing -data_g2simple_packing, &grib_accessor_class_data_g2simple_packing -data_g2simple_packing_with_preprocessing, &grib_accessor_class_data_g2simple_packing_with_preprocessing -data_jpeg2000_packing, &grib_accessor_class_data_jpeg2000_packing -data_png_packing, &grib_accessor_class_data_png_packing -data_raw_packing, &grib_accessor_class_data_raw_packing -data_run_length_packing, &grib_accessor_class_data_run_length_packing -data_secondary_bitmap, &grib_accessor_class_data_secondary_bitmap -data_sh_packed, &grib_accessor_class_data_sh_packed -data_sh_unpacked, &grib_accessor_class_data_sh_unpacked -data_shsimple_packing, &grib_accessor_class_data_shsimple_packing -data_simple_packing, &grib_accessor_class_data_simple_packing -decimal_precision, &grib_accessor_class_decimal_precision -dictionary, &grib_accessor_class_dictionary -dirty, &grib_accessor_class_dirty -divdouble, &grib_accessor_class_divdouble -double, &grib_accessor_class_double -element, &grib_accessor_class_element -evaluate, &grib_accessor_class_evaluate -expanded_descriptors, &grib_accessor_class_expanded_descriptors -from_scale_factor_scaled_value, &grib_accessor_class_from_scale_factor_scaled_value -g1_half_byte_codeflag, &grib_accessor_class_g1_half_byte_codeflag -g1_message_length, &grib_accessor_class_g1_message_length -g1_section4_length, &grib_accessor_class_g1_section4_length -g1bitmap, &grib_accessor_class_g1bitmap -g1date, &grib_accessor_class_g1date -g1day_of_the_year_date, &grib_accessor_class_g1day_of_the_year_date -g1end_of_interval_monthly, &grib_accessor_class_g1end_of_interval_monthly -g1fcperiod, &grib_accessor_class_g1fcperiod -g1forecastmonth, &grib_accessor_class_g1forecastmonth -g1monthlydate, &grib_accessor_class_g1monthlydate -g1number_of_coded_values_sh_complex, &grib_accessor_class_g1number_of_coded_values_sh_complex -g1number_of_coded_values_sh_simple, &grib_accessor_class_g1number_of_coded_values_sh_simple -g1step_range, &grib_accessor_class_g1step_range -g1verificationdate, &grib_accessor_class_g1verificationdate -g2_aerosol, &grib_accessor_class_g2_aerosol -g2_chemical, &grib_accessor_class_g2_chemical -g2_eps, &grib_accessor_class_g2_eps -g2_mars_labeling, &grib_accessor_class_g2_mars_labeling -g2bitmap, &grib_accessor_class_g2bitmap -g2bitmap_present, &grib_accessor_class_g2bitmap_present -g2date, &grib_accessor_class_g2date -g2end_step, &grib_accessor_class_g2end_step -g2grid, &grib_accessor_class_g2grid -g2latlon, &grib_accessor_class_g2latlon -g2level, &grib_accessor_class_g2level -g2lon, &grib_accessor_class_g2lon -g2step_range, &grib_accessor_class_g2step_range -gaussian_grid_name, &grib_accessor_class_gaussian_grid_name -gds_is_present, &grib_accessor_class_gds_is_present -gds_not_present_bitmap, &grib_accessor_class_gds_not_present_bitmap -gen, &grib_accessor_class_gen -getenv, &grib_accessor_class_getenv -global_gaussian, &grib_accessor_class_global_gaussian -group, &grib_accessor_class_group -gts_header, &grib_accessor_class_gts_header -hash_array, &grib_accessor_class_hash_array -headers_only, &grib_accessor_class_headers_only -ibmfloat, &grib_accessor_class_ibmfloat -ieeefloat, &grib_accessor_class_ieeefloat -ifs_param, &grib_accessor_class_ifs_param +#count_file, &grib_accessor_class_count_file +#count_missing, &grib_accessor_class_count_missing +#count_total, &grib_accessor_class_count_total +#data_apply_bitmap, &grib_accessor_class_data_apply_bitmap +#data_apply_boustrophedonic, &grib_accessor_class_data_apply_boustrophedonic +#data_apply_boustrophedonic_bitmap, &grib_accessor_class_data_apply_boustrophedonic_bitmap +#data_ccsds_packing, &grib_accessor_class_data_ccsds_packing +#data_complex_packing, &grib_accessor_class_data_complex_packing +#data_dummy_field, &grib_accessor_class_data_dummy_field +#data_g1complex_packing, &grib_accessor_class_data_g1complex_packing +#data_g1second_order_constant_width_packing, &grib_accessor_class_data_g1second_order_constant_width_packing +#data_g1second_order_general_extended_packing, &grib_accessor_class_data_g1second_order_general_extended_packing +#data_g1second_order_general_packing, &grib_accessor_class_data_g1second_order_general_packing +#data_g1second_order_row_by_row_packing, &grib_accessor_class_data_g1second_order_row_by_row_packing +#data_g1secondary_bitmap, &grib_accessor_class_data_g1secondary_bitmap +#data_g1shsimple_packing, &grib_accessor_class_data_g1shsimple_packing +#data_g1simple_packing, &grib_accessor_class_data_g1simple_packing +#data_g22order_packing, &grib_accessor_class_data_g22order_packing +#data_g2bifourier_packing, &grib_accessor_class_data_g2bifourier_packing +#data_g2complex_packing, &grib_accessor_class_data_g2complex_packing +#data_g2secondary_bitmap, &grib_accessor_class_data_g2secondary_bitmap +#data_g2shsimple_packing, &grib_accessor_class_data_g2shsimple_packing +#data_g2simple_packing, &grib_accessor_class_data_g2simple_packing +#data_g2simple_packing_with_preprocessing, &grib_accessor_class_data_g2simple_packing_with_preprocessing +#data_jpeg2000_packing, &grib_accessor_class_data_jpeg2000_packing +#data_png_packing, &grib_accessor_class_data_png_packing +#data_raw_packing, &grib_accessor_class_data_raw_packing +#data_run_length_packing, &grib_accessor_class_data_run_length_packing +#data_secondary_bitmap, &grib_accessor_class_data_secondary_bitmap +#data_sh_packed, &grib_accessor_class_data_sh_packed +#data_sh_unpacked, &grib_accessor_class_data_sh_unpacked +#data_shsimple_packing, &grib_accessor_class_data_shsimple_packing +#data_simple_packing, &grib_accessor_class_data_simple_packing +#decimal_precision, &grib_accessor_class_decimal_precision +#dictionary, &grib_accessor_class_dictionary +#dirty, &grib_accessor_class_dirty +#divdouble, &grib_accessor_class_divdouble +#double, &grib_accessor_class_double +#element, &grib_accessor_class_element +#evaluate, &grib_accessor_class_evaluate +#expanded_descriptors, &grib_accessor_class_expanded_descriptors +#from_scale_factor_scaled_value, &grib_accessor_class_from_scale_factor_scaled_value +#g1_half_byte_codeflag, &grib_accessor_class_g1_half_byte_codeflag +#g1_message_length, &grib_accessor_class_g1_message_length +#g1_section4_length, &grib_accessor_class_g1_section4_length +#g1bitmap, &grib_accessor_class_g1bitmap +#g1date, &grib_accessor_class_g1date +#g1day_of_the_year_date, &grib_accessor_class_g1day_of_the_year_date +#g1end_of_interval_monthly, &grib_accessor_class_g1end_of_interval_monthly +#g1fcperiod, &grib_accessor_class_g1fcperiod +#g1forecastmonth, &grib_accessor_class_g1forecastmonth +#g1monthlydate, &grib_accessor_class_g1monthlydate +#g1number_of_coded_values_sh_complex, &grib_accessor_class_g1number_of_coded_values_sh_complex +#g1number_of_coded_values_sh_simple, &grib_accessor_class_g1number_of_coded_values_sh_simple +#g1step_range, &grib_accessor_class_g1step_range +#g1verificationdate, &grib_accessor_class_g1verificationdate +#g2_aerosol, &grib_accessor_class_g2_aerosol +#g2_chemical, &grib_accessor_class_g2_chemical +#g2_eps, &grib_accessor_class_g2_eps +#g2_mars_labeling, &grib_accessor_class_g2_mars_labeling +#g2bitmap, &grib_accessor_class_g2bitmap +#g2bitmap_present, &grib_accessor_class_g2bitmap_present +#g2date, &grib_accessor_class_g2date +#g2end_step, &grib_accessor_class_g2end_step +#g2grid, &grib_accessor_class_g2grid +#g2latlon, &grib_accessor_class_g2latlon +#g2level, &grib_accessor_class_g2level +#g2lon, &grib_accessor_class_g2lon +#g2step_range, &grib_accessor_class_g2step_range +#gaussian_grid_name, &grib_accessor_class_gaussian_grid_name +#gds_is_present, &grib_accessor_class_gds_is_present +#gds_not_present_bitmap, &grib_accessor_class_gds_not_present_bitmap +#gen, &grib_accessor_class_gen +#getenv, &grib_accessor_class_getenv +#global_gaussian, &grib_accessor_class_global_gaussian +#group, &grib_accessor_class_group +#gts_header, &grib_accessor_class_gts_header +#hash_array, &grib_accessor_class_hash_array +#headers_only, &grib_accessor_class_headers_only +#ibmfloat, &grib_accessor_class_ibmfloat +#ieeefloat, &grib_accessor_class_ieeefloat +#ifs_param, &grib_accessor_class_ifs_param iterator, &grib_accessor_class_iterator -julian_date, &grib_accessor_class_julian_date -julian_day, &grib_accessor_class_julian_day -ksec1expver, &grib_accessor_class_ksec1expver -label, &grib_accessor_class_label -latitudes, &grib_accessor_class_latitudes -latlon_increment, &grib_accessor_class_latlon_increment -latlonvalues, &grib_accessor_class_latlonvalues -library_version, &grib_accessor_class_library_version -local_definition, &grib_accessor_class_local_definition +#julian_date, &grib_accessor_class_julian_date +#julian_day, &grib_accessor_class_julian_day +#ksec1expver, &grib_accessor_class_ksec1expver +#label, &grib_accessor_class_label +#latitudes, &grib_accessor_class_latitudes +#latlon_increment, &grib_accessor_class_latlon_increment +#latlonvalues, &grib_accessor_class_latlonvalues +#library_version, &grib_accessor_class_library_version +#local_definition, &grib_accessor_class_local_definition long, &grib_accessor_class_long -long_vector, &grib_accessor_class_long_vector -longitudes, &grib_accessor_class_longitudes -lookup, &grib_accessor_class_lookup -mars_param, &grib_accessor_class_mars_param -mars_step, &grib_accessor_class_mars_step -md5, &grib_accessor_class_md5 -message, &grib_accessor_class_message -message_copy, &grib_accessor_class_message_copy -multdouble, &grib_accessor_class_multdouble +#long_vector, &grib_accessor_class_long_vector +#longitudes, &grib_accessor_class_longitudes +#lookup, &grib_accessor_class_lookup +#mars_param, &grib_accessor_class_mars_param +#mars_step, &grib_accessor_class_mars_step +#md5, &grib_accessor_class_md5 +#message, &grib_accessor_class_message +#message_copy, &grib_accessor_class_message_copy +#multdouble, &grib_accessor_class_multdouble nearest, &grib_accessor_class_nearest -non_alpha, &grib_accessor_class_non_alpha -number_of_coded_values, &grib_accessor_class_number_of_coded_values -number_of_points, &grib_accessor_class_number_of_points -number_of_points_gaussian, &grib_accessor_class_number_of_points_gaussian -number_of_values, &grib_accessor_class_number_of_values -number_of_values_data_raw_packing, &grib_accessor_class_number_of_values_data_raw_packing -octahedral_gaussian, &grib_accessor_class_octahedral_gaussian -octet_number, &grib_accessor_class_octet_number -offset_file, &grib_accessor_class_offset_file -offset_values, &grib_accessor_class_offset_values -optimal_step_units, &grib_accessor_class_optimal_step_units -pack_bufr_values, &grib_accessor_class_pack_bufr_values -packing_type, &grib_accessor_class_packing_type -pad, &grib_accessor_class_pad -padding, &grib_accessor_class_padding -padto, &grib_accessor_class_padto -padtoeven, &grib_accessor_class_padtoeven -padtomultiple, &grib_accessor_class_padtomultiple -position, &grib_accessor_class_position -proj_string, &grib_accessor_class_proj_string -raw, &grib_accessor_class_raw -rdbtime_guess_date, &grib_accessor_class_rdbtime_guess_date -reference_value_error, &grib_accessor_class_reference_value_error -round, &grib_accessor_class_round -scale, &grib_accessor_class_scale -scale_values, &grib_accessor_class_scale_values -second_order_bits_per_value, &grib_accessor_class_second_order_bits_per_value -section, &grib_accessor_class_section -section_length, &grib_accessor_class_section_length -section_padding, &grib_accessor_class_section_padding -section_pointer, &grib_accessor_class_section_pointer -select_step_template, &grib_accessor_class_select_step_template -sexagesimal2decimal, &grib_accessor_class_sexagesimal2decimal -signed, &grib_accessor_class_signed -signed_bits, &grib_accessor_class_signed_bits -simple_packing_error, &grib_accessor_class_simple_packing_error -size, &grib_accessor_class_size +#non_alpha, &grib_accessor_class_non_alpha +#number_of_coded_values, &grib_accessor_class_number_of_coded_values +#number_of_points, &grib_accessor_class_number_of_points +#number_of_points_gaussian, &grib_accessor_class_number_of_points_gaussian +#number_of_values, &grib_accessor_class_number_of_values +#number_of_values_data_raw_packing, &grib_accessor_class_number_of_values_data_raw_packing +#octahedral_gaussian, &grib_accessor_class_octahedral_gaussian +#octet_number, &grib_accessor_class_octet_number +#offset_file, &grib_accessor_class_offset_file +#offset_values, &grib_accessor_class_offset_values +#optimal_step_units, &grib_accessor_class_optimal_step_units +#pack_bufr_values, &grib_accessor_class_pack_bufr_values +#packing_type, &grib_accessor_class_packing_type +#pad, &grib_accessor_class_pad +#padding, &grib_accessor_class_padding +#padto, &grib_accessor_class_padto +#padtoeven, &grib_accessor_class_padtoeven +#padtomultiple, &grib_accessor_class_padtomultiple +#position, &grib_accessor_class_position +#proj_string, &grib_accessor_class_proj_string +#raw, &grib_accessor_class_raw +#rdbtime_guess_date, &grib_accessor_class_rdbtime_guess_date +#reference_value_error, &grib_accessor_class_reference_value_error +#round, &grib_accessor_class_round +#scale, &grib_accessor_class_scale +#scale_values, &grib_accessor_class_scale_values +#second_order_bits_per_value, &grib_accessor_class_second_order_bits_per_value +#section, &grib_accessor_class_section +#section_length, &grib_accessor_class_section_length +#section_padding, &grib_accessor_class_section_padding +#section_pointer, &grib_accessor_class_section_pointer +#select_step_template, &grib_accessor_class_select_step_template +#sexagesimal2decimal, &grib_accessor_class_sexagesimal2decimal +#signed, &grib_accessor_class_signed +#signed_bits, &grib_accessor_class_signed_bits +#simple_packing_error, &grib_accessor_class_simple_packing_error +#size, &grib_accessor_class_size smart_table, &grib_accessor_class_smart_table -smart_table_column, &grib_accessor_class_smart_table_column -spd, &grib_accessor_class_spd -spectral_truncation, &grib_accessor_class_spectral_truncation -sprintf, &grib_accessor_class_sprintf -statistics, &grib_accessor_class_statistics -statistics_spectral, &grib_accessor_class_statistics_spectral -step_human_readable, &grib_accessor_class_step_human_readable -step_in_units, &grib_accessor_class_step_in_units -sum, &grib_accessor_class_sum -suppressed, &grib_accessor_class_suppressed -time, &grib_accessor_class_time -to_double, &grib_accessor_class_to_double -to_integer, &grib_accessor_class_to_integer -to_string, &grib_accessor_class_to_string +#smart_table_column, &grib_accessor_class_smart_table_column +#spd, &grib_accessor_class_spd +#spectral_truncation, &grib_accessor_class_spectral_truncation +#sprintf, &grib_accessor_class_sprintf +#statistics, &grib_accessor_class_statistics +#statistics_spectral, &grib_accessor_class_statistics_spectral +#step_human_readable, &grib_accessor_class_step_human_readable +#step_in_units, &grib_accessor_class_step_in_units +#sum, &grib_accessor_class_sum +#suppressed, &grib_accessor_class_suppressed +#time, &grib_accessor_class_time +#to_double, &grib_accessor_class_to_double +#to_integer, &grib_accessor_class_to_integer +#to_string, &grib_accessor_class_to_string transient, &grib_accessor_class_transient -transient_darray, &grib_accessor_class_transient_darray -trim, &grib_accessor_class_trim -uint16, &grib_accessor_class_uint16 -uint32, &grib_accessor_class_uint32 -uint32_little_endian, &grib_accessor_class_uint32_little_endian -uint64, &grib_accessor_class_uint64 -uint64_little_endian, &grib_accessor_class_uint64_little_endian -uint8, &grib_accessor_class_uint8 -unexpanded_descriptors, &grib_accessor_class_unexpanded_descriptors -unpack_bufr_values, &grib_accessor_class_unpack_bufr_values +#transient_darray, &grib_accessor_class_transient_darray +#trim, &grib_accessor_class_trim +#uint16, &grib_accessor_class_uint16 +#uint32, &grib_accessor_class_uint32 +#uint32_little_endian, &grib_accessor_class_uint32_little_endian +#uint64, &grib_accessor_class_uint64 +#uint64_little_endian, &grib_accessor_class_uint64_little_endian +#uint8, &grib_accessor_class_uint8 +#unexpanded_descriptors, &grib_accessor_class_unexpanded_descriptors +#unpack_bufr_values, &grib_accessor_class_unpack_bufr_values unsigned, &grib_accessor_class_unsigned -unsigned_bits, &grib_accessor_class_unsigned_bits -validity_date, &grib_accessor_class_validity_date -validity_time, &grib_accessor_class_validity_time -values, &grib_accessor_class_values +#unsigned_bits, &grib_accessor_class_unsigned_bits +#validity_date, &grib_accessor_class_validity_date +#validity_time, &grib_accessor_class_validity_time +#values, &grib_accessor_class_values variable, &grib_accessor_class_variable -vector, &grib_accessor_class_vector -when, &grib_accessor_class_when +#vector, &grib_accessor_class_vector +#when, &grib_accessor_class_when diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index e54b76615..0cff18a9b 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -240,7 +240,7 @@ typedef struct grib_action_file grib_action_file; typedef struct grib_action_file_list grib_action_file_list; typedef struct grib_block_of_accessors grib_block_of_accessors; typedef struct grib_buffer grib_buffer; -typedef struct grib_accessor_class grib_accessor_class; +class grib_accessor_class; typedef struct grib_action grib_action; typedef struct grib_action_class grib_action_class; typedef struct grib_section grib_section; @@ -248,7 +248,7 @@ typedef struct grib_packer grib_packer; typedef struct grib_codetable grib_codetable; typedef struct grib_smart_table grib_smart_table; -typedef struct grib_accessor grib_accessor; +class grib_accessor; typedef struct grib_iterator_class grib_iterator_class; typedef struct grib_nearest_class grib_nearest_class; typedef struct grib_dumper grib_dumper; @@ -281,53 +281,6 @@ typedef long (*iterator_has_next_proc)(grib_iterator* i); typedef int (*grib_pack_proc)(grib_handle* h, const double* in, size_t inlen, void* out, size_t* outlen); typedef int (*grib_unpack_proc)(grib_handle* h, const void* in, size_t inlen, double* out, size_t* outlen); -typedef void (*accessor_destroy_proc)(grib_context*, grib_accessor*); - -typedef int (*accessor_unpack_long_proc)(grib_accessor*, long*, size_t* len); -typedef int (*accessor_unpack_double_proc)(grib_accessor*, double*, size_t* len); -typedef int (*accessor_unpack_float_proc)(grib_accessor*, float*, size_t* len); - -typedef int (*accessor_unpack_double_element_proc)(grib_accessor*, size_t, double*); -typedef int (*accessor_unpack_float_element_proc)(grib_accessor*, size_t, float*); -typedef int (*accessor_unpack_double_element_set_proc)(grib_accessor*, const size_t*, size_t, double*); -typedef int (*accessor_unpack_float_element_set_proc)(grib_accessor*, const size_t*, size_t, float*); - -typedef int (*accessor_unpack_double_subarray_proc)(grib_accessor*, double*, size_t, size_t); -typedef int (*accessor_unpack_string_proc)(grib_accessor*, char*, size_t* len); -typedef int (*accessor_unpack_string_array_proc)(grib_accessor*, char**, size_t* len); -typedef int (*accessor_unpack_bytes_proc)(grib_accessor*, unsigned char*, size_t* len); -typedef int (*accessor_get_native_type_proc)(grib_accessor*); -typedef int (*accessor_notify_change_proc)(grib_accessor*, grib_accessor*); -typedef void (*accessor_update_size_proc)(grib_accessor*, size_t); -typedef size_t (*accessor_preferred_size_proc)(grib_accessor*, int); -typedef void (*accessor_resize_proc)(grib_accessor*, size_t); - -typedef grib_accessor* (*accessor_next_proc)(grib_accessor*, int); -typedef grib_section* (*accessor_sub_section_proc)(grib_accessor*); - -typedef int (*accessor_pack_missing_proc)(grib_accessor*); -typedef int (*accessor_pack_is_missing_proc)(grib_accessor*); -typedef int (*accessor_pack_long_proc)(grib_accessor*, const long*, size_t* len); -typedef int (*accessor_pack_double_proc)(grib_accessor*, const double*, size_t* len); -typedef int (*accessor_pack_float_proc)(grib_accessor*, const float*, size_t* len); -typedef int (*accessor_pack_string_proc)(grib_accessor*, const char*, size_t* len); -typedef int (*accessor_pack_string_array_proc)(grib_accessor*, const char**, size_t* len); -typedef int (*accessor_pack_bytes_proc)(grib_accessor*, const unsigned char*, size_t* len); -typedef int (*accessor_pack_expression_proc)(grib_accessor*, grib_expression*); -typedef int (*accessor_clear_proc)(grib_accessor*); -typedef grib_accessor* (*accessor_clone_proc)(grib_accessor*, grib_section*, int*); - -typedef void (*accessor_init_class_proc)(grib_accessor_class*); - -typedef int (*accessor_compare_proc)(grib_accessor*, grib_accessor*); -typedef size_t (*accessor_string_proc)(grib_accessor*); -typedef int (*accessor_value_with_ret_proc)(grib_accessor*, long*); -typedef long (*accessor_value_proc)(grib_accessor*); -typedef void (*accessor_dump_proc)(grib_accessor*, grib_dumper*); -typedef void (*accessor_init_proc)(grib_accessor*, const long len, grib_arguments*); -typedef void (*accessor_post_init_proc)(grib_accessor*); - -typedef int (*accessor_nearest_proc)(grib_accessor*, double, double*); typedef long (*grib_binop_long_proc)(long, long); typedef long (*grib_unop_long_proc)(long); @@ -411,16 +364,7 @@ struct grib_action char* debug_info; /** purely for debugging and tracing */ }; -typedef struct grib_accessors_list grib_accessors_list; - -struct grib_accessors_list -{ - grib_accessor* accessor; - int rank; - grib_accessors_list* next; - grib_accessors_list* prev; - grib_accessors_list* last; -}; +class grib_accessors_list; typedef int (*action_create_accessors_handle_proc)(grib_section* p, grib_action* a, grib_loader* h); typedef int (*action_notify_change_proc)(grib_action* a, grib_accessor* observer, grib_accessor* observed); @@ -495,34 +439,6 @@ struct grib_virtual_value int type; }; -struct grib_accessor -{ - const char* name; /** < name of the accessor */ - const char* name_space; /** < namespace to which the accessor belongs */ - grib_context* context; - grib_handle* h; - grib_action* creator; /** < action that created the accessor */ - long length; /** < byte length of the accessor */ - long offset; /** < offset of the data in the buffer */ - grib_section* parent; /** < section to which the accessor is attached */ - grib_accessor* next; /** < next accessor in list */ - grib_accessor* previous; /** < next accessor in list */ - grib_accessor_class* cclass; /** < behaviour of the accessor */ - unsigned long flags; /** < Various flags */ - grib_section* sub_section; - - const char* all_names[MAX_ACCESSOR_NAMES]; /** < name of the accessor */ - const char* all_name_spaces[MAX_ACCESSOR_NAMES]; /** < namespace to which the accessor belongs */ - int dirty; - - grib_accessor* same; /** < accessors with the same name */ - long loop; /** < used in lists */ - grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ - const char* set; - grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES]; /** < attributes are accessors */ - grib_accessor* parent_as_attribute; -}; - #define GRIB_ACCESSOR_FLAG_READ_ONLY (1 << 1) #define GRIB_ACCESSOR_FLAG_DUMP (1 << 2) #define GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC (1 << 3) @@ -856,71 +772,6 @@ struct grib_multi_handle size_t length; }; -struct grib_accessor_class -{ - grib_accessor_class** super; - const char* name; - size_t size; - - int inited; - accessor_init_class_proc init_class; - - accessor_init_proc init; - accessor_post_init_proc post_init; - accessor_destroy_proc destroy; - - accessor_dump_proc dump; - accessor_value_proc next_offset; - - accessor_string_proc string_length; - accessor_value_with_ret_proc value_count; - - accessor_value_proc byte_count; - accessor_value_proc byte_offset; - - accessor_get_native_type_proc get_native_type; - - accessor_sub_section_proc sub_section; - - accessor_pack_missing_proc pack_missing; - accessor_pack_is_missing_proc is_missing; - - accessor_pack_long_proc pack_long; - accessor_unpack_long_proc unpack_long; - - accessor_pack_double_proc pack_double; - accessor_pack_float_proc pack_float; - accessor_unpack_double_proc unpack_double; - accessor_unpack_float_proc unpack_float; - - accessor_pack_string_proc pack_string; - accessor_unpack_string_proc unpack_string; - - accessor_pack_string_array_proc pack_string_array; - accessor_unpack_string_array_proc unpack_string_array; - - accessor_pack_bytes_proc pack_bytes; - accessor_unpack_bytes_proc unpack_bytes; - - accessor_pack_expression_proc pack_expression; - - accessor_notify_change_proc notify_change; - accessor_update_size_proc update_size; - - accessor_preferred_size_proc preferred_size; - accessor_resize_proc resize; - - accessor_nearest_proc nearest_smaller_value; - accessor_next_proc next; - accessor_compare_proc compare; - accessor_unpack_double_element_proc unpack_double_element; - accessor_unpack_float_element_proc unpack_float_element; - accessor_unpack_double_element_set_proc unpack_double_element_set; - accessor_unpack_float_element_set_proc unpack_float_element_set; - accessor_unpack_double_subarray_proc unpack_double_subarray; - accessor_clear_proc clear; - accessor_clone_proc make_clone; -}; typedef struct grib_multi_support grib_multi_support; struct grib_multi_support @@ -1461,6 +1312,8 @@ typedef struct j2k_encode_helper #ifdef __cplusplus } +#include "accessor/grib_accessor.h" +#include "accessor/grib_accessors_list.h" #endif #endif diff --git a/src/grib_buffer.cc b/src/grib_buffer.cc index 525e59f31..89313429d 100644 --- a/src/grib_buffer.cc +++ b/src/grib_buffer.cc @@ -152,10 +152,10 @@ static void update_offsets_after(grib_accessor* a, long len) // { // int ret; // if(s->owner) -// plen = grib_get_next_position_offset(s->block->last) - s->owner->offset; +// plen = s->block->last->get_next_position_offset() - s->owner->offset; // else -// plen = grib_get_next_position_offset(s->block->last); -// if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS) +// plen = s->block->last->get_next_position_offset(); +// if((ret = s->aclength->pack_long(&plen, &len)) != GRIB_SUCCESS) // ; // // if(s->h->context->debug) @@ -174,19 +174,19 @@ static void update_offsets_after(grib_accessor* a, long len) // { // int ret; // if(s->owner) -// plen = grib_get_next_position_offset(s->block->last) - s->owner->offset; +// plen = s->block->last->get_next_position_offset() - s->owner->offset; // else -// plen = grib_get_next_position_offset(s->block->last); +// plen = s->block->last->get_next_position_offset(); // /* if(s->owner) */ // /* s->owner->length = plen; */ // /* if(s->aclength) */ -// if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS) +// if((ret = s->aclength->pack_long(&plen, &len)) != GRIB_SUCCESS) // ; // if(s->h->context->debug) // { // printf("SECTION updating length %ld .. %s\n",plen,s->owner->name); // printf("NEXT_POS = %ld, owner offset= %ld %s %s\n", -// grib_get_next_position_offset(s->block->last), +// s->block->last->get_next_position_offset(), // s->owner ? s->owner->offset : 0L, s->owner->name, // s->block->last->name); // } @@ -199,7 +199,7 @@ int grib_buffer_replace(grib_accessor* a, const unsigned char* data, size_t newsize, int update_lengths, int update_paddings) { size_t offset = a->offset; - long oldsize = grib_get_next_position_offset(a) - offset; + long oldsize = a->get_next_position_offset() - offset; long increase = (long)newsize - (long)oldsize; grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; @@ -231,7 +231,7 @@ int grib_buffer_replace(grib_accessor* a, const unsigned char* data, if (increase) { update_offsets_after(a, increase); if (update_lengths) { - grib_update_size(a, newsize); + a->update_size(newsize); int err = grib_section_adjust_sizes(grib_handle_of_accessor(a)->root, 1, 0); if (err) return err; if (update_paddings) diff --git a/src/grib_bufr_descriptor.cc b/src/grib_bufr_descriptor.cc index fcaeeac46..ef6bc1fbc 100644 --- a/src/grib_bufr_descriptor.cc +++ b/src/grib_bufr_descriptor.cc @@ -14,7 +14,11 @@ bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err) { - bufr_descriptor* ret = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, err); + // ===== TODO(maee): Enable this when grib_accessor_class_bufr_elements_table.cc is moved to C++ ===== + throw std::runtime_error("grib_bufr_descriptor_new not implemented"); + bufr_descriptor* ret = NULL; + //bufr_descriptor* ret = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, err); + // ===== END TODO ===== if (!silent && *err) grib_context_log(tables_accessor->context, GRIB_LOG_ERROR, "unable to get descriptor %06d from table", code); diff --git a/src/grib_dependency.cc b/src/grib_dependency.cc index 4c417173e..37c89dbbf 100644 --- a/src/grib_dependency.cc +++ b/src/grib_dependency.cc @@ -124,7 +124,7 @@ int grib_dependency_notify_change(grib_accessor* observed) while (d) { if (d->run) { /*printf("grib_dependency_notify_change %s %s %p\n", observed->name, d->observer ? d->observer->name : "?", (void*)d->observer);*/ - if (d->observer && (ret = grib_accessor_notify_change(d->observer, observed)) != GRIB_SUCCESS) + if (d->observer && (ret = d->observer->notify_change(observed)) != GRIB_SUCCESS) return ret; } d = d->next; @@ -149,7 +149,7 @@ int grib_dependency_notify_change_h(grib_handle* h, grib_accessor* observed) while (d) { if (d->run) { /*printf("grib_dependency_notify_change %s %s %p\n",observed->name,d->observer ? d->observer->name : "?", (void*)d->observer);*/ - if (d->observer && (ret = grib_accessor_notify_change(d->observer, observed)) != GRIB_SUCCESS) + if (d->observer && (ret = d->observer->notify_change(observed)) != GRIB_SUCCESS) return ret; } d = d->next; diff --git a/src/grib_dumper_class.cc b/src/grib_dumper_class.cc index abd1cbf02..eca1610b0 100644 --- a/src/grib_dumper_class.cc +++ b/src/grib_dumper_class.cc @@ -52,7 +52,7 @@ void grib_dump_accessors_block(grib_dumper* dumper, grib_block_of_accessors* blo { grib_accessor* a = block->first; while (a) { - grib_accessor_dump(a, dumper); + a->dump(dumper); a = a->next; } } @@ -61,8 +61,8 @@ void grib_dump_accessors_list(grib_dumper* dumper, grib_accessors_list* al) { grib_accessors_list* cur = al; while (cur) { - grib_accessor_dump(cur->accessor, dumper); - cur = cur->next; + cur->accessor->dump(dumper); + cur = cur->next_; } } @@ -70,7 +70,7 @@ int grib_print(grib_handle* h, const char* name, grib_dumper* d) { grib_accessor* act = grib_find_accessor(h, name); if (act) { - grib_accessor_dump(act, d); + act->dump(d); return GRIB_SUCCESS; } return GRIB_NOT_FOUND; @@ -106,7 +106,7 @@ void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long fla for (i = 0; i < num_keys; ++i) { acc = grib_find_accessor(h, keys[i]); if (acc) - grib_accessor_dump(acc, dumper); + acc->dump(dumper); } grib_dumper_delete(dumper); } diff --git a/src/grib_dumper_class_bufr_decode_C.cc b/src/grib_dumper_class_bufr_decode_C.cc index 49805279b..6811cdf94 100644 --- a/src/grib_dumper_class_bufr_decode_C.cc +++ b/src/grib_dumper_class_bufr_decode_C.cc @@ -150,11 +150,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -220,11 +220,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -279,7 +279,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -305,7 +305,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -368,11 +368,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -428,7 +428,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -477,7 +477,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -497,7 +497,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if (self->isLeaf == 0) { if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0) @@ -545,7 +545,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -656,7 +656,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_filter.cc b/src/grib_dumper_class_bufr_decode_filter.cc index 0fff0fc14..87cb0e2fe 100644 --- a/src/grib_dumper_class_bufr_decode_filter.cc +++ b/src/grib_dumper_class_bufr_decode_filter.cc @@ -140,11 +140,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->begin = 0; @@ -199,11 +199,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -244,7 +244,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -270,7 +270,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->begin = 0; @@ -353,7 +353,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->begin = 0; self->empty = 0; @@ -399,7 +399,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -457,7 +457,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -569,7 +569,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_fortran.cc b/src/grib_dumper_class_bufr_decode_fortran.cc index b07f59b49..dbc4ed271 100644 --- a/src/grib_dumper_class_bufr_decode_fortran.cc +++ b/src/grib_dumper_class_bufr_decode_fortran.cc @@ -142,11 +142,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -202,11 +202,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -249,7 +249,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -275,7 +275,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -331,11 +331,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -384,7 +384,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -429,7 +429,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -485,7 +485,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -595,7 +595,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_python.cc b/src/grib_dumper_class_bufr_decode_python.cc index 632cbe98b..3e2edc70a 100644 --- a/src/grib_dumper_class_bufr_decode_python.cc +++ b/src/grib_dumper_class_bufr_decode_python.cc @@ -150,11 +150,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -213,11 +213,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -265,7 +265,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -291,7 +291,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -345,11 +345,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -397,7 +397,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -445,7 +445,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -498,7 +498,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -605,7 +605,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_C.cc b/src/grib_dumper_class_bufr_encode_C.cc index 568a035bb..915649814 100644 --- a/src/grib_dumper_class_bufr_encode_C.cc +++ b/src/grib_dumper_class_bufr_encode_C.cc @@ -168,15 +168,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -264,15 +264,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -357,7 +357,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -385,10 +385,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -488,15 +488,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -568,7 +568,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -614,7 +614,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -633,7 +633,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " svalues[%lu]=\"%s\"; \n", (unsigned long)i, values[i]); } @@ -697,7 +697,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -833,7 +833,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_filter.cc b/src/grib_dumper_class_bufr_encode_filter.cc index 49c4d19ef..a90ab0f56 100644 --- a/src/grib_dumper_class_bufr_encode_filter.cc +++ b/src/grib_dumper_class_bufr_encode_filter.cc @@ -144,15 +144,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -234,15 +234,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -306,7 +306,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -333,10 +333,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -416,15 +416,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -489,7 +489,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->begin = 0; self->empty = 0; @@ -538,7 +538,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -563,7 +563,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); fprintf(self->dumper.out, "{"); depth += 2; @@ -624,7 +624,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->begin = 0; self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -759,7 +759,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_fortran.cc b/src/grib_dumper_class_bufr_encode_fortran.cc index e76bd0872..1e6cd3bd7 100644 --- a/src/grib_dumper_class_bufr_encode_fortran.cc +++ b/src/grib_dumper_class_bufr_encode_fortran.cc @@ -217,15 +217,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -312,15 +312,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -406,7 +406,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -433,10 +433,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -535,15 +535,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -620,7 +620,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -665,7 +665,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -685,7 +685,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " \"%s\", &\n", values[i]); @@ -747,7 +747,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -880,7 +880,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_python.cc b/src/grib_dumper_class_bufr_encode_python.cc index 34367c913..565bc34ac 100644 --- a/src/grib_dumper_class_bufr_encode_python.cc +++ b/src/grib_dumper_class_bufr_encode_python.cc @@ -164,15 +164,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -258,15 +258,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -351,7 +351,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -378,10 +378,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -478,15 +478,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -558,7 +558,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -603,7 +603,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -620,7 +620,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " \"%s\", \n", values[i]); @@ -680,7 +680,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -814,7 +814,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_simple.cc b/src/grib_dumper_class_bufr_simple.cc index ca4701f38..868b81ba5 100644 --- a/src/grib_dumper_class_bufr_simple.cc +++ b/src/grib_dumper_class_bufr_simple.cc @@ -141,15 +141,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -231,15 +231,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -304,7 +304,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -314,7 +314,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) /* Note: the "subsetNumber" key is only there for UNCOMPRESSED BUFR messages */ if (self->numberOfSubsets > 1 && strcmp(a->name, "subsetNumber") == 0) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); DEBUG_ASSERT(!err); fprintf(self->dumper.out, "%s=%ld\n", a->name, value); DEBUG_ASSERT(!grib_is_missing_long(a, value)); @@ -340,10 +340,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -432,15 +432,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -504,7 +504,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; @@ -554,7 +554,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -576,7 +576,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); fprintf(self->dumper.out, "{"); for (i = 0; i < size - 1; i++) { @@ -631,7 +631,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) { fprintf(self->dumper.out, " *** ERR=%d (%s) [dump_string on '%s']", err, grib_get_error_message(err), acc_name); return; @@ -768,7 +768,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_debug.cc b/src/grib_dumper_class_debug.cc index 77206c829..ead1c7cf4 100644 --- a/src/grib_dumper_class_debug.cc +++ b/src/grib_dumper_class_debug.cc @@ -188,14 +188,14 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_READ_ONLY) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); } else { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } set_begin_end(d, a); @@ -234,14 +234,14 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%ld-%ld %s %s = MISSING", self->begin, self->theEnd, a->creator->op, a->name); else fprintf(self->dumper.out, "%ld-%ld %s %s = %ld", self->begin, self->theEnd, a->creator->op, a->name, value); if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) fprintf(self->dumper.out, " %s", "(can be missing)"); if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) @@ -266,7 +266,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_debug* self = (grib_dumper_debug*)d; long value = 0; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); int i; if (a->length == 0 && @@ -303,7 +303,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_debug* self = (grib_dumper_debug*)d; double value = 0; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); int i; if (a->length == 0 && @@ -315,14 +315,14 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) for (i = 0; i < d->depth; i++) fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%ld-%ld %s %s = MISSING", self->begin, self->theEnd, a->creator->op, a->name); else fprintf(self->dumper.out, "%ld-%ld %s %s = %g", self->begin, self->theEnd, a->creator->op, a->name, value); if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if (err) fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_double]", err, grib_get_error_message(err)); aliases(d, a); @@ -342,7 +342,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) return; grib_get_string_length_acc(a, &size); - if ((size < 2) && grib_is_missing_internal(a)) { + if ((size < 2) && a->is_missing_internal()) { /* GRIB-302: transients and missing keys. Need to re-adjust the size */ size = 10; /* big enough to hold the string "missing" */ } @@ -350,7 +350,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(a->context, size); if (!value) return; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) strcpy(value, ""); @@ -372,7 +372,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if (err) fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_string]", err, grib_get_error_message(err)); @@ -412,7 +412,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -463,7 +463,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_double(d, a, NULL); @@ -489,7 +489,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_values]\n}", err, grib_get_error_message(err)); @@ -567,10 +567,10 @@ static void set_begin_end(grib_dumper* d, grib_accessor* a) grib_dumper_debug* self = (grib_dumper_debug*)d; if ((d->option_flags & GRIB_DUMP_FLAG_OCTET) != 0) { self->begin = a->offset - self->section_offset + 1; - self->theEnd = grib_get_next_position_offset(a) - self->section_offset; + self->theEnd = a->get_next_position_offset() - self->section_offset; } else { self->begin = a->offset; - self->theEnd = grib_get_next_position_offset(a); + self->theEnd = a->get_next_position_offset(); } } diff --git a/src/grib_dumper_class_default.cc b/src/grib_dumper_class_default.cc index e9bfdc702..819344cbe 100644 --- a/src/grib_dumper_class_default.cc +++ b/src/grib_dumper_class_default.cc @@ -147,7 +147,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; print_offset(self->dumper.out, d, a); @@ -159,10 +159,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -195,7 +195,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_context_free(a->context, values); } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %ld;", a->name, value); @@ -224,12 +224,12 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) int err = 0; int isDouble = 0; - switch (grib_accessor_get_native_type(a)) { + switch (a->get_native_type()) { case GRIB_TYPE_LONG: - grib_unpack_long(a, &lvalue, &size); + a->unpack_long(&lvalue, &size); break; case GRIB_TYPE_DOUBLE: - grib_unpack_double(a, &dvalue, &size); + a->unpack_double(&dvalue, &size); isDouble = 1; break; default: @@ -269,7 +269,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else { if (isDouble) @@ -292,7 +292,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_default* self = (grib_dumper_default*)d; double value = 0; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; @@ -318,7 +318,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %g;", a->name, value); @@ -341,7 +341,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm int tab = 0; long count = 0; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -354,7 +354,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; @@ -420,7 +420,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) return; } - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; while (*p) { @@ -449,7 +449,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %s;", a->name, value); @@ -499,7 +499,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) // fprintf(self->dumper.out,"\n"); -// err = grib_unpack_bytes(a,buf,&size); +// err = a->unpack_bytes(buf,&size); // if(err){ // grib_context_free(d->context,buf); // fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_default::dump_bytes]\n}",err,grib_get_error_message(err)); @@ -549,7 +549,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_double(d, a, NULL); @@ -562,7 +562,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { char type_name[32] = ""; - const long native_type = grib_accessor_get_native_type(a); + const long native_type = a->get_native_type(); if (native_type == GRIB_TYPE_LONG) strcpy(type_name, "(int)"); else if (native_type == GRIB_TYPE_DOUBLE) @@ -596,7 +596,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); @@ -690,7 +690,7 @@ static void print_offset(FILE* out, grib_dumper* d, grib_accessor* a) grib_handle* h = grib_handle_of_accessor(a); theBegin = a->offset - self->section_offset + 1; - theEnd = grib_get_next_position_offset(a) - self->section_offset; + theEnd = a->get_next_position_offset() - self->section_offset; if ((d->option_flags & GRIB_DUMP_FLAG_HEXADECIMAL) != 0 && a->length != 0) { if (theBegin == theEnd) { diff --git a/src/grib_dumper_class_grib_encode_C.cc b/src/grib_dumper_class_grib_encode_C.cc index 5ecb6953d..5c41e11a0 100644 --- a/src/grib_dumper_class_grib_encode_C.cc +++ b/src/grib_dumper_class_grib_encode_C.cc @@ -130,7 +130,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return; @@ -161,7 +161,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); int i; char buf[1024]; @@ -201,7 +201,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; double value; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return; @@ -221,7 +221,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; char value[1024]; size_t size = sizeof(value); - int err = grib_unpack_string(a, value, &size); + int err = a->unpack_string(value, &size); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return; @@ -260,7 +260,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) return; } - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_grib_encode_C::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -305,7 +305,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) || ((a->flags & GRIB_ACCESSOR_FLAG_DATA) && (d->option_flags & GRIB_DUMP_FLAG_NO_DATA))) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { @@ -313,7 +313,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; } - type = grib_accessor_get_native_type(a); + type = a->get_native_type(); switch (type) { case GRIB_TYPE_LONG: snprintf(stype, sizeof(stype), "%s", "long"); @@ -331,7 +331,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; } - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); diff --git a/src/grib_dumper_class_json.cc b/src/grib_dumper_class_json.cc index a3b052844..dd0210521 100644 --- a/src/grib_dumper_class_json.cc +++ b/src/grib_dumper_class_json.cc @@ -129,15 +129,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; h = grib_handle_of_accessor(a); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); (void)err; /* TODO */ @@ -222,15 +222,15 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -327,7 +327,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); if (self->begin == 0 && self->empty == 0 && self->isAttribute == 0) fprintf(self->dumper.out, ",\n"); @@ -374,7 +374,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -401,7 +401,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if (self->isLeaf == 0) { fprintf(self->dumper.out, "%-*s", depth, " "); @@ -470,7 +470,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) { snprintf(value, sizeof(value), " *** ERR=%d (%s) [dump_string on '%s']", err, grib_get_error_message(err), a->name); @@ -582,7 +582,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a) fprintf(out, "\"%s\" : ", a->attributes[i]->name); flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long(d, a->attributes[i], 0); break; diff --git a/src/grib_dumper_class_serialize.cc b/src/grib_dumper_class_serialize.cc index 6dc4d5c87..57f10cee0 100644 --- a/src/grib_dumper_class_serialize.cc +++ b/src/grib_dumper_class_serialize.cc @@ -102,7 +102,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; long value = 0; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -136,7 +136,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -171,7 +171,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; double value; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -200,7 +200,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; char value[1024] = {0,}; size_t size = sizeof(value); - int err = grib_unpack_string(a, value, &size); + int err = a->unpack_string(value, &size); int i; char* p = value; @@ -261,7 +261,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_serialize::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -319,7 +319,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (self->format) { @@ -376,7 +376,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); diff --git a/src/grib_dumper_class_wmo.cc b/src/grib_dumper_class_wmo.cc index 814ed016f..3949e97a2 100644 --- a/src/grib_dumper_class_wmo.cc +++ b/src/grib_dumper_class_wmo.cc @@ -152,15 +152,15 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); } else { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0 && @@ -192,7 +192,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING", a->name); else fprintf(self->dumper.out, "%s = %ld", a->name, value); @@ -228,7 +228,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); set_begin_end(d, a); //for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," "); @@ -274,7 +274,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); set_begin_end(d, a); //for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," "); @@ -283,7 +283,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) fprintf(self->dumper.out, "%s (double) ", a->creator->op); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING", a->name); else fprintf(self->dumper.out, "%s = %g", a->name, value); @@ -317,7 +317,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_context_log(a->context, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; set_begin_end(d, a); @@ -381,7 +381,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_wmo::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -433,7 +433,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { @@ -452,7 +452,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) print_offset(self->dumper.out, self->begin, self->theEnd, 12); // ECC-1749 if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { char type_name[32] = ""; - const long native_type = grib_accessor_get_native_type(a); + const long native_type = a->get_native_type(); if (native_type == GRIB_TYPE_LONG) strcpy(type_name, "(int)"); else if (native_type == GRIB_TYPE_DOUBLE) @@ -476,7 +476,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); @@ -566,11 +566,11 @@ static void set_begin_end(grib_dumper* d, grib_accessor* a) grib_dumper_wmo* self = (grib_dumper_wmo*)d; if ((d->option_flags & GRIB_DUMP_FLAG_OCTET) != 0) { self->begin = a->offset - self->section_offset + 1; - self->theEnd = grib_get_next_position_offset(a) - self->section_offset; + self->theEnd = a->get_next_position_offset() - self->section_offset; } else { self->begin = a->offset; - self->theEnd = grib_get_next_position_offset(a); + self->theEnd = a->get_next_position_offset(); } } @@ -604,7 +604,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; c = a->context; - grib_value_count(a, &count); + a->value_count(&count); if (count == 0) return; size = count; @@ -619,7 +619,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); // print_offset(self->dumper.out,d,a); print_offset(self->dumper.out, self->begin, self->theEnd); diff --git a/src/grib_handle.cc b/src/grib_handle.cc index 732537f12..08b6f7eaa 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -99,7 +99,7 @@ void grib_empty_section(grib_context* c, grib_section* b) grib_section_delete(c, current->sub_section); current->sub_section = 0; } - grib_accessor_delete(c, current); + current->destroy(c); current = next; } b->block->first = b->block->last = 0; diff --git a/src/grib_keys_iterator.cc b/src/grib_keys_iterator.cc index 854b4a2c5..06c112c04 100644 --- a/src/grib_keys_iterator.cc +++ b/src/grib_keys_iterator.cc @@ -165,11 +165,11 @@ int grib_keys_iterator_next(grib_keys_iterator* kiter) kiter->at_start = 0; } else { - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); } while (kiter->current && skip(kiter)) - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); return kiter->current != NULL; } @@ -200,29 +200,29 @@ int grib_keys_iterator_delete(grib_keys_iterator* kiter) int grib_keys_iterator_get_long(const grib_keys_iterator* kiter, long* v, size_t* len) { - return grib_unpack_long(kiter->current, v, len); + return kiter->current->unpack_long(v, len); } int grib_keys_iterator_get_double(const grib_keys_iterator* kiter, double* v, size_t* len) { - return grib_unpack_double(kiter->current, v, len); + return kiter->current->unpack_double(v, len); } int grib_keys_iterator_get_float(const grib_keys_iterator* kiter, float* v, size_t* len) { - return grib_unpack_float(kiter->current, v, len); + return kiter->current->unpack_float(v, len); } int grib_keys_iterator_get_string(const grib_keys_iterator* kiter, char* v, size_t* len) { - return grib_unpack_string(kiter->current, v, len); + return kiter->current->unpack_string(v, len); } int grib_keys_iterator_get_bytes(const grib_keys_iterator* kiter, unsigned char* v, size_t* len) { - return grib_unpack_bytes(kiter->current, v, len); + return kiter->current->unpack_bytes(v, len); } int grib_keys_iterator_get_native_type(const grib_keys_iterator* kiter) { - return grib_accessor_get_native_type(kiter->current); + return kiter->current->get_native_type(); } diff --git a/src/grib_loader_from_handle.cc b/src/grib_loader_from_handle.cc index a423c31cc..a0d1fec6e 100644 --- a/src/grib_loader_from_handle.cc +++ b/src/grib_loader_from_handle.cc @@ -23,14 +23,14 @@ static int copy_values(grib_handle* h, grib_accessor* ga) /*printf("SET VALUES %s\n",h->values[j][i].name);*/ switch (h->values[j][i].type) { case GRIB_TYPE_LONG: - return grib_pack_long(ga, &h->values[j][i].long_value, &len); + return ga->pack_long(&h->values[j][i].long_value, &len); case GRIB_TYPE_DOUBLE: - return grib_pack_double(ga, &h->values[j][i].double_value, &len); + return ga->pack_double(&h->values[j][i].double_value, &len); case GRIB_TYPE_STRING: len = strlen(h->values[j][i].string_value); - return grib_pack_string(ga, h->values[j][i].string_value, &len); + return ga->pack_string(h->values[j][i].string_value, &len); } } } @@ -46,7 +46,7 @@ int grib_lookup_long_from_handle(grib_context* gc, grib_loader* loader, const ch grib_accessor* b = grib_find_accessor(h, name); size_t len = 1; if (b) - return grib_unpack_long(b, value, &len); + return b->unpack_long(value, &len); /* TODO: fix me. For now, we don't fail on a lookup. */ *value = -1; @@ -76,7 +76,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ if (default_value) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying: setting %s to default value", ga->name); - grib_pack_expression(ga, grib_arguments_get_expression(h, default_value, 0)); + ga->pack_expression(grib_arguments_get_expression(h, default_value, 0)); } if ((ga->flags & GRIB_ACCESSOR_FLAG_NO_COPY) || @@ -149,11 +149,11 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ } if ((ga->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && grib_is_missing(h, name, &e) && e == GRIB_SUCCESS && len == 1) { - grib_pack_missing(ga); + ga->pack_missing(); pack_missing = 1; } - const long ga_type = grib_accessor_get_native_type(ga); + const long ga_type = ga->get_native_type(); if ((ga->flags & GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION) && !loader->changing_edition) { // See ECC-1560 and ECC-1644 @@ -169,7 +169,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ ret = grib_get_string_internal(h, name, sval, &len); if (ret == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying string %s to %s", sval, name); - ret = grib_pack_string(ga, sval, &len); + ret = ga->pack_string(sval, &len); } grib_context_free(h->context, sval); @@ -199,7 +199,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ *lval = 0; /* Reset to a reasonable value */ } } - ret = grib_pack_long(ga, lval, &len); + ret = ga->pack_long(lval, &len); } } @@ -220,7 +220,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ ret = GRIB_SUCCESS; } else - ret = grib_pack_double(ga, dval, &len); + ret = ga->pack_double(dval, &len); } grib_context_free(h->context, dval); @@ -229,13 +229,13 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ case GRIB_TYPE_BYTES: ao = grib_find_accessor(h, name); - len = grib_byte_count(ao); + len = ao->byte_count(); uval = (unsigned char*)grib_context_malloc(h->context, len * sizeof(char)); - ret = grib_unpack_bytes(ao, uval, &len); + ret = ao->unpack_bytes(uval, &len); /* ret = grib_get_bytes_internal(h,name,uval,&len); */ if (ret == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying %d byte(s) to %s", len, name); - ret = grib_pack_bytes(ga, uval, &len); + ret = ga->pack_bytes(uval, &len); } grib_context_free(h->context, uval); @@ -247,7 +247,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ default: grib_context_log(h->context, GRIB_LOG_ERROR, - "Copying %s, cannot establish type %ld [%s]", name, grib_accessor_get_native_type(ga), ga->creator->cclass->name); + "Copying %s, cannot establish type %ld [%s]", name, ga->get_native_type(), ga->creator->cclass->name); break; } diff --git a/src/grib_parse_utils.cc b/src/grib_parse_utils.cc index 1d014995c..51de29332 100644 --- a/src/grib_parse_utils.cc +++ b/src/grib_parse_utils.cc @@ -117,16 +117,16 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una switch (type) { case GRIB_TYPE_STRING: replen = 1024; - ret = grib_unpack_string(a, val, &replen); + ret = a->unpack_string(val, &replen); break; case GRIB_TYPE_DOUBLE: replen = 1; - ret = grib_unpack_double(a, &dval, &replen); + ret = a->unpack_double(&dval, &replen); snprintf(val, sizeof(val), "%.12g", dval); break; case GRIB_TYPE_LONG: replen = 1; - ret = grib_unpack_long(a, &lval, &replen); + ret = a->unpack_long(&lval, &replen); snprintf(val, sizeof(val), "%d", (int)lval); break; default: @@ -194,11 +194,11 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // grib_handle* h = grib_handle_of_accessor(a); // if (type == -1) -// type = grib_accessor_get_native_type(a); +// type = a->get_native_type(); // switch (type) { // case GRIB_TYPE_STRING: // replen = sizeof(sbuf) / sizeof(*sbuf); -// ret = grib_unpack_string(a, sbuf, &replen); +// ret = a->unpack_string(sbuf, &replen); // fprintf(out, "%s", sbuf); // break; // case GRIB_TYPE_DOUBLE: @@ -206,7 +206,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // myseparator = separator ? (char*)separator : default_separator; // if (name[0] == '/' || name[0] == '#') { // long count; -// ret = grib_value_count(a, &count); +// ret = a->value_count(&count); // size = count; // } // else { @@ -216,7 +216,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); // if (name[0] == '/' || name[0] == '#') { // replen = size; -// ret = grib_unpack_double(a, dval, &replen); +// ret = a->unpack_double(dval, &replen); // } // else { // replen = 0; @@ -247,7 +247,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // myseparator = separator ? (char*)separator : default_separator; // if (name[0] == '/' || name[0] == '#') { // long count; -// ret = grib_value_count(a, &count); +// ret = a->value_count(&count); // size = count; // } // else { @@ -257,7 +257,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size); // if (name[0] == '/' || name[0] == '#') { // replen = size; -// ret = grib_unpack_long(a, lval, &replen); +// ret = a->unpack_long(lval, &replen); // } // else { // replen = 0; @@ -286,7 +286,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // case GRIB_TYPE_BYTES: // replen = a->length; // sval = (char*)grib_context_malloc(h->context, replen * sizeof(char)); -// ret = grib_unpack_string(a, sval, &replen); +// ret = a->unpack_string(sval, &replen); // p = sval; // while ((replen--) > 0) // fprintf(out, "%c", *(p++)); @@ -321,15 +321,15 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha maxcols = INT_MAX; if (type == -1) - type = grib_accessor_get_native_type(al->accessor); - grib_accessors_list_value_count(al, &size); + type = al->accessor->get_native_type(); + al->value_count(&size); switch (type) { case GRIB_TYPE_STRING: myseparator = separator ? (char*)separator : default_separator; if (size == 1) { char sbuf[1024] = {0,}; len = sizeof(sbuf); - ret = grib_unpack_string(al->accessor, sbuf, &len); + ret = al->accessor->unpack_string(sbuf, &len); if (grib_is_missing_string(al->accessor, (unsigned char*)sbuf, len)) { fprintf(out, "%s", "MISSING"); } @@ -341,7 +341,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha int cols = 0; j = 0; cvals = (char**)grib_context_malloc_clear(h->context, sizeof(char*) * size); - grib_accessors_list_unpack_string(al, cvals, &size); + al->unpack_string(cvals, &size); for (j = 0; j < size; j++) { *newline = 1; fprintf(out, "%s", cvals[j]); @@ -362,7 +362,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha myformat = format ? (char*)format : double_format; myseparator = separator ? (char*)separator : default_separator; dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); - ret = grib_accessors_list_unpack_double(al, dval, &size); + ret = al->unpack_double(dval, &size); if (size == 1) fprintf(out, myformat, dval[0]); else { @@ -387,7 +387,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha myformat = format ? (char*)format : long_format; myseparator = separator ? (char*)separator : default_separator; lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size); - ret = grib_accessors_list_unpack_long(al, lval, &size); + ret = al->unpack_long(lval, &size); if (size == 1) fprintf(out, myformat, lval[0]); else { @@ -411,7 +411,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha case GRIB_TYPE_BYTES: replen = a->length; bval = (unsigned char*)grib_context_malloc(h->context, replen * sizeof(unsigned char)); - ret = grib_unpack_bytes(al->accessor, bval, &replen); + ret = al->accessor->unpack_bytes(bval, &replen); for (j = 0; j < replen; j++) { fprintf(out, "%02x", bval[j]); } diff --git a/src/grib_query.cc b/src/grib_query.cc index 253217c0b..e8d82541d 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -213,7 +213,11 @@ static char* get_condition(const char* name, codes_condition* condition) static grib_accessor* _search_by_rank(grib_accessor* a, const char* name, int rank) { - grib_trie_with_rank* t = accessor_bufr_data_array_get_dataAccessorsTrie(a); + // ===== TODO(maee): Enable when grib_accessor_class_bufr_data_array.cc is moved to C++ ===== + throw "grib_accessor_class_bufr_data_array.cc is not yet moved to C++"; + grib_trie_with_rank* t = NULL; + //grib_trie_with_rank* t = accessor_bufr_data_array_get_dataAccessorsTrie(a); + // ===== END TODO ===== grib_accessor* ret = (grib_accessor*)grib_trie_with_rank_get(t, name, rank); return ret; } @@ -257,14 +261,14 @@ static int get_single_long_val(grib_accessor* a, long* result) size_t size = 1; if (c->bufr_multi_element_constant_arrays) { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); if (count > 1) { size_t i = 0; long val0 = 0; int is_constant = 1; long* values = (long*)grib_context_malloc_clear(c, sizeof(long) * count); size = count; - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); val0 = values[0]; for (i = 0; i < size; i++) { if (val0 != values[i]) { @@ -281,11 +285,11 @@ static int get_single_long_val(grib_accessor* a, long* result) } } else { - err = grib_unpack_long(a, result, &size); + err = a->unpack_long(result, &size); } } else { - err = grib_unpack_long(a, result, &size); + err = a->unpack_long(result, &size); } return err; } @@ -296,14 +300,14 @@ static int get_single_double_val(grib_accessor* a, double* result) size_t size = 1; if (c->bufr_multi_element_constant_arrays) { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); if (count > 1) { size_t i = 0; double val0 = 0; int is_constant = 1; double* values = (double*)grib_context_malloc_clear(c, sizeof(double) * count); size = count; - err = grib_unpack_double(a, values, &size); + err = a->unpack_double(values, &size); val0 = values[0]; for (i = 0; i < size; i++) { if (val0 != values[i]) { @@ -320,11 +324,11 @@ static int get_single_double_val(grib_accessor* a, double* result) } } else { - err = grib_unpack_double(a, result, &size); + err = a->unpack_double(result, &size); } } else { - err = grib_unpack_double(a, result, &size); + err = a->unpack_double(result, &size); } return err; } @@ -377,27 +381,27 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces while (al && al != end && al->accessor) { if (grib_inline_strcmp(al->accessor->name, accessor_name) == 0) { if (attribute_name[0]) { - accessor_result = grib_accessor_get_attribute(al->accessor, attribute_name); + accessor_result = al->accessor->get_attribute(attribute_name); } else { accessor_result = al->accessor; } if (accessor_result) { - grib_accessors_list_push(result, accessor_result, al->rank); + result->push(accessor_result, al->rank); } } - al = al->next; + al = al->next_; } if (al == end && al->accessor) { if (grib_inline_strcmp(al->accessor->name, accessor_name) == 0) { if (attribute_name[0]) { - accessor_result = grib_accessor_get_attribute(al->accessor, attribute_name); + accessor_result = al->accessor->get_attribute(attribute_name); } else { accessor_result = al->accessor; } if (accessor_result) { - grib_accessors_list_push(result, accessor_result, al->rank); + result->push(accessor_result, al->rank); } } } @@ -416,7 +420,7 @@ static void search_accessors_list_by_condition(grib_accessors_list* al, const ch if (start && !condition_true(al->accessor, condition)) end = al; } - if (start != NULL && (end != NULL || al->next == NULL)) { + if (start != NULL && (end != NULL || al->next_ == NULL)) { if (end == NULL) end = al; search_from_accessors_list(start, end, name, result); @@ -424,7 +428,7 @@ static void search_accessors_list_by_condition(grib_accessors_list* al, const ch start = NULL; end = NULL; } - al = al->next; + al = al->next_; } } @@ -434,7 +438,10 @@ static grib_accessors_list* search_by_condition(grib_handle* h, const char* name grib_accessors_list* result = NULL; grib_accessor* data = search_and_cache(h, "dataAccessors", 0); if (data && condition->left) { - al = accessor_bufr_data_array_get_dataAccessors(data); + // ===== TODO(maee): Enable when grib_accessor_class_bufr_data_array.cc is moved to C++ ===== + //al = accessor_bufr_data_array_get_dataAccessors(data); + throw "grib_accessor_class_bufr_data_array.cc is not yet moved to C++"; + // ===== END TODO ===== if (!al) return NULL; result = (grib_accessors_list*)grib_context_malloc_clear(al->accessor->context, sizeof(grib_accessors_list)); @@ -452,7 +459,7 @@ static void grib_find_same_and_push(grib_accessors_list* al, grib_accessor* a) { if (a) { grib_find_same_and_push(al, a->same); - grib_accessors_list_push(al, a, al->rank); + al->push(a, al->rank); } } @@ -484,7 +491,7 @@ grib_accessors_list* grib_find_accessors_list(const grib_handle* ch, const char* int r; al = (grib_accessors_list*)grib_context_malloc_clear(h->context, sizeof(grib_accessors_list)); str2 = get_rank(h->context, name, &r); - grib_accessors_list_push(al, a, r); + al->push(a, r); grib_context_free(h->context, str2); } } @@ -585,7 +592,7 @@ grib_accessor* grib_find_accessor(const grib_handle* h, const char* name) aret = a; } else if (a) { - aret = grib_accessor_get_attribute(a, attribute_name); + aret = a->get_attribute(attribute_name); grib_context_free(h->context, accessor_name); } } @@ -600,7 +607,7 @@ grib_accessor* grib_find_accessor(const grib_handle* h, const char* name) // *err = GRIB_NOT_FOUND; // return NULL; // } -// if ((act = grib_accessor_get_attribute(a, attr_name)) == NULL) { +// if ((act = a->get_attribute(attr_name)) == NULL) { // *err = GRIB_ATTRIBUTE_NOT_FOUND; // return NULL; // } diff --git a/src/grib_value.cc b/src/grib_value.cc index 1320bc9b7..2913d5849 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -13,9 +13,10 @@ #include "grib_api_internal.h" #include "grib_value.h" -#include "grib_accessor.h" +//#include "grib_accessor.h" #include #include +#include /* Note: A fast cut-down version of strcmp which does NOT return -1 */ /* 0 means input strings are equal and 1 means not equal */ @@ -70,7 +71,7 @@ int grib_set_expression(grib_handle* h, const char* name, grib_expression* e) if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_expression(a, e); + ret = a->pack_expression(e); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -92,7 +93,7 @@ int grib_set_long_internal(grib_handle* h, const char* name, long val) fprintf(stderr, "ECCODES DEBUG grib_set_long_internal %s=%ld\n", name, val); if (a) { - ret = grib_pack_long(a, &val, &l); + ret = a->pack_long(&val, &l); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -125,7 +126,7 @@ int grib_set_long(grib_handle* h, const char* name, long val) if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_long(a, &val, &l); + ret = a->pack_long(&val, &l); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); @@ -151,7 +152,7 @@ int grib_set_double_internal(grib_handle* h, const char* name, double val) fprintf(stderr, "ECCODES DEBUG grib_set_double_internal %s=%.10g\n", name, val); if (a) { - ret = grib_pack_double(a, &val, &l); + ret = a->pack_double(&val, &l); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -357,7 +358,7 @@ int grib_set_double(grib_handle* h, const char* name, double val) if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_double(a, &val, &l); + ret = a->pack_double(&val, &l); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); @@ -378,7 +379,7 @@ int grib_set_string_internal(grib_handle* h, const char* name, fprintf(stderr, "ECCODES DEBUG grib_set_string_internal %s=%s\n", name, val); if (a) { - ret = grib_pack_string(a, val, length); + ret = a->pack_string(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -475,7 +476,7 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* l if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_string(a, val, length); + ret = a->pack_string(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -504,7 +505,7 @@ int grib_set_string_array(grib_handle* h, const char* name, const char** val, si if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_string_array(a, val, &length); + ret = a->pack_string_array(val, &length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -519,7 +520,7 @@ int grib_set_string_array(grib_handle* h, const char* name, const char** val, si // grib_accessor* a = NULL; // a = grib_find_accessor(h, name); // if (a) { -// ret = grib_pack_bytes(a, val, length); +// ret = a->pack_bytes(val, length); // if (ret == GRIB_SUCCESS) { // return grib_dependency_notify_change(a); // } @@ -540,7 +541,7 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s /* if(a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) */ /* return GRIB_READ_ONLY; */ - ret = grib_pack_bytes(a, val, length); + ret = a->pack_bytes(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -557,7 +558,7 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s // if (a) { // if (a->length == 0) // return 0; -// if ((ret = grib_pack_zero(a)) != GRIB_SUCCESS) +// if ((ret = a->grib_pack_zero()) != GRIB_SUCCESS) // grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to clear %s (%s)", // name, grib_get_error_message(ret)); // return ret; @@ -581,7 +582,7 @@ int grib_set_missing(grib_handle* h, const char* name) if (h->context->debug) fprintf(stderr, "ECCODES DEBUG grib_set_missing %s\n", name); - ret = grib_pack_missing(a); + ret = a->pack_missing(); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); } @@ -637,7 +638,7 @@ int grib_accessor_is_missing(grib_accessor* a, int* err) *err = GRIB_SUCCESS; if (a) { if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_is_missing_internal(a); + return a->is_missing_internal(); else return 0; } @@ -697,7 +698,7 @@ static int _grib_set_double_array_internal(grib_handle* h, grib_accessor* a, if (err == GRIB_SUCCESS) { size_t len = buffer_len - *encoded_length; if (len) { - err = grib_pack_double(a, val + *encoded_length, &len); + err = a->pack_double(val + *encoded_length, &len); *encoded_length += len; if (err == GRIB_SUCCESS) { /* See ECC-778 */ @@ -729,7 +730,7 @@ static int _grib_set_double_array(grib_handle* h, const char* name, if (name[0] == '/' || name[0] == '#') { if (check && (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return GRIB_READ_ONLY; - err = grib_pack_double(a, val, &length); + err = a->pack_double(val, &length); encoded = length; } else @@ -754,7 +755,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl if (length == 0) { grib_accessor* a = grib_find_accessor(h, name); - ret = grib_pack_double(a, val, &length); + ret = a->pack_double(val, &length); } else { ret = _grib_set_double_array(h, name, val, length, 0); @@ -783,7 +784,7 @@ static int __grib_set_double_array(grib_handle* h, const char* name, const doubl if (length == 0) { grib_accessor* a = grib_find_accessor(h, name); - return grib_pack_double(a, val, &length); + return a->pack_double(val, &length); } /*second order doesn't have a proper representation for constant fields @@ -873,7 +874,7 @@ static int _grib_set_long_array_internal(grib_handle* h, grib_accessor* a, const if (err == GRIB_SUCCESS) { size_t len = buffer_len - *encoded_length; if (len) { - err = grib_pack_long(a, val + *encoded_length, &len); + err = a->pack_long(val + *encoded_length, &len); *encoded_length += len; } else { @@ -915,7 +916,7 @@ static int _grib_set_long_array(grib_handle* h, const char* name, const long* va if (name[0] == '/' || name[0] == '#') { if (check && (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return GRIB_READ_ONLY; - err = grib_pack_long(a, val, &length); + err = a->pack_long(val, &length); encoded = length; } else @@ -989,14 +990,14 @@ int grib_get_long(const grib_handle* h, const char* name, long* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_long(al->accessor, val, &length); + ret = al->accessor->unpack_long(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_long(a, val, &length); + ret = a->unpack_long(val, &length); } return ret; } @@ -1024,14 +1025,14 @@ int grib_get_double(const grib_handle* h, const char* name, double* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_double(al->accessor, val, &length); + ret = al->accessor->unpack_double(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_double(a, val, &length); + ret = a->unpack_double(val, &length); } return ret; } @@ -1047,14 +1048,14 @@ int grib_get_float(const grib_handle* h, const char* name, float* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_float(al->accessor, val, &length); + ret = al->accessor->unpack_float(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_float(a, val, &length); + ret = a->unpack_float(val, &length); } return ret; } @@ -1076,7 +1077,7 @@ int grib_get_double_element(const grib_handle* h, const char* name, int i, doubl grib_accessor* act = grib_find_accessor(h, name); if (act) { - return grib_unpack_double_element(act, i, val); + return act->unpack_double_element(i, val); } return GRIB_NOT_FOUND; } @@ -1085,7 +1086,7 @@ int grib_get_float_element(const grib_handle* h, const char* name, int i, float* grib_accessor* act = grib_find_accessor(h, name); if (act) { - return grib_unpack_float_element(act, i, val); + return act->unpack_float_element(i, val); } return GRIB_NOT_FOUND; } @@ -1118,7 +1119,7 @@ int grib_get_double_element_set(const grib_handle* h, const char* name, const si grib_accessor* acc = grib_find_accessor(h, name); if (acc) { - return grib_unpack_double_element_set(acc, index_array, len, val_array); + return acc->unpack_double_element_set(index_array, len, val_array); } return GRIB_NOT_FOUND; } @@ -1127,7 +1128,7 @@ int grib_get_float_element_set(const grib_handle* h, const char* name, const siz grib_accessor* acc = grib_find_accessor(h, name); if (acc) { - return grib_unpack_float_element_set(acc, index_array, len, val_array); + return acc->unpack_float_element_set(index_array, len, val_array); } return GRIB_NOT_FOUND; } @@ -1168,7 +1169,7 @@ int grib_get_double_elements(const grib_handle* h, const char* name, const int* return GRIB_OUT_OF_MEMORY; } - err = grib_unpack_double(act, values, &size); + err = act->unpack_double(values, &size); if (!err) { for (j = 0; j < len; j++) { val_array[j] = values[index_array[j]]; @@ -1206,7 +1207,7 @@ int grib_get_string(const grib_handle* h, const char* name, char* val, size_t* l al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_string(al->accessor, val, length); + ret = al->accessor->unpack_string(val, length); grib_context_free(h->context, al); return ret; } @@ -1214,7 +1215,7 @@ int grib_get_string(const grib_handle* h, const char* name, char* val, size_t* l a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - return grib_unpack_string(a, val, length); + return a->unpack_string(val, length); } } @@ -1232,7 +1233,7 @@ int grib_get_bytes(const grib_handle* h, const char* name, unsigned char* val, s { int err = 0; grib_accessor* act = grib_find_accessor(h, name); - err = act ? grib_unpack_bytes(act, val, length) : GRIB_NOT_FOUND; + err = act ? act->unpack_bytes(val, length) : GRIB_NOT_FOUND; if (err) grib_context_log(h->context, GRIB_LOG_ERROR, "grib_get_bytes %s failed %s", name, grib_get_error_message(err)); @@ -1251,14 +1252,14 @@ int grib_get_native_type(const grib_handle* h, const char* name, int* type) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - *type = grib_accessor_get_native_type(al->accessor); + *type = al->accessor->get_native_type(); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - *type = grib_accessor_get_native_type(a); + *type = a->get_native_type(); } return GRIB_SUCCESS; @@ -1273,13 +1274,13 @@ int grib_get_native_type(const grib_handle* h, const char* name, int* type) template static int _grib_get_array_internal(const grib_handle* h, grib_accessor* a, T* val, size_t buffer_len, size_t* decoded_length) { - static_assert(std::is_floating_point::value, "Requires floating point numbers"); + //static_assert(std::is_floating_point::value, "Requires floating point numbers"); if (a) { int err = _grib_get_array_internal(h, a->same, val, buffer_len, decoded_length); if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack(a, val + *decoded_length, &len); + err = a->unpack(val + *decoded_length, &len); *decoded_length += len; } @@ -1311,7 +1312,7 @@ int grib_get_double_array(const grib_handle* h, const char* name, double* val, s al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_double(al, val, length); + ret = al->unpack_double(val, length); grib_accessors_list_delete(h->context, al); return ret; } @@ -1320,7 +1321,7 @@ int grib_get_double_array(const grib_handle* h, const char* name, double* val, s if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack(a, val, length); + return a->unpack(val, length); } else { *length = 0; @@ -1364,7 +1365,7 @@ int grib_get_string_length_acc(grib_accessor* a, size_t* size) *size = 0; while (a) { - s = grib_string_length(a); + s = a->string_length(); if (s > *size) *size = s; a = a->same; @@ -1407,7 +1408,7 @@ int grib_get_size_acc(const grib_handle* h, grib_accessor* a, size_t* size) *size = 0; while (a) { if (err == 0) { - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; *size += count; @@ -1429,7 +1430,7 @@ int grib_get_size(const grib_handle* ch, const char* name, size_t* size) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_value_count(al, size); + ret = al->value_count(size); grib_accessors_list_delete(h->context, al); return ret; } @@ -1439,7 +1440,7 @@ int grib_get_size(const grib_handle* ch, const char* name, size_t* size) return GRIB_NOT_FOUND; if (name[0] == '#') { long count = *size; - ret = grib_value_count(a, &count); + ret = a->value_count(&count); *size = count; return ret; } @@ -1471,7 +1472,7 @@ int grib_get_offset(const grib_handle* ch, const char* key, size_t* val) const grib_handle* h = (grib_handle*)ch; grib_accessor* act = grib_find_accessor(h, key); if (act) { - *val = (size_t)grib_byte_offset(act); + *val = (size_t) act->byte_offset(); return GRIB_SUCCESS; } return GRIB_NOT_FOUND; @@ -1484,7 +1485,7 @@ static int grib_get_string_array_internal_(const grib_handle* h, grib_accessor* if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack_string_array(a, val + *decoded_length, &len); + err = a->unpack_string_array(val + *decoded_length, &len); *decoded_length += len; } @@ -1506,7 +1507,7 @@ int grib_get_string_array(const grib_handle* h, const char* name, char** val, si al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_string(al, val, length); + ret = al->unpack_string(val, length); grib_context_free(h->context, al); return ret; } @@ -1515,7 +1516,7 @@ int grib_get_string_array(const grib_handle* h, const char* name, char** val, si if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack_string_array(a, val, length); + return a->unpack_string_array(val, length); } else { *length = 0; @@ -1531,7 +1532,7 @@ static int _grib_get_long_array_internal(const grib_handle* h, grib_accessor* a, if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack_long(a, val + *decoded_length, &len); + err = a->unpack_long(val + *decoded_length, &len); *decoded_length += len; } @@ -1565,7 +1566,7 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_ al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_long(al, val, length); + ret = al->unpack_long(val, length); grib_context_free(h->context, al); } else { @@ -1573,7 +1574,7 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_ if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack_long(a, val, length); + return a->unpack_long(val, length); } else { *length = 0; @@ -1838,7 +1839,7 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name, { grib_accessor* act = grib_find_accessor(h, name); Assert(act); - return grib_nearest_smaller_value(act, val, nearest); + return act->nearest_smaller_value(val, nearest); } void grib_print_values(const char* title, grib_values* values, FILE* out) @@ -2028,5 +2029,5 @@ int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int com return GRIB_NOT_FOUND; } - return grib_compare_accessors(a1, a2, GRIB_COMPARE_TYPES); + return a1->compare_accessors(a2, GRIB_COMPARE_TYPES); } diff --git a/tests/grib_unpack_subarray.cc b/tests/grib_unpack_subarray.cc index 3321b4040..1a7bfadab 100644 --- a/tests/grib_unpack_subarray.cc +++ b/tests/grib_unpack_subarray.cc @@ -34,12 +34,12 @@ int main(int argc, char** argv) Assert(sub_values); size_t len = nvalues; - GRIB_CHECK(grib_unpack_double(a, all_values, &len), 0); + GRIB_CHECK(a->unpack_double(all_values, &len), 0); size_t start = nvalues / 10; len = nvalues / 5; printf("nvalues=%zu, start=%zu, len=%zu\n", nvalues, start, len); - GRIB_CHECK(grib_unpack_double_subarray(a, sub_values, start, len), 0); + GRIB_CHECK(a->unpack_double_subarray(sub_values, start, len), 0); for (size_t i = 0; i < len; ++i) { //printf("sub[%zu]=%.10e\n", start + i, sub_values[i]); Assert(all_values[start+i] == sub_values[i]); diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index ae4c485cc..679ec79a3 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -475,7 +475,10 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } } a = grib_find_accessor(h, "numericValues"); - al = accessor_bufr_data_array_get_dataAccessors(a); + // ===== TODO(maee): Reanable this ==== + //al = accessor_bufr_data_array_get_dataAccessors(a); + throw std::runtime_error("Functionality disabled"); + // ===== TODO(maee): Reanable this ==== options->dump_flags = GRIB_DUMP_FLAG_ALL_ATTRIBUTES; codes_dump_bufr_flat(al, h, stdout, options->dump_mode, options->dump_flags, 0); break; From c598a51954c8f5e1a41919b930b59217e0b7a9d2 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Mon, 18 Mar 2024 12:55:12 +0000 Subject: [PATCH 05/90] Add "accessor/" prefix to grib_accessor_class_*.cc --- src/CMakeLists.txt | 396 ++++++++++++++++++++++----------------------- 1 file changed, 198 insertions(+), 198 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21548a39c..53e2c3b1d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,9 +9,9 @@ # nor does it submit to any jurisdiction. # list( APPEND eccodes_src_files - ./accessor/grib_accessor.cc - ./accessor/grib_accessors_list.cc - ./grib_accessor_class.cc + accessor/grib_accessor.cc + accessor/grib_accessors_list.cc + grib_accessor_class.cc step_unit.cc step.cc step_utilities.cc @@ -23,9 +23,9 @@ list( APPEND eccodes_src_files action_class_gen.cc action_class_if.cc action_class_switch.cc - #grib_accessor_class_g1fcperiod.cc - #grib_accessor_class_g1end_of_interval_monthly.cc - #grib_accessor_class_mars_param.cc + #accessor/grib_accessor_class_g1fcperiod.cc + #accessor/grib_accessor_class_g1end_of_interval_monthly.cc + #accessor/grib_accessor_class_mars_param.cc action_class_section.cc action_class_list.cc action_class_while.cc @@ -63,207 +63,207 @@ list( APPEND eccodes_src_files grib_viarray.cc codes_memfs.cc accessor/grib_accessor_class_gen.cc - #grib_accessor_class_ascii.cc - #grib_accessor_class_bit.cc - #grib_accessor_class_bitmap.cc - #grib_accessor_class_bits.cc - #grib_accessor_class_bits_per_value.cc - #grib_accessor_class_bufr_elements_table.cc - #grib_accessor_class_bufr_data_array.cc - #grib_accessor_class_bufr_data_element.cc - #grib_accessor_class_bufr_group.cc - #grib_accessor_class_bufr_string_values.cc - #grib_accessor_class_pack_bufr_values.cc - #grib_accessor_class_unpack_bufr_values.cc - #grib_accessor_class_group.cc - #grib_accessor_class_non_alpha.cc - #grib_accessor_class_g1bitmap.cc - #grib_accessor_class_g2bitmap.cc - #grib_accessor_class_concept.cc - #grib_accessor_class_hash_array.cc - #grib_accessor_class_decimal_precision.cc - #grib_accessor_class_divdouble.cc - #grib_accessor_class_multdouble.cc - #grib_accessor_class_budgdate.cc - #grib_accessor_class_validity_date.cc - #grib_accessor_class_validity_time.cc - #grib_accessor_class_bytes.cc - #grib_accessor_class_change_alternative_row_scanning.cc - #grib_accessor_class_change_scanning_direction.cc - #grib_accessor_class_check_internal_version.cc - #grib_accessor_class_codeflag.cc + #accessor/grib_accessor_class_ascii.cc + #accessor/grib_accessor_class_bit.cc + #accessor/grib_accessor_class_bitmap.cc + #accessor/grib_accessor_class_bits.cc + #accessor/grib_accessor_class_bits_per_value.cc + #accessor/grib_accessor_class_bufr_elements_table.cc + #accessor/grib_accessor_class_bufr_data_array.cc + #accessor/grib_accessor_class_bufr_data_element.cc + #accessor/grib_accessor_class_bufr_group.cc + #accessor/grib_accessor_class_bufr_string_values.cc + #accessor/grib_accessor_class_pack_bufr_values.cc + #accessor/grib_accessor_class_unpack_bufr_values.cc + #accessor/grib_accessor_class_group.cc + #accessor/grib_accessor_class_non_alpha.cc + #accessor/grib_accessor_class_g1bitmap.cc + #accessor/grib_accessor_class_g2bitmap.cc + #accessor/grib_accessor_class_concept.cc + #accessor/grib_accessor_class_hash_array.cc + #accessor/grib_accessor_class_decimal_precision.cc + #accessor/grib_accessor_class_divdouble.cc + #accessor/grib_accessor_class_multdouble.cc + #accessor/grib_accessor_class_budgdate.cc + #accessor/grib_accessor_class_validity_date.cc + #accessor/grib_accessor_class_validity_time.cc + #accessor/grib_accessor_class_bytes.cc + #accessor/grib_accessor_class_change_alternative_row_scanning.cc + #accessor/grib_accessor_class_change_scanning_direction.cc + #accessor/grib_accessor_class_check_internal_version.cc + #accessor/grib_accessor_class_codeflag.cc accessor/grib_accessor_class_smart_table.cc - #grib_accessor_class_smart_table_column.cc + #accessor/grib_accessor_class_smart_table_column.cc accessor/grib_accessor_class_codetable.cc - #grib_accessor_class_codetable_units.cc - #grib_accessor_class_codetable_title.cc - #grib_accessor_class_step_human_readable.cc - #grib_accessor_class_count_file.cc - #grib_accessor_class_count_total.cc - #grib_accessor_class_double.cc - #grib_accessor_class_element.cc - #grib_accessor_class_evaluate.cc - #grib_accessor_class_g1date.cc - #grib_accessor_class_g1monthlydate.cc - #grib_accessor_class_library_version.cc - #grib_accessor_class_when.cc - #grib_accessor_class_g1verificationdate.cc - #grib_accessor_class_g1day_of_the_year_date.cc - #grib_accessor_class_g1_half_byte_codeflag.cc - #grib_accessor_class_g1forecastmonth.cc - #grib_accessor_class_g1step_range.cc - #grib_accessor_class_g2step_range.cc - #grib_accessor_class_data_g22order_packing.cc - #grib_accessor_class_mars_step.cc - #grib_accessor_class_message_copy.cc - #grib_accessor_class_dictionary.cc - #grib_accessor_class_latlon_increment.cc - #grib_accessor_class_g2date.cc - #grib_accessor_class_g2level.cc - #grib_accessor_class_g2end_step.cc - #grib_accessor_class_g2latlon.cc - #grib_accessor_class_g2lon.cc - #grib_accessor_class_global_gaussian.cc - #grib_accessor_class_gaussian_grid_name.cc - #grib_accessor_class_gen.cc - #grib_accessor_class_getenv.cc - #grib_accessor_class_gts_header.cc - #grib_accessor_class_ifs_param.cc - #grib_accessor_class_julian_day.cc - #grib_accessor_class_julian_date.cc - #grib_accessor_class_closest_date.cc - #grib_accessor_class_latlonvalues.cc - #grib_accessor_class_latitudes.cc - #grib_accessor_class_longitudes.cc - #grib_accessor_class_offset_file.cc - #grib_accessor_class_scale.cc - #grib_accessor_class_from_scale_factor_scaled_value.cc - #grib_accessor_class_g2bitmap_present.cc - #grib_accessor_class_ibmfloat.cc - #grib_accessor_class_ieeefloat.cc + #accessor/grib_accessor_class_codetable_units.cc + #accessor/grib_accessor_class_codetable_title.cc + #accessor/grib_accessor_class_step_human_readable.cc + #accessor/grib_accessor_class_count_file.cc + #accessor/grib_accessor_class_count_total.cc + #accessor/grib_accessor_class_double.cc + #accessor/grib_accessor_class_element.cc + #accessor/grib_accessor_class_evaluate.cc + #accessor/grib_accessor_class_g1date.cc + #accessor/grib_accessor_class_g1monthlydate.cc + #accessor/grib_accessor_class_library_version.cc + #accessor/grib_accessor_class_when.cc + #accessor/grib_accessor_class_g1verificationdate.cc + #accessor/grib_accessor_class_g1day_of_the_year_date.cc + #accessor/grib_accessor_class_g1_half_byte_codeflag.cc + #accessor/grib_accessor_class_g1forecastmonth.cc + #accessor/grib_accessor_class_g1step_range.cc + #accessor/grib_accessor_class_g2step_range.cc + #accessor/grib_accessor_class_data_g22order_packing.cc + #accessor/grib_accessor_class_mars_step.cc + #accessor/grib_accessor_class_message_copy.cc + #accessor/grib_accessor_class_dictionary.cc + #accessor/grib_accessor_class_latlon_increment.cc + #accessor/grib_accessor_class_g2date.cc + #accessor/grib_accessor_class_g2level.cc + #accessor/grib_accessor_class_g2end_step.cc + #accessor/grib_accessor_class_g2latlon.cc + #accessor/grib_accessor_class_g2lon.cc + #accessor/grib_accessor_class_global_gaussian.cc + #accessor/grib_accessor_class_gaussian_grid_name.cc + #accessor/grib_accessor_class_gen.cc + #accessor/grib_accessor_class_getenv.cc + #accessor/grib_accessor_class_gts_header.cc + #accessor/grib_accessor_class_ifs_param.cc + #accessor/grib_accessor_class_julian_day.cc + #accessor/grib_accessor_class_julian_date.cc + #accessor/grib_accessor_class_closest_date.cc + #accessor/grib_accessor_class_latlonvalues.cc + #accessor/grib_accessor_class_latitudes.cc + #accessor/grib_accessor_class_longitudes.cc + #accessor/grib_accessor_class_offset_file.cc + #accessor/grib_accessor_class_scale.cc + #accessor/grib_accessor_class_from_scale_factor_scaled_value.cc + #accessor/grib_accessor_class_g2bitmap_present.cc + #accessor/grib_accessor_class_ibmfloat.cc + #accessor/grib_accessor_class_ieeefloat.cc accessor/grib_accessor_class_constant.cc accessor/grib_accessor_class_iterator.cc - #grib_accessor_class_message.cc + #accessor/grib_accessor_class_message.cc accessor/grib_accessor_class_nearest.cc - #grib_accessor_class_ksec1expver.cc - #grib_accessor_class_label.cc + #accessor/grib_accessor_class_ksec1expver.cc + #accessor/grib_accessor_class_label.cc accessor/grib_accessor_class_long.cc - #grib_accessor_class_lookup.cc - #grib_accessor_class_octahedral_gaussian.cc - #grib_accessor_class_octet_number.cc - #grib_accessor_class_headers_only.cc - #grib_accessor_class_padding.cc - #grib_accessor_class_pad.cc - #grib_accessor_class_padto.cc - #grib_accessor_class_padtoeven.cc - #grib_accessor_class_padtomultiple.cc - #grib_accessor_class_section_padding.cc - #grib_accessor_class_packing_type.cc - #grib_accessor_class_section_pointer.cc - #grib_accessor_class_position.cc - #grib_accessor_class_signed.cc - #grib_accessor_class_signed_bits.cc - #grib_accessor_class_section.cc - #grib_accessor_class_step_in_units.cc - #grib_accessor_class_optimal_step_units.cc - #grib_accessor_class_section_length.cc - #grib_accessor_class_g1_message_length.cc - #grib_accessor_class_g1_section4_length.cc - #grib_accessor_class_size.cc - #grib_accessor_class_rdbtime_guess_date.cc - #grib_accessor_class_scale_values.cc - #grib_accessor_class_offset_values.cc - #grib_accessor_class_sprintf.cc - #grib_accessor_class_round.cc - #grib_accessor_class_spectral_truncation.cc - #grib_accessor_class_time.cc + #accessor/grib_accessor_class_lookup.cc + #accessor/grib_accessor_class_octahedral_gaussian.cc + #accessor/grib_accessor_class_octet_number.cc + #accessor/grib_accessor_class_headers_only.cc + #accessor/grib_accessor_class_padding.cc + #accessor/grib_accessor_class_pad.cc + #accessor/grib_accessor_class_padto.cc + #accessor/grib_accessor_class_padtoeven.cc + #accessor/grib_accessor_class_padtomultiple.cc + #accessor/grib_accessor_class_section_padding.cc + #accessor/grib_accessor_class_packing_type.cc + #accessor/grib_accessor_class_section_pointer.cc + #accessor/grib_accessor_class_position.cc + #accessor/grib_accessor_class_signed.cc + #accessor/grib_accessor_class_signed_bits.cc + #accessor/grib_accessor_class_section.cc + #accessor/grib_accessor_class_step_in_units.cc + #accessor/grib_accessor_class_optimal_step_units.cc + #accessor/grib_accessor_class_section_length.cc + #accessor/grib_accessor_class_g1_message_length.cc + #accessor/grib_accessor_class_g1_section4_length.cc + #accessor/grib_accessor_class_size.cc + #accessor/grib_accessor_class_rdbtime_guess_date.cc + #accessor/grib_accessor_class_scale_values.cc + #accessor/grib_accessor_class_offset_values.cc + #accessor/grib_accessor_class_sprintf.cc + #accessor/grib_accessor_class_round.cc + #accessor/grib_accessor_class_spectral_truncation.cc + #accessor/grib_accessor_class_time.cc accessor/grib_accessor_class_transient.cc - #grib_accessor_class_trim.cc - #grib_accessor_class_transient_darray.cc - #grib_accessor_class_values.cc - #grib_accessor_class_simple_packing_error.cc - #grib_accessor_class_data_simple_packing.cc - #grib_accessor_class_count_missing.cc - #grib_accessor_class_data_sh_packed.cc - #grib_accessor_class_data_sh_unpacked.cc - #grib_accessor_class_number_of_values_data_raw_packing.cc - #grib_accessor_class_data_g1simple_packing.cc - #grib_accessor_class_data_g1shsimple_packing.cc - #grib_accessor_class_data_shsimple_packing.cc - #grib_accessor_class_data_dummy_field.cc + #accessor/grib_accessor_class_trim.cc + #accessor/grib_accessor_class_transient_darray.cc + #accessor/grib_accessor_class_values.cc + #accessor/grib_accessor_class_simple_packing_error.cc + #accessor/grib_accessor_class_data_simple_packing.cc + #accessor/grib_accessor_class_count_missing.cc + #accessor/grib_accessor_class_data_sh_packed.cc + #accessor/grib_accessor_class_data_sh_unpacked.cc + #accessor/grib_accessor_class_number_of_values_data_raw_packing.cc + #accessor/grib_accessor_class_data_g1simple_packing.cc + #accessor/grib_accessor_class_data_g1shsimple_packing.cc + #accessor/grib_accessor_class_data_shsimple_packing.cc + #accessor/grib_accessor_class_data_dummy_field.cc accessor/grib_accessor_class_variable.cc - #grib_accessor_class_second_order_bits_per_value.cc - #grib_accessor_class_data_g2simple_packing.cc - #grib_accessor_class_data_g2simple_packing_with_preprocessing.cc - #grib_accessor_class_data_g2shsimple_packing.cc - #grib_accessor_class_data_g2complex_packing.cc - #grib_accessor_class_data_g1second_order_row_by_row_packing.cc - #grib_accessor_class_data_g1second_order_constant_width_packing.cc - #grib_accessor_class_data_g1second_order_general_packing.cc - #grib_accessor_class_data_g1second_order_general_extended_packing.cc - #grib_accessor_class_g2grid.cc - #grib_accessor_class_unexpanded_descriptors.cc - #grib_accessor_class_expanded_descriptors.cc - #grib_accessor_class_bufrdc_expanded_descriptors.cc - #grib_accessor_class_data_apply_bitmap.cc - #grib_accessor_class_data_apply_boustrophedonic.cc - #grib_accessor_class_data_apply_boustrophedonic_bitmap.cc - #grib_accessor_class_data_secondary_bitmap.cc - #grib_accessor_class_data_g1secondary_bitmap.cc - #grib_accessor_class_data_g2secondary_bitmap.cc - #grib_accessor_class_data_jpeg2000_packing.cc - #grib_accessor_class_data_png_packing.cc - #grib_accessor_class_data_ccsds_packing.cc - #grib_accessor_class_data_raw_packing.cc - #grib_accessor_class_data_complex_packing.cc - #grib_accessor_class_data_g1complex_packing.cc - #grib_accessor_class_gds_not_present_bitmap.cc - #grib_accessor_class_gds_is_present.cc - #grib_accessor_class_select_step_template.cc - #grib_accessor_class_local_definition.cc - #grib_accessor_class_g2_eps.cc - #grib_accessor_class_g2_aerosol.cc - #grib_accessor_class_g2_chemical.cc - #grib_accessor_class_g2_mars_labeling.cc - #grib_accessor_class_md5.cc - #grib_accessor_class_proj_string.cc + #accessor/grib_accessor_class_second_order_bits_per_value.cc + #accessor/grib_accessor_class_data_g2simple_packing.cc + #accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc + #accessor/grib_accessor_class_data_g2shsimple_packing.cc + #accessor/grib_accessor_class_data_g2complex_packing.cc + #accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc + #accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc + #accessor/grib_accessor_class_data_g1second_order_general_packing.cc + #accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc + #accessor/grib_accessor_class_g2grid.cc + #accessor/grib_accessor_class_unexpanded_descriptors.cc + #accessor/grib_accessor_class_expanded_descriptors.cc + #accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc + #accessor/grib_accessor_class_data_apply_bitmap.cc + #accessor/grib_accessor_class_data_apply_boustrophedonic.cc + #accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc + #accessor/grib_accessor_class_data_secondary_bitmap.cc + #accessor/grib_accessor_class_data_g1secondary_bitmap.cc + #accessor/grib_accessor_class_data_g2secondary_bitmap.cc + #accessor/grib_accessor_class_data_jpeg2000_packing.cc + #accessor/grib_accessor_class_data_png_packing.cc + #accessor/grib_accessor_class_data_ccsds_packing.cc + #accessor/grib_accessor_class_data_raw_packing.cc + #accessor/grib_accessor_class_data_complex_packing.cc + #accessor/grib_accessor_class_data_g1complex_packing.cc + #accessor/grib_accessor_class_gds_not_present_bitmap.cc + #accessor/grib_accessor_class_gds_is_present.cc + #accessor/grib_accessor_class_select_step_template.cc + #accessor/grib_accessor_class_local_definition.cc + #accessor/grib_accessor_class_g2_eps.cc + #accessor/grib_accessor_class_g2_aerosol.cc + #accessor/grib_accessor_class_g2_chemical.cc + #accessor/grib_accessor_class_g2_mars_labeling.cc + #accessor/grib_accessor_class_md5.cc + #accessor/grib_accessor_class_proj_string.cc grib_jasper_encoding.cc grib_openjpeg_encoding.cc action_class_set_missing.cc - #grib_accessor_class_number_of_points.cc - #grib_accessor_class_suppressed.cc + #accessor/grib_accessor_class_number_of_points.cc + #accessor/grib_accessor_class_suppressed.cc grib_index.cc - #grib_accessor_class_number_of_points_gaussian.cc - #grib_accessor_class_number_of_values.cc - #grib_accessor_class_number_of_coded_values.cc - #grib_accessor_class_g1number_of_coded_values_sh_complex.cc - #grib_accessor_class_g1number_of_coded_values_sh_simple.cc - #grib_accessor_class_dirty.cc - #grib_accessor_class_statistics.cc - #grib_accessor_class_statistics_spectral.cc + #accessor/grib_accessor_class_number_of_points_gaussian.cc + #accessor/grib_accessor_class_number_of_values.cc + #accessor/grib_accessor_class_number_of_coded_values.cc + #accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc + #accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc + #accessor/grib_accessor_class_dirty.cc + #accessor/grib_accessor_class_statistics.cc + #accessor/grib_accessor_class_statistics_spectral.cc accessor/grib_accessor_class_unsigned.cc - #grib_accessor_class_unsigned_bits.cc - #grib_accessor_class_raw.cc - #grib_accessor_class_bufr_simple_thinning.cc - #grib_accessor_class_bufr_extract_subsets.cc - #grib_accessor_class_bufr_extract_area_subsets.cc - #grib_accessor_class_bufr_extract_datetime_subsets.cc - #grib_accessor_class_spd.cc - #grib_accessor_class_sum.cc - #grib_accessor_class_to_integer.cc - #grib_accessor_class_to_double.cc - #grib_accessor_class_to_string.cc - #grib_accessor_class_sexagesimal2decimal.cc - #grib_accessor_class_vector.cc - #grib_accessor_class_long_vector.cc + #accessor/grib_accessor_class_unsigned_bits.cc + #accessor/grib_accessor_class_raw.cc + #accessor/grib_accessor_class_bufr_simple_thinning.cc + #accessor/grib_accessor_class_bufr_extract_subsets.cc + #accessor/grib_accessor_class_bufr_extract_area_subsets.cc + #accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc + #accessor/grib_accessor_class_spd.cc + #accessor/grib_accessor_class_sum.cc + #accessor/grib_accessor_class_to_integer.cc + #accessor/grib_accessor_class_to_double.cc + #accessor/grib_accessor_class_to_string.cc + #accessor/grib_accessor_class_sexagesimal2decimal.cc + #accessor/grib_accessor_class_vector.cc + #accessor/grib_accessor_class_long_vector.cc grib_gaussian_reduced.cc - #grib_accessor_class_abstract_vector.cc - #grib_accessor_class_abstract_long_vector.cc + #accessor/grib_accessor_class_abstract_vector.cc + #accessor/grib_accessor_class_abstract_long_vector.cc grib_loader_from_handle.cc grib_bits.cc grib_ibmfloat.cc grib_ieeefloat.cc - #grib_accessor_class_reference_value_error.cc + #accessor/grib_accessor_class_reference_value_error.cc grib_memory.cc grib_buffer.cc grib_dumper.cc @@ -366,16 +366,16 @@ list( APPEND eccodes_src_files grib_yacc.h md5.h md5.cc - #grib_accessor_class_uint16.cc - #grib_accessor_class_uint32.cc - #grib_accessor_class_uint32_little_endian.cc - #grib_accessor_class_uint64.cc - #grib_accessor_class_uint64_little_endian.cc - #grib_accessor_class_uint8.cc - #grib_accessor_class_blob.cc + #accessor/grib_accessor_class_uint16.cc + #accessor/grib_accessor_class_uint32.cc + #accessor/grib_accessor_class_uint32_little_endian.cc + #accessor/grib_accessor_class_uint64.cc + #accessor/grib_accessor_class_uint64_little_endian.cc + #accessor/grib_accessor_class_uint8.cc + #accessor/grib_accessor_class_blob.cc grib_optimize_decimal_factor.cc - #grib_accessor_class_data_g2bifourier_packing.cc - #grib_accessor_class_data_run_length_packing.cc + #accessor/grib_accessor_class_data_g2bifourier_packing.cc + #accessor/grib_accessor_class_data_run_length_packing.cc eccodes_windef.h # We ship our own generated lex/yacc C files grib_yacc.cc grib_lex.cc ) From f1d68aa7f63357b394945f85143244461fb9249b Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Mon, 18 Mar 2024 22:41:56 +0000 Subject: [PATCH 06/90] 18% tests passed, 276 tests failed out of 337 --- examples/C/grib_pthreads.c | 2 +- src/CMakeLists.txt | 391 +++++----- ...rib_accessor_class_abstract_long_vector.cc | 17 + ...grib_accessor_class_abstract_long_vector.h | 33 + .../grib_accessor_class_abstract_vector.cc | 17 + .../grib_accessor_class_abstract_vector.h | 32 + src/accessor/grib_accessor_class_ascii.cc | 164 +++++ src/accessor/grib_accessor_class_ascii.h | 42 ++ src/accessor/grib_accessor_class_bit.cc | 79 ++ src/accessor/grib_accessor_class_bit.h | 35 + src/accessor/grib_accessor_class_bitmap.cc | 175 +++++ src/accessor/grib_accessor_class_bitmap.h | 45 ++ .../{todo => }/grib_accessor_class_bits.cc | 170 +---- src/accessor/grib_accessor_class_bits.h | 45 ++ .../grib_accessor_class_bits_per_value.cc | 73 ++ .../grib_accessor_class_bits_per_value.h | 35 + src/accessor/grib_accessor_class_blob.cc | 42 ++ src/accessor/grib_accessor_class_blob.h | 34 + src/accessor/grib_accessor_class_budgdate.cc | 82 +++ src/accessor/grib_accessor_class_budgdate.h | 36 + .../grib_accessor_class_bufr_data_array.cc | 530 ++++---------- .../grib_accessor_class_bufr_data_array.h | 93 +++ .../grib_accessor_class_bufr_data_element.cc | 254 ++----- .../grib_accessor_class_bufr_data_element.h | 56 ++ ...grib_accessor_class_bufr_elements_table.cc | 137 +--- .../grib_accessor_class_bufr_elements_table.h | 39 + ...ccessor_class_bufr_extract_area_subsets.cc | 128 +--- ...accessor_class_bufr_extract_area_subsets.h | 43 ++ ...sor_class_bufr_extract_datetime_subsets.cc | 114 +-- ...ssor_class_bufr_extract_datetime_subsets.h | 36 + ...rib_accessor_class_bufr_extract_subsets.cc | 58 ++ ...grib_accessor_class_bufr_extract_subsets.h | 37 + .../grib_accessor_class_bufr_group.cc | 39 + src/accessor/grib_accessor_class_bufr_group.h | 31 + ...rib_accessor_class_bufr_simple_thinning.cc | 114 +++ ...grib_accessor_class_bufr_simple_thinning.h | 39 + .../grib_accessor_class_bufr_string_values.cc | 84 +++ .../grib_accessor_class_bufr_string_values.h | 38 + ...essor_class_bufrdc_expanded_descriptors.cc | 98 +++ ...cessor_class_bufrdc_expanded_descriptors.h | 37 + src/accessor/grib_accessor_class_bytes.cc | 99 +++ src/accessor/grib_accessor_class_bytes.h | 35 + ...r_class_change_alternative_row_scanning.cc | 117 +++ ...or_class_change_alternative_row_scanning.h | 38 + ...ccessor_class_change_scanning_direction.cc | 121 +--- ...accessor_class_change_scanning_direction.h | 42 ++ ...b_accessor_class_check_internal_version.cc | 51 ++ ...ib_accessor_class_check_internal_version.h | 33 + .../grib_accessor_class_closest_date.cc | 126 +--- .../grib_accessor_class_closest_date.h | 43 ++ src/accessor/grib_accessor_class_codeflag.cc | 119 +++ src/accessor/grib_accessor_class_codeflag.h | 34 + .../grib_accessor_class_codetable_title.cc | 69 ++ .../grib_accessor_class_codetable_title.h | 34 + .../grib_accessor_class_codetable_units.cc | 70 ++ .../grib_accessor_class_codetable_units.h | 34 + .../{todo => }/grib_accessor_class_concept.cc | 186 +---- src/accessor/grib_accessor_class_concept.h | 43 ++ .../grib_accessor_class_count_file.cc | 28 + src/accessor/grib_accessor_class_count_file.h | 32 + .../grib_accessor_class_count_missing.cc | 117 +-- .../grib_accessor_class_count_missing.h | 37 + .../grib_accessor_class_count_total.cc | 28 + .../grib_accessor_class_count_total.h | 32 + .../grib_accessor_class_data_apply_bitmap.cc | 179 +---- .../grib_accessor_class_data_apply_bitmap.h | 46 ++ ...cessor_class_data_apply_boustrophedonic.cc | 145 +--- ...ccessor_class_data_apply_boustrophedonic.h | 44 ++ ...class_data_apply_boustrophedonic_bitmap.cc | 157 +--- ..._class_data_apply_boustrophedonic_bitmap.h | 45 ++ .../grib_accessor_class_data_ccsds_packing.cc | 195 +---- .../grib_accessor_class_data_ccsds_packing.h | 47 ++ ...rib_accessor_class_data_complex_packing.cc | 173 +---- ...grib_accessor_class_data_complex_packing.h | 45 ++ .../grib_accessor_class_data_dummy_field.cc | 102 +++ .../grib_accessor_class_data_dummy_field.h | 37 + ...b_accessor_class_data_g1complex_packing.cc | 112 +++ ...ib_accessor_class_data_g1complex_packing.h | 37 + ...a_g1second_order_constant_width_packing.cc | 177 +---- ...ta_g1second_order_constant_width_packing.h | 53 ++ ...g1second_order_general_extended_packing.cc | 220 +----- ..._g1second_order_general_extended_packing.h | 65 ++ ...ass_data_g1second_order_general_packing.cc | 173 +---- ...lass_data_g1second_order_general_packing.h | 51 ++ ..._data_g1second_order_row_by_row_packing.cc | 171 +---- ...s_data_g1second_order_row_by_row_packing.h | 51 ++ ..._accessor_class_data_g1secondary_bitmap.cc | 128 ++++ ...b_accessor_class_data_g1secondary_bitmap.h | 34 + ..._accessor_class_data_g1shsimple_packing.cc | 64 ++ ...b_accessor_class_data_g1shsimple_packing.h | 32 + ...ib_accessor_class_data_g1simple_packing.cc | 136 +--- ...rib_accessor_class_data_g1simple_packing.h | 37 + ...ib_accessor_class_data_g22order_packing.cc | 227 +----- ...rib_accessor_class_data_g22order_packing.h | 57 ++ ...accessor_class_data_g2bifourier_packing.cc | 193 +---- ..._accessor_class_data_g2bifourier_packing.h | 47 ++ ...b_accessor_class_data_g2complex_packing.cc | 47 ++ ...ib_accessor_class_data_g2complex_packing.h | 34 + ..._accessor_class_data_g2secondary_bitmap.cc | 107 +++ ...b_accessor_class_data_g2secondary_bitmap.h | 34 + ..._accessor_class_data_g2shsimple_packing.cc | 92 +++ ...b_accessor_class_data_g2shsimple_packing.h | 36 + ...ib_accessor_class_data_g2simple_packing.cc | 157 +--- ...rib_accessor_class_data_g2simple_packing.h | 34 + ...ata_g2simple_packing_with_preprocessing.cc | 179 +++++ ...data_g2simple_packing_with_preprocessing.h | 36 + ...ib_accessor_class_data_jpeg2000_packing.cc | 185 +---- ...rib_accessor_class_data_jpeg2000_packing.h | 46 ++ .../grib_accessor_class_data_png_packing.cc | 191 +---- .../grib_accessor_class_data_png_packing.h | 46 ++ .../grib_accessor_class_data_raw_packing.cc | 194 +++++ .../grib_accessor_class_data_raw_packing.h | 38 + ..._accessor_class_data_run_length_packing.cc | 134 +--- ...b_accessor_class_data_run_length_packing.h | 40 ++ ...ib_accessor_class_data_secondary_bitmap.cc | 118 +++ ...rib_accessor_class_data_secondary_bitmap.h | 38 + .../grib_accessor_class_data_sh_packed.cc | 147 +--- .../grib_accessor_class_data_sh_packed.h | 43 ++ .../grib_accessor_class_data_sh_unpacked.cc | 147 +--- .../grib_accessor_class_data_sh_unpacked.h | 43 ++ ...ib_accessor_class_data_shsimple_packing.cc | 60 ++ ...rib_accessor_class_data_shsimple_packing.h | 37 + ...grib_accessor_class_data_simple_packing.cc | 186 +---- .../grib_accessor_class_data_simple_packing.h | 48 ++ .../grib_accessor_class_decimal_precision.cc | 103 +++ .../grib_accessor_class_decimal_precision.h | 37 + .../grib_accessor_class_dictionary.cc | 129 +--- src/accessor/grib_accessor_class_dictionary.h | 42 ++ src/accessor/grib_accessor_class_dirty.cc | 47 ++ src/accessor/grib_accessor_class_dirty.h | 34 + src/accessor/grib_accessor_class_divdouble.cc | 43 ++ src/accessor/grib_accessor_class_divdouble.h | 34 + src/accessor/grib_accessor_class_double.cc | 105 +++ src/accessor/grib_accessor_class_double.h | 35 + .../{todo => }/grib_accessor_class_element.cc | 117 +-- src/accessor/grib_accessor_class_element.h | 36 + src/accessor/grib_accessor_class_evaluate.cc | 33 + src/accessor/grib_accessor_class_evaluate.h | 33 + ...rib_accessor_class_expanded_descriptors.cc | 200 +----- ...grib_accessor_class_expanded_descriptors.h | 47 ++ ...or_class_from_scale_factor_scaled_value.cc | 125 +--- ...sor_class_from_scale_factor_scaled_value.h | 37 + ...ib_accessor_class_g1_half_byte_codeflag.cc | 60 ++ ...rib_accessor_class_g1_half_byte_codeflag.h | 35 + .../grib_accessor_class_g1_message_length.cc | 110 +-- .../grib_accessor_class_g1_message_length.h | 34 + .../grib_accessor_class_g1_section4_length.cc | 53 ++ .../grib_accessor_class_g1_section4_length.h | 34 + src/accessor/grib_accessor_class_g1bitmap.cc | 98 +++ src/accessor/grib_accessor_class_g1bitmap.h | 35 + .../{todo => }/grib_accessor_class_g1date.cc | 124 +--- src/accessor/grib_accessor_class_g1date.h | 39 + ...b_accessor_class_g1day_of_the_year_date.cc | 60 ++ ...ib_accessor_class_g1day_of_the_year_date.h | 33 + ...ccessor_class_g1end_of_interval_monthly.cc | 135 ++++ ...accessor_class_g1end_of_interval_monthly.h | 36 + .../grib_accessor_class_g1fcperiod.cc | 42 ++ src/accessor/grib_accessor_class_g1fcperiod.h | 31 + .../grib_accessor_class_g1forecastmonth.cc | 129 +--- .../grib_accessor_class_g1forecastmonth.h | 40 ++ .../grib_accessor_class_g1monthlydate.cc | 41 ++ .../grib_accessor_class_g1monthlydate.h | 33 + ...ass_g1number_of_coded_values_sh_complex.cc | 81 +++ ...lass_g1number_of_coded_values_sh_complex.h | 40 ++ ...lass_g1number_of_coded_values_sh_simple.cc | 62 ++ ...class_g1number_of_coded_values_sh_simple.h | 37 + .../grib_accessor_class_g1step_range.cc | 164 +---- .../grib_accessor_class_g1step_range.h | 48 ++ .../grib_accessor_class_g1verificationdate.cc | 64 ++ .../grib_accessor_class_g1verificationdate.h | 35 + .../grib_accessor_class_g2_aerosol.cc | 114 +++ src/accessor/grib_accessor_class_g2_aerosol.h | 37 + .../grib_accessor_class_g2_chemical.cc | 116 +-- .../grib_accessor_class_g2_chemical.h | 37 + .../{todo => }/grib_accessor_class_g2_eps.cc | 121 +--- src/accessor/grib_accessor_class_g2_eps.h | 39 + .../grib_accessor_class_g2_mars_labeling.cc | 159 +---- .../grib_accessor_class_g2_mars_labeling.h | 47 ++ src/accessor/grib_accessor_class_g2bitmap.cc | 75 ++ src/accessor/grib_accessor_class_g2bitmap.h | 34 + .../grib_accessor_class_g2bitmap_present.cc | 59 ++ .../grib_accessor_class_g2bitmap_present.h | 34 + src/accessor/grib_accessor_class_g2date.cc | 82 +++ src/accessor/grib_accessor_class_g2date.h | 37 + .../grib_accessor_class_g2end_step.cc | 207 +----- src/accessor/grib_accessor_class_g2end_step.h | 56 ++ .../{todo => }/grib_accessor_class_g2grid.cc | 136 +--- src/accessor/grib_accessor_class_g2grid.h | 42 ++ src/accessor/grib_accessor_class_g2latlon.cc | 115 +++ src/accessor/grib_accessor_class_g2latlon.h | 38 + .../{todo => }/grib_accessor_class_g2level.cc | 134 +--- src/accessor/grib_accessor_class_g2level.h | 40 ++ src/accessor/grib_accessor_class_g2lon.cc | 58 ++ src/accessor/grib_accessor_class_g2lon.h | 34 + .../grib_accessor_class_g2step_range.cc | 143 +--- .../grib_accessor_class_g2step_range.h | 41 ++ .../grib_accessor_class_gaussian_grid_name.cc | 84 +++ .../grib_accessor_class_gaussian_grid_name.h | 37 + .../grib_accessor_class_gds_is_present.cc | 86 +++ .../grib_accessor_class_gds_is_present.h | 37 + ...b_accessor_class_gds_not_present_bitmap.cc | 109 +++ ...ib_accessor_class_gds_not_present_bitmap.h | 40 ++ src/accessor/grib_accessor_class_getenv.cc | 62 ++ src/accessor/grib_accessor_class_getenv.h | 38 + .../grib_accessor_class_global_gaussian.cc | 126 +--- .../grib_accessor_class_global_gaussian.h | 44 ++ src/accessor/grib_accessor_class_group.cc | 160 +++++ src/accessor/grib_accessor_class_group.h | 41 ++ .../grib_accessor_class_gts_header.cc | 61 ++ src/accessor/grib_accessor_class_gts_header.h | 36 + .../grib_accessor_class_hash_array.cc | 176 +++++ src/accessor/grib_accessor_class_hash_array.h | 45 ++ .../grib_accessor_class_headers_only.cc | 33 + .../grib_accessor_class_headers_only.h | 33 + src/accessor/grib_accessor_class_ibmfloat.cc | 150 ++++ src/accessor/grib_accessor_class_ibmfloat.h | 40 ++ src/accessor/grib_accessor_class_ieeefloat.cc | 123 ++++ src/accessor/grib_accessor_class_ieeefloat.h | 37 + src/accessor/grib_accessor_class_ifs_param.cc | 93 +++ src/accessor/grib_accessor_class_ifs_param.h | 36 + .../grib_accessor_class_julian_date.cc | 163 +---- .../grib_accessor_class_julian_date.h | 48 ++ .../grib_accessor_class_julian_day.cc | 107 +++ src/accessor/grib_accessor_class_julian_day.h | 40 ++ .../grib_accessor_class_ksec1expver.cc | 95 +++ .../grib_accessor_class_ksec1expver.h | 34 + src/accessor/grib_accessor_class_label.cc | 40 ++ src/accessor/grib_accessor_class_label.h | 34 + .../grib_accessor_class_latitudes.cc | 127 +--- src/accessor/grib_accessor_class_latitudes.h | 38 + .../grib_accessor_class_latlon_increment.cc | 125 +--- .../grib_accessor_class_latlon_increment.h | 43 ++ .../grib_accessor_class_latlonvalues.cc | 76 ++ .../grib_accessor_class_latlonvalues.h | 34 + .../grib_accessor_class_library_version.cc | 46 ++ .../grib_accessor_class_library_version.h | 33 + .../grib_accessor_class_local_definition.cc | 136 +--- .../grib_accessor_class_local_definition.h | 43 ++ .../grib_accessor_class_long_vector.cc | 95 +++ .../grib_accessor_class_long_vector.h | 37 + .../grib_accessor_class_longitudes.cc | 123 +--- src/accessor/grib_accessor_class_longitudes.h | 38 + src/accessor/grib_accessor_class_lookup.cc | 133 ++++ src/accessor/grib_accessor_class_lookup.h | 42 ++ .../grib_accessor_class_mars_param.cc | 53 ++ src/accessor/grib_accessor_class_mars_param.h | 36 + src/accessor/grib_accessor_class_mars_step.cc | 115 +++ src/accessor/grib_accessor_class_mars_step.h | 40 ++ .../{todo => }/grib_accessor_class_md5.cc | 126 +--- src/accessor/grib_accessor_class_md5.h | 39 + src/accessor/grib_accessor_class_message.cc | 75 ++ src/accessor/grib_accessor_class_message.h | 36 + .../grib_accessor_class_message_copy.cc | 59 ++ .../grib_accessor_class_message_copy.h | 36 + .../grib_accessor_class_multdouble.cc | 40 ++ src/accessor/grib_accessor_class_multdouble.h | 34 + src/accessor/grib_accessor_class_non_alpha.cc | 112 +++ src/accessor/grib_accessor_class_non_alpha.h | 39 + ...b_accessor_class_number_of_coded_values.cc | 66 ++ ...ib_accessor_class_number_of_coded_values.h | 37 + .../grib_accessor_class_number_of_points.cc | 80 +++ .../grib_accessor_class_number_of_points.h | 36 + ...ccessor_class_number_of_points_gaussian.cc | 148 +--- ...accessor_class_number_of_points_gaussian.h | 42 ++ .../grib_accessor_class_number_of_values.cc | 67 ++ .../grib_accessor_class_number_of_values.h | 38 + ...class_number_of_values_data_raw_packing.cc | 63 ++ ..._class_number_of_values_data_raw_packing.h | 35 + ...grib_accessor_class_octahedral_gaussian.cc | 120 ++++ .../grib_accessor_class_octahedral_gaussian.h | 37 + .../grib_accessor_class_octet_number.cc | 47 ++ .../grib_accessor_class_octet_number.h | 35 + .../grib_accessor_class_offset_file.cc | 55 ++ .../grib_accessor_class_offset_file.h | 33 + .../grib_accessor_class_offset_values.cc | 83 +++ .../grib_accessor_class_offset_values.h | 35 + .../grib_accessor_class_optimal_step_units.cc | 144 +--- .../grib_accessor_class_optimal_step_units.h | 44 ++ .../grib_accessor_class_pack_bufr_values.cc | 69 ++ .../grib_accessor_class_pack_bufr_values.h | 42 ++ .../grib_accessor_class_packing_type.cc | 74 ++ .../grib_accessor_class_packing_type.h | 37 + src/accessor/grib_accessor_class_pad.cc | 36 + src/accessor/grib_accessor_class_pad.h | 34 + src/accessor/grib_accessor_class_padding.cc | 58 ++ src/accessor/grib_accessor_class_padding.h | 37 + src/accessor/grib_accessor_class_padto.cc | 45 ++ src/accessor/grib_accessor_class_padto.h | 34 + src/accessor/grib_accessor_class_padtoeven.cc | 48 ++ src/accessor/grib_accessor_class_padtoeven.h | 34 + .../grib_accessor_class_padtomultiple.cc | 40 ++ .../grib_accessor_class_padtomultiple.h | 34 + src/accessor/grib_accessor_class_position.cc | 50 ++ src/accessor/grib_accessor_class_position.h | 34 + .../grib_accessor_class_proj_string.cc | 137 +--- .../grib_accessor_class_proj_string.h | 35 + src/accessor/grib_accessor_class_raw.cc | 117 +++ src/accessor/grib_accessor_class_raw.h | 41 ++ .../grib_accessor_class_rdbtime_guess_date.cc | 76 ++ .../grib_accessor_class_rdbtime_guess_date.h | 38 + ...ib_accessor_class_reference_value_error.cc | 50 ++ ...rib_accessor_class_reference_value_error.h | 34 + src/accessor/grib_accessor_class_round.cc | 69 ++ src/accessor/grib_accessor_class_round.h | 32 + src/accessor/grib_accessor_class_scale.cc | 134 ++++ src/accessor/grib_accessor_class_scale.h | 39 + .../grib_accessor_class_scale_values.cc | 85 +++ .../grib_accessor_class_scale_values.h | 35 + ...essor_class_second_order_bits_per_value.cc | 120 +--- ...cessor_class_second_order_bits_per_value.h | 37 + src/accessor/grib_accessor_class_section.cc | 95 +++ src/accessor/grib_accessor_class_section.h | 37 + .../grib_accessor_class_section_length.cc | 34 + .../grib_accessor_class_section_length.h | 33 + .../grib_accessor_class_section_padding.cc | 70 ++ .../grib_accessor_class_section_padding.h | 33 + .../grib_accessor_class_section_pointer.cc | 97 +++ .../grib_accessor_class_section_pointer.h | 38 + ...rib_accessor_class_select_step_template.cc | 113 +-- ...grib_accessor_class_select_step_template.h | 36 + ...grib_accessor_class_sexagesimal2decimal.cc | 146 ++++ .../grib_accessor_class_sexagesimal2decimal.h | 34 + .../{todo => }/grib_accessor_class_signed.cc | 160 +---- src/accessor/grib_accessor_class_signed.h | 42 ++ .../grib_accessor_class_signed_bits.cc | 152 ++++ .../grib_accessor_class_signed_bits.h | 40 ++ ...rib_accessor_class_simple_packing_error.cc | 70 ++ ...grib_accessor_class_simple_packing_error.h | 37 + src/accessor/grib_accessor_class_size.cc | 35 + src/accessor/grib_accessor_class_size.h | 33 + .../grib_accessor_class_smart_table_column.cc | 177 +++++ .../grib_accessor_class_smart_table_column.h | 39 + src/accessor/grib_accessor_class_spd.cc | 158 ++++ src/accessor/grib_accessor_class_spd.h | 40 ++ ...grib_accessor_class_spectral_truncation.cc | 81 +++ .../grib_accessor_class_spectral_truncation.h | 36 + .../{todo => }/grib_accessor_class_sprintf.cc | 110 +-- src/accessor/grib_accessor_class_sprintf.h | 35 + .../grib_accessor_class_statistics.cc | 143 +--- src/accessor/grib_accessor_class_statistics.h | 38 + ...grib_accessor_class_statistics_spectral.cc | 165 +++++ .../grib_accessor_class_statistics_spectral.h | 40 ++ ...grib_accessor_class_step_human_readable.cc | 79 ++ .../grib_accessor_class_step_human_readable.h | 35 + .../grib_accessor_class_step_in_units.cc | 146 +--- .../grib_accessor_class_step_in_units.h | 43 ++ src/accessor/grib_accessor_class_sum.cc | 107 +++ src/accessor/grib_accessor_class_sum.h | 35 + .../grib_accessor_class_suppressed.cc | 65 ++ src/accessor/grib_accessor_class_suppressed.h | 37 + src/accessor/grib_accessor_class_time.cc | 113 +++ src/accessor/grib_accessor_class_time.h | 37 + src/accessor/grib_accessor_class_to_double.cc | 130 ++++ src/accessor/grib_accessor_class_to_double.h | 43 ++ .../grib_accessor_class_to_integer.cc | 132 ++++ src/accessor/grib_accessor_class_to_integer.h | 45 ++ src/accessor/grib_accessor_class_to_string.cc | 120 ++++ src/accessor/grib_accessor_class_to_string.h | 42 ++ .../grib_accessor_class_transient_darray.cc | 111 +++ .../grib_accessor_class_transient_darray.h | 41 ++ src/accessor/grib_accessor_class_trim.cc | 76 ++ src/accessor/grib_accessor_class_trim.h | 37 + src/accessor/grib_accessor_class_uint16.cc | 35 + src/accessor/grib_accessor_class_uint16.h | 32 + src/accessor/grib_accessor_class_uint32.cc | 35 + src/accessor/grib_accessor_class_uint32.h | 32 + ...rib_accessor_class_uint32_little_endian.cc | 35 + ...grib_accessor_class_uint32_little_endian.h | 32 + src/accessor/grib_accessor_class_uint64.cc | 51 ++ src/accessor/grib_accessor_class_uint64.h | 32 + ...rib_accessor_class_uint64_little_endian.cc | 51 ++ ...grib_accessor_class_uint64_little_endian.h | 32 + src/accessor/grib_accessor_class_uint8.cc | 37 + src/accessor/grib_accessor_class_uint8.h | 32 + ...b_accessor_class_unexpanded_descriptors.cc | 132 ++++ ...ib_accessor_class_unexpanded_descriptors.h | 39 + .../grib_accessor_class_unpack_bufr_values.cc | 98 +++ .../grib_accessor_class_unpack_bufr_values.h | 42 ++ .../grib_accessor_class_unsigned_bits.cc | 159 +++++ .../grib_accessor_class_unsigned_bits.h | 40 ++ .../grib_accessor_class_validity_date.cc | 96 +++ .../grib_accessor_class_validity_date.h | 39 + .../grib_accessor_class_validity_time.cc | 116 +++ .../grib_accessor_class_validity_time.h | 39 + src/accessor/grib_accessor_class_values.cc | 139 ++++ src/accessor/grib_accessor_class_values.h | 44 ++ src/accessor/grib_accessor_class_vector.cc | 57 ++ src/accessor/grib_accessor_class_vector.h | 34 + src/accessor/grib_accessor_class_when.cc | 35 + src/accessor/grib_accessor_class_when.h | 34 + ...rib_accessor_class_abstract_long_vector.cc | 103 --- .../grib_accessor_class_abstract_vector.cc | 98 --- .../todo/grib_accessor_class_ascii.cc | 278 -------- src/accessor/todo/grib_accessor_class_bit.cc | 170 ----- .../todo/grib_accessor_class_bitmap.cc | 297 -------- .../grib_accessor_class_bits_per_value.cc | 165 ----- src/accessor/todo/grib_accessor_class_blob.cc | 128 ---- .../todo/grib_accessor_class_budgdate.cc | 174 ----- ...rib_accessor_class_bufr_extract_subsets.cc | 152 ---- .../todo/grib_accessor_class_bufr_group.cc | 126 ---- ...rib_accessor_class_bufr_simple_thinning.cc | 211 ------ .../grib_accessor_class_bufr_string_values.cc | 189 ----- ...essor_class_bufrdc_expanded_descriptors.cc | 206 ------ .../todo/grib_accessor_class_bytes.cc | 192 ----- ...r_class_change_alternative_row_scanning.cc | 212 ------ ...b_accessor_class_check_internal_version.cc | 136 ---- .../todo/grib_accessor_class_codeflag.cc | 216 ------ .../grib_accessor_class_codetable_title.cc | 171 ----- .../grib_accessor_class_codetable_units.cc | 171 ----- .../todo/grib_accessor_class_count_file.cc | 114 --- .../todo/grib_accessor_class_count_total.cc | 116 --- .../grib_accessor_class_data_dummy_field.cc | 219 ------ ...b_accessor_class_data_g1complex_packing.cc | 235 ------ ..._accessor_class_data_g1secondary_bitmap.cc | 220 ------ ..._accessor_class_data_g1shsimple_packing.cc | 150 ---- ...b_accessor_class_data_g2complex_packing.cc | 164 ----- ..._accessor_class_data_g2secondary_bitmap.cc | 199 ------ ..._accessor_class_data_g2shsimple_packing.cc | 188 ----- ...ata_g2simple_packing_with_preprocessing.cc | 287 -------- .../grib_accessor_class_data_raw_packing.cc | 306 -------- ...ib_accessor_class_data_secondary_bitmap.cc | 214 ------ ...ib_accessor_class_data_shsimple_packing.cc | 153 ---- .../grib_accessor_class_decimal_precision.cc | 199 ------ .../todo/grib_accessor_class_dirty.cc | 138 ---- .../todo/grib_accessor_class_divdouble.cc | 129 ---- .../todo/grib_accessor_class_double.cc | 201 ------ .../todo/grib_accessor_class_evaluate.cc | 118 --- ...ib_accessor_class_g1_half_byte_codeflag.cc | 150 ---- .../grib_accessor_class_g1_section4_length.cc | 143 ---- .../todo/grib_accessor_class_g1bitmap.cc | 206 ------ ...b_accessor_class_g1day_of_the_year_date.cc | 152 ---- ...ccessor_class_g1end_of_interval_monthly.cc | 234 ------ .../todo/grib_accessor_class_g1fcperiod.cc | 134 ---- .../todo/grib_accessor_class_g1monthlydate.cc | 132 ---- ...ass_g1number_of_coded_values_sh_complex.cc | 183 ----- ...lass_g1number_of_coded_values_sh_simple.cc | 158 ---- .../grib_accessor_class_g1verificationdate.cc | 154 ---- .../todo/grib_accessor_class_g2_aerosol.cc | 210 ------ .../todo/grib_accessor_class_g2bitmap.cc | 178 ----- .../grib_accessor_class_g2bitmap_present.cc | 150 ---- .../todo/grib_accessor_class_g2date.cc | 175 ----- .../todo/grib_accessor_class_g2latlon.cc | 215 ------ .../todo/grib_accessor_class_g2lon.cc | 149 ---- .../grib_accessor_class_gaussian_grid_name.cc | 176 ----- .../grib_accessor_class_gds_is_present.cc | 183 ----- ...b_accessor_class_gds_not_present_bitmap.cc | 216 ------ src/accessor/todo/grib_accessor_class_gen.cc | 675 ------------------ .../todo/grib_accessor_class_getenv.cc | 157 ---- .../todo/grib_accessor_class_group.cc | 272 ------- .../todo/grib_accessor_class_gts_header.cc | 152 ---- .../todo/grib_accessor_class_hash_array.cc | 293 -------- .../todo/grib_accessor_class_headers_only.cc | 116 --- .../todo/grib_accessor_class_ibmfloat.cc | 264 ------- .../todo/grib_accessor_class_ieeefloat.cc | 226 ------ .../todo/grib_accessor_class_ifs_param.cc | 188 ----- .../todo/grib_accessor_class_julian_day.cc | 209 ------ .../todo/grib_accessor_class_ksec1expver.cc | 185 ----- .../todo/grib_accessor_class_label.cc | 125 ---- .../todo/grib_accessor_class_latlonvalues.cc | 164 ----- .../grib_accessor_class_library_version.cc | 130 ---- .../todo/grib_accessor_class_long_vector.cc | 208 ------ .../todo/grib_accessor_class_lookup.cc | 242 ------- .../todo/grib_accessor_class_mars_param.cc | 144 ---- .../todo/grib_accessor_class_mars_step.cc | 218 ------ .../todo/grib_accessor_class_message.cc | 166 ----- .../todo/grib_accessor_class_message_copy.cc | 151 ---- .../todo/grib_accessor_class_multdouble.cc | 127 ---- .../todo/grib_accessor_class_non_alpha.cc | 215 ------ ...b_accessor_class_number_of_coded_values.cc | 162 ----- .../grib_accessor_class_number_of_points.cc | 174 ----- .../grib_accessor_class_number_of_values.cc | 165 ----- ...class_number_of_values_data_raw_packing.cc | 165 ----- ...grib_accessor_class_octahedral_gaussian.cc | 216 ------ .../todo/grib_accessor_class_octet_number.cc | 136 ---- .../todo/grib_accessor_class_offset_file.cc | 141 ---- .../todo/grib_accessor_class_offset_values.cc | 175 ----- .../grib_accessor_class_pack_bufr_values.cc | 177 ----- .../todo/grib_accessor_class_packing_type.cc | 167 ----- src/accessor/todo/grib_accessor_class_pad.cc | 126 ---- .../todo/grib_accessor_class_padding.cc | 151 ---- .../todo/grib_accessor_class_padto.cc | 136 ---- .../todo/grib_accessor_class_padtoeven.cc | 139 ---- .../todo/grib_accessor_class_padtomultiple.cc | 132 ---- .../todo/grib_accessor_class_position.cc | 137 ---- src/accessor/todo/grib_accessor_class_raw.cc | 219 ------ .../grib_accessor_class_rdbtime_guess_date.cc | 172 ----- ...ib_accessor_class_reference_value_error.cc | 142 ---- .../todo/grib_accessor_class_round.cc | 154 ---- .../todo/grib_accessor_class_scale.cc | 237 ------ .../todo/grib_accessor_class_scale_values.cc | 177 ----- .../todo/grib_accessor_class_section.cc | 194 ----- .../grib_accessor_class_section_length.cc | 122 ---- .../grib_accessor_class_section_padding.cc | 155 ---- .../grib_accessor_class_section_pointer.cc | 194 ----- ...grib_accessor_class_sexagesimal2decimal.cc | 241 ------- .../todo/grib_accessor_class_signed_bits.cc | 258 ------- ...rib_accessor_class_simple_packing_error.cc | 163 ----- src/accessor/todo/grib_accessor_class_size.cc | 119 --- .../grib_accessor_class_smart_table_column.cc | 294 -------- src/accessor/todo/grib_accessor_class_spd.cc | 264 ------- ...grib_accessor_class_spectral_truncation.cc | 177 ----- ...grib_accessor_class_statistics_spectral.cc | 277 ------- ...grib_accessor_class_step_human_readable.cc | 169 ----- src/accessor/todo/grib_accessor_class_sum.cc | 203 ------ .../todo/grib_accessor_class_suppressed.cc | 162 ----- src/accessor/todo/grib_accessor_class_time.cc | 208 ------ .../todo/grib_accessor_class_to_double.cc | 241 ------- .../todo/grib_accessor_class_to_integer.cc | 245 ------- .../todo/grib_accessor_class_to_string.cc | 227 ------ .../grib_accessor_class_transient_darray.cc | 214 ------ src/accessor/todo/grib_accessor_class_trim.cc | 170 ----- .../todo/grib_accessor_class_uint16.cc | 118 --- .../todo/grib_accessor_class_uint32.cc | 118 --- ...rib_accessor_class_uint32_little_endian.cc | 118 --- .../todo/grib_accessor_class_uint64.cc | 134 ---- ...rib_accessor_class_uint64_little_endian.cc | 134 ---- .../todo/grib_accessor_class_uint8.cc | 120 ---- ...b_accessor_class_unexpanded_descriptors.cc | 236 ------ .../grib_accessor_class_unpack_bufr_values.cc | 207 ------ .../todo/grib_accessor_class_unsigned_bits.cc | 265 ------- .../todo/grib_accessor_class_validity_date.cc | 229 ------ .../todo/grib_accessor_class_validity_time.cc | 249 ------- .../todo/grib_accessor_class_values.cc | 259 ------- .../todo/grib_accessor_class_vector.cc | 162 ----- src/accessor/todo/grib_accessor_class_when.cc | 122 ---- src/eccodes_prototypes.h | 7 - src/grib_accessor_class.h | 392 +++++----- src/grib_accessor_classes_hash.cc | 597 ++++++++++++++-- src/grib_accessor_factory.h | 390 +++++----- src/grib_accessor_factory_hash_list | 390 +++++----- src/shared_functions.cc | 47 ++ src/shared_functions.h | 9 + 532 files changed, 21431 insertions(+), 34120 deletions(-) create mode 100644 src/accessor/grib_accessor_class_abstract_long_vector.cc create mode 100644 src/accessor/grib_accessor_class_abstract_long_vector.h create mode 100644 src/accessor/grib_accessor_class_abstract_vector.cc create mode 100644 src/accessor/grib_accessor_class_abstract_vector.h create mode 100644 src/accessor/grib_accessor_class_ascii.cc create mode 100644 src/accessor/grib_accessor_class_ascii.h create mode 100644 src/accessor/grib_accessor_class_bit.cc create mode 100644 src/accessor/grib_accessor_class_bit.h create mode 100644 src/accessor/grib_accessor_class_bitmap.cc create mode 100644 src/accessor/grib_accessor_class_bitmap.h rename src/accessor/{todo => }/grib_accessor_class_bits.cc (51%) create mode 100644 src/accessor/grib_accessor_class_bits.h create mode 100644 src/accessor/grib_accessor_class_bits_per_value.cc create mode 100644 src/accessor/grib_accessor_class_bits_per_value.h create mode 100644 src/accessor/grib_accessor_class_blob.cc create mode 100644 src/accessor/grib_accessor_class_blob.h create mode 100644 src/accessor/grib_accessor_class_budgdate.cc create mode 100644 src/accessor/grib_accessor_class_budgdate.h rename src/accessor/{todo => }/grib_accessor_class_bufr_data_array.cc (87%) create mode 100644 src/accessor/grib_accessor_class_bufr_data_array.h rename src/accessor/{todo => }/grib_accessor_class_bufr_data_element.cc (68%) create mode 100644 src/accessor/grib_accessor_class_bufr_data_element.h rename src/accessor/{todo => }/grib_accessor_class_bufr_elements_table.cc (68%) create mode 100644 src/accessor/grib_accessor_class_bufr_elements_table.h rename src/accessor/{todo => }/grib_accessor_class_bufr_extract_area_subsets.cc (57%) create mode 100644 src/accessor/grib_accessor_class_bufr_extract_area_subsets.h rename src/accessor/{todo => }/grib_accessor_class_bufr_extract_datetime_subsets.cc (76%) create mode 100644 src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h create mode 100644 src/accessor/grib_accessor_class_bufr_extract_subsets.cc create mode 100644 src/accessor/grib_accessor_class_bufr_extract_subsets.h create mode 100644 src/accessor/grib_accessor_class_bufr_group.cc create mode 100644 src/accessor/grib_accessor_class_bufr_group.h create mode 100644 src/accessor/grib_accessor_class_bufr_simple_thinning.cc create mode 100644 src/accessor/grib_accessor_class_bufr_simple_thinning.h create mode 100644 src/accessor/grib_accessor_class_bufr_string_values.cc create mode 100644 src/accessor/grib_accessor_class_bufr_string_values.h create mode 100644 src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc create mode 100644 src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h create mode 100644 src/accessor/grib_accessor_class_bytes.cc create mode 100644 src/accessor/grib_accessor_class_bytes.h create mode 100644 src/accessor/grib_accessor_class_change_alternative_row_scanning.cc create mode 100644 src/accessor/grib_accessor_class_change_alternative_row_scanning.h rename src/accessor/{todo => }/grib_accessor_class_change_scanning_direction.cc (57%) create mode 100644 src/accessor/grib_accessor_class_change_scanning_direction.h create mode 100644 src/accessor/grib_accessor_class_check_internal_version.cc create mode 100644 src/accessor/grib_accessor_class_check_internal_version.h rename src/accessor/{todo => }/grib_accessor_class_closest_date.cc (57%) create mode 100644 src/accessor/grib_accessor_class_closest_date.h create mode 100644 src/accessor/grib_accessor_class_codeflag.cc create mode 100644 src/accessor/grib_accessor_class_codeflag.h create mode 100644 src/accessor/grib_accessor_class_codetable_title.cc create mode 100644 src/accessor/grib_accessor_class_codetable_title.h create mode 100644 src/accessor/grib_accessor_class_codetable_units.cc create mode 100644 src/accessor/grib_accessor_class_codetable_units.h rename src/accessor/{todo => }/grib_accessor_class_concept.cc (71%) create mode 100644 src/accessor/grib_accessor_class_concept.h create mode 100644 src/accessor/grib_accessor_class_count_file.cc create mode 100644 src/accessor/grib_accessor_class_count_file.h rename src/accessor/{todo => }/grib_accessor_class_count_missing.cc (55%) create mode 100644 src/accessor/grib_accessor_class_count_missing.h create mode 100644 src/accessor/grib_accessor_class_count_total.cc create mode 100644 src/accessor/grib_accessor_class_count_total.h rename src/accessor/{todo => }/grib_accessor_class_data_apply_bitmap.cc (64%) create mode 100644 src/accessor/grib_accessor_class_data_apply_bitmap.h rename src/accessor/{todo => }/grib_accessor_class_data_apply_boustrophedonic.cc (61%) create mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic.h rename src/accessor/{todo => }/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc (69%) create mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h rename src/accessor/{todo => }/grib_accessor_class_data_ccsds_packing.cc (77%) create mode 100644 src/accessor/grib_accessor_class_data_ccsds_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_complex_packing.cc (82%) create mode 100644 src/accessor/grib_accessor_class_data_complex_packing.h create mode 100644 src/accessor/grib_accessor_class_data_dummy_field.cc create mode 100644 src/accessor/grib_accessor_class_data_dummy_field.h create mode 100644 src/accessor/grib_accessor_class_data_g1complex_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_g1complex_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g1second_order_constant_width_packing.cc (58%) create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g1second_order_general_extended_packing.cc (85%) create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g1second_order_general_packing.cc (55%) create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g1second_order_row_by_row_packing.cc (64%) create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h create mode 100644 src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc create mode 100644 src/accessor/grib_accessor_class_data_g1secondary_bitmap.h create mode 100644 src/accessor/grib_accessor_class_data_g1shsimple_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_g1shsimple_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g1simple_packing.cc (64%) create mode 100644 src/accessor/grib_accessor_class_data_g1simple_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g22order_packing.cc (88%) create mode 100644 src/accessor/grib_accessor_class_data_g22order_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g2bifourier_packing.cc (77%) create mode 100644 src/accessor/grib_accessor_class_data_g2bifourier_packing.h create mode 100644 src/accessor/grib_accessor_class_data_g2complex_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_g2complex_packing.h create mode 100644 src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc create mode 100644 src/accessor/grib_accessor_class_data_g2secondary_bitmap.h create mode 100644 src/accessor/grib_accessor_class_data_g2shsimple_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_g2shsimple_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_g2simple_packing.cc (51%) create mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing.h create mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc create mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h rename src/accessor/{todo => }/grib_accessor_class_data_jpeg2000_packing.cc (73%) create mode 100644 src/accessor/grib_accessor_class_data_jpeg2000_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_png_packing.cc (75%) create mode 100644 src/accessor/grib_accessor_class_data_png_packing.h create mode 100644 src/accessor/grib_accessor_class_data_raw_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_raw_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_run_length_packing.cc (73%) create mode 100644 src/accessor/grib_accessor_class_data_run_length_packing.h create mode 100644 src/accessor/grib_accessor_class_data_secondary_bitmap.cc create mode 100644 src/accessor/grib_accessor_class_data_secondary_bitmap.h rename src/accessor/{todo => }/grib_accessor_class_data_sh_packed.cc (63%) create mode 100644 src/accessor/grib_accessor_class_data_sh_packed.h rename src/accessor/{todo => }/grib_accessor_class_data_sh_unpacked.cc (61%) create mode 100644 src/accessor/grib_accessor_class_data_sh_unpacked.h create mode 100644 src/accessor/grib_accessor_class_data_shsimple_packing.cc create mode 100644 src/accessor/grib_accessor_class_data_shsimple_packing.h rename src/accessor/{todo => }/grib_accessor_class_data_simple_packing.cc (79%) create mode 100644 src/accessor/grib_accessor_class_data_simple_packing.h create mode 100644 src/accessor/grib_accessor_class_decimal_precision.cc create mode 100644 src/accessor/grib_accessor_class_decimal_precision.h rename src/accessor/{todo => }/grib_accessor_class_dictionary.cc (62%) create mode 100644 src/accessor/grib_accessor_class_dictionary.h create mode 100644 src/accessor/grib_accessor_class_dirty.cc create mode 100644 src/accessor/grib_accessor_class_dirty.h create mode 100644 src/accessor/grib_accessor_class_divdouble.cc create mode 100644 src/accessor/grib_accessor_class_divdouble.h create mode 100644 src/accessor/grib_accessor_class_double.cc create mode 100644 src/accessor/grib_accessor_class_double.h rename src/accessor/{todo => }/grib_accessor_class_element.cc (55%) create mode 100644 src/accessor/grib_accessor_class_element.h create mode 100644 src/accessor/grib_accessor_class_evaluate.cc create mode 100644 src/accessor/grib_accessor_class_evaluate.h rename src/accessor/{todo => }/grib_accessor_class_expanded_descriptors.cc (80%) create mode 100644 src/accessor/grib_accessor_class_expanded_descriptors.h rename src/accessor/{todo => }/grib_accessor_class_from_scale_factor_scaled_value.cc (59%) create mode 100644 src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h create mode 100644 src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc create mode 100644 src/accessor/grib_accessor_class_g1_half_byte_codeflag.h rename src/accessor/{todo => }/grib_accessor_class_g1_message_length.cc (53%) create mode 100644 src/accessor/grib_accessor_class_g1_message_length.h create mode 100644 src/accessor/grib_accessor_class_g1_section4_length.cc create mode 100644 src/accessor/grib_accessor_class_g1_section4_length.h create mode 100644 src/accessor/grib_accessor_class_g1bitmap.cc create mode 100644 src/accessor/grib_accessor_class_g1bitmap.h rename src/accessor/{todo => }/grib_accessor_class_g1date.cc (51%) create mode 100644 src/accessor/grib_accessor_class_g1date.h create mode 100644 src/accessor/grib_accessor_class_g1day_of_the_year_date.cc create mode 100644 src/accessor/grib_accessor_class_g1day_of_the_year_date.h create mode 100644 src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc create mode 100644 src/accessor/grib_accessor_class_g1end_of_interval_monthly.h create mode 100644 src/accessor/grib_accessor_class_g1fcperiod.cc create mode 100644 src/accessor/grib_accessor_class_g1fcperiod.h rename src/accessor/{todo => }/grib_accessor_class_g1forecastmonth.cc (58%) create mode 100644 src/accessor/grib_accessor_class_g1forecastmonth.h create mode 100644 src/accessor/grib_accessor_class_g1monthlydate.cc create mode 100644 src/accessor/grib_accessor_class_g1monthlydate.h create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h rename src/accessor/{todo => }/grib_accessor_class_g1step_range.cc (79%) create mode 100644 src/accessor/grib_accessor_class_g1step_range.h create mode 100644 src/accessor/grib_accessor_class_g1verificationdate.cc create mode 100644 src/accessor/grib_accessor_class_g1verificationdate.h create mode 100644 src/accessor/grib_accessor_class_g2_aerosol.cc create mode 100644 src/accessor/grib_accessor_class_g2_aerosol.h rename src/accessor/{todo => }/grib_accessor_class_g2_chemical.cc (54%) create mode 100644 src/accessor/grib_accessor_class_g2_chemical.h rename src/accessor/{todo => }/grib_accessor_class_g2_eps.cc (58%) create mode 100644 src/accessor/grib_accessor_class_g2_eps.h rename src/accessor/{todo => }/grib_accessor_class_g2_mars_labeling.cc (75%) create mode 100644 src/accessor/grib_accessor_class_g2_mars_labeling.h create mode 100644 src/accessor/grib_accessor_class_g2bitmap.cc create mode 100644 src/accessor/grib_accessor_class_g2bitmap.h create mode 100644 src/accessor/grib_accessor_class_g2bitmap_present.cc create mode 100644 src/accessor/grib_accessor_class_g2bitmap_present.h create mode 100644 src/accessor/grib_accessor_class_g2date.cc create mode 100644 src/accessor/grib_accessor_class_g2date.h rename src/accessor/{todo => }/grib_accessor_class_g2end_step.cc (76%) create mode 100644 src/accessor/grib_accessor_class_g2end_step.h rename src/accessor/{todo => }/grib_accessor_class_g2grid.cc (58%) create mode 100644 src/accessor/grib_accessor_class_g2grid.h create mode 100644 src/accessor/grib_accessor_class_g2latlon.cc create mode 100644 src/accessor/grib_accessor_class_g2latlon.h rename src/accessor/{todo => }/grib_accessor_class_g2level.cc (66%) create mode 100644 src/accessor/grib_accessor_class_g2level.h create mode 100644 src/accessor/grib_accessor_class_g2lon.cc create mode 100644 src/accessor/grib_accessor_class_g2lon.h rename src/accessor/{todo => }/grib_accessor_class_g2step_range.cc (64%) create mode 100644 src/accessor/grib_accessor_class_g2step_range.h create mode 100644 src/accessor/grib_accessor_class_gaussian_grid_name.cc create mode 100644 src/accessor/grib_accessor_class_gaussian_grid_name.h create mode 100644 src/accessor/grib_accessor_class_gds_is_present.cc create mode 100644 src/accessor/grib_accessor_class_gds_is_present.h create mode 100644 src/accessor/grib_accessor_class_gds_not_present_bitmap.cc create mode 100644 src/accessor/grib_accessor_class_gds_not_present_bitmap.h create mode 100644 src/accessor/grib_accessor_class_getenv.cc create mode 100644 src/accessor/grib_accessor_class_getenv.h rename src/accessor/{todo => }/grib_accessor_class_global_gaussian.cc (64%) create mode 100644 src/accessor/grib_accessor_class_global_gaussian.h create mode 100644 src/accessor/grib_accessor_class_group.cc create mode 100644 src/accessor/grib_accessor_class_group.h create mode 100644 src/accessor/grib_accessor_class_gts_header.cc create mode 100644 src/accessor/grib_accessor_class_gts_header.h create mode 100644 src/accessor/grib_accessor_class_hash_array.cc create mode 100644 src/accessor/grib_accessor_class_hash_array.h create mode 100644 src/accessor/grib_accessor_class_headers_only.cc create mode 100644 src/accessor/grib_accessor_class_headers_only.h create mode 100644 src/accessor/grib_accessor_class_ibmfloat.cc create mode 100644 src/accessor/grib_accessor_class_ibmfloat.h create mode 100644 src/accessor/grib_accessor_class_ieeefloat.cc create mode 100644 src/accessor/grib_accessor_class_ieeefloat.h create mode 100644 src/accessor/grib_accessor_class_ifs_param.cc create mode 100644 src/accessor/grib_accessor_class_ifs_param.h rename src/accessor/{todo => }/grib_accessor_class_julian_date.cc (66%) create mode 100644 src/accessor/grib_accessor_class_julian_date.h create mode 100644 src/accessor/grib_accessor_class_julian_day.cc create mode 100644 src/accessor/grib_accessor_class_julian_day.h create mode 100644 src/accessor/grib_accessor_class_ksec1expver.cc create mode 100644 src/accessor/grib_accessor_class_ksec1expver.h create mode 100644 src/accessor/grib_accessor_class_label.cc create mode 100644 src/accessor/grib_accessor_class_label.h rename src/accessor/{todo => }/grib_accessor_class_latitudes.cc (59%) create mode 100644 src/accessor/grib_accessor_class_latitudes.h rename src/accessor/{todo => }/grib_accessor_class_latlon_increment.cc (61%) create mode 100644 src/accessor/grib_accessor_class_latlon_increment.h create mode 100644 src/accessor/grib_accessor_class_latlonvalues.cc create mode 100644 src/accessor/grib_accessor_class_latlonvalues.h create mode 100644 src/accessor/grib_accessor_class_library_version.cc create mode 100644 src/accessor/grib_accessor_class_library_version.h rename src/accessor/{todo => }/grib_accessor_class_local_definition.cc (72%) create mode 100644 src/accessor/grib_accessor_class_local_definition.h create mode 100644 src/accessor/grib_accessor_class_long_vector.cc create mode 100644 src/accessor/grib_accessor_class_long_vector.h rename src/accessor/{todo => }/grib_accessor_class_longitudes.cc (56%) create mode 100644 src/accessor/grib_accessor_class_longitudes.h create mode 100644 src/accessor/grib_accessor_class_lookup.cc create mode 100644 src/accessor/grib_accessor_class_lookup.h create mode 100644 src/accessor/grib_accessor_class_mars_param.cc create mode 100644 src/accessor/grib_accessor_class_mars_param.h create mode 100644 src/accessor/grib_accessor_class_mars_step.cc create mode 100644 src/accessor/grib_accessor_class_mars_step.h rename src/accessor/{todo => }/grib_accessor_class_md5.cc (51%) create mode 100644 src/accessor/grib_accessor_class_md5.h create mode 100644 src/accessor/grib_accessor_class_message.cc create mode 100644 src/accessor/grib_accessor_class_message.h create mode 100644 src/accessor/grib_accessor_class_message_copy.cc create mode 100644 src/accessor/grib_accessor_class_message_copy.h create mode 100644 src/accessor/grib_accessor_class_multdouble.cc create mode 100644 src/accessor/grib_accessor_class_multdouble.h create mode 100644 src/accessor/grib_accessor_class_non_alpha.cc create mode 100644 src/accessor/grib_accessor_class_non_alpha.h create mode 100644 src/accessor/grib_accessor_class_number_of_coded_values.cc create mode 100644 src/accessor/grib_accessor_class_number_of_coded_values.h create mode 100644 src/accessor/grib_accessor_class_number_of_points.cc create mode 100644 src/accessor/grib_accessor_class_number_of_points.h rename src/accessor/{todo => }/grib_accessor_class_number_of_points_gaussian.cc (72%) create mode 100644 src/accessor/grib_accessor_class_number_of_points_gaussian.h create mode 100644 src/accessor/grib_accessor_class_number_of_values.cc create mode 100644 src/accessor/grib_accessor_class_number_of_values.h create mode 100644 src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc create mode 100644 src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h create mode 100644 src/accessor/grib_accessor_class_octahedral_gaussian.cc create mode 100644 src/accessor/grib_accessor_class_octahedral_gaussian.h create mode 100644 src/accessor/grib_accessor_class_octet_number.cc create mode 100644 src/accessor/grib_accessor_class_octet_number.h create mode 100644 src/accessor/grib_accessor_class_offset_file.cc create mode 100644 src/accessor/grib_accessor_class_offset_file.h create mode 100644 src/accessor/grib_accessor_class_offset_values.cc create mode 100644 src/accessor/grib_accessor_class_offset_values.h rename src/accessor/{todo => }/grib_accessor_class_optimal_step_units.cc (54%) create mode 100644 src/accessor/grib_accessor_class_optimal_step_units.h create mode 100644 src/accessor/grib_accessor_class_pack_bufr_values.cc create mode 100644 src/accessor/grib_accessor_class_pack_bufr_values.h create mode 100644 src/accessor/grib_accessor_class_packing_type.cc create mode 100644 src/accessor/grib_accessor_class_packing_type.h create mode 100644 src/accessor/grib_accessor_class_pad.cc create mode 100644 src/accessor/grib_accessor_class_pad.h create mode 100644 src/accessor/grib_accessor_class_padding.cc create mode 100644 src/accessor/grib_accessor_class_padding.h create mode 100644 src/accessor/grib_accessor_class_padto.cc create mode 100644 src/accessor/grib_accessor_class_padto.h create mode 100644 src/accessor/grib_accessor_class_padtoeven.cc create mode 100644 src/accessor/grib_accessor_class_padtoeven.h create mode 100644 src/accessor/grib_accessor_class_padtomultiple.cc create mode 100644 src/accessor/grib_accessor_class_padtomultiple.h create mode 100644 src/accessor/grib_accessor_class_position.cc create mode 100644 src/accessor/grib_accessor_class_position.h rename src/accessor/{todo => }/grib_accessor_class_proj_string.cc (67%) create mode 100644 src/accessor/grib_accessor_class_proj_string.h create mode 100644 src/accessor/grib_accessor_class_raw.cc create mode 100644 src/accessor/grib_accessor_class_raw.h create mode 100644 src/accessor/grib_accessor_class_rdbtime_guess_date.cc create mode 100644 src/accessor/grib_accessor_class_rdbtime_guess_date.h create mode 100644 src/accessor/grib_accessor_class_reference_value_error.cc create mode 100644 src/accessor/grib_accessor_class_reference_value_error.h create mode 100644 src/accessor/grib_accessor_class_round.cc create mode 100644 src/accessor/grib_accessor_class_round.h create mode 100644 src/accessor/grib_accessor_class_scale.cc create mode 100644 src/accessor/grib_accessor_class_scale.h create mode 100644 src/accessor/grib_accessor_class_scale_values.cc create mode 100644 src/accessor/grib_accessor_class_scale_values.h rename src/accessor/{todo => }/grib_accessor_class_second_order_bits_per_value.cc (51%) create mode 100644 src/accessor/grib_accessor_class_second_order_bits_per_value.h create mode 100644 src/accessor/grib_accessor_class_section.cc create mode 100644 src/accessor/grib_accessor_class_section.h create mode 100644 src/accessor/grib_accessor_class_section_length.cc create mode 100644 src/accessor/grib_accessor_class_section_length.h create mode 100644 src/accessor/grib_accessor_class_section_padding.cc create mode 100644 src/accessor/grib_accessor_class_section_padding.h create mode 100644 src/accessor/grib_accessor_class_section_pointer.cc create mode 100644 src/accessor/grib_accessor_class_section_pointer.h rename src/accessor/{todo => }/grib_accessor_class_select_step_template.cc (60%) create mode 100644 src/accessor/grib_accessor_class_select_step_template.h create mode 100644 src/accessor/grib_accessor_class_sexagesimal2decimal.cc create mode 100644 src/accessor/grib_accessor_class_sexagesimal2decimal.h rename src/accessor/{todo => }/grib_accessor_class_signed.cc (51%) create mode 100644 src/accessor/grib_accessor_class_signed.h create mode 100644 src/accessor/grib_accessor_class_signed_bits.cc create mode 100644 src/accessor/grib_accessor_class_signed_bits.h create mode 100644 src/accessor/grib_accessor_class_simple_packing_error.cc create mode 100644 src/accessor/grib_accessor_class_simple_packing_error.h create mode 100644 src/accessor/grib_accessor_class_size.cc create mode 100644 src/accessor/grib_accessor_class_size.h create mode 100644 src/accessor/grib_accessor_class_smart_table_column.cc create mode 100644 src/accessor/grib_accessor_class_smart_table_column.h create mode 100644 src/accessor/grib_accessor_class_spd.cc create mode 100644 src/accessor/grib_accessor_class_spd.h create mode 100644 src/accessor/grib_accessor_class_spectral_truncation.cc create mode 100644 src/accessor/grib_accessor_class_spectral_truncation.h rename src/accessor/{todo => }/grib_accessor_class_sprintf.cc (54%) create mode 100644 src/accessor/grib_accessor_class_sprintf.h rename src/accessor/{todo => }/grib_accessor_class_statistics.cc (55%) create mode 100644 src/accessor/grib_accessor_class_statistics.h create mode 100644 src/accessor/grib_accessor_class_statistics_spectral.cc create mode 100644 src/accessor/grib_accessor_class_statistics_spectral.h create mode 100644 src/accessor/grib_accessor_class_step_human_readable.cc create mode 100644 src/accessor/grib_accessor_class_step_human_readable.h rename src/accessor/{todo => }/grib_accessor_class_step_in_units.cc (63%) create mode 100644 src/accessor/grib_accessor_class_step_in_units.h create mode 100644 src/accessor/grib_accessor_class_sum.cc create mode 100644 src/accessor/grib_accessor_class_sum.h create mode 100644 src/accessor/grib_accessor_class_suppressed.cc create mode 100644 src/accessor/grib_accessor_class_suppressed.h create mode 100644 src/accessor/grib_accessor_class_time.cc create mode 100644 src/accessor/grib_accessor_class_time.h create mode 100644 src/accessor/grib_accessor_class_to_double.cc create mode 100644 src/accessor/grib_accessor_class_to_double.h create mode 100644 src/accessor/grib_accessor_class_to_integer.cc create mode 100644 src/accessor/grib_accessor_class_to_integer.h create mode 100644 src/accessor/grib_accessor_class_to_string.cc create mode 100644 src/accessor/grib_accessor_class_to_string.h create mode 100644 src/accessor/grib_accessor_class_transient_darray.cc create mode 100644 src/accessor/grib_accessor_class_transient_darray.h create mode 100644 src/accessor/grib_accessor_class_trim.cc create mode 100644 src/accessor/grib_accessor_class_trim.h create mode 100644 src/accessor/grib_accessor_class_uint16.cc create mode 100644 src/accessor/grib_accessor_class_uint16.h create mode 100644 src/accessor/grib_accessor_class_uint32.cc create mode 100644 src/accessor/grib_accessor_class_uint32.h create mode 100644 src/accessor/grib_accessor_class_uint32_little_endian.cc create mode 100644 src/accessor/grib_accessor_class_uint32_little_endian.h create mode 100644 src/accessor/grib_accessor_class_uint64.cc create mode 100644 src/accessor/grib_accessor_class_uint64.h create mode 100644 src/accessor/grib_accessor_class_uint64_little_endian.cc create mode 100644 src/accessor/grib_accessor_class_uint64_little_endian.h create mode 100644 src/accessor/grib_accessor_class_uint8.cc create mode 100644 src/accessor/grib_accessor_class_uint8.h create mode 100644 src/accessor/grib_accessor_class_unexpanded_descriptors.cc create mode 100644 src/accessor/grib_accessor_class_unexpanded_descriptors.h create mode 100644 src/accessor/grib_accessor_class_unpack_bufr_values.cc create mode 100644 src/accessor/grib_accessor_class_unpack_bufr_values.h create mode 100644 src/accessor/grib_accessor_class_unsigned_bits.cc create mode 100644 src/accessor/grib_accessor_class_unsigned_bits.h create mode 100644 src/accessor/grib_accessor_class_validity_date.cc create mode 100644 src/accessor/grib_accessor_class_validity_date.h create mode 100644 src/accessor/grib_accessor_class_validity_time.cc create mode 100644 src/accessor/grib_accessor_class_validity_time.h create mode 100644 src/accessor/grib_accessor_class_values.cc create mode 100644 src/accessor/grib_accessor_class_values.h create mode 100644 src/accessor/grib_accessor_class_vector.cc create mode 100644 src/accessor/grib_accessor_class_vector.h create mode 100644 src/accessor/grib_accessor_class_when.cc create mode 100644 src/accessor/grib_accessor_class_when.h delete mode 100644 src/accessor/todo/grib_accessor_class_abstract_long_vector.cc delete mode 100644 src/accessor/todo/grib_accessor_class_abstract_vector.cc delete mode 100644 src/accessor/todo/grib_accessor_class_ascii.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bit.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bits_per_value.cc delete mode 100644 src/accessor/todo/grib_accessor_class_blob.cc delete mode 100644 src/accessor/todo/grib_accessor_class_budgdate.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bufr_group.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bufr_string_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc delete mode 100644 src/accessor/todo/grib_accessor_class_bytes.cc delete mode 100644 src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc delete mode 100644 src/accessor/todo/grib_accessor_class_check_internal_version.cc delete mode 100644 src/accessor/todo/grib_accessor_class_codeflag.cc delete mode 100644 src/accessor/todo/grib_accessor_class_codetable_title.cc delete mode 100644 src/accessor/todo/grib_accessor_class_codetable_units.cc delete mode 100644 src/accessor/todo/grib_accessor_class_count_file.cc delete mode 100644 src/accessor/todo/grib_accessor_class_count_total.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_dummy_field.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_raw_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_secondary_bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_decimal_precision.cc delete mode 100644 src/accessor/todo/grib_accessor_class_dirty.cc delete mode 100644 src/accessor/todo/grib_accessor_class_divdouble.cc delete mode 100644 src/accessor/todo/grib_accessor_class_double.cc delete mode 100644 src/accessor/todo/grib_accessor_class_evaluate.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1_section4_length.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1fcperiod.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1monthlydate.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g1verificationdate.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2_aerosol.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2bitmap_present.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2date.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2latlon.cc delete mode 100644 src/accessor/todo/grib_accessor_class_g2lon.cc delete mode 100644 src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc delete mode 100644 src/accessor/todo/grib_accessor_class_gds_is_present.cc delete mode 100644 src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc delete mode 100644 src/accessor/todo/grib_accessor_class_gen.cc delete mode 100644 src/accessor/todo/grib_accessor_class_getenv.cc delete mode 100644 src/accessor/todo/grib_accessor_class_group.cc delete mode 100644 src/accessor/todo/grib_accessor_class_gts_header.cc delete mode 100644 src/accessor/todo/grib_accessor_class_hash_array.cc delete mode 100644 src/accessor/todo/grib_accessor_class_headers_only.cc delete mode 100644 src/accessor/todo/grib_accessor_class_ibmfloat.cc delete mode 100644 src/accessor/todo/grib_accessor_class_ieeefloat.cc delete mode 100644 src/accessor/todo/grib_accessor_class_ifs_param.cc delete mode 100644 src/accessor/todo/grib_accessor_class_julian_day.cc delete mode 100644 src/accessor/todo/grib_accessor_class_ksec1expver.cc delete mode 100644 src/accessor/todo/grib_accessor_class_label.cc delete mode 100644 src/accessor/todo/grib_accessor_class_latlonvalues.cc delete mode 100644 src/accessor/todo/grib_accessor_class_library_version.cc delete mode 100644 src/accessor/todo/grib_accessor_class_long_vector.cc delete mode 100644 src/accessor/todo/grib_accessor_class_lookup.cc delete mode 100644 src/accessor/todo/grib_accessor_class_mars_param.cc delete mode 100644 src/accessor/todo/grib_accessor_class_mars_step.cc delete mode 100644 src/accessor/todo/grib_accessor_class_message.cc delete mode 100644 src/accessor/todo/grib_accessor_class_message_copy.cc delete mode 100644 src/accessor/todo/grib_accessor_class_multdouble.cc delete mode 100644 src/accessor/todo/grib_accessor_class_non_alpha.cc delete mode 100644 src/accessor/todo/grib_accessor_class_number_of_coded_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_number_of_points.cc delete mode 100644 src/accessor/todo/grib_accessor_class_number_of_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc delete mode 100644 src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc delete mode 100644 src/accessor/todo/grib_accessor_class_octet_number.cc delete mode 100644 src/accessor/todo/grib_accessor_class_offset_file.cc delete mode 100644 src/accessor/todo/grib_accessor_class_offset_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_pack_bufr_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_packing_type.cc delete mode 100644 src/accessor/todo/grib_accessor_class_pad.cc delete mode 100644 src/accessor/todo/grib_accessor_class_padding.cc delete mode 100644 src/accessor/todo/grib_accessor_class_padto.cc delete mode 100644 src/accessor/todo/grib_accessor_class_padtoeven.cc delete mode 100644 src/accessor/todo/grib_accessor_class_padtomultiple.cc delete mode 100644 src/accessor/todo/grib_accessor_class_position.cc delete mode 100644 src/accessor/todo/grib_accessor_class_raw.cc delete mode 100644 src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc delete mode 100644 src/accessor/todo/grib_accessor_class_reference_value_error.cc delete mode 100644 src/accessor/todo/grib_accessor_class_round.cc delete mode 100644 src/accessor/todo/grib_accessor_class_scale.cc delete mode 100644 src/accessor/todo/grib_accessor_class_scale_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_section.cc delete mode 100644 src/accessor/todo/grib_accessor_class_section_length.cc delete mode 100644 src/accessor/todo/grib_accessor_class_section_padding.cc delete mode 100644 src/accessor/todo/grib_accessor_class_section_pointer.cc delete mode 100644 src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc delete mode 100644 src/accessor/todo/grib_accessor_class_signed_bits.cc delete mode 100644 src/accessor/todo/grib_accessor_class_simple_packing_error.cc delete mode 100644 src/accessor/todo/grib_accessor_class_size.cc delete mode 100644 src/accessor/todo/grib_accessor_class_smart_table_column.cc delete mode 100644 src/accessor/todo/grib_accessor_class_spd.cc delete mode 100644 src/accessor/todo/grib_accessor_class_spectral_truncation.cc delete mode 100644 src/accessor/todo/grib_accessor_class_statistics_spectral.cc delete mode 100644 src/accessor/todo/grib_accessor_class_step_human_readable.cc delete mode 100644 src/accessor/todo/grib_accessor_class_sum.cc delete mode 100644 src/accessor/todo/grib_accessor_class_suppressed.cc delete mode 100644 src/accessor/todo/grib_accessor_class_time.cc delete mode 100644 src/accessor/todo/grib_accessor_class_to_double.cc delete mode 100644 src/accessor/todo/grib_accessor_class_to_integer.cc delete mode 100644 src/accessor/todo/grib_accessor_class_to_string.cc delete mode 100644 src/accessor/todo/grib_accessor_class_transient_darray.cc delete mode 100644 src/accessor/todo/grib_accessor_class_trim.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint16.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint32.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint32_little_endian.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint64.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint64_little_endian.cc delete mode 100644 src/accessor/todo/grib_accessor_class_uint8.cc delete mode 100644 src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc delete mode 100644 src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_unsigned_bits.cc delete mode 100644 src/accessor/todo/grib_accessor_class_validity_date.cc delete mode 100644 src/accessor/todo/grib_accessor_class_validity_time.cc delete mode 100644 src/accessor/todo/grib_accessor_class_values.cc delete mode 100644 src/accessor/todo/grib_accessor_class_vector.cc delete mode 100644 src/accessor/todo/grib_accessor_class_when.cc create mode 100644 src/shared_functions.cc create mode 100644 src/shared_functions.h diff --git a/examples/C/grib_pthreads.c b/examples/C/grib_pthreads.c index d9b23344c..eab0a5e74 100644 --- a/examples/C/grib_pthreads.c +++ b/examples/C/grib_pthreads.c @@ -51,7 +51,7 @@ static void* process_grib(void* threadID) ProductKind prod_kind = 0; codes_handle* h = codes_grib_handle_new_from_samples(0, "regular_ll_pl_grib2"); - Assert(h); + Assert(h != NULL); CODES_CHECK(codes_get_product_kind(h, &prod_kind), 0); Assert(prod_kind == PRODUCT_GRIB); printf("Thread %ld running\n", tid); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53e2c3b1d..28e037c21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ list( APPEND eccodes_src_files accessor/grib_accessor.cc accessor/grib_accessors_list.cc grib_accessor_class.cc + shared_functions.cc step_unit.cc step.cc step_utilities.cc @@ -23,9 +24,9 @@ list( APPEND eccodes_src_files action_class_gen.cc action_class_if.cc action_class_switch.cc - #accessor/grib_accessor_class_g1fcperiod.cc - #accessor/grib_accessor_class_g1end_of_interval_monthly.cc - #accessor/grib_accessor_class_mars_param.cc + accessor/grib_accessor_class_g1fcperiod.cc + accessor/grib_accessor_class_g1end_of_interval_monthly.cc + accessor/grib_accessor_class_mars_param.cc action_class_section.cc action_class_list.cc action_class_while.cc @@ -63,207 +64,207 @@ list( APPEND eccodes_src_files grib_viarray.cc codes_memfs.cc accessor/grib_accessor_class_gen.cc - #accessor/grib_accessor_class_ascii.cc - #accessor/grib_accessor_class_bit.cc - #accessor/grib_accessor_class_bitmap.cc - #accessor/grib_accessor_class_bits.cc - #accessor/grib_accessor_class_bits_per_value.cc - #accessor/grib_accessor_class_bufr_elements_table.cc - #accessor/grib_accessor_class_bufr_data_array.cc - #accessor/grib_accessor_class_bufr_data_element.cc - #accessor/grib_accessor_class_bufr_group.cc - #accessor/grib_accessor_class_bufr_string_values.cc - #accessor/grib_accessor_class_pack_bufr_values.cc - #accessor/grib_accessor_class_unpack_bufr_values.cc - #accessor/grib_accessor_class_group.cc - #accessor/grib_accessor_class_non_alpha.cc - #accessor/grib_accessor_class_g1bitmap.cc - #accessor/grib_accessor_class_g2bitmap.cc - #accessor/grib_accessor_class_concept.cc - #accessor/grib_accessor_class_hash_array.cc - #accessor/grib_accessor_class_decimal_precision.cc - #accessor/grib_accessor_class_divdouble.cc - #accessor/grib_accessor_class_multdouble.cc - #accessor/grib_accessor_class_budgdate.cc - #accessor/grib_accessor_class_validity_date.cc - #accessor/grib_accessor_class_validity_time.cc - #accessor/grib_accessor_class_bytes.cc - #accessor/grib_accessor_class_change_alternative_row_scanning.cc - #accessor/grib_accessor_class_change_scanning_direction.cc - #accessor/grib_accessor_class_check_internal_version.cc - #accessor/grib_accessor_class_codeflag.cc + accessor/grib_accessor_class_ascii.cc + accessor/grib_accessor_class_bit.cc + accessor/grib_accessor_class_bitmap.cc + accessor/grib_accessor_class_bits.cc + accessor/grib_accessor_class_bits_per_value.cc + accessor/grib_accessor_class_bufr_elements_table.cc + accessor/grib_accessor_class_bufr_data_array.cc + accessor/grib_accessor_class_bufr_data_element.cc + accessor/grib_accessor_class_bufr_group.cc + accessor/grib_accessor_class_bufr_string_values.cc + accessor/grib_accessor_class_pack_bufr_values.cc + accessor/grib_accessor_class_unpack_bufr_values.cc + accessor/grib_accessor_class_group.cc + accessor/grib_accessor_class_non_alpha.cc + accessor/grib_accessor_class_g1bitmap.cc + accessor/grib_accessor_class_g2bitmap.cc + accessor/grib_accessor_class_concept.cc + accessor/grib_accessor_class_hash_array.cc + accessor/grib_accessor_class_decimal_precision.cc + accessor/grib_accessor_class_divdouble.cc + accessor/grib_accessor_class_multdouble.cc + accessor/grib_accessor_class_budgdate.cc + accessor/grib_accessor_class_validity_date.cc + accessor/grib_accessor_class_validity_time.cc + accessor/grib_accessor_class_bytes.cc + accessor/grib_accessor_class_change_alternative_row_scanning.cc + accessor/grib_accessor_class_change_scanning_direction.cc + accessor/grib_accessor_class_check_internal_version.cc + accessor/grib_accessor_class_codeflag.cc accessor/grib_accessor_class_smart_table.cc - #accessor/grib_accessor_class_smart_table_column.cc + accessor/grib_accessor_class_smart_table_column.cc accessor/grib_accessor_class_codetable.cc - #accessor/grib_accessor_class_codetable_units.cc - #accessor/grib_accessor_class_codetable_title.cc - #accessor/grib_accessor_class_step_human_readable.cc - #accessor/grib_accessor_class_count_file.cc - #accessor/grib_accessor_class_count_total.cc - #accessor/grib_accessor_class_double.cc - #accessor/grib_accessor_class_element.cc - #accessor/grib_accessor_class_evaluate.cc - #accessor/grib_accessor_class_g1date.cc - #accessor/grib_accessor_class_g1monthlydate.cc - #accessor/grib_accessor_class_library_version.cc - #accessor/grib_accessor_class_when.cc - #accessor/grib_accessor_class_g1verificationdate.cc - #accessor/grib_accessor_class_g1day_of_the_year_date.cc - #accessor/grib_accessor_class_g1_half_byte_codeflag.cc - #accessor/grib_accessor_class_g1forecastmonth.cc - #accessor/grib_accessor_class_g1step_range.cc - #accessor/grib_accessor_class_g2step_range.cc - #accessor/grib_accessor_class_data_g22order_packing.cc - #accessor/grib_accessor_class_mars_step.cc - #accessor/grib_accessor_class_message_copy.cc - #accessor/grib_accessor_class_dictionary.cc - #accessor/grib_accessor_class_latlon_increment.cc - #accessor/grib_accessor_class_g2date.cc - #accessor/grib_accessor_class_g2level.cc - #accessor/grib_accessor_class_g2end_step.cc - #accessor/grib_accessor_class_g2latlon.cc - #accessor/grib_accessor_class_g2lon.cc - #accessor/grib_accessor_class_global_gaussian.cc - #accessor/grib_accessor_class_gaussian_grid_name.cc - #accessor/grib_accessor_class_gen.cc - #accessor/grib_accessor_class_getenv.cc - #accessor/grib_accessor_class_gts_header.cc - #accessor/grib_accessor_class_ifs_param.cc - #accessor/grib_accessor_class_julian_day.cc - #accessor/grib_accessor_class_julian_date.cc - #accessor/grib_accessor_class_closest_date.cc - #accessor/grib_accessor_class_latlonvalues.cc - #accessor/grib_accessor_class_latitudes.cc - #accessor/grib_accessor_class_longitudes.cc - #accessor/grib_accessor_class_offset_file.cc - #accessor/grib_accessor_class_scale.cc - #accessor/grib_accessor_class_from_scale_factor_scaled_value.cc - #accessor/grib_accessor_class_g2bitmap_present.cc - #accessor/grib_accessor_class_ibmfloat.cc - #accessor/grib_accessor_class_ieeefloat.cc + accessor/grib_accessor_class_codetable_units.cc + accessor/grib_accessor_class_codetable_title.cc + accessor/grib_accessor_class_step_human_readable.cc + accessor/grib_accessor_class_count_file.cc + accessor/grib_accessor_class_count_total.cc + accessor/grib_accessor_class_double.cc + accessor/grib_accessor_class_element.cc + accessor/grib_accessor_class_evaluate.cc + accessor/grib_accessor_class_g1date.cc + accessor/grib_accessor_class_g1monthlydate.cc + accessor/grib_accessor_class_library_version.cc + accessor/grib_accessor_class_when.cc + accessor/grib_accessor_class_g1verificationdate.cc + accessor/grib_accessor_class_g1day_of_the_year_date.cc + accessor/grib_accessor_class_g1_half_byte_codeflag.cc + accessor/grib_accessor_class_g1forecastmonth.cc + accessor/grib_accessor_class_g1step_range.cc + accessor/grib_accessor_class_g2step_range.cc + accessor/grib_accessor_class_data_g22order_packing.cc + accessor/grib_accessor_class_mars_step.cc + accessor/grib_accessor_class_message_copy.cc + accessor/grib_accessor_class_dictionary.cc + accessor/grib_accessor_class_latlon_increment.cc + accessor/grib_accessor_class_g2date.cc + accessor/grib_accessor_class_g2level.cc + accessor/grib_accessor_class_g2end_step.cc + accessor/grib_accessor_class_g2latlon.cc + accessor/grib_accessor_class_g2lon.cc + accessor/grib_accessor_class_global_gaussian.cc + accessor/grib_accessor_class_gaussian_grid_name.cc + accessor/grib_accessor_class_gen.cc + accessor/grib_accessor_class_getenv.cc + accessor/grib_accessor_class_gts_header.cc + accessor/grib_accessor_class_ifs_param.cc + accessor/grib_accessor_class_julian_day.cc + accessor/grib_accessor_class_julian_date.cc + accessor/grib_accessor_class_closest_date.cc + accessor/grib_accessor_class_latlonvalues.cc + accessor/grib_accessor_class_latitudes.cc + accessor/grib_accessor_class_longitudes.cc + accessor/grib_accessor_class_offset_file.cc + accessor/grib_accessor_class_scale.cc + accessor/grib_accessor_class_from_scale_factor_scaled_value.cc + accessor/grib_accessor_class_g2bitmap_present.cc + accessor/grib_accessor_class_ibmfloat.cc + accessor/grib_accessor_class_ieeefloat.cc accessor/grib_accessor_class_constant.cc accessor/grib_accessor_class_iterator.cc - #accessor/grib_accessor_class_message.cc + accessor/grib_accessor_class_message.cc accessor/grib_accessor_class_nearest.cc - #accessor/grib_accessor_class_ksec1expver.cc - #accessor/grib_accessor_class_label.cc + accessor/grib_accessor_class_ksec1expver.cc + accessor/grib_accessor_class_label.cc accessor/grib_accessor_class_long.cc - #accessor/grib_accessor_class_lookup.cc - #accessor/grib_accessor_class_octahedral_gaussian.cc - #accessor/grib_accessor_class_octet_number.cc - #accessor/grib_accessor_class_headers_only.cc - #accessor/grib_accessor_class_padding.cc - #accessor/grib_accessor_class_pad.cc - #accessor/grib_accessor_class_padto.cc - #accessor/grib_accessor_class_padtoeven.cc - #accessor/grib_accessor_class_padtomultiple.cc - #accessor/grib_accessor_class_section_padding.cc - #accessor/grib_accessor_class_packing_type.cc - #accessor/grib_accessor_class_section_pointer.cc - #accessor/grib_accessor_class_position.cc - #accessor/grib_accessor_class_signed.cc - #accessor/grib_accessor_class_signed_bits.cc - #accessor/grib_accessor_class_section.cc - #accessor/grib_accessor_class_step_in_units.cc - #accessor/grib_accessor_class_optimal_step_units.cc - #accessor/grib_accessor_class_section_length.cc - #accessor/grib_accessor_class_g1_message_length.cc - #accessor/grib_accessor_class_g1_section4_length.cc - #accessor/grib_accessor_class_size.cc - #accessor/grib_accessor_class_rdbtime_guess_date.cc - #accessor/grib_accessor_class_scale_values.cc - #accessor/grib_accessor_class_offset_values.cc - #accessor/grib_accessor_class_sprintf.cc - #accessor/grib_accessor_class_round.cc - #accessor/grib_accessor_class_spectral_truncation.cc - #accessor/grib_accessor_class_time.cc + accessor/grib_accessor_class_lookup.cc + accessor/grib_accessor_class_octahedral_gaussian.cc + accessor/grib_accessor_class_octet_number.cc + accessor/grib_accessor_class_headers_only.cc + accessor/grib_accessor_class_padding.cc + accessor/grib_accessor_class_pad.cc + accessor/grib_accessor_class_padto.cc + accessor/grib_accessor_class_padtoeven.cc + accessor/grib_accessor_class_padtomultiple.cc + accessor/grib_accessor_class_section_padding.cc + accessor/grib_accessor_class_packing_type.cc + accessor/grib_accessor_class_section_pointer.cc + accessor/grib_accessor_class_position.cc + accessor/grib_accessor_class_signed.cc + accessor/grib_accessor_class_signed_bits.cc + accessor/grib_accessor_class_section.cc + accessor/grib_accessor_class_step_in_units.cc + accessor/grib_accessor_class_optimal_step_units.cc + accessor/grib_accessor_class_section_length.cc + accessor/grib_accessor_class_g1_message_length.cc + accessor/grib_accessor_class_g1_section4_length.cc + accessor/grib_accessor_class_size.cc + accessor/grib_accessor_class_rdbtime_guess_date.cc + accessor/grib_accessor_class_scale_values.cc + accessor/grib_accessor_class_offset_values.cc + accessor/grib_accessor_class_sprintf.cc + accessor/grib_accessor_class_round.cc + accessor/grib_accessor_class_spectral_truncation.cc + accessor/grib_accessor_class_time.cc accessor/grib_accessor_class_transient.cc - #accessor/grib_accessor_class_trim.cc - #accessor/grib_accessor_class_transient_darray.cc - #accessor/grib_accessor_class_values.cc - #accessor/grib_accessor_class_simple_packing_error.cc - #accessor/grib_accessor_class_data_simple_packing.cc - #accessor/grib_accessor_class_count_missing.cc - #accessor/grib_accessor_class_data_sh_packed.cc - #accessor/grib_accessor_class_data_sh_unpacked.cc - #accessor/grib_accessor_class_number_of_values_data_raw_packing.cc - #accessor/grib_accessor_class_data_g1simple_packing.cc - #accessor/grib_accessor_class_data_g1shsimple_packing.cc - #accessor/grib_accessor_class_data_shsimple_packing.cc - #accessor/grib_accessor_class_data_dummy_field.cc + accessor/grib_accessor_class_trim.cc + accessor/grib_accessor_class_transient_darray.cc + accessor/grib_accessor_class_values.cc + accessor/grib_accessor_class_simple_packing_error.cc + accessor/grib_accessor_class_data_simple_packing.cc + accessor/grib_accessor_class_count_missing.cc + accessor/grib_accessor_class_data_sh_packed.cc + accessor/grib_accessor_class_data_sh_unpacked.cc + accessor/grib_accessor_class_number_of_values_data_raw_packing.cc + accessor/grib_accessor_class_data_g1simple_packing.cc + accessor/grib_accessor_class_data_g1shsimple_packing.cc + accessor/grib_accessor_class_data_shsimple_packing.cc + accessor/grib_accessor_class_data_dummy_field.cc accessor/grib_accessor_class_variable.cc - #accessor/grib_accessor_class_second_order_bits_per_value.cc - #accessor/grib_accessor_class_data_g2simple_packing.cc - #accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc - #accessor/grib_accessor_class_data_g2shsimple_packing.cc - #accessor/grib_accessor_class_data_g2complex_packing.cc - #accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc - #accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc - #accessor/grib_accessor_class_data_g1second_order_general_packing.cc - #accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc - #accessor/grib_accessor_class_g2grid.cc - #accessor/grib_accessor_class_unexpanded_descriptors.cc - #accessor/grib_accessor_class_expanded_descriptors.cc - #accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc - #accessor/grib_accessor_class_data_apply_bitmap.cc - #accessor/grib_accessor_class_data_apply_boustrophedonic.cc - #accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc - #accessor/grib_accessor_class_data_secondary_bitmap.cc - #accessor/grib_accessor_class_data_g1secondary_bitmap.cc - #accessor/grib_accessor_class_data_g2secondary_bitmap.cc - #accessor/grib_accessor_class_data_jpeg2000_packing.cc - #accessor/grib_accessor_class_data_png_packing.cc - #accessor/grib_accessor_class_data_ccsds_packing.cc - #accessor/grib_accessor_class_data_raw_packing.cc - #accessor/grib_accessor_class_data_complex_packing.cc - #accessor/grib_accessor_class_data_g1complex_packing.cc - #accessor/grib_accessor_class_gds_not_present_bitmap.cc - #accessor/grib_accessor_class_gds_is_present.cc - #accessor/grib_accessor_class_select_step_template.cc - #accessor/grib_accessor_class_local_definition.cc - #accessor/grib_accessor_class_g2_eps.cc - #accessor/grib_accessor_class_g2_aerosol.cc - #accessor/grib_accessor_class_g2_chemical.cc - #accessor/grib_accessor_class_g2_mars_labeling.cc - #accessor/grib_accessor_class_md5.cc - #accessor/grib_accessor_class_proj_string.cc + accessor/grib_accessor_class_second_order_bits_per_value.cc + accessor/grib_accessor_class_data_g2simple_packing.cc + accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc + accessor/grib_accessor_class_data_g2shsimple_packing.cc + accessor/grib_accessor_class_data_g2complex_packing.cc + accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc + accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc + accessor/grib_accessor_class_data_g1second_order_general_packing.cc + accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc + accessor/grib_accessor_class_g2grid.cc + accessor/grib_accessor_class_unexpanded_descriptors.cc + accessor/grib_accessor_class_expanded_descriptors.cc + accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc + accessor/grib_accessor_class_data_apply_bitmap.cc + accessor/grib_accessor_class_data_apply_boustrophedonic.cc + accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc + accessor/grib_accessor_class_data_secondary_bitmap.cc + accessor/grib_accessor_class_data_g1secondary_bitmap.cc + accessor/grib_accessor_class_data_g2secondary_bitmap.cc + accessor/grib_accessor_class_data_jpeg2000_packing.cc + accessor/grib_accessor_class_data_png_packing.cc + accessor/grib_accessor_class_data_ccsds_packing.cc + accessor/grib_accessor_class_data_raw_packing.cc + accessor/grib_accessor_class_data_complex_packing.cc + accessor/grib_accessor_class_data_g1complex_packing.cc + accessor/grib_accessor_class_gds_not_present_bitmap.cc + accessor/grib_accessor_class_gds_is_present.cc + accessor/grib_accessor_class_select_step_template.cc + accessor/grib_accessor_class_local_definition.cc + accessor/grib_accessor_class_g2_eps.cc + accessor/grib_accessor_class_g2_aerosol.cc + accessor/grib_accessor_class_g2_chemical.cc + accessor/grib_accessor_class_g2_mars_labeling.cc + accessor/grib_accessor_class_md5.cc + accessor/grib_accessor_class_proj_string.cc grib_jasper_encoding.cc grib_openjpeg_encoding.cc action_class_set_missing.cc - #accessor/grib_accessor_class_number_of_points.cc - #accessor/grib_accessor_class_suppressed.cc + accessor/grib_accessor_class_number_of_points.cc + accessor/grib_accessor_class_suppressed.cc grib_index.cc - #accessor/grib_accessor_class_number_of_points_gaussian.cc - #accessor/grib_accessor_class_number_of_values.cc - #accessor/grib_accessor_class_number_of_coded_values.cc - #accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc - #accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc - #accessor/grib_accessor_class_dirty.cc - #accessor/grib_accessor_class_statistics.cc - #accessor/grib_accessor_class_statistics_spectral.cc + accessor/grib_accessor_class_number_of_points_gaussian.cc + accessor/grib_accessor_class_number_of_values.cc + accessor/grib_accessor_class_number_of_coded_values.cc + accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc + accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc + accessor/grib_accessor_class_dirty.cc + accessor/grib_accessor_class_statistics.cc + accessor/grib_accessor_class_statistics_spectral.cc accessor/grib_accessor_class_unsigned.cc - #accessor/grib_accessor_class_unsigned_bits.cc - #accessor/grib_accessor_class_raw.cc - #accessor/grib_accessor_class_bufr_simple_thinning.cc - #accessor/grib_accessor_class_bufr_extract_subsets.cc - #accessor/grib_accessor_class_bufr_extract_area_subsets.cc - #accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc - #accessor/grib_accessor_class_spd.cc - #accessor/grib_accessor_class_sum.cc - #accessor/grib_accessor_class_to_integer.cc - #accessor/grib_accessor_class_to_double.cc - #accessor/grib_accessor_class_to_string.cc - #accessor/grib_accessor_class_sexagesimal2decimal.cc - #accessor/grib_accessor_class_vector.cc - #accessor/grib_accessor_class_long_vector.cc + accessor/grib_accessor_class_unsigned_bits.cc + accessor/grib_accessor_class_raw.cc + accessor/grib_accessor_class_bufr_simple_thinning.cc + accessor/grib_accessor_class_bufr_extract_subsets.cc + accessor/grib_accessor_class_bufr_extract_area_subsets.cc + accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc + accessor/grib_accessor_class_spd.cc + accessor/grib_accessor_class_sum.cc + accessor/grib_accessor_class_to_integer.cc + accessor/grib_accessor_class_to_double.cc + accessor/grib_accessor_class_to_string.cc + accessor/grib_accessor_class_sexagesimal2decimal.cc + accessor/grib_accessor_class_vector.cc + accessor/grib_accessor_class_long_vector.cc grib_gaussian_reduced.cc - #accessor/grib_accessor_class_abstract_vector.cc - #accessor/grib_accessor_class_abstract_long_vector.cc + accessor/grib_accessor_class_abstract_vector.cc + accessor/grib_accessor_class_abstract_long_vector.cc grib_loader_from_handle.cc grib_bits.cc grib_ibmfloat.cc grib_ieeefloat.cc - #accessor/grib_accessor_class_reference_value_error.cc + accessor/grib_accessor_class_reference_value_error.cc grib_memory.cc grib_buffer.cc grib_dumper.cc @@ -366,16 +367,16 @@ list( APPEND eccodes_src_files grib_yacc.h md5.h md5.cc - #accessor/grib_accessor_class_uint16.cc - #accessor/grib_accessor_class_uint32.cc - #accessor/grib_accessor_class_uint32_little_endian.cc - #accessor/grib_accessor_class_uint64.cc - #accessor/grib_accessor_class_uint64_little_endian.cc - #accessor/grib_accessor_class_uint8.cc - #accessor/grib_accessor_class_blob.cc + accessor/grib_accessor_class_uint16.cc + accessor/grib_accessor_class_uint32.cc + accessor/grib_accessor_class_uint32_little_endian.cc + accessor/grib_accessor_class_uint64.cc + accessor/grib_accessor_class_uint64_little_endian.cc + accessor/grib_accessor_class_uint8.cc + accessor/grib_accessor_class_blob.cc grib_optimize_decimal_factor.cc - #accessor/grib_accessor_class_data_g2bifourier_packing.cc - #accessor/grib_accessor_class_data_run_length_packing.cc + accessor/grib_accessor_class_data_g2bifourier_packing.cc + accessor/grib_accessor_class_data_run_length_packing.cc eccodes_windef.h # We ship our own generated lex/yacc C files grib_yacc.cc grib_lex.cc ) diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.cc b/src/accessor/grib_accessor_class_abstract_long_vector.cc new file mode 100644 index 000000000..ad0740841 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_long_vector.cc @@ -0,0 +1,17 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_abstract_long_vector.h" + +grib_accessor_class_abstract_long_vector_t _grib_accessor_class_abstract_long_vector{"abstract_long_vector"}; +grib_accessor_class* grib_accessor_class_abstract_long_vector = &_grib_accessor_class_abstract_long_vector; + diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h b/src/accessor/grib_accessor_class_abstract_long_vector.h new file mode 100644 index 000000000..2961979d8 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_abstract_long_vector_h +#define eccodes_accessor_abstract_long_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t +{ +public: + /* Members defined in abstract_long_vector */ + long* v; + long pack_index; + int number_of_elements; +}; + +class grib_accessor_class_abstract_long_vector_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_abstract_long_vector_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; } +}; +#endif /* eccodes_accessor_abstract_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_abstract_vector.cc b/src/accessor/grib_accessor_class_abstract_vector.cc new file mode 100644 index 000000000..692e9c404 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_vector.cc @@ -0,0 +1,17 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +grib_accessor_class_abstract_vector_t _grib_accessor_class_abstract_vector{"abstract_vector"}; +grib_accessor_class* grib_accessor_class_abstract_vector = &_grib_accessor_class_abstract_vector; + diff --git a/src/accessor/grib_accessor_class_abstract_vector.h b/src/accessor/grib_accessor_class_abstract_vector.h new file mode 100644 index 000000000..df7e3fdbf --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_vector.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_abstract_vector_h +#define eccodes_accessor_abstract_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_abstract_vector_t : public grib_accessor_double_t +{ +public: + /* Members defined in abstract_vector */ + double* v; + int number_of_elements; +}; + +class grib_accessor_class_abstract_vector_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_abstract_vector_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; } +}; +#endif /* eccodes_accessor_abstract_vector_h */ diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc new file mode 100644 index 000000000..4fedc7c60 --- /dev/null +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -0,0 +1,164 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +grib_accessor_class_ascii_t _grib_accessor_class_ascii{"ascii"}; +grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; + + +void grib_accessor_class_ascii_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_ascii_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_ascii_t::string_length(grib_accessor* a){ + return a->length; +} + +void grib_accessor_class_ascii_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_ascii_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_ascii_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + size_t i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + const size_t alen = a->length; + + if (*len < (alen + 1)) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, alen+1, *len); + *len = alen + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < alen; i++) + val[i] = hand->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + size_t i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + const size_t alen = a->length; + if (len[0] > (alen + 1)) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "pack_string: Wrong size (%zu) for %s, it contains %ld values", len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < alen; i++) { + if (i < len[0]) + hand->buffer->data[a->offset + i] = val[i]; + else + hand->buffer->data[a->offset + i] = 0; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::pack_long(grib_accessor* a, const long* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as long (It's a string)", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::pack_double(grib_accessor* a, const double* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as double (It's a string)", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + + int err = a->unpack_string(val, &l); if (err) return err; + + *v = strtod(val, &last); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + + grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot unpack %s as double. Hint: Try unpacking as string", a->name); + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = 0; + char* aval = 0; + char* bval = 0; + int err = 0; + + size_t alen = a->length+1; + size_t blen = b->length+1; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); + bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); + + err = a->unpack_string(aval, &alen); if (err) return err; + err = b->unpack_string(bval, &blen); if (err) return err; + + retval = GRIB_SUCCESS; + if (!STR_EQUAL(aval, bval)) + retval = GRIB_STRING_VALUE_MISMATCH; + + grib_context_free(a->context, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_ascii.h b/src/accessor/grib_accessor_class_ascii.h new file mode 100644 index 000000000..cb8e68bd7 --- /dev/null +++ b/src/accessor/grib_accessor_class_ascii.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ascii_h +#define eccodes_accessor_ascii_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_ascii_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ascii */ +}; + +class grib_accessor_class_ascii_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ascii_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ascii_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_ascii_h */ diff --git a/src/accessor/grib_accessor_class_bit.cc b/src/accessor/grib_accessor_class_bit.cc new file mode 100644 index 000000000..2cf31bd48 --- /dev/null +++ b/src/accessor/grib_accessor_class_bit.cc @@ -0,0 +1,79 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bit.h" + +grib_accessor_class_bit_t _grib_accessor_class_bit{"bit"}; +grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; + + +void grib_accessor_class_bit_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + a->length = 0; + self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); +} + +int grib_accessor_class_bit_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + int ret = 0; + long data = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: unpack_long: Wrong size for %s, it contains %d values ", a->name, 1); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->owner, &data)) != GRIB_SUCCESS) { + *len = 0; + return ret; + } + + if (data & (1 << self->bit_index)) + *val = 1; + else + *val = 0; + + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: pack_long: At least one value to pack for %s", a->name); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + grib_accessor* owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner); + if (!owner) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: Cannot get the owner %s for computing the bit value of %s", + self->owner, a->name); + *len = 0; + return GRIB_NOT_FOUND; + } + + unsigned char* mdata = grib_handle_of_accessor(a)->buffer->data; + mdata += owner->byte_offset(); + /* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */ + if (a->context->debug) { + /* Print bit positions from 1 (MSB) */ + fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0) ); + } + grib_set_bit(mdata, 7 - self->bit_index, *val > 0); + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bit.h b/src/accessor/grib_accessor_class_bit.h new file mode 100644 index 000000000..3a9eee2d7 --- /dev/null +++ b/src/accessor/grib_accessor_class_bit.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bit_h +#define eccodes_accessor_bit_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bit_t : public grib_accessor_long_t +{ +public: + /* Members defined in bit */ + const char* owner; + int bit_index; +}; + +class grib_accessor_class_bit_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bit_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bit_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bit_h */ diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc new file mode 100644 index 000000000..eb45c4464 --- /dev/null +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -0,0 +1,175 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bitmap.h" + +grib_accessor_class_bitmap_t _grib_accessor_class_bitmap{"bitmap"}; +grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; + + + +void compute_size(grib_accessor* a){ + long slen = 0; + long off = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; + grib_get_long_internal(hand, self->offsetbsec, &off); + grib_get_long_internal(hand, self->sLength, &slen); + + if (slen == 0) { + grib_accessor* seclen; + size_t size; + /* Assume reparsing */ + Assert(hand->loader != 0); + if (hand->loader != 0) { + seclen = grib_find_accessor(hand, self->sLength); + Assert(seclen); + grib_get_block_length(seclen->parent, &size); + slen = size; + } + } + + // printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset); + + a->length = off + (slen - a->offset); + + if (a->length < 0) { + /* Assume reparsing */ + /*Assert(hand->loader != 0);*/ + a->length = 0; + } + + Assert(a->length >= 0); +} + +void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->tableReference = grib_arguments_get_name(hand, arg, n++); + self->missing_value = grib_arguments_get_name(hand, arg, n++); + self->offsetbsec = grib_arguments_get_name(hand, arg, n++); + self->sLength = grib_arguments_get_name(hand, arg, n++); + + compute_size(a); +} + +long grib_accessor_class_bitmap_t::next_offset(grib_accessor* a){ + return a->byte_offset() + a->byte_count();} + +void grib_accessor_class_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ + long len = 0; + char label[1024]; + + a->value_count(&len); + snprintf(label, 1024, "Bitmap of %ld values", len); + grib_dump_bytes(dumper, a, label); +} + +int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long pos = a->offset * 8; + long tlen = 0; + const grib_handle* hand = grib_handle_of_accessor(a); + + int err = a->value_count(&tlen); if (err) + return err; + + if (*len < tlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); + *len = tlen; + return GRIB_ARRAY_TOO_SMALL; + } + + for (long i = 0; i < tlen; i++) { + val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); + } + *len = tlen; + return GRIB_SUCCESS; +} + +template +int unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating points numbers"); + long pos = a->offset * 8; + long tlen; + grib_handle* hand = grib_handle_of_accessor(a); + + int err = a->value_count(&tlen); if (err) + return err; + + if (*len < tlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); + *len = tlen; + return GRIB_ARRAY_TOO_SMALL; + } + + for (long i = 0; i < tlen; i++) { + val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); + } + *len = tlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return unpack(a, val, len); +} + +int grib_accessor_class_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len){ + return unpack(a, val, len); +} + +int grib_accessor_class_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + long pos = a->offset * 8; + + pos += idx; + *val = (double)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, 1); + + return GRIB_SUCCESS; +} +int grib_accessor_class_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + for (size_t i=0; ilength = s; +} + +size_t grib_accessor_class_bitmap_t::string_length(grib_accessor* a){ + return a->length; +} + +int grib_accessor_class_bitmap_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_handle* hand = grib_handle_of_accessor(a); + const size_t l = a->length; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + for (long i = 0; i < a->length; i++) { + val[i] = hand->buffer->data[a->offset + i]; + } + + *len = a->length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bitmap.h b/src/accessor/grib_accessor_class_bitmap.h new file mode 100644 index 000000000..d9b3ab9df --- /dev/null +++ b/src/accessor/grib_accessor_class_bitmap.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bitmap_h +#define eccodes_accessor_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_bitmap_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in bitmap */ + const char* tableReference; + const char* missing_value; + const char* offsetbsec; + const char* sLength; +}; + +class grib_accessor_class_bitmap_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_bitmap_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bitmap_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_bitmap_h */ diff --git a/src/accessor/todo/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_bits.cc rename to src/accessor/grib_accessor_class_bits.cc index 5e86e2fef..b38de626c 100644 --- a/src/accessor/todo/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,127 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - #include "grib_api_internal.h" +#include "grib_accessor_class_bits.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = unpack_bytes; byte_count - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = unpack_string - IMPLEMENTS = init - MEMBERS=const char* argument - MEMBERS=long start - MEMBERS=long len - MEMBERS=double referenceValue - MEMBERS=double referenceValuePresent - MEMBERS=double scale - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bits */ - const char* argument; - long start; - long len; - double referenceValue; - double referenceValuePresent; - double scale; -} grib_accessor_bits; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bits = { - &grib_accessor_class_gen, /* super */ - "bits", /* name */ - sizeof(grib_accessor_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_bits_t _grib_accessor_class_bits{"bits"}; grib_accessor_class* grib_accessor_class_bits = &_grib_accessor_class_bits; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +void grib_accessor_class_bits_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_handle* hand = grib_handle_of_accessor(a); grib_expression* e = NULL; int n = 0; @@ -154,9 +43,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; unsigned char* p = NULL; grib_handle* h = grib_handle_of_accessor(a); @@ -173,17 +61,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - *val = grib_decode_unsigned_long(p, &start, length); + p = h->buffer->data + x->byte_offset(); *val = grib_decode_unsigned_long(p, &start, length); *len = 1; return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; unsigned char* p = NULL; grib_handle* h = grib_handle_of_accessor(a); @@ -200,8 +86,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - *val = grib_decode_unsigned_long(p, &start, length); + p = h->buffer->data + x->byte_offset(); *val = grib_decode_unsigned_long(p, &start, length); *val = ((long)*val + self->referenceValue) / self->scale; @@ -210,9 +95,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; grib_handle* h = grib_handle_of_accessor(a); unsigned char* p = NULL; @@ -228,15 +112,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - + p = h->buffer->data + x->byte_offset(); lval = round(*val * self->scale) - self->referenceValue; return grib_encode_unsigned_longb(p, lval, &start, length); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; grib_handle* h = grib_handle_of_accessor(a); unsigned char* p = NULL; @@ -285,14 +167,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_ENCODING_ERROR; } - p = h->buffer->data + grib_byte_offset(x); - return grib_encode_unsigned_longb(p, *val, &start, length); + p = h->buffer->data + x->byte_offset(); return grib_encode_unsigned_longb(p, *val, &start, length); } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bits_t::get_native_type(grib_accessor* a){ int type = GRIB_TYPE_BYTES; - grib_accessor_bits* self = (grib_accessor_bits*)a; + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) type = GRIB_TYPE_STRING; @@ -306,8 +186,7 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ +int grib_accessor_class_bits_t::unpack_string(grib_accessor* a, char* v, size_t* len){ int ret = 0; double dval = 0; long lval = 0; @@ -328,20 +207,17 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) break; default: - super = *(a->cclass->super); - ret = super->unpack_string(a, v, len); + ret = grib_accessor_class_gen_t::unpack_string(a, v, len); } return ret; } -static long byte_count(grib_accessor* a) -{ +long grib_accessor_class_bits_t::byte_count(grib_accessor* a){ grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); return a->length; } -static int unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) -{ +int grib_accessor_class_bits_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ if (*len < a->length) { *len = a->length; return GRIB_ARRAY_TOO_SMALL; diff --git a/src/accessor/grib_accessor_class_bits.h b/src/accessor/grib_accessor_class_bits.h new file mode 100644 index 000000000..b5dd2977b --- /dev/null +++ b/src/accessor/grib_accessor_class_bits.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bits_h +#define eccodes_accessor_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bits_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bits */ + const char* argument; + long start; + long len; + double referenceValue; + double referenceValuePresent; + double scale; +}; + +class grib_accessor_class_bits_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bits_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bits_h */ diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc new file mode 100644 index 000000000..b5d3698e0 --- /dev/null +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -0,0 +1,73 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bits_per_value.h" + +grib_accessor_class_bits_per_value_t _grib_accessor_class_bits_per_value{"bits_per_value"}; +grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_bits_per_value; + + +void grib_accessor_class_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* args){ + int n = 0; + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->bits_per_value, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + return ret; +} + +int grib_accessor_class_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + double* values = NULL; + size_t size = 0; + int ret = 0; + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->bits_per_value, *val)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bits_per_value.h b/src/accessor/grib_accessor_class_bits_per_value.h new file mode 100644 index 000000000..59514fc05 --- /dev/null +++ b/src/accessor/grib_accessor_class_bits_per_value.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bits_per_value_h +#define eccodes_accessor_bits_per_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in bits_per_value */ + const char* values; + const char* bits_per_value; +}; + +class grib_accessor_class_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc new file mode 100644 index 000000000..ddcfc9961 --- /dev/null +++ b/src/accessor/grib_accessor_class_blob.cc @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_blob.h" + +grib_accessor_class_blob_t _grib_accessor_class_blob{"blob"}; +grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; + + +void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); + Assert(a->length >= 0); +} + +int grib_accessor_class_blob_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ + if (*len < (size_t)a->length) { + *len = a->length; + return GRIB_ARRAY_TOO_SMALL; + } + *len = a->length; + + memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); + + return GRIB_SUCCESS; +} + +void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_bytes(dumper, a, NULL); +} diff --git a/src/accessor/grib_accessor_class_blob.h b/src/accessor/grib_accessor_class_blob.h new file mode 100644 index 000000000..a2da98a03 --- /dev/null +++ b/src/accessor/grib_accessor_class_blob.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_blob_h +#define eccodes_accessor_blob_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_blob_t : public grib_accessor_gen_t +{ +public: + /* Members defined in blob */ +}; + +class grib_accessor_class_blob_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_blob_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_blob_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_blob_h */ diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc new file mode 100644 index 000000000..1bfd6e7b9 --- /dev/null +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -0,0 +1,82 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_budgdate.h" + +grib_accessor_class_budgdate_t _grib_accessor_class_budgdate{"budgdate"}; +grib_accessor_class* grib_accessor_class_budgdate = &_grib_accessor_class_budgdate; + + +void grib_accessor_class_budgdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + int n = 0; + + self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_budgdate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + + long year = 0; + long month = 0; + long day = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + val[0] = (1900 + year) * 10000 + month * 100 + day; + + return ret; +} + +/* TODO: Check for a valid date */ +int grib_accessor_class_budgdate_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int ret = 0; + long v = val[0]; + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + + long year = 0; + long month = 0; + long day = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + year = v / 10000; + v %= 10000; + month = v / 100; + v %= 100; + day = v; + + year -= 1900; + + Assert(year < 255); + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) + return ret; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_budgdate.h b/src/accessor/grib_accessor_class_budgdate.h new file mode 100644 index 000000000..c3fc849c7 --- /dev/null +++ b/src/accessor/grib_accessor_class_budgdate.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_budgdate_h +#define eccodes_accessor_budgdate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_budgdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in budgdate */ + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_budgdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_budgdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_budgdate_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_budgdate_h */ diff --git a/src/accessor/todo/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc similarity index 87% rename from src/accessor/todo/grib_accessor_class_bufr_data_array.cc rename to src/accessor/grib_accessor_class_bufr_data_array.cc index 3d044835a..ea32d69c4 100644 --- a/src/accessor/todo/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -10,202 +11,11 @@ #include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_bufr_data_array.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = dump;destroy - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count; value_count - IMPLEMENTS = byte_offset; unpack_double - IMPLEMENTS = get_native_type - IMPLEMENTS = pack_long; unpack_double; pack_double - MEMBERS = const char* bufrDataEncodedName - MEMBERS = const char* numberOfSubsetsName - MEMBERS = const char* expandedDescriptorsName - MEMBERS = const char* flagsName - MEMBERS = const char* unitsName - MEMBERS = const char* elementsDescriptorsIndexName - MEMBERS = const char* compressedDataName - MEMBERS = bufr_descriptors_array* expanded - MEMBERS = grib_accessor* expandedAccessor - MEMBERS = int* canBeMissing - MEMBERS = long numberOfSubsets - MEMBERS = long compressedData - MEMBERS = grib_vdarray* numericValues - MEMBERS = grib_vsarray* stringValues - MEMBERS = grib_viarray* elementsDescriptorsIndex - MEMBERS = int do_decode - MEMBERS = int bitmapStartElementsDescriptorsIndex - MEMBERS = int bitmapCurrentElementsDescriptorsIndex - MEMBERS = int bitmapSize - MEMBERS = int bitmapStart - MEMBERS = int bitmapCurrent - MEMBERS = grib_accessors_list* dataAccessors - MEMBERS = int unpackMode - MEMBERS = int bitsToEndData - MEMBERS = grib_section* dataKeys - MEMBERS = double* inputBitmap - MEMBERS = int nInputBitmap - MEMBERS = int iInputBitmap - MEMBERS = long* inputReplications - MEMBERS = int nInputReplications - MEMBERS = int iInputReplications - MEMBERS = long* inputExtendedReplications - MEMBERS = int nInputExtendedReplications - MEMBERS = int iInputExtendedReplications - MEMBERS = long* inputShortReplications - MEMBERS = int nInputShortReplications - MEMBERS = int iInputShortReplications - MEMBERS = grib_iarray* iss_list - MEMBERS = grib_trie_with_rank* dataAccessorsTrie - MEMBERS = grib_sarray* tempStrings - MEMBERS = grib_vdarray* tempDoubleValues - MEMBERS = int change_ref_value_operand - MEMBERS = size_t refValListSize - MEMBERS = long* refValList - MEMBERS = long refValIndex - MEMBERS = bufr_tableb_override* tableb_override - MEMBERS = int set_to_missing_if_out_of_range - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_data_array -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_data_array */ - const char* bufrDataEncodedName; - const char* numberOfSubsetsName; - const char* expandedDescriptorsName; - const char* flagsName; - const char* unitsName; - const char* elementsDescriptorsIndexName; - const char* compressedDataName; - bufr_descriptors_array* expanded; - grib_accessor* expandedAccessor; - int* canBeMissing; - long numberOfSubsets; - long compressedData; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - int do_decode; - int bitmapStartElementsDescriptorsIndex; - int bitmapCurrentElementsDescriptorsIndex; - int bitmapSize; - int bitmapStart; - int bitmapCurrent; - grib_accessors_list* dataAccessors; - int unpackMode; - int bitsToEndData; - grib_section* dataKeys; - double* inputBitmap; - int nInputBitmap; - int iInputBitmap; - long* inputReplications; - int nInputReplications; - int iInputReplications; - long* inputExtendedReplications; - int nInputExtendedReplications; - int iInputExtendedReplications; - long* inputShortReplications; - int nInputShortReplications; - int iInputShortReplications; - grib_iarray* iss_list; - grib_trie_with_rank* dataAccessorsTrie; - grib_sarray* tempStrings; - grib_vdarray* tempDoubleValues; - int change_ref_value_operand; - size_t refValListSize; - long* refValList; - long refValIndex; - bufr_tableb_override* tableb_override; - int set_to_missing_if_out_of_range; -} grib_accessor_bufr_data_array; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_data_array = { - &grib_accessor_class_gen, /* super */ - "bufr_data_array", /* name */ - sizeof(grib_accessor_bufr_data_array), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_bufr_data_array_t _grib_accessor_class_bufr_data_array{"bufr_data_array"}; grib_accessor_class* grib_accessor_class_bufr_data_array = &_grib_accessor_class_bufr_data_array; -/* END_CLASS_IMP */ #define MAX_NESTED_REPLICATIONS 8 @@ -225,33 +35,27 @@ grib_accessor_class* grib_accessor_class_bufr_data_array = &_grib_accessor_class return retval; \ } -static int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset); +int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset); +typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); +typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); -typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); -typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); - -static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); - -static void restart_bitmap(grib_accessor_bufr_data_array* self) -{ +int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); +void restart_bitmap(grib_accessor_bufr_data_array_t* self){ self->bitmapCurrent = -1; self->bitmapCurrentElementsDescriptorsIndex = self->bitmapStartElementsDescriptorsIndex - 1; } -static void cancel_bitmap(grib_accessor_bufr_data_array* self) -{ +void cancel_bitmap(grib_accessor_bufr_data_array_t* self){ self->bitmapCurrent = -1; self->bitmapStart = -1; } -static int is_bitmap_start_defined(grib_accessor_bufr_data_array* self) -{ +int is_bitmap_start_defined(grib_accessor_bufr_data_array_t* self){ return self->bitmapStart == -1 ? 0 : 1; } -static size_t get_length(grib_accessor* a) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +size_t get_length(grib_accessor* a){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; size_t len = 0; const grib_handle* h = grib_handle_of_accessor(a); @@ -262,8 +66,7 @@ static size_t get_length(grib_accessor* a) } /* Operator 203YYY: Store the TableB code and changed reference value in linked list */ -static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array* self, int code, long new_ref_val) -{ +void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array_t* self, int code, long new_ref_val){ bufr_tableb_override* tb = (bufr_tableb_override*)grib_context_malloc_clear(c, sizeof(bufr_tableb_override)); tb->code = code; tb->new_ref_val = new_ref_val; @@ -280,8 +83,7 @@ static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_da } /* Operator 203YYY: Retrieve changed reference value from linked list */ -static int tableB_override_get_ref_val(grib_accessor_bufr_data_array* self, int code, long* out_ref_val) -{ +int tableB_override_get_ref_val(grib_accessor_bufr_data_array_t* self, int code, long* out_ref_val){ bufr_tableb_override* p = self->tableb_override; while (p) { if (p->code == code) { @@ -294,8 +96,7 @@ static int tableB_override_get_ref_val(grib_accessor_bufr_data_array* self, int } /* Operator 203YYY: Clear and free linked list */ -static void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array* self) -{ +void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array_t* self){ bufr_tableb_override* tb = self->tableb_override; while (tb) { bufr_tableb_override* n = tb->next; @@ -306,8 +107,7 @@ static void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array } /* Operator 203YYY: Copy contents of linked list to the transient array key */ -static int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array* self) -{ +int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array_t* self){ int err = GRIB_SUCCESS; size_t size = 0; long* refVals = NULL; @@ -327,8 +127,7 @@ static int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array return err; } /* Check numBits is sufficient for entries in the overridden reference values list*/ -static int check_overridden_reference_values(const grib_context* c, long* refValList, size_t refValListSize, int numBits) -{ +int check_overridden_reference_values(const grib_context* c, long* refValList, size_t refValListSize, int numBits){ const long maxval = (1 << (numBits - 1)) - 1; const long minval = -(1 << (numBits - 1)); size_t i = 0; @@ -343,7 +142,7 @@ static int check_overridden_reference_values(const grib_context* c, long* refVal return GRIB_SUCCESS; } -// static void tableB_override_dump(grib_accessor_bufr_data_array *self) +// void tableB_override_dump(grib_accessor_bufr_data_array_t *self) // { // bufr_tableb_override* p = self->tableb_override; // int i = 1; @@ -357,9 +156,8 @@ static int check_overridden_reference_values(const grib_context* c, long* refVal #define DYN_ARRAY_SIZE_INIT 1000 /* Initial size for grib_iarray_new and grib_darray_new */ #define DYN_ARRAY_SIZE_INCR 1000 /* Increment size for grib_iarray_new and grib_darray_new */ -static void init(grib_accessor* a, const long v, grib_arguments* params) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::init(grib_accessor* a, const long v, grib_arguments* params){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int n = 0; const char* dataKeysName = NULL; grib_accessor* dataKeysAcc = NULL; @@ -397,7 +195,7 @@ static void init(grib_accessor* a, const long v, grib_arguments* params) /* Assert(a->length>=0); */ } -// static void clean_string(char* s,int len) +// void clean_string(char* s,int len) // { // int i=len-1; // while (i) { @@ -407,8 +205,7 @@ static void init(grib_accessor* a, const long v, grib_arguments* params) // } // } -static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array* self, int size) -{ +int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, int size){ const int saved_bitsToEndData = self->bitsToEndData; if (c->debug == 1) grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data decoding: \tbitsToEndData=%d elementSize=%d", self->bitsToEndData, size); @@ -422,8 +219,7 @@ static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bu return 0; } -static void self_clear(grib_context* c, grib_accessor_bufr_data_array* self) -{ +void self_clear(grib_context* c, grib_accessor_bufr_data_array_t* self){ grib_context_free(c, self->canBeMissing); grib_vdarray_delete_content(c, self->numericValues); grib_vdarray_delete(c, self->numericValues); @@ -452,69 +248,62 @@ static void self_clear(grib_context* c, grib_accessor_bufr_data_array* self) if (self->inputBitmap) grib_context_free(c, self->inputBitmap); } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bufr_data_array_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_DOUBLE; } -static long byte_count(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::byte_count(grib_accessor* a){ return 0; } -static long byte_offset(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::byte_offset(grib_accessor* a){ return a->offset; } -static long next_offset(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::next_offset(grib_accessor* a){ return a->offset; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int grib_accessor_class_bufr_data_array_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->do_decode = 1; return GRIB_NOT_IMPLEMENTED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int grib_accessor_class_bufr_data_array_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->do_decode = 1; return process_elements(a, PROCESS_ENCODE, 0, 0, 0); } grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; process_elements(a, PROCESS_DECODE, 0, 0, 0); return self->stringValues; } grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; return self->dataAccessors; } grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; return self->dataAccessorsTrie; } void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->unpackMode = unpackMode; } -static int get_descriptors(grib_accessor* a) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int get_descriptors(grib_accessor* a){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int ret = 0, i, numberOfDescriptors; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = a->context; @@ -539,8 +328,8 @@ static int get_descriptors(grib_accessor* a) return ret; } -static int decode_string_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self) +int decode_string_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self) { int ret = 0; int* err = &ret; @@ -597,9 +386,9 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos, return ret; } -static grib_darray* decode_double_array(grib_context* c, unsigned char* data, long* pos, +grib_darray* decode_double_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, int canBeMissing, - grib_accessor_bufr_data_array* self, int* err) + grib_accessor_bufr_data_array_t* self, int* err) { grib_darray* ret = NULL; int j; @@ -680,8 +469,8 @@ static grib_darray* decode_double_array(grib_context* c, unsigned char* data, lo return ret; } -static int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, grib_sarray* stringValues) +int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self, grib_sarray* stringValues) { int err = 0, n, ival; int k, j, modifiedWidth, width; @@ -737,8 +526,7 @@ static int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bu return err; } -static void set_missing_long_to_double(grib_darray* dvalues) -{ +void set_missing_long_to_double(grib_darray* dvalues){ size_t i, n = grib_darray_used_size(dvalues); for (i = 0; i < n; i++) { if (dvalues->v[i] == GRIB_MISSING_LONG) @@ -747,7 +535,7 @@ static void set_missing_long_to_double(grib_darray* dvalues) } /* ECC-750: The 'factor' argument is 10^-scale */ -static int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor, +int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor, double* minAllowed, double* maxAllowed) { /* Maximum value is allowed to be the largest number (all bits 1) which means it's MISSING */ @@ -763,8 +551,8 @@ static int descriptor_get_min_max(bufr_descriptor* bd, long width, long referenc return GRIB_SUCCESS; } -static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, grib_darray* dvalues) +int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self, grib_darray* dvalues) { int err = 0; int j, i; @@ -981,8 +769,8 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu return err; } -static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, double value) +int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self, double value) { size_t lval; double maxAllowed, minAllowed; @@ -1028,8 +816,8 @@ static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bu return err; } -static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, char* sval) +int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self, char* sval) { int err = 0; int len; @@ -1044,8 +832,8 @@ static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bu return err; } -static char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, int* err) +char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, + grib_accessor_bufr_data_array_t* self, int* err) { char* sval = 0; int len; @@ -1067,9 +855,9 @@ static char* decode_string_value(grib_context* c, unsigned char* data, long* pos return sval; } -static double decode_double_value(grib_context* c, unsigned char* data, long* pos, +double decode_double_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, int canBeMissing, - grib_accessor_bufr_data_array* self, int* err) + grib_accessor_bufr_data_array_t* self, int* err) { size_t lval; int modifiedWidth, modifiedReference; @@ -1098,7 +886,7 @@ static double decode_double_value(grib_context* c, unsigned char* data, long* po return dval; } -static int decode_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1180,7 +968,7 @@ static int decode_element(grib_context* c, grib_accessor_bufr_data_array* self, return err; } -static int decode_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int ret = 0; @@ -1245,8 +1033,7 @@ static int decode_replication(grib_context* c, grib_accessor_bufr_data_array* se return ret; } -static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array* self) -{ +int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array_t* self){ grib_darray* doubleValues = NULL; int err = 0; double cdval = 0; @@ -1268,7 +1055,7 @@ static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int } /* Operator 203YYY: Change Reference Values: Encoding definition phase */ -static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array* self, +int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array_t* self, grib_buffer* buff, long* pos, bufr_descriptor* bd) { int err = 0; @@ -1307,7 +1094,7 @@ static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr return err; } -static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1367,7 +1154,7 @@ static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array* se return err; } -static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int err = 0; @@ -1430,7 +1217,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array return err; } -static int encode_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1501,7 +1288,7 @@ static int encode_element(grib_context* c, grib_accessor_bufr_data_array* self, return err; } -static int encode_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { @@ -1517,7 +1304,7 @@ static int encode_replication(grib_context* c, grib_accessor_bufr_data_array* se return encode_element(c, self, subsetIndex, buff, data, pos, i, 0, elementIndex, dval, 0); } -static int build_bitmap(grib_accessor_bufr_data_array* self, unsigned char* data, long* pos, +int build_bitmap(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; @@ -1615,8 +1402,7 @@ static int build_bitmap(grib_accessor_bufr_data_array* self, unsigned char* data return GRIB_SUCCESS; } -static int consume_bitmap(grib_accessor_bufr_data_array* self, int iBitmapOperator) -{ +int consume_bitmap(grib_accessor_bufr_data_array_t* self, int iBitmapOperator){ int bitmapSize = 0, iDelayedReplication; int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1646,7 +1432,7 @@ static int consume_bitmap(grib_accessor_bufr_data_array* self, int iBitmapOperat return GRIB_SUCCESS; } -static int build_bitmap_new_data(grib_accessor_bufr_data_array* self, unsigned char* data, long* pos, +int build_bitmap_new_data(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; @@ -1733,8 +1519,7 @@ static int build_bitmap_new_data(grib_accessor_bufr_data_array* self, unsigned c } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array* self, grib_iarray* elementsDescriptorsIndex, int compressedData) -{ +int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, int compressedData){ int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1771,8 +1556,7 @@ static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_a } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues) -{ +int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues){ int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1813,8 +1597,7 @@ static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self, return elementsDescriptorsIndex->v[self->bitmapCurrentElementsDescriptorsIndex]; } -static void push_zero_element(grib_accessor_bufr_data_array* self, grib_darray* dval) -{ +void push_zero_element(grib_accessor_bufr_data_array_t* self, grib_darray* dval){ grib_darray* d = 0; grib_accessor* a = (grib_accessor*)self; grib_context* c = a->context; @@ -1828,7 +1611,7 @@ static void push_zero_element(grib_accessor_bufr_data_array* self, grib_darray* } } -static grib_accessor* create_attribute_variable(const char* name, grib_section* section, int type, char* sval, double dval, long lval, unsigned long flags) +grib_accessor* create_attribute_variable(const char* name, grib_section* section, int type, char* sval, double dval, long lval, unsigned long flags) { grib_accessor* a = NULL; grib_action creator = {0,}; @@ -1846,26 +1629,22 @@ static grib_accessor* create_attribute_variable(const char* name, grib_section* len = 1; switch (type) { case GRIB_TYPE_LONG: - grib_pack_long(a, &lval, &len); - break; + a->pack_long(&lval, &len); break; case GRIB_TYPE_DOUBLE: - grib_pack_double(a, &dval, &len); - break; + a->pack_double(&dval, &len); break; case GRIB_TYPE_STRING: if (!sval) return NULL; /* Performance: No need for len=strlen(sval). It's not used. */ /* See grib_accessor_class_variable.c, pack_string() */ len = 0; - grib_pack_string(a, sval, &len); - break; + a->pack_string(sval, &len); break; } return a; } -static void set_creator_name(grib_action* creator, int code) -{ +void set_creator_name(grib_action* creator, int code){ switch (code) { case 222000: creator->name = (char*)"qualityInformationFollows"; @@ -1937,8 +1716,7 @@ static void set_creator_name(grib_action* creator, int code) } /* See ECC-741 */ -static int adding_extra_key_attributes(grib_handle* h) -{ +int adding_extra_key_attributes(grib_handle* h){ long skip = 0; /* default is to add */ int err = 0; err = grib_get_long(h, "skipExtraKeyAttributes", &skip); @@ -1947,11 +1725,11 @@ static int adding_extra_key_attributes(grib_handle* h) return (!skip); } -static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, grib_accessor* attribute, grib_section* section, +grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, grib_accessor* attribute, grib_section* section, long ide, long subset, int add_dump_flag, int add_coord_flag, int count, int add_extra_attributes) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; char code[10] = {0,}; char* temp_str = NULL; int idx = 0; @@ -2014,13 +1792,13 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr if (attribute->attributes[i]) attribute->attributes[i]->parent=elementAccessor->parent; } */ - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); temp_str = grib_context_strdup(a->context, code); @@ -2028,28 +1806,28 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr if (!attribute) return NULL; grib_sarray_push(a->context, self->tempStrings, temp_str); /* ECC-325: store alloc'd string (due to strdup) for clean up later */ - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); if (add_extra_attributes) { attribute = create_attribute_variable("units", section, GRIB_TYPE_STRING, self->expanded->v[idx]->units, 0, 0, GRIB_ACCESSOR_FLAG_DUMP | flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("scale", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->scale, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("reference", section, GRIB_TYPE_DOUBLE, 0, self->expanded->v[idx]->reference, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("width", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->width, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } break; case 2: @@ -2071,7 +1849,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } else { elementAccessor = grib_accessor_factory(section, &operatorCreator, 0, NULL); @@ -2080,13 +1858,13 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } self->expanded->v[idx]->a = elementAccessor; break; @@ -2106,34 +1884,34 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); if (add_extra_attributes) { attribute = create_attribute_variable("units", section, GRIB_TYPE_STRING, self->expanded->v[idx]->units, 0, 0, GRIB_ACCESSOR_FLAG_DUMP); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("scale", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->scale, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("reference", section, GRIB_TYPE_DOUBLE, 0, self->expanded->v[idx]->reference, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("width", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->width, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } break; } @@ -2179,19 +1957,18 @@ static grib_accessor* get_element_from_bitmap(const grib_accessor* a, bitmap_s* while (bitmapVal) { len = 1; if (bitmap->cursor && bitmap->cursor->accessor) { - ret = grib_unpack_long(bitmap->cursor->accessor, &bitmapVal, &len); - } + ret = bitmap->cursor->accessor->unpack_long(&bitmapVal, &len); } else { return NULL; } if (ret != 0) return NULL; - bitmap->cursor = bitmap->cursor->next; + bitmap->cursor = bitmap->cursor->next_; if (bitmap->referredElement) - bitmap->referredElement = bitmap->referredElement->next; + bitmap->referredElement = bitmap->referredElement->next_; } - return bitmap->referredElement ? bitmap->referredElement->prev->accessor : NULL; + return bitmap->referredElement ? bitmap->referredElement->prev_->accessor : NULL; } // static GRIB_INLINE void reset_qualifiers(grib_accessor* significanceQualifierGroup[]) @@ -2201,8 +1978,7 @@ static grib_accessor* get_element_from_bitmap(const grib_accessor* a, bitmap_s* // significanceQualifierGroup[i]=0; // } -static void grib_convert_to_attribute(grib_accessor* a) -{ +void grib_convert_to_attribute(grib_accessor* a){ if (a->h == NULL && a->parent != NULL) { a->h = grib_handle_of_accessor(a); a->parent = NULL; @@ -2211,7 +1987,7 @@ static void grib_convert_to_attribute(grib_accessor* a) /* subsetList can be NULL in which case subsetListSize will be 0 */ static grib_iarray* set_subset_list( - grib_context* c, grib_accessor_bufr_data_array* self, + grib_context* c, grib_accessor_bufr_data_array_t* self, long onlySubset, long startSubset, long endSubset, const long* subsetList, size_t subsetListSize) { grib_iarray* list = grib_iarray_new(c, self->numberOfSubsets, 10); @@ -2249,8 +2025,7 @@ static grib_iarray* set_subset_list( return list; } -static int bitmap_ref_skip(grib_accessors_list* al, int* err) -{ +int bitmap_ref_skip(grib_accessors_list* al, int* err){ grib_accessor* acode = NULL; long code[1]; size_t l = 1; @@ -2258,11 +2033,10 @@ static int bitmap_ref_skip(grib_accessors_list* al, int* err) if (!al || !al->accessor) return 0; - acode = grib_accessor_get_attribute(al->accessor, "code"); + acode = al->accessor->get_attribute("code"); if (acode) - *err = grib_unpack_long(acode, code, &l); - else + *err = acode->unpack_long(code, &l); else return 1; switch (code[0]) { @@ -2283,18 +2057,16 @@ static int bitmap_ref_skip(grib_accessors_list* al, int* err) } /* Return 1 if the descriptor is an operator marking the start of a bitmap */ -static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err) -{ +int is_bitmap_start_descriptor(grib_accessors_list* al, int* err){ grib_accessor* acode = NULL; long code[1]; size_t l = 1; if (!al || !al->accessor) return 0; - acode = grib_accessor_get_attribute(al->accessor, "code"); + acode = al->accessor->get_attribute("code"); if (acode) - *err = grib_unpack_long(acode, code, &l); - else + *err = acode->unpack_long(code, &l); else return 1; switch (code[0]) { @@ -2309,18 +2081,16 @@ static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err) { //long index[1]; //grib_accessor* anindex=grib_accessor_get_attribute(al->accessor,"index"); - //grib_unpack_long(anindex,index,&l); - return 1; + //anindex->unpack_long(index,&l); return 1; } } return 0; } -static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize) -{ +void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize){ int i = 0, ret = 0; fprintf(stderr, "ECCODES DEBUG: bitmap_init: bitmapSize=%d\n", bitmapSize); - bitmap->cursor = bitmapStart->next; + bitmap->cursor = bitmapStart->next_; bitmap->referredElement = bitmapStart; while (bitmap_ref_skip(bitmap->referredElement, &ret)) { @@ -2328,7 +2098,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce if (is_bitmap_start_descriptor(bitmap->referredElement, &ret)) { is_bmp = 1; } - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; if (is_bmp) { break; } @@ -2337,7 +2107,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce for (i = 1; i < bitmapSize; i++) { if (bitmap->referredElement) { fprintf(stderr, "ECCODES DEBUG:\t bitmap_init: i=%d |%s|\n", i, bitmap->referredElement->accessor->name); - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; } } } @@ -2346,13 +2116,13 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize, grib_accessors_list* lastAccessorInList) { int ret = 0, i; - bitmap->cursor = bitmapStart->next; + bitmap->cursor = bitmapStart->next_; if (bitmap->referredElementStart != NULL) { bitmap->referredElement = bitmap->referredElementStart; return ret; } bitmap->referredElement = bitmapStart; - /*while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev;*/ + /*while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev_;*/ /* See ECC-869 * We have to INCLUDE the replication factors that come after the bitmap operators */ @@ -2361,7 +2131,7 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, if (is_bitmap_start_descriptor(bitmap->referredElement, &ret)) { is_bmp = 1; } - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; if (is_bmp) { break; } @@ -2375,7 +2145,7 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, return GRIB_INTERNAL_ERROR; } /*printf(" bitmap_init: i=%d |%s|\n", i,bitmap->referredElement->accessor->name);*/ - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; } bitmap->referredElementStart = bitmap->referredElement; return ret; @@ -2383,13 +2153,13 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, static grib_accessor* accessor_or_attribute_with_same_name(grib_accessor* a, const char* name) { - if (grib_accessor_has_attributes(a) == 0) { + if (a->has_attributes() == 0) { return a; } else { grib_accessor* ok = a; grib_accessor* next; - while ((next = grib_accessor_get_attribute(ok, name)) != NULL) { + while ((next = ok->get_attribute(name)) != NULL) { ok = next; } return ok; @@ -2408,14 +2178,12 @@ static grib_accessor* accessor_or_attribute_with_same_name(grib_accessor* a, con // return *r; // } -static int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a) -{ +int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a){ return grib_trie_with_rank_insert(accessorsTrie, a->name, a); } -static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int err = 0; int rank; grib_accessor* elementAccessor = 0; @@ -2509,7 +2277,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset /*if (associatedFieldAccessor) grib_accessor_delete(c, associatedFieldAccessor);*/ associatedFieldAccessor = NULL; if (associatedFieldSignificanceAccessor) { - grib_accessor_delete(c, associatedFieldSignificanceAccessor); + associatedFieldSignificanceAccessor->destroy(c); associatedFieldSignificanceAccessor = NULL; } for (ide = 0; ide < elementsInSubset; ide++) { @@ -2577,7 +2345,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset //return err; bitmapIndex--; } - bitmapStart[bitmapIndex] = grib_accessors_list_last(self->dataAccessors); + bitmapStart[bitmapIndex] = self->dataAccessors->last(); bitmapSize[bitmapIndex] = 1; if (self->expanded->v[idx - 1]->code == 31002 || self->expanded->v[idx - 1]->code == 31001) extraElement += 1; @@ -2659,11 +2427,10 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset creatorsn.name = (char*)"subsetNumber"; asn = grib_accessor_factory(section, &creatorsn, 0, NULL); accessor_variable_set_type(asn, GRIB_TYPE_LONG); - grib_pack_long(asn, &subsetNumber, &len); - + asn->pack_long(&subsetNumber, &len); grib_push_accessor(asn, section->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, asn); - grib_accessors_list_push(self->dataAccessors, asn, rank); + self->dataAccessors->push(asn, rank); } count++; elementAccessor = create_accessor_from_descriptor(a, associatedFieldAccessor, section, ide, iss, @@ -2681,16 +2448,17 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset if (elementFromBitmap && self->unpackMode == CODES_BUFR_UNPACK_STRUCTURE) { if (descriptor->code != 33007 && descriptor->code != 223255) { char* aname = grib_context_strdup(c, elementFromBitmap->name); - grib_accessor* newAccessor = grib_accessor_clone(elementAccessor, section, &err); + grib_accessor* newAccessor = elementAccessor->clone(section, &err); newAccessor->parent = groupSection; newAccessor->name = aname; grib_sarray_push(a->context, self->tempStrings, aname); grib_push_accessor(newAccessor, groupSection->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, newAccessor); - grib_accessors_list_push(self->dataAccessors, newAccessor, rank); + self->dataAccessors->push(newAccessor, rank); } - err = grib_accessor_add_attribute(accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name), elementAccessor, 1); + //err = grib_accessor_add_attribute(accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name), elementAccessor, 1); + err = accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name)->add_attribute( elementAccessor, 1); } else if (elementAccessor) { int add_key = 1; @@ -2700,17 +2468,17 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset associatedFieldAccessor = elementAccessor; grib_convert_to_attribute(associatedFieldAccessor); if (associatedFieldSignificanceAccessor) { - grib_accessor* newAccessor = grib_accessor_clone(associatedFieldSignificanceAccessor, section, &err); + grib_accessor* newAccessor = associatedFieldSignificanceAccessor->clone(section, &err); if (err) { grib_context_log(a->context, GRIB_LOG_ERROR,"Unable to clone accessor '%s'\n", associatedFieldSignificanceAccessor->name); return err; } - grib_accessor_add_attribute(associatedFieldAccessor, newAccessor, 1); + associatedFieldAccessor->add_attribute(newAccessor, 1); } break; case 31021: if (associatedFieldSignificanceAccessor) - grib_accessor_delete(c, associatedFieldSignificanceAccessor); + associatedFieldSignificanceAccessor->destroy(c); associatedFieldSignificanceAccessor = elementAccessor; break; /*case 33007:*/ @@ -2728,8 +2496,8 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset if (add_key) { grib_push_accessor(elementAccessor, section->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, elementAccessor); - grib_accessors_list_push(self->dataAccessors, elementAccessor, rank); - lastAccessorInList = grib_accessors_list_last(self->dataAccessors); + self->dataAccessors->push(elementAccessor, rank); + lastAccessorInList = self->dataAccessors->last(); } } } @@ -2739,8 +2507,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset return err; } -static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array* self) -{ +void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array_t* self){ size_t nInputReplications; size_t nInputExtendedReplications; size_t nInputShortReplications; @@ -2785,8 +2552,7 @@ static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array } } -static void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array* self) -{ +void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array_t* self){ size_t nInputBitmap; self->nInputBitmap = -1; self->iInputBitmap = 0; @@ -2803,8 +2569,7 @@ static void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array* self } } -static int set_to_missing_if_out_of_range(grib_handle* h) -{ +int set_to_missing_if_out_of_range(grib_handle* h){ /* First check if the transient key is set */ long setToMissingIfOutOfRange = 0; if (grib_get_long(h, "setToMissingIfOutOfRange", &setToMissingIfOutOfRange) == GRIB_SUCCESS && @@ -2815,8 +2580,7 @@ static int set_to_missing_if_out_of_range(grib_handle* h) return h->context->bufr_set_to_missing_if_out_of_range; } -static int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset) -{ +int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset){ int err = 0; long inr, innr, ir, ip; long n[MAX_NESTED_REPLICATIONS] = {0,}; @@ -2846,7 +2610,7 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st grib_darray* dval = NULL; grib_sarray* sval = NULL; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = h->context; @@ -3373,19 +3137,17 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st return err; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - // grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::dump(grib_accessor* a, grib_dumper* dumper){ + // grib_accessor_bufr_data_array_t *self =(grib_accessor_bufr_data_array_t*)a; // int err=process_elements(a,PROCESS_DECODE); // grib_dump_section(dumper,a,self->dataKeys->block); return; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_bufr_data_array_t::value_count(grib_accessor* a, long* count){ int err = 0, l; long i; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; err = process_elements(a, PROCESS_DECODE, 0, 0, 0); if (err) @@ -3405,13 +3167,12 @@ static int value_count(grib_accessor* a, long* count) return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_bufr_data_array_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int err = 0, i, k, ii; int proc_flag = PROCESS_DECODE; size_t l = 0, elementsInSubset; long numberOfSubsets = 0; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; if (self->unpackMode == CODES_BUFR_NEW_DATA) proc_flag = PROCESS_NEW_DATA; @@ -3459,9 +3220,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self_clear(c, self); if (self->dataAccessors) grib_accessors_list_delete(c, self->dataAccessors); diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h b/src/accessor/grib_accessor_class_bufr_data_array.h new file mode 100644 index 000000000..386d4ce9c --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_array.h @@ -0,0 +1,93 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_data_array_h +#define eccodes_accessor_bufr_data_array_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_array_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_data_array */ + const char* bufrDataEncodedName; + const char* numberOfSubsetsName; + const char* expandedDescriptorsName; + const char* flagsName; + const char* unitsName; + const char* elementsDescriptorsIndexName; + const char* compressedDataName; + bufr_descriptors_array* expanded; + grib_accessor* expandedAccessor; + int* canBeMissing; + long numberOfSubsets; + long compressedData; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + int do_decode; + int bitmapStartElementsDescriptorsIndex; + int bitmapCurrentElementsDescriptorsIndex; + int bitmapSize; + int bitmapStart; + int bitmapCurrent; + grib_accessors_list* dataAccessors; + int unpackMode; + int bitsToEndData; + grib_section* dataKeys; + double* inputBitmap; + int nInputBitmap; + int iInputBitmap; + long* inputReplications; + int nInputReplications; + int iInputReplications; + long* inputExtendedReplications; + int nInputExtendedReplications; + int iInputExtendedReplications; + long* inputShortReplications; + int nInputShortReplications; + int iInputShortReplications; + grib_iarray* iss_list; + grib_trie_with_rank* dataAccessorsTrie; + grib_sarray* tempStrings; + grib_vdarray* tempDoubleValues; + int change_ref_value_operand; + size_t refValListSize; + long* refValList; + long refValIndex; + bufr_tableb_override* tableb_override; + int set_to_missing_if_out_of_range; +}; + +class grib_accessor_class_bufr_data_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; + +grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); +grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); +grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); +void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); +#endif /* eccodes_accessor_bufr_data_array_h */ diff --git a/src/accessor/todo/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc similarity index 68% rename from src/accessor/todo/grib_accessor_class_bufr_data_element.cc rename to src/accessor/grib_accessor_class_bufr_data_element.cc index 3301eb10f..295c0b13e 100644 --- a/src/accessor/todo/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,144 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - #include "grib_api_internal.h" +#include "grib_accessor_class_bufr_data_element.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = unpack_double_element ; is_missing - IMPLEMENTS = pack_long; pack_double ; pack_string_array; pack_string; pack_missing - IMPLEMENTS = value_count; get_native_type; make_clone; destroy - MEMBERS = long index - MEMBERS = int type - MEMBERS = long compressedData - MEMBERS = long subsetNumber - MEMBERS = long numberOfSubsets - MEMBERS = bufr_descriptors_array* descriptors - MEMBERS = grib_vdarray* numericValues - MEMBERS = grib_vsarray* stringValues - MEMBERS = grib_viarray* elementsDescriptorsIndex - MEMBERS = char* cname - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_string_array(grib_accessor*, const char**, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_bufr_data_element -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_data_element */ - long index; - int type; - long compressedData; - long subsetNumber; - long numberOfSubsets; - bufr_descriptors_array* descriptors; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - char* cname; -} grib_accessor_bufr_data_element; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_data_element = { - &grib_accessor_class_gen, /* super */ - "bufr_data_element", /* name */ - sizeof(grib_accessor_bufr_data_element), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - &pack_string_array, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - &make_clone, /* clone accessor */ -}; - - +grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{"bufr_data_element"}; grib_accessor_class* grib_accessor_class_bufr_data_element = &_grib_accessor_class_bufr_data_element; -/* END_CLASS_IMP */ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) { grib_accessor* the_clone = NULL; grib_accessor* attribute = NULL; - grib_accessor_bufr_data_element* elementAccessor; - grib_accessor_bufr_data_element* self; + grib_accessor_bufr_data_element_t* elementAccessor; + grib_accessor_bufr_data_element_t* self; char* copied_name = NULL; int i; grib_action creator = {0,}; @@ -161,8 +37,8 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) the_clone = grib_accessor_factory(s, &creator, 0, NULL); copied_name = grib_context_strdup(a->context, a->name); the_clone->name = copied_name; - elementAccessor = (grib_accessor_bufr_data_element*)the_clone; - self = (grib_accessor_bufr_data_element*)a; + elementAccessor = (grib_accessor_bufr_data_element_t*)the_clone; + self = (grib_accessor_bufr_data_element_t*)a; the_clone->flags = a->flags; the_clone->parent = NULL; the_clone->h = s->h; @@ -179,9 +55,9 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) i = 0; while (a->attributes[i]) { - attribute = grib_accessor_clone(a->attributes[i], s, err); + attribute = a->attributes[i]->clone(s, err); /* attribute->parent=a->parent; */ - grib_accessor_add_attribute(the_clone, attribute, 0); + the_clone->add_attribute(attribute, 0); i++; } @@ -190,69 +66,67 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) void accessor_bufr_data_element_set_index(grib_accessor* a, long index) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->index = index; } void accessor_bufr_data_element_set_type(grib_accessor* a, int type) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->type = type; } void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->numberOfSubsets = numberOfSubsets; } void accessor_bufr_data_element_set_subsetNumber(grib_accessor* a, long subsetNumber) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->subsetNumber = subsetNumber; } void accessor_bufr_data_element_set_compressedData(grib_accessor* a, int compressedData) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->compressedData = compressedData; } void accessor_bufr_data_element_set_descriptors(grib_accessor* a, bufr_descriptors_array* descriptors) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->descriptors = descriptors; } void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray* numericValues) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->numericValues = numericValues; } void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->stringValues = stringValues; } void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; self->elementsDescriptorsIndex = elementsDescriptorsIndex; } -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA; /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ self->cname = NULL; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper){ int type = get_native_type(a); switch (type) { @@ -268,9 +142,8 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } } -static int unpack_string_array(grib_accessor* a, char** val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = 0, idx = 0; size_t count = 0, i = 0; @@ -297,9 +170,8 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len) return ret; } -static int pack_string_array(grib_accessor* a, const char** v, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; size_t i = 0; @@ -340,9 +212,8 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len) return ret; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; char* str = NULL; char* p = 0; size_t slen = 0; @@ -409,9 +280,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; char* s = NULL; @@ -432,9 +302,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS; long count = 0, i = 0; @@ -461,9 +330,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS; long count = 0, i = 0; @@ -490,9 +358,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS; size_t count = 1, i = 0; grib_context* c = a->context; @@ -520,9 +387,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = 0; size_t count = 1, i = 0; grib_context* c = a->context; @@ -550,11 +416,10 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count){ int ret = 0, type = 0, idx = 0; size_t size = 0; - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; if (!self->compressedData) { *count = 1; @@ -577,10 +442,9 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ /* ECC-415 */ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS; long count = 0; @@ -598,9 +462,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return ret; } -static int get_native_type(grib_accessor* a) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_TYPE_DOUBLE; DEBUG_ASSERT(self); switch (self->type) { @@ -624,16 +487,15 @@ static int get_native_type(grib_accessor* a) return ret; } -static void destroy(grib_context* ct, grib_accessor* a) -{ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; +void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a){ + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int i = 0; if (self->cname) grib_context_free(ct, self->cname); /* ECC-765 */ while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { /*grib_context_log(ct,GRIB_LOG_DEBUG,"deleting attribute %s->%s",a->name,a->attributes[i]->name);*/ /*printf("bufr_data_element destroy %s %p\n", a->attributes[i]->name, (void*)a->attributes[i]);*/ - grib_accessor_delete(ct, a->attributes[i]); + a->attributes[i]->destroy(ct); a->attributes[i] = NULL; i++; } @@ -641,8 +503,7 @@ static void destroy(grib_context* ct, grib_accessor* a) #define MAX_STRING_SIZE 4096 /* Return 1 if BUFR element(s) is/are missing, 0 otherwise. In case of decoding errors, also return 0 */ -static int is_missing(grib_accessor* a) -{ +int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ const int ktype = get_native_type(a); int err = 0, result = 1; /* default: assume all are missing */ long count = 0; @@ -657,11 +518,9 @@ static int is_missing(grib_accessor* a) size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); - } + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); - } + err = a->unpack_long(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -684,11 +543,9 @@ static int is_missing(grib_accessor* a) size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); - } + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); - } + err = a->unpack_double(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -710,8 +567,7 @@ static int is_missing(grib_accessor* a) size = count; if (size > 1) { values = (char**)grib_context_malloc_clear(a->context, size * sizeof(char*)); - err = grib_unpack_string_array(a, values, &size); - if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string_array(values, &size); if (err) return 0; /* TODO: no way of propagating the error up */ for (i = 0; i < size; i++) { if (!grib_is_missing_string(a, (unsigned char*)values[i], size)) { result = 0; @@ -723,8 +579,7 @@ static int is_missing(grib_accessor* a) } else { char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */ size = MAX_STRING_SIZE; - err = grib_unpack_string(a, value, &size); - if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string(value, &size); if (err) return 0; /* TODO: no way of propagating the error up */ result = grib_is_missing_string(a, (unsigned char*)value, size); } } @@ -734,8 +589,7 @@ static int is_missing(grib_accessor* a) return result; } -static int pack_missing(grib_accessor* a) -{ +int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a){ int ktype = GRIB_TYPE_UNDEFINED; int err = 0; size_t size = 1; diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h new file mode 100644 index 000000000..d75afbe03 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -0,0 +1,56 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_data_element_h +#define eccodes_accessor_bufr_data_element_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_data_element */ + long index; + int type; + long compressedData; + long subsetNumber; + long numberOfSubsets; + bufr_descriptors_array* descriptors; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + char* cname; +}; + +class grib_accessor_class_bufr_data_element_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_element_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_element_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; +}; +#endif /* eccodes_accessor_bufr_data_element_h */ diff --git a/src/accessor/todo/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc similarity index 68% rename from src/accessor/todo/grib_accessor_class_bufr_elements_table.cc rename to src/accessor/grib_accessor_class_bufr_elements_table.cc index 4858ff63d..9b589c114 100644 --- a/src/accessor/todo/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,12 +9,10 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_bufr_elements_table.h" +#include "grib_scaling.h" + #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; @@ -31,7 +30,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex1; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_bufr_elements_table_c) { @@ -43,107 +42,14 @@ static void thread_init() } #endif -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string;unpack_long;unpack_double - IMPLEMENTS = value_count; get_native_type; - MEMBERS = const char* dictionary - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_elements_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_elements_table */ - const char* dictionary; - const char* masterDir; - const char* localDir; -} grib_accessor_bufr_elements_table; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_elements_table = { - &grib_accessor_class_gen, /* super */ - "bufr_elements_table", /* name */ - sizeof(grib_accessor_bufr_elements_table), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_bufr_elements_table_t _grib_accessor_class_bufr_elements_table{"bufr_elements_table"}; grib_accessor_class* grib_accessor_class_bufr_elements_table = &_grib_accessor_class_bufr_elements_table; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ +void grib_accessor_class_bufr_elements_table_t::init(grib_accessor* a, const long len, grib_arguments* params){ int n = 0; - grib_accessor_bufr_elements_table* self = (grib_accessor_bufr_elements_table*)a; + grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; self->dictionary = grib_arguments_get_string(grib_handle_of_accessor(a), params, n++); self->masterDir = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); @@ -155,7 +61,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) { - grib_accessor_bufr_elements_table* self = (grib_accessor_bufr_elements_table*)a; + grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; char* filename = NULL; char line[1024] = {0,}; @@ -273,8 +179,7 @@ the_end: return dictionary; } -static int convert_type(const char* stype) -{ +int convert_type(const char* stype){ int ret = BUFR_DESCRIPTOR_TYPE_UNKNOWN; switch (stype[0]) { case 's': @@ -304,14 +209,13 @@ static int convert_type(const char* stype) return ret; } -static long atol_fast(const char* input) -{ +long atol_fast(const char* input){ if (strcmp(input, "0") == 0) return 0; return atol(input); } -static int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) -{ + +int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v){ int ret = 0; char** list = 0; char code[7] = { 0 }; @@ -407,28 +311,23 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i return v; } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ +int grib_accessor_class_bufr_elements_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_bufr_elements_table_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bufr_elements_table_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_bufr_elements_table_t::unpack_long(grib_accessor* a, long* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_bufr_elements_table_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h b/src/accessor/grib_accessor_class_bufr_elements_table.h new file mode 100644 index 000000000..8ddd8a824 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_elements_table_h +#define eccodes_accessor_bufr_elements_table_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_elements_table */ + const char* dictionary; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_bufr_elements_table_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_elements_table_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_elements_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_elements_table_h */ diff --git a/src/accessor/todo/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc similarity index 57% rename from src/accessor/todo/grib_accessor_class_bufr_extract_area_subsets.cc rename to src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index 473a5148d..85eb98d0d 100644 --- a/src/accessor/todo/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,117 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - MEMBERS = const char* extractAreaWestLongitude - MEMBERS = const char* extractAreaEastLongitude - MEMBERS = const char* extractAreaNorthLatitude - MEMBERS = const char* extractAreaSouthLatitude - MEMBERS = const char* extractAreaLongitudeRank - MEMBERS = const char* extractAreaLatitudeRank - MEMBERS = const char* extractedAreaNumberOfSubsets - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_area_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_area_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* extractAreaWestLongitude; - const char* extractAreaEastLongitude; - const char* extractAreaNorthLatitude; - const char* extractAreaSouthLatitude; - const char* extractAreaLongitudeRank; - const char* extractAreaLatitudeRank; - const char* extractedAreaNumberOfSubsets; -} grib_accessor_bufr_extract_area_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_area_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_area_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_area_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_extract_area_subsets.h" +grib_accessor_class_bufr_extract_area_subsets_t _grib_accessor_class_bufr_extract_area_subsets{"bufr_extract_area_subsets"}; grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets = &_grib_accessor_class_bufr_extract_area_subsets; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; +void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; @@ -138,22 +36,19 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bufr_extract_area_subsets_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_LONG; } /* Copy first element of array into all others */ -static void fill_in(double a[], long length) -{ +void fill_in(double a[], long length){ long i; for (i = 1; i < length; ++i) a[i] = a[0]; } -static int select_area(grib_accessor* a) -{ - grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; +int select_area(grib_accessor* a){ + grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; int ret = 0; long compressed = 0; @@ -281,9 +176,8 @@ static int select_area(grib_accessor* a) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - /*grib_accessor_bufr_extract_area_subsets *self =(grib_accessor_bufr_extract_area_subsets*)a;*/ +int grib_accessor_class_bufr_extract_area_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + /*grib_accessor_bufr_extract_area_subsets_t *self =(grib_accessor_bufr_extract_area_subsets_t*)a;*/ if (*len == 0) return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h new file mode 100644 index 000000000..d079f958e --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_area_subsets_h +#define eccodes_accessor_bufr_extract_area_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_area_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* extractAreaWestLongitude; + const char* extractAreaEastLongitude; + const char* extractAreaNorthLatitude; + const char* extractAreaSouthLatitude; + const char* extractAreaLongitudeRank; + const char* extractAreaLatitudeRank; + const char* extractedAreaNumberOfSubsets; +}; + +class grib_accessor_class_bufr_extract_area_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_area_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_area_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_area_subsets_h */ diff --git a/src/accessor/todo/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc similarity index 76% rename from src/accessor/todo/grib_accessor_class_bufr_extract_datetime_subsets.cc rename to src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index d5ec98bf6..0568f02dc 100644 --- a/src/accessor/todo/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,104 +10,15 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_datetime_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_datetime_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; -} grib_accessor_bufr_extract_datetime_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_datetime_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_datetime_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_datetime_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_extract_datetime_subsets.h" +grib_accessor_class_bufr_extract_datetime_subsets_t _grib_accessor_class_bufr_extract_datetime_subsets{"bufr_extract_datetime_subsets"}; grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets = &_grib_accessor_class_bufr_extract_datetime_subsets; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ +void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ int n = 0; - grib_accessor_bufr_extract_datetime_subsets* self = (grib_accessor_bufr_extract_datetime_subsets*)a; + grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; a->length = 0; self->doExtractSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); @@ -116,14 +28,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bufr_extract_datetime_subsets_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_LONG; } /* Convert input date to Julian number. If date is invalid, return -1 */ -static double date_to_julian(long year, long month, long day, long hour, long minute, double second) -{ +double date_to_julian(long year, long month, long day, long hour, long minute, double second){ double result = 0; /* Julian number in units of days */ /* For validating the date/time, we specify seconds as an integer */ @@ -194,11 +104,10 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, return err; } -static int select_datetime(grib_accessor* a) -{ +int select_datetime(grib_accessor* a){ int ret = 0; long compressed = 0; - grib_accessor_bufr_extract_datetime_subsets* self = (grib_accessor_bufr_extract_datetime_subsets*)a; + grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = h->context; size_t n; @@ -423,9 +332,8 @@ cleanup: return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - /*grib_accessor_bufr_extract_datetime_subsets *self =(grib_accessor_bufr_extract_datetime_subsets*)a;*/ +int grib_accessor_class_bufr_extract_datetime_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + /*grib_accessor_bufr_extract_datetime_subsets_t *self =(grib_accessor_bufr_extract_datetime_subsets_t*)a;*/ if (*len == 0) return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h new file mode 100644 index 000000000..7acfd35b3 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_datetime_subsets_h +#define eccodes_accessor_bufr_extract_datetime_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_datetime_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; +}; + +class grib_accessor_class_bufr_extract_datetime_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_datetime_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_datetime_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_datetime_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc new file mode 100644 index 000000000..6fbea28a2 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc @@ -0,0 +1,58 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bufr_extract_subsets.h" + +grib_accessor_class_bufr_extract_subsets_t _grib_accessor_class_bufr_extract_subsets{"bufr_extract_subsets"}; +grib_accessor_class* grib_accessor_class_bufr_extract_subsets = &_grib_accessor_class_bufr_extract_subsets; + + +void get_accessors(grib_accessor* a){ + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + const grib_handle* h = grib_handle_of_accessor(a); + + if (self->packAccessor) + return; + self->numericValuesAccessor = grib_find_accessor(h, self->numericValues); + self->packAccessor = grib_find_accessor(h, self->pack); +} + +void grib_accessor_class_bufr_extract_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + int n = 0; + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + + a->length = 0; + self->numericValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->pack = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; +} + +int grib_accessor_class_bufr_extract_subsets_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_bufr_extract_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + size_t l = 1; + long v[1]; + + get_accessors(a); + + v[0] = 1; + int err = self->packAccessor->pack_long(v, &l); if (err) { + if (err == GRIB_ENCODING_ERROR) + grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?"); + return err; + } + + return err; +} diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_subsets.h new file mode 100644 index 000000000..80392338d --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_subsets_h +#define eccodes_accessor_bufr_extract_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_subsets */ + const char* numericValues; + const char* pack; + grib_accessor* numericValuesAccessor; + grib_accessor* packAccessor; +}; + +class grib_accessor_class_bufr_extract_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_group.cc b/src/accessor/grib_accessor_class_bufr_group.cc new file mode 100644 index 000000000..73075fcf1 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_group.cc @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bufr_group.h" + +grib_accessor_class_bufr_group_t _grib_accessor_class_bufr_group{"bufr_group"}; +grib_accessor_class* grib_accessor_class_bufr_group = &_grib_accessor_class_bufr_group; + + +void grib_accessor_class_bufr_group_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_section(dumper, a, a->sub_section->block); +} + +static grib_accessor* next(grib_accessor* a, int explore) +{ + grib_accessor* next = NULL; + if (explore) { + next = a->sub_section->block->first; + if (!next) + next = a->next; + } + else { + next = a->next; + } + if (!next) { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h new file mode 100644 index 000000000..84a202583 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -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. + */ + +#ifndef eccodes_accessor_bufr_group_h +#define eccodes_accessor_bufr_group_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_variable.h" + +class grib_accessor_bufr_group_t : public grib_accessor_variable_t +{ +public: + /* Members defined in bufr_group */ +}; + +class grib_accessor_class_bufr_group_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_bufr_group_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; } + void dump(grib_accessor*, grib_dumper*) override; +}; +#endif /* eccodes_accessor_bufr_group_h */ diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc new file mode 100644 index 000000000..1743104fd --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -0,0 +1,114 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bufr_simple_thinning.h" + +grib_accessor_class_bufr_simple_thinning_t _grib_accessor_class_bufr_simple_thinning{"bufr_simple_thinning"}; +grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_class_bufr_simple_thinning; + + +void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; + + a->length = 0; + self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); + self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); + self->extractSubsetList = grib_arguments_get_name(h, arg, n++); + self->simpleThinningStart = grib_arguments_get_name(h, arg, n++); + self->simpleThinningMissingRadius = grib_arguments_get_name(h, arg, n++); + self->simpleThinningSkip = grib_arguments_get_name(h, arg, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; +} + +int grib_accessor_class_bufr_simple_thinning_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int apply_thinning(grib_accessor* a){ + const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + + long skip; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = h->context; + long compressed = 0, nsubsets; + grib_iarray* subsets; + long* subsets_ar = 0; + long start = 0, radius = 0; + + int ret = grib_get_long(h, "compressedData", &compressed); + if (ret) + return ret; + if (compressed) { + long numberOfSubsets = 0; + ret = grib_get_long(h, self->numberOfSubsets, &numberOfSubsets); + if (ret) + return ret; + + ret = grib_get_long(h, self->simpleThinningStart, &start); + if (ret) + return ret; + + ret = grib_get_long(h, self->simpleThinningSkip, &skip); + if (ret) + return ret; + if (skip <= 0) + return GRIB_INVALID_KEY_VALUE; + + ret = grib_get_long(h, self->simpleThinningMissingRadius, &radius); + if (ret) + return ret; + + subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10); + for (long i = 0; i < numberOfSubsets; i += skip + 1) { + grib_iarray_push(subsets, i + 1); + } + + nsubsets = grib_iarray_used_size(subsets); + + if (nsubsets != 0) { + subsets_ar = grib_iarray_get_array(subsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); + if (ret) + return ret; + + ret = grib_set_long(h, "unpack", 1); + if (ret) + return ret; + + ret = grib_set_long(h, self->doExtractSubsets, 1); + if (ret) + return ret; + } + grib_iarray_delete(subsets); + } + else { + return GRIB_NOT_IMPLEMENTED; + } + + return ret; +} + +int grib_accessor_class_bufr_simple_thinning_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + + if (*len == 0) + return GRIB_SUCCESS; + int err = apply_thinning(a); + if (err) + return err; + + return grib_set_long(a->parent->h, self->doExtractSubsets, 1); +} diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h b/src/accessor/grib_accessor_class_bufr_simple_thinning.h new file mode 100644 index 000000000..eb786f966 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_simple_thinning_h +#define eccodes_accessor_bufr_simple_thinning_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_simple_thinning */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* simpleThinningStart; + const char* simpleThinningMissingRadius; + const char* simpleThinningSkip; +}; + +class grib_accessor_class_bufr_simple_thinning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_simple_thinning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_simple_thinning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_simple_thinning_h */ diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc new file mode 100644 index 000000000..2568021a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -0,0 +1,84 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bufr_string_values.h" +#include "grib_accessor_class_bufr_data_array.h" + +grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{"bufr_string_values"}; +grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; + + +void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; + int n = 0; + self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->dataAccessor = NULL; + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string_array(dumper, a, NULL); +} + +static grib_accessor* get_accessor(grib_accessor* a) +{ + grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; + if (!self->dataAccessor) { + self->dataAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->dataAccessorName); + } + return self->dataAccessor; +} + +int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + grib_accessor* data = 0; + grib_context* c = a->context; + grib_vsarray* stringValues = NULL; + size_t l = 0, tl; + size_t i, j, n = 0; + char** b = buffer; + + data = get_accessor(a); + if (!data) + return GRIB_NOT_FOUND; + + stringValues = accessor_bufr_data_array_get_stringValues(data); + + n = grib_vsarray_used_size(stringValues); + + tl = 0; + for (j = 0; j < n; j++) { + l = grib_sarray_used_size(stringValues->v[j]); + tl += l; + + if (tl > *len) + return GRIB_ARRAY_TOO_SMALL; + + for (i = 0; i < l; i++) { + *(b++) = grib_context_strdup(c, stringValues->v[j]->v[i]); + } + } + *len = tl; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen){ + grib_accessor* descriptors = get_accessor(a); + return descriptors->value_count(rlen);} + +void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a){ +} diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h b/src/accessor/grib_accessor_class_bufr_string_values.h new file mode 100644 index 000000000..9038a8d73 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_string_values.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_string_values_h +#define eccodes_accessor_bufr_string_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in bufr_string_values */ + const char* dataAccessorName; + grib_accessor* dataAccessor; +}; + +class grib_accessor_class_bufr_string_values_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_bufr_string_values_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_string_values_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_string_values_h */ diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc new file mode 100644 index 000000000..2f4073460 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -0,0 +1,98 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bufrdc_expanded_descriptors.h" + +grib_accessor_class_bufrdc_expanded_descriptors_t _grib_accessor_class_bufrdc_expanded_descriptors{"bufrdc_expanded_descriptors"}; +grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors = &_grib_accessor_class_bufrdc_expanded_descriptors; + + +void grib_accessor_class_bufrdc_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_bufrdc_expanded_descriptors_t* self = (grib_accessor_bufrdc_expanded_descriptors_t*)a; + int n = 0; + self->expandedDescriptors = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->expandedDescriptorsAccessor = 0; + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +static grib_accessor* get_accessor(grib_accessor* a) +{ + grib_accessor_bufrdc_expanded_descriptors_t* self = (grib_accessor_bufrdc_expanded_descriptors_t*)a; + if (!self->expandedDescriptorsAccessor) { + self->expandedDescriptorsAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->expandedDescriptors); + } + return self->expandedDescriptorsAccessor; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor* descriptors = 0; + size_t rlen = 0, l; + long lenall = 0; + size_t i = 0; + long* v = 0; + grib_context* c = a->context; + + descriptors = get_accessor(a); + if (!descriptors) return GRIB_NOT_FOUND; + + a->value_count(&lenall); v = (long*)grib_context_malloc_clear(c, sizeof(long) * lenall); + l = lenall; + descriptors->unpack_long(v, &l); + rlen = 0; + for (i = 0; i < l; i++) { + if ((v[i] < 100000 || v[i] > 221999)) + val[rlen++] = v[i]; + } + *len = rlen; + grib_context_free(c,v); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + int err = 0; + grib_accessor* descriptors = 0; + size_t l = 0; + long lenall = 0; + size_t i = 0; + long* v = 0; + char buf[25] = {0,}; + grib_context* c = a->context; + + descriptors = get_accessor(a); + if (!descriptors) return GRIB_NOT_FOUND; + + err = a->value_count(&lenall); if (err) return err; + l = lenall; + if (l > *len) return GRIB_ARRAY_TOO_SMALL; + + v = (long*)grib_context_malloc_clear(c, sizeof(long) * l); + err = descriptors->unpack_long(v, &l); if (err) return err; + + for (i = 0; i < l; i++) { + snprintf(buf, sizeof(buf), "%06ld", v[i]); + buffer[i] = grib_context_strdup(c, buf); + } + *len = l; + grib_context_free(c,v); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen){ + grib_accessor* descriptors = get_accessor(a); + + return descriptors->value_count(rlen);} + +void grib_accessor_class_bufrdc_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ +} diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h new file mode 100644 index 000000000..588f9d08b --- /dev/null +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufrdc_expanded_descriptors_h +#define eccodes_accessor_bufrdc_expanded_descriptors_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in bufrdc_expanded_descriptors */ + const char* expandedDescriptors; + grib_accessor* expandedDescriptorsAccessor; +}; + +class grib_accessor_class_bufrdc_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bufrdc_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufrdc_expanded_descriptors_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufrdc_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_bytes.cc b/src/accessor/grib_accessor_class_bytes.cc new file mode 100644 index 000000000..e0002429a --- /dev/null +++ b/src/accessor/grib_accessor_class_bytes.cc @@ -0,0 +1,99 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +grib_accessor_class_bytes_t _grib_accessor_class_bytes{"bytes"}; +grib_accessor_class* grib_accessor_class_bytes = &_grib_accessor_class_bytes; + + +void grib_accessor_class_bytes_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_bytes_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_bytes_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + + size_t alen = (size_t)a->byte_count(); size_t blen = (size_t)b->byte_count(); + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + return retval; +} + +int grib_accessor_class_bytes_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + unsigned char* p = NULL; + char* s = v; + long i = 0; + const long length = a->byte_count(); const long slength = 2 * length; + + if (*len < (size_t)slength) { + *len = slength; + return GRIB_BUFFER_TOO_SMALL; + } + + p = grib_handle_of_accessor(a)->buffer->data + a->byte_offset(); + for (i = 0; i < length; i++) { + snprintf(s, INT_MAX, "%02x", *(p++)); + s += 2; + } + + *len = slength; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bytes_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + /* The string representation (val) of the byte array will have two chars + * per byte e.g. 4C5B means the 2 bytes 0114 and 0133 in octal + * so has to be twice the length of the byte array + */ + int err = 0; + grib_context* c = a->context; + size_t nbytes = a->length; + const size_t expected_blen = nbytes; + const size_t expected_slen = 2 * expected_blen; + unsigned char* bytearray = NULL; + size_t i = 0, slen = strlen(val); + + if (slen != expected_slen || *len != expected_slen) { + grib_context_log(c, GRIB_LOG_ERROR, + "%s: Key %s is %lu bytes. Expected a string with %lu characters (actual length=%zu)", + __func__, a->name, expected_blen, expected_slen, *len); + return GRIB_WRONG_ARRAY_SIZE; + } + + bytearray = (unsigned char*)grib_context_malloc(c, nbytes * (sizeof(unsigned char))); + if (!bytearray) return GRIB_OUT_OF_MEMORY; + + for (i = 0; i < (slen/2); i++) { + unsigned int byteVal = 0; + if (sscanf(val + 2*i, "%02x", &byteVal) != 1) { + grib_context_log(c, GRIB_LOG_ERROR,"%s: Invalid hex byte specfication '%.2s'", __func__, val + 2*i); + grib_context_free(c, bytearray); + return GRIB_INVALID_KEY_VALUE; + } + Assert(byteVal < 256); + bytearray[i] = (int)byteVal; + } + + /* Forward to base class to pack the byte array */ + err = grib_accessor_class_gen_t::pack_bytes(a, bytearray, &nbytes); + grib_context_free(c, bytearray); + return err; +} diff --git a/src/accessor/grib_accessor_class_bytes.h b/src/accessor/grib_accessor_class_bytes.h new file mode 100644 index 000000000..8204ceba7 --- /dev/null +++ b/src/accessor/grib_accessor_class_bytes.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bytes_h +#define eccodes_accessor_bytes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bytes_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bytes */ +}; + +class grib_accessor_class_bytes_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bytes_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bytes_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_bytes_h */ diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc new file mode 100644 index 000000000..8375ee26d --- /dev/null +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc @@ -0,0 +1,117 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_change_alternative_row_scanning.h" + +grib_accessor_class_change_alternative_row_scanning_t _grib_accessor_class_change_alternative_row_scanning{"change_alternative_row_scanning"}; +grib_accessor_class* grib_accessor_class_change_alternative_row_scanning = &_grib_accessor_class_change_alternative_row_scanning; + + +void grib_accessor_class_change_alternative_row_scanning_t::init(grib_accessor* a, const long len, grib_arguments* args){ + int n = 0; + grib_accessor_change_alternative_row_scanning_t* self = (grib_accessor_change_alternative_row_scanning_t*)a; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->Ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->Nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->alternativeRowScanning = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_change_alternative_row_scanning_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int err = 0; + grib_accessor_change_alternative_row_scanning_t* self = (grib_accessor_change_alternative_row_scanning_t*)a; + const grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning; + size_t size = 0; + double* values = NULL; + double tmp = 0.0; + + if (*val == 0) + return 0; + + /* Make sure Ni / Nj are not missing */ + if (grib_is_missing(h, self->Ni, &err) && !err) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Ni); + return GRIB_WRONG_GRID; + } + if (grib_is_missing(h, self->Nj, &err) && !err) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Nj); + return GRIB_WRONG_GRID; + } + + if ((err = grib_get_long_internal(h, self->Ni, &Ni)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(h, self->Nj, &Nj)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(h, self->alternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return err; + + if ( size > (size_t)(Ni * Nj) ) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%zu!=%ld*%ld)", size, Ni, Nj); + return GRIB_WRONG_ARRAY_SIZE; + } + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + theEnd = Ni / 2; + for (j = 0; j < Nj; j++) { + jr = Ni * j; + for (i = 0; i < theEnd; i++) { + if (j % 2 == 1) { + /* Swap first and last value on every odd row */ + k = jr + i; + kp = jr + Ni - i - 1; + tmp = values[k]; + values[k] = values[kp]; + values[kp] = tmp; + } + } + } + alternativeRowScanning = !alternativeRowScanning; + if ((err = grib_set_long_internal(h, self->alternativeRowScanning, alternativeRowScanning)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_change_alternative_row_scanning_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_change_alternative_row_scanning_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + /* Decoding this accessor doesn't make sense so we return a dummy value */ + *v = -1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h new file mode 100644 index 000000000..c893e242f --- /dev/null +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_change_alternative_row_scanning_h +#define eccodes_accessor_change_alternative_row_scanning_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_alternative_row_scanning */ + const char* values; + const char* Ni; + const char* Nj; + const char* alternativeRowScanning; +}; + +class grib_accessor_class_change_alternative_row_scanning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_alternative_row_scanning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_alternative_row_scanning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_change_alternative_row_scanning_h */ diff --git a/src/accessor/todo/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc similarity index 57% rename from src/accessor/todo/grib_accessor_class_change_scanning_direction.cc rename to src/accessor/grib_accessor_class_change_scanning_direction.cc index f951c9083..b8f71f14c 100644 --- a/src/accessor/todo/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,115 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long; - IMPLEMENTS = unpack_long - IMPLEMENTS = init;get_native_type - MEMBERS = const char* values - MEMBERS = const char* Ni - MEMBERS = const char* Nj - MEMBERS = const char* i_scans_negatively - MEMBERS = const char* j_scans_positively - MEMBERS = const char* first - MEMBERS = const char* last - MEMBERS = const char* axis - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_change_scanning_direction -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in change_scanning_direction */ - const char* values; - const char* Ni; - const char* Nj; - const char* i_scans_negatively; - const char* j_scans_positively; - const char* first; - const char* last; - const char* axis; -} grib_accessor_change_scanning_direction; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_change_scanning_direction = { - &grib_accessor_class_gen, /* super */ - "change_scanning_direction", /* name */ - sizeof(grib_accessor_change_scanning_direction), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_change_scanning_direction.h" +grib_accessor_class_change_scanning_direction_t _grib_accessor_class_change_scanning_direction{"change_scanning_direction"}; grib_accessor_class* grib_accessor_class_change_scanning_direction = &_grib_accessor_class_change_scanning_direction; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a; +void grib_accessor_class_change_scanning_direction_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_change_scanning_direction_t* self = (grib_accessor_change_scanning_direction_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; @@ -134,8 +34,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* args) a->length = 0; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_change_scanning_direction_t::pack_long(grib_accessor* a, const long* val, size_t* len){ int err = 0; long i, j, jr, theEnd, Ni, Nj, k, kp; double tmp; @@ -145,7 +44,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) double last = 0; size_t size = 0; double* values = NULL; - grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a; + grib_accessor_change_scanning_direction_t* self = (grib_accessor_change_scanning_direction_t*)a; const grib_context* c = a->context; grib_handle* h = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -248,13 +147,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_change_scanning_direction_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_LONG; } -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ +int grib_accessor_class_change_scanning_direction_t::unpack_long(grib_accessor* a, long* v, size_t* len){ /* ECC-976: decoding this accessor doesn't make sense so we return a dummy value */ *v = -1; return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h b/src/accessor/grib_accessor_class_change_scanning_direction.h new file mode 100644 index 000000000..08f2ceb55 --- /dev/null +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_change_scanning_direction_h +#define eccodes_accessor_change_scanning_direction_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_scanning_direction */ + const char* values; + const char* Ni; + const char* Nj; + const char* i_scans_negatively; + const char* j_scans_positively; + const char* first; + const char* last; + const char* axis; +}; + +class grib_accessor_class_change_scanning_direction_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_scanning_direction_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_scanning_direction_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_change_scanning_direction_h */ diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc new file mode 100644 index 000000000..65bdbcbf0 --- /dev/null +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -0,0 +1,51 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_check_internal_version.h" + +grib_accessor_class_check_internal_version_t _grib_accessor_class_check_internal_version{"check_internal_version"}; +grib_accessor_class* grib_accessor_class_check_internal_version = &_grib_accessor_class_check_internal_version; + + +/* This is the internal engine version number */ +/* We check this against the version number found in the definitions boot.def file */ +/* See the key "internalVersion" */ +#define LATEST_ENGINE_VERSION 30 + +void grib_accessor_class_check_internal_version_t::init(grib_accessor* a, const long l, grib_arguments* args){ + /* Check version of definition files is compatible with the engine */ + int err = 0; + long defs_file_version = 0; + grib_handle* h = grib_handle_of_accessor(a); + const char* s_defn_version = grib_arguments_get_name(h, args, 0); + Assert(s_defn_version); + + err = grib_get_long_internal(h, s_defn_version, &defs_file_version); + if (!err) { + if (defs_file_version > LATEST_ENGINE_VERSION) { + grib_context_log(h->context, GRIB_LOG_FATAL, + "Definition files version (%d) is greater than engine version (%d)!\n" + " " /* indent for 2nd line */ + "These definition files are for a later version of the ecCodes engine.", + defs_file_version, LATEST_ENGINE_VERSION); + } + } +} + +int grib_accessor_class_check_internal_version_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_check_internal_version_t::string_length(grib_accessor* a){ + return 255; +} diff --git a/src/accessor/grib_accessor_class_check_internal_version.h b/src/accessor/grib_accessor_class_check_internal_version.h new file mode 100644 index 000000000..871f5a56e --- /dev/null +++ b/src/accessor/grib_accessor_class_check_internal_version.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_check_internal_version_h +#define eccodes_accessor_check_internal_version_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in check_internal_version */ +}; + +class grib_accessor_class_check_internal_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_check_internal_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_check_internal_version_t{}; } + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_check_internal_version_h */ diff --git a/src/accessor/todo/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc similarity index 57% rename from src/accessor/todo/grib_accessor_class_closest_date.cc rename to src/accessor/grib_accessor_class_closest_date.cc index 08ba9f333..462b90078 100644 --- a/src/accessor/todo/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,121 +10,15 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_closest_date.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = dump - IMPLEMENTS = init - MEMBERS = const char *dateLocal - MEMBERS = const char *timeLocal - MEMBERS = const char *numForecasts - MEMBERS = const char *year - MEMBERS = const char *month - MEMBERS = const char *day - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_closest_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in closest_date */ - const char *dateLocal; - const char *timeLocal; - const char *numForecasts; - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; -} grib_accessor_closest_date; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_closest_date = { - &grib_accessor_class_double, /* super */ - "closest_date", /* name */ - sizeof(grib_accessor_closest_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_closest_date_t _grib_accessor_class_closest_date{"closest_date"}; grib_accessor_class* grib_accessor_class_closest_date = &_grib_accessor_class_closest_date; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_closest_date* self = (grib_accessor_closest_date*)a; +void grib_accessor_class_closest_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_closest_date_t* self = (grib_accessor_closest_date_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; @@ -140,13 +35,11 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_closest_date_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_closest_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int ret = 0; double v = 0; @@ -157,9 +50,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* Sets val to the 'index' of the closes date */ -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - const grib_accessor_closest_date* self = (grib_accessor_closest_date*)a; +int grib_accessor_class_closest_date_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_closest_date_t* self = (grib_accessor_closest_date_t*)a; int err = 0; long num_forecasts = 0; /* numberOfForecastsUsedInLocalTime */ diff --git a/src/accessor/grib_accessor_class_closest_date.h b/src/accessor/grib_accessor_class_closest_date.h new file mode 100644 index 000000000..b4fbace12 --- /dev/null +++ b/src/accessor/grib_accessor_class_closest_date.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_closest_date_h +#define eccodes_accessor_closest_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_closest_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in closest_date */ + const char *dateLocal; + const char *timeLocal; + const char *numForecasts; + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_closest_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_closest_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_closest_date_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_closest_date_h */ diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc new file mode 100644 index 000000000..3baa24c1b --- /dev/null +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -0,0 +1,119 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_codeflag.h" + +grib_accessor_class_codeflag_t _grib_accessor_class_codeflag{"codeflag"}; +grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codeflag; + + +void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* param){ + grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + a->length = len; + self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0); + Assert(a->length >= 0); +} + +int test_bit(long a, long b){ + DEBUG_ASSERT(b>=0); + return a & (1 << b); +} + +int grib_get_codeflag(grib_accessor* a, long code, char* codename){ + const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + FILE* f = NULL; + char fname[1024]; + char bval[50]; + char num[50]; + char* filename = 0; + char line[1024]; + size_t i = 0; + int j = 0; + int err = 0; + + err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); + if (err) { + strncpy(fname, self->tablename, sizeof(fname)-1); + fname[sizeof(fname)-1] = '\0'; + } + + if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) { + grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot open flag table %s", filename); + strcpy(codename, "Cannot open flag table"); + return GRIB_FILE_NOT_FOUND; + } + + f = codes_fopen(filename, "r"); + if (!f) { + grib_context_log(a->context, (GRIB_LOG_WARNING) | (GRIB_LOG_PERROR), "Cannot open flag table %s", filename); + strcpy(codename, "Cannot open flag table"); + return GRIB_FILE_NOT_FOUND; + } + + // strcpy(codename, self->tablename); + // strcat(codename,": "); + // j = strlen(codename); + + while (fgets(line, sizeof(line) - 1, f)) { + sscanf(line, "%49s %49s", num, bval); + + if (num[0] != '#') { + if ((test_bit(code, a->length * 8 - atol(num)) > 0) == atol(bval)) { + size_t linelen = strlen(line); + codename[j++] = '('; + codename[j++] = num[0]; + codename[j++] = '='; + codename[j++] = bval[0]; + codename[j++] = ')'; + codename[j++] = ' '; + if (j) + codename[j++] = ' '; + + for (i = (strlen(num) + strlen(bval) + 2); i < linelen - 1; i++) + codename[j++] = line[i]; + if (line[i] != '\n') + codename[j++] = line[i]; + codename[j++] = ';'; + } + } + } + + if (j > 1 && codename[j - 1] == ';') + j--; + codename[j] = 0; + + strcat(codename, ":"); + strcat(codename, fname); + + fclose(f); + return GRIB_SUCCESS; +} + +int grib_accessor_class_codeflag_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +void grib_accessor_class_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper){ + const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + long v = 0; + char flagname[1024] = {0,}; + char fname[1024] = {0,}; + + size_t llen = 1; + + grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); + a->unpack_long(&v, &llen); + grib_get_codeflag(a, v, flagname); + + grib_dump_bits(dumper, a, flagname); +} diff --git a/src/accessor/grib_accessor_class_codeflag.h b/src/accessor/grib_accessor_class_codeflag.h new file mode 100644 index 000000000..734369b74 --- /dev/null +++ b/src/accessor/grib_accessor_class_codeflag.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codeflag_h +#define eccodes_accessor_codeflag_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_codeflag_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in codeflag */ + const char* tablename; +}; + +class grib_accessor_class_codeflag_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_codeflag_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codeflag_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc new file mode 100644 index 000000000..27d787170 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -0,0 +1,69 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_codetable_title.h" +#include "grib_accessor_class_codetable.h" + +grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{"codetable_title"}; +grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; + +void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; + grib_codetable* table = NULL; + + size_t size = 1; + long value; + int err = GRIB_SUCCESS; + char tmp[1024]; + size_t l = 1024; + grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); + + if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) + return err; + + table = ca->table; + + if (table && (value >= 0) && (value < table->size) && table->entries[value].title) { + strcpy(tmp, table->entries[value].title); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)value); + } + + l = strlen(tmp) + 1; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(buffer, tmp); + *len = l; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_codetable_title.h b/src/accessor/grib_accessor_class_codetable_title.h new file mode 100644 index 000000000..e115a9c28 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_title.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codetable_title_h +#define eccodes_accessor_codetable_title_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_title_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_title */ + const char* codetable; +}; + +class grib_accessor_class_codetable_title_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_title_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_title_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codetable_title_h */ diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc new file mode 100644 index 000000000..cc2c3815b --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_codetable_units.h" +#include "grib_accessor_class_codetable.h" + +grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{"codetable_units"}; +grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; + +void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; + + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; + grib_codetable* table = NULL; + + size_t size = 1; + long value; + int err = GRIB_SUCCESS; + char tmp[1024]; + size_t l = sizeof(tmp); + grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); + + if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) + return err; + + table = ca->table; + + if (table && (value >= 0) && (value < table->size) && table->entries[value].units) { + strcpy(tmp, table->entries[value].units); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)value); + } + + l = strlen(tmp) + 1; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(buffer, tmp); + *len = l; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_codetable_units.h b/src/accessor/grib_accessor_class_codetable_units.h new file mode 100644 index 000000000..b5cfb75c8 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_units.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codetable_units_h +#define eccodes_accessor_codetable_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_units */ + const char* codetable; +}; + +class grib_accessor_class_codetable_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_units_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codetable_units_h */ diff --git a/src/accessor/todo/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc similarity index 71% rename from src/accessor/todo/grib_accessor_class_concept.cc rename to src/accessor/grib_accessor_class_concept.cc index 6fa4122f8..55f535cb2 100644 --- a/src/accessor/todo/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,113 +9,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ - -/******************************************************* - * Enrico Fucile - ******************************************************/ - #include "grib_api_internal.h" +#include "grib_accessor_class_concept.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_concept -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in concept */ -} grib_accessor_concept; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_concept = { - &grib_accessor_class_gen, /* super */ - "concept", /* name */ - sizeof(grib_accessor_concept), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_concept_t _grib_accessor_class_concept{"concept"}; grib_accessor_class* grib_accessor_class_concept = &_grib_accessor_class_concept; -/* END_CLASS_IMP */ #define MAX_CONCEPT_STRING_LENGTH 255 @@ -134,19 +34,16 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ +void grib_accessor_class_concept_t::init(grib_accessor* a, const long len, grib_arguments* args){ a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_concept_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } /* Return 1 (=True) or 0 (=False) */ -static int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c) -{ +int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c){ long lval; long lres = 0; int ok = FALSE; /* Boolean */ @@ -190,8 +87,7 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit } /* Return 1 (=True) or 0 (=False) */ -static int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c) -{ +int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c){ long* val = NULL; size_t size = 0, i; int ret; /* Boolean */ @@ -221,8 +117,7 @@ static int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* } /* Return 1 (=True) or 0 (=False) */ -static int concept_condition_true(grib_handle* h, grib_concept_condition* c) -{ +int concept_condition_true(grib_handle* h, grib_concept_condition* c){ if (c->expression == NULL) return concept_condition_iarray_true(h, c); else @@ -263,8 +158,7 @@ static const char* concept_evaluate(grib_accessor* a) #define MAX_NUM_CONCEPT_VALUES 40 -static int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* e, grib_values* values, grib_sarray* sa, int* n) -{ +int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* e, grib_values* values, grib_sarray* sa, int* n){ long lres = 0; double dres = 0.0; int count = *n; @@ -295,30 +189,26 @@ static int concept_conditions_expression_apply(grib_handle* h, grib_concept_cond return err; } -static int concept_conditions_iarray_apply(grib_handle* h, grib_concept_condition* c) -{ +int concept_conditions_iarray_apply(grib_handle* h, grib_concept_condition* c){ size_t size = grib_iarray_used_size(c->iarray); return grib_set_long_array(h, c->name, c->iarray->v, size); } -static int concept_conditions_apply(grib_handle* h, grib_concept_condition* c, grib_values* values, grib_sarray* sa, int* n) -{ +int concept_conditions_apply(grib_handle* h, grib_concept_condition* c, grib_values* values, grib_sarray* sa, int* n){ if (c->expression == NULL) return concept_conditions_iarray_apply(h, c); else return concept_conditions_expression_apply(h, c, values, sa, n); } -static int cmpstringp(const void* p1, const void* p2) -{ +int cmpstringp(const void* p1, const void* p2){ /* The actual arguments to this function are "pointers to pointers to char", but strcmp(3) arguments are "pointers to char", hence the following cast plus dereference */ return strcmp(*(char* const*)p1, *(char* const*)p2); } -static bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value) -{ +bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value){ if ( strcmp(concept_name, "packingType")==0 ) { char input_packing_type[100]; size_t len = sizeof(input_packing_type); @@ -345,8 +235,7 @@ static bool blacklisted(grib_handle* h, long edition, const char* concept_name, return false; } -static int grib_concept_apply(grib_accessor* a, const char* name) -{ +int grib_concept_apply(grib_accessor* a, const char* name){ int err = 0; int count = 0; grib_concept_condition* e = NULL; @@ -440,13 +329,11 @@ static int grib_concept_apply(grib_accessor* a, const char* name) return err; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_concept_t::pack_double(grib_accessor* a, const double* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_concept_t::pack_long(grib_accessor* a, const long* val, size_t* len){ char buf[80]; size_t s; snprintf(buf, sizeof(buf), "%ld", *val); @@ -458,8 +345,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return pack_string(a, buf, &s); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_concept_t::unpack_double(grib_accessor* a, double* val, size_t* len){ /* * If we want to have a condition which contains tests for paramId as well * as a floating point key, then need to be able to evaluate paramId as a @@ -491,8 +377,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size_t* len){ const char* p = concept_evaluate(a); if (!p) { @@ -527,8 +412,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_concept_t::get_native_type(grib_accessor* a){ int type = GRIB_TYPE_STRING; if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) type = GRIB_TYPE_LONG; @@ -536,14 +420,12 @@ static int get_native_type(grib_accessor* a) return type; } -static void destroy(grib_context* c, grib_accessor* a) -{ - //grib_accessor_concept *self = (grib_accessor_concept*)a; +void grib_accessor_class_concept_t::destroy(grib_context* c, grib_accessor* a){ + //grib_accessor_concept_t *self = (grib_accessor_concept_t*)a; //grib_context_free(c,self->cval); } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ +int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, size_t* len){ size_t slen; const char* p = concept_evaluate(a); @@ -576,24 +458,20 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_concept_t::pack_string(grib_accessor* a, const char* val, size_t* len){ return grib_concept_apply(a, val); } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_concept_t::string_length(grib_accessor* a){ return MAX_CONCEPT_STRING_LENGTH; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_concept_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static int compare(grib_accessor* a, grib_accessor* b) -{ +int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b){ int retval = 0; char* aval = 0; char* bval = 0; @@ -603,12 +481,10 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); - if (err) return err; + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); - if (err) return err; + err = b->value_count(&count); if (err) return err; blen = count; if (alen != blen) @@ -619,10 +495,8 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - err = grib_unpack_string(a, aval, &alen); - if (err) return err; - err = grib_unpack_string(b, bval, &blen); - if (err) return err; + err = a->unpack_string(aval, &alen); if (err) return err; + err = b->unpack_string(bval, &blen); if (err) return err; retval = GRIB_SUCCESS; if (!aval || !bval || grib_inline_strcmp(aval, bval)) diff --git a/src/accessor/grib_accessor_class_concept.h b/src/accessor/grib_accessor_class_concept.h new file mode 100644 index 000000000..99405ed48 --- /dev/null +++ b/src/accessor/grib_accessor_class_concept.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_concept_h +#define eccodes_accessor_concept_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_concept_t : public grib_accessor_gen_t +{ +public: + /* Members defined in concept */ +}; + +class grib_accessor_class_concept_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_concept_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_concept_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_concept_h */ diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc new file mode 100644 index 000000000..9e88700a3 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -0,0 +1,28 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_count_file.h" + +grib_accessor_class_count_file_t _grib_accessor_class_count_file{"count_file"}; +grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; + + +void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + *val = grib_context_get_handle_file_count(a->context); + *len = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_count_file.h b/src/accessor/grib_accessor_class_count_file.h new file mode 100644 index 000000000..4b9a0b4f0 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_file.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_file_h +#define eccodes_accessor_count_file_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_file_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_file */ +}; + +class grib_accessor_class_count_file_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_file_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_file_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_file_h */ diff --git a/src/accessor/todo/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc similarity index 55% rename from src/accessor/todo/grib_accessor_class_count_missing.cc rename to src/accessor/grib_accessor_class_count_missing.cc index a4ed76841..f0e74d165 100644 --- a/src/accessor/todo/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,103 +10,11 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init; - IMPLEMENTS = value_count - MEMBERS = const char* bitmap - MEMBERS = const char* unusedBitsInBitmap - MEMBERS = const char* numberOfDataPoints - MEMBERS = const char* missingValueManagementUsed - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_missing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_missing */ - const char* bitmap; - const char* unusedBitsInBitmap; - const char* numberOfDataPoints; - const char* missingValueManagementUsed; -} grib_accessor_count_missing; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_missing = { - &grib_accessor_class_long, /* super */ - "count_missing", /* name */ - sizeof(grib_accessor_count_missing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_count_missing.h" +grib_accessor_class_count_missing_t _grib_accessor_class_count_missing{"count_missing"}; grib_accessor_class* grib_accessor_class_count_missing = &_grib_accessor_class_count_missing; -/* END_CLASS_IMP */ static const unsigned char bitsoff[] = { 8, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4, 7, @@ -126,10 +35,9 @@ static const unsigned char bitsoff[] = { 0 }; -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ +void grib_accessor_class_count_missing_t::init(grib_accessor* a, const long len, grib_arguments* arg){ int n = 0; - grib_accessor_count_missing* self = (grib_accessor_count_missing*)a; + grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; grib_handle* h = grib_handle_of_accessor(a); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; @@ -141,8 +49,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) static const int used[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; -static int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing) -{ +int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing){ int err = 0; long count_of_missing = 0; size_t vsize = 0, ii = 0; @@ -165,9 +72,8 @@ static int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_count_missing* self = (grib_accessor_count_missing*)a; +int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; unsigned char* p; int i; long size = 0; @@ -195,9 +101,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } - size = grib_byte_count(bitmap); - offset = grib_byte_offset(bitmap); - + size = bitmap->byte_count(); offset = bitmap->byte_offset(); if (grib_get_long(h, self->unusedBitsInBitmap, &unusedBitsInBitmap) != GRIB_SUCCESS) { if (grib_get_long(h, self->numberOfDataPoints, &numberOfDataPoints) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to count missing values"); @@ -224,8 +128,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_count_missing_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_count_missing.h b/src/accessor/grib_accessor_class_count_missing.h new file mode 100644 index 000000000..fbf583109 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_missing.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_missing_h +#define eccodes_accessor_count_missing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_missing_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_missing */ + const char* bitmap; + const char* unusedBitsInBitmap; + const char* numberOfDataPoints; + const char* missingValueManagementUsed; +}; + +class grib_accessor_class_count_missing_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_missing_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_missing_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_missing_h */ diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc new file mode 100644 index 000000000..2c2c69c3c --- /dev/null +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -0,0 +1,28 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_count_total.h" + +grib_accessor_class_count_total_t _grib_accessor_class_count_total{"count_total"}; +grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; + + +void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + *val = grib_context_get_handle_total_count(a->context); + *len = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_count_total.h b/src/accessor/grib_accessor_class_count_total.h new file mode 100644 index 000000000..ab044e8a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_total.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_total_h +#define eccodes_accessor_count_total_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_total_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_total */ +}; + +class grib_accessor_class_count_total_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_total_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_total_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_total_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc similarity index 64% rename from src/accessor/todo/grib_accessor_class_data_apply_bitmap.cc rename to src/accessor/grib_accessor_class_data_apply_bitmap.cc index 675e7b3de..ac7fccc1c 100644 --- a/src/accessor/todo/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,123 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_value.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = dump;get_native_type - IMPLEMENTS = compare - MEMBERS=const char* coded_values - MEMBERS=const char* bitmap - MEMBERS=const char* missing_value - MEMBERS=const char* number_of_data_points - MEMBERS=const char* number_of_values - MEMBERS=const char* binary_scale_factor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_apply_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_apply_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* number_of_data_points; - const char* number_of_values; - const char* binary_scale_factor; -} grib_accessor_data_apply_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_apply_bitmap = { - &grib_accessor_class_gen, /* super */ - "data_apply_bitmap", /* name */ - sizeof(grib_accessor_data_apply_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_api_internal.h" +#include "grib_accessor_class_data_apply_bitmap.h" +grib_accessor_class_data_apply_bitmap_t _grib_accessor_class_data_apply_bitmap{"data_apply_bitmap"}; grib_accessor_class* grib_accessor_class_data_apply_bitmap = &_grib_accessor_class_data_apply_bitmap; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ +void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ int n = 0; - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -135,14 +29,12 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_data_apply_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; +int grib_accessor_class_data_apply_bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; size_t len = 0; int ret = 0; @@ -156,9 +48,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, i = 0; size_t cidx = 0; @@ -167,8 +58,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) size_t n_vals = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -203,9 +93,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return grib_get_double_element_internal(gh, self->coded_values, cidx, val); } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, all_missing = 1; size_t cidx = 0; /* index into the coded_values array */ @@ -216,8 +105,7 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array size_t n_vals = 0, i = 0, j = 0, idx = 0, count_1s = 0, ci = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; if (!grib_find_accessor(gh, self->bitmap)) @@ -283,9 +171,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; +int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; int err = 0; size_t bmaplen = *len; long coded_n_vals = 0; @@ -344,10 +231,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) } template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ +int unpack(grib_accessor* a, T* val, size_t* len){ static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; size_t i = 0; size_t j = 0; @@ -358,8 +244,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) T* coded_vals = NULL; double missing_value = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -426,26 +311,22 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_apply_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_apply_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len){ return unpack(a, val, len); } -static int get_native_type(grib_accessor* a) -{ - //grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; +int grib_accessor_class_data_apply_bitmap_t::get_native_type(grib_accessor* a){ + //grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); return GRIB_TYPE_DOUBLE; } -static int compare(grib_accessor* a, grib_accessor* b) -{ +int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_accessor* b){ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -455,13 +336,11 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); - if (err) + err = b->value_count(&count); if (err) return err; blen = count; @@ -471,9 +350,7 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->numberOfRows = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -130,14 +28,12 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* numberOfPoints) -{ - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; +int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints){ + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; int ret = 0; *numberOfPoints = 0; @@ -147,9 +43,8 @@ static int value_count(grib_accessor* a, long* numberOfPoints) } template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; +int unpack(grib_accessor* a, T* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; size_t plSize = 0; long* pl = 0; @@ -242,18 +137,15 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor* a, float* val, size_t* len){ return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ size_t size; double* values; int err = 0; @@ -276,8 +168,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ size_t size = 0, i = 0; double* values; int err = 0; @@ -304,9 +195,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; +int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; size_t plSize = 0; long* pl = 0; @@ -388,7 +278,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_data_apply_boustrophedonic_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_DOUBLE; } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h new file mode 100644 index 000000000..a0358195f --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_apply_boustrophedonic_h +#define eccodes_accessor_data_apply_boustrophedonic_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic */ + const char* values; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; + const char* pl; +}; + +class grib_accessor_class_data_apply_boustrophedonic_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_apply_boustrophedonic_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc similarity index 69% rename from src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc rename to src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index b68e362db..217431b43 100644 --- a/src/accessor/todo/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,121 +10,15 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_data_apply_boustrophedonic_bitmap.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = dump;get_native_type - MEMBERS=const char* coded_values - MEMBERS=const char* bitmap - MEMBERS=const char* missing_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* numberOfRows - MEMBERS=const char* numberOfColumns - MEMBERS=const char* numberOfPoints - - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_apply_boustrophedonic_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_apply_boustrophedonic_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* binary_scale_factor; - const char* numberOfRows; - const char* numberOfColumns; - const char* numberOfPoints; -} grib_accessor_data_apply_boustrophedonic_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_apply_boustrophedonic_bitmap = { - &grib_accessor_class_gen, /* super */ - "data_apply_boustrophedonic_bitmap", /* name */ - sizeof(grib_accessor_data_apply_boustrophedonic_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_apply_boustrophedonic_bitmap_t _grib_accessor_class_data_apply_boustrophedonic_bitmap{"data_apply_boustrophedonic_bitmap"}; grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap = &_grib_accessor_class_data_apply_boustrophedonic_bitmap; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ +void grib_accessor_class_data_apply_boustrophedonic_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ int n = 0; - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->coded_values = grib_arguments_get_name(gh, args, n++); @@ -138,14 +33,12 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_data_apply_boustrophedonic_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); size_t len = 0; int ret = 0; @@ -158,9 +51,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); size_t i = 0, j = 0, n_vals = 0, irow = 0; @@ -171,8 +63,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) double missing_value = 0; long numberOfPoints, numberOfRows, numberOfColumns; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -268,9 +159,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, i = 0; size_t cidx = 0; @@ -279,8 +169,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) size_t n_vals = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -315,9 +204,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return grib_get_double_element_internal(gh, self->coded_values, cidx, val); } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, all_missing = 1; size_t cidx = 0; /* index into the coded_values array */ @@ -328,8 +216,7 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array size_t n_vals = 0, i = 0, j = 0, idx = 0, count_1s = 0, ci = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; if (!grib_find_accessor(gh, self->bitmap)) @@ -395,9 +282,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0; size_t bmaplen = *len; @@ -495,9 +381,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return err; } -static int get_native_type(grib_accessor* a) -{ - //grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::get_native_type(grib_accessor* a){ + //grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); return GRIB_TYPE_DOUBLE; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h new file mode 100644 index 000000000..e92299eab --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h +#define eccodes_accessor_data_apply_boustrophedonic_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic_bitmap */ + const char* coded_values; + const char* bitmap; + const char* missing_value; + const char* binary_scale_factor; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; +}; + +class grib_accessor_class_data_apply_boustrophedonic_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_apply_boustrophedonic_bitmap_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc similarity index 77% rename from src/accessor/todo/grib_accessor_class_data_ccsds_packing.cc rename to src/accessor/grib_accessor_class_data_ccsds_packing.cc index ccfd48c03..5158ee7fd 100644 --- a/src/accessor/todo/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,137 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_bits_any_endian_simple.h" +#include "grib_api_internal.h" +#include "grib_accessor_class_data_ccsds_packing.h" #include "grib_scaling.h" -#include -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scaling_factor - MEMBERS=const char* bits_per_value - MEMBERS=const char* number_of_data_points - MEMBERS=const char* ccsds_flags - MEMBERS=const char* ccsds_block_size - MEMBERS=const char* ccsds_rsi - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_ccsds_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_ccsds_packing */ - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - const char* bits_per_value; - const char* number_of_data_points; - const char* ccsds_flags; - const char* ccsds_block_size; - const char* ccsds_rsi; -} grib_accessor_data_ccsds_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_ccsds_packing = { - &grib_accessor_class_values, /* super */ - "data_ccsds_packing", /* name */ - sizeof(grib_accessor_data_ccsds_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{"data_ccsds_packing"}; grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; +void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* h = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(h, args, self->carg++); @@ -155,9 +35,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; +int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, count); } @@ -177,8 +56,7 @@ static bool is_big_endian() return reinterpret_cast(&endianess_test)[0] == is_big_endian; } -static void modify_aec_flags(long* flags) -{ +void modify_aec_flags(long* flags){ // ECC-1602: Performance improvement: enabled the use of native data types *flags &= ~AEC_DATA_3BYTE; // disable support for 3-bytes per value if (is_big_endian()) @@ -197,8 +75,7 @@ static const char* aec_get_error_message(int code) return "Unknown error code"; } -static void print_aec_stream_info(struct aec_stream* strm, const char* func) -{ +void print_aec_stream_info(struct aec_stream* strm, const char* func){ fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.bits_per_sample=%u\n", func, strm->bits_per_sample); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); @@ -207,9 +84,8 @@ static void print_aec_stream_info(struct aec_stream* strm, const char* func) fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -499,10 +375,9 @@ cleanup: } template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ +int unpack(grib_accessor* a, T* val, size_t* len){ static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -530,7 +405,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) self->dirty = 0; - if ((err = grib_value_count(a, &nn)) != GRIB_SUCCESS) + if ((err = a->value_count(&nn)) != GRIB_SUCCESS) return err; n_vals = nn; @@ -569,10 +444,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len) bscale = codes_power(binary_scale_factor, 2); dscale = codes_power(-decimal_scale_factor, 10); - buflen = grib_byte_count(a); - buf = (unsigned char*)hand->buffer->data; - buf += grib_byte_offset(a); - + buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; + buf += a->byte_offset(); strm.flags = ccsds_flags; strm.bits_per_sample = bits_per_value; strm.block_size = ccsds_block_size; @@ -637,20 +510,17 @@ cleanup: return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ // The index idx relates to codedValues NOT values! - const grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; + const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; size_t size = 0; @@ -684,9 +554,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - const grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; double* values = NULL; @@ -732,34 +601,28 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array #else -static void print_error_feature_not_enabled(grib_context* c) -{ +static void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "CCSDS support not enabled. " "Please rebuild with -DENABLE_AEC=ON (Adaptive Entropy Coding library)"); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h new file mode 100644 index 000000000..2d06c6f09 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_ccsds_packing_h +#define eccodes_accessor_data_ccsds_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_ccsds_packing */ + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; + const char* bits_per_value; + const char* number_of_data_points; + const char* ccsds_flags; + const char* ccsds_block_size; + const char* ccsds_rsi; +}; + +class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_ccsds_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_ccsds_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_ccsds_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc similarity index 82% rename from src/accessor/todo/grib_accessor_class_data_complex_packing.cc rename to src/accessor/grib_accessor_class_data_complex_packing.cc index 49d312611..e9c36000f 100644 --- a/src/accessor/todo/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,147 +9,20 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_ieeefloat.h" +#include "grib_api_internal.h" +#include "grib_accessor_class_data_complex_packing.h" #include "grib_scaling.h" -#include -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_complex_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_complex_packing", /* name */ - sizeof(grib_accessor_data_complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_ieeefloat.h" +grib_accessor_class_data_complex_packing_t _grib_accessor_class_data_complex_packing{"data_complex_packing"}; grib_accessor_class* grib_accessor_class_data_complex_packing = &_grib_accessor_class_data_complex_packing; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; +void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(gh, args, self->carg++); @@ -165,9 +39,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; +int grib_accessor_class_data_complex_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; int ret = 0; grib_handle* gh = grib_handle_of_accessor(a); long pen_j = 0; @@ -195,8 +68,7 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation) -{ +double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation){ /*long n_vals = ((fieldTruncation+1)*(fieldTruncation+2));*/ long loop, index, m, n = 0; double pFactor, zeps = 1.0e-15; @@ -302,9 +174,8 @@ static double calculate_pfactor(const grib_context* ctx, const double* spectralF return pFactor; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; +int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -673,10 +544,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ +int unpack(grib_accessor* a, T* val, size_t* len){ static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -724,8 +594,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) decode_float_proc decode_float = NULL; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < n_vals) { @@ -798,8 +667,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) maxv = pen_j + 1; - buf += grib_byte_offset(a); - hres = buf; + buf += a->byte_offset(); hres = buf; lres = buf; if (pen_j == sub_j) { @@ -814,8 +682,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return 0; } - packed_offset = grib_byte_offset(a) + bytes * (sub_k + 1) * (sub_k + 2); - + packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); lpos = 8 * (packed_offset - offsetdata); s = codes_power(binary_scale_factor, 2); @@ -895,13 +762,11 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_complex_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_complex_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ // TODO(maee): See ECC-1579 // Investigate why results are not bit-identical diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h b/src/accessor/grib_accessor_class_data_complex_packing.h new file mode 100644 index 000000000..2c4618865 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_complex_packing.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_complex_packing_h +#define eccodes_accessor_data_complex_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_complex_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_complex_packing */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_complex_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_complex_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_dummy_field.cc b/src/accessor/grib_accessor_class_data_dummy_field.cc new file mode 100644 index 000000000..5216c2a94 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_dummy_field.cc @@ -0,0 +1,102 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_dummy_field.h" + +grib_accessor_class_data_dummy_field_t _grib_accessor_class_data_dummy_field{"data_dummy_field"}; +grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_class_data_dummy_field; + + +void grib_accessor_class_data_dummy_field_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); +} + +int grib_accessor_class_data_dummy_field_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + size_t i = 0, n_vals = 0; + long numberOfPoints; + double missing_value = 0; + int err = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints)) != GRIB_SUCCESS) + return err; + n_vals = numberOfPoints; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < n_vals; i++) + val[i] = missing_value; + + if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) { + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->bitmap, val, n_vals)) != GRIB_SUCCESS) + return err; + } + + *len = (long)n_vals; + return err; +} + +int grib_accessor_class_data_dummy_field_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + + size_t n_vals = *len; + int err = 0; + long bits_per_value = 0; + long half_byte = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + + buflen = (1 + ((bits_per_value * n_vals) / 8)) * sizeof(unsigned char); + + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + + half_byte = (buflen * 8) - ((*len) * bits_per_value); + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte)) != GRIB_SUCCESS) { + grib_context_free(a->context, buf); + return err; + } + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_data_dummy_field_t::value_count(grib_accessor* a, long* numberOfPoints){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + int err = 0; + *numberOfPoints = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints)) != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to get count of %s (%s)", a->name, grib_get_error_message(err)); + } + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h b/src/accessor/grib_accessor_class_data_dummy_field.h new file mode 100644 index 000000000..00de1fe73 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_dummy_field.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_dummy_field_h +#define eccodes_accessor_data_dummy_field_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_g1simple_packing.h" + +class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t +{ +public: + /* Members defined in data_dummy_field */ + const char* missing_value; + const char* numberOfPoints; + const char* bitmap; +}; + +class grib_accessor_class_data_dummy_field_t : public grib_accessor_class_data_g1simple_packing_t +{ +public: + grib_accessor_class_data_dummy_field_t(const char* name) : grib_accessor_class_data_g1simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_dummy_field_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_dummy_field_h */ diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc new file mode 100644 index 000000000..eecf83cfb --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -0,0 +1,112 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g1complex_packing.h" + +grib_accessor_class_data_g1complex_packing_t _grib_accessor_class_data_g1complex_packing{"data_g1complex_packing"}; +grib_accessor_class* grib_accessor_class_data_g1complex_packing = &_grib_accessor_class_data_g1complex_packing; + + +void grib_accessor_class_data_g1complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1complex_packing_t* self = (grib_accessor_data_g1complex_packing_t*)a; + self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->N = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->ieee_packing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->edition = 1; + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g1complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g1complex_packing_t* self = (grib_accessor_data_g1complex_packing_t*)a; + int ret = GRIB_SUCCESS; + long seclen = 0; + long sub_j = 0; + long sub_k = 0; + long sub_m = 0; + long n = 0; + long half_byte = 0; + long bits_per_value = 0; + size_t buflen = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + +// /* TODO: spectral_ieee does not work */ +// if (c->ieee_packing && self->ieee_packing) { +// grib_handle* h = grib_handle_of_accessor(a); +// grib_context* c = a->context; +// char* packingType_s = NULL; +// char* ieee_packing_s = NULL; +// long precision = c->ieee_packing == 32 ? 1 : 2; +// size_t lenstr = strlen(self->ieee_packing); + +// packingType_s = grib_context_strdup(c, self->packingType); +// ieee_packing_s = grib_context_strdup(c, self->ieee_packing); +// precision_s = grib_context_strdup(c, self->precision); + +// grib_set_string(h, packingType_s, ieee_packing_s, &lenstr); +// grib_set_long(h, precision_s, precision); + +// grib_context_free(c, packingType_s); +// grib_context_free(c, ieee_packing_s); +// grib_context_free(c, precision_s); +// return grib_set_double_array(h, "values", val, *len); +// } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_j, &sub_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_k, &sub_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_m, &sub_m)) != GRIB_SUCCESS) + return ret; + + self->dirty = 1; + + Assert((sub_j == sub_k) && (sub_m == sub_j)); + + ret = grib_accessor_class_data_complex_packing_t::pack_double(a, val, len); + + if (ret == GRIB_SUCCESS) { + n = a->offset + 4 * ((sub_k + 1) * (sub_k + 2)); + + /* Octet number starts from beginning of message but shouldn't */ + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n)) != GRIB_SUCCESS) + return ret; + + // ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection); + // if (ret != GRIB_SUCCESS) + // return ret; + // if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS) + // return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value); + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen); + if (ret != GRIB_SUCCESS) + return ret; + + buflen = 32 * (sub_k + 1) * (sub_k + 2) + (*len - (sub_k + 1) * (sub_k + 2)) * bits_per_value + 18 * 8; + half_byte = seclen * 8 - buflen; + if (a->context->debug == -1) { + fprintf(stderr, "ECCODES DEBUG: half_byte=%ld\n", half_byte); + } + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte); + if (ret != GRIB_SUCCESS) + return ret; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h b/src/accessor/grib_accessor_class_data_g1complex_packing.h new file mode 100644 index 000000000..cc6208c95 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1complex_packing_h +#define eccodes_accessor_data_g1complex_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g1complex_packing */ + const char* N; + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g1complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1complex_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc similarity index 58% rename from src/accessor/todo/grib_accessor_class_data_g1second_order_constant_width_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc index 079e91829..b0009cfa9 100644 --- a/src/accessor/todo/grib_accessor_class_data_g1second_order_constant_width_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,157 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_data_g1second_order_constant_width_packing.h" +#include "grib_scaling.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidth - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g1second_order_constant_width_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_constant_width_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidth; -} grib_accessor_data_g1second_order_constant_width_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_constant_width_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_constant_width_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_constant_width_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_g1second_order_constant_width_packing_t _grib_accessor_class_data_g1second_order_constant_width_packing{"data_g1second_order_constant_width_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing = &_grib_accessor_class_data_g1second_order_constant_width_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; +void grib_accessor_class_data_g1second_order_constant_width_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(hand, args, self->carg++); @@ -181,10 +41,9 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues){ int err = 0; - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; *numberOfSecondOrderPackedValues = 0; err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); @@ -192,14 +51,12 @@ static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) return err; } -static int unpack_float(grib_accessor*, float* val, size_t* len) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_float(grib_accessor*, float* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* values, size_t* len) -{ - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long groupWidth = 0; @@ -218,8 +75,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) long* secondaryBitmap; grib_handle* hand = grib_handle_of_accessor(a); - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(hand, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -321,15 +177,13 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s: Not implemented", cclass_name, __func__); return GRIB_NOT_IMPLEMENTED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0; double* values = NULL; @@ -354,8 +208,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; double* values = NULL; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h new file mode 100644 index 000000000..adfc36716 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h @@ -0,0 +1,53 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_constant_width_packing_h +#define eccodes_accessor_data_g1second_order_constant_width_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_constant_width_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidth; +}; + +class grib_accessor_class_data_g1second_order_constant_width_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_constant_width_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_constant_width_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_g1second_order_constant_width_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc similarity index 85% rename from src/accessor/todo/grib_accessor_class_data_g1second_order_general_extended_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index d337dba48..5058a2102 100644 --- a/src/accessor/todo/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,178 +9,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" -#include "grib_optimize_decimal_factor.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - IMPLEMENTS = destroy - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* firstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* codedNumberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* groupWidths - MEMBERS=const char* widthOfWidths - MEMBERS=const char* groupLengths - MEMBERS=const char* widthOfLengths - MEMBERS=const char* NL - MEMBERS=const char* SPD - MEMBERS=const char* widthOfSPD - MEMBERS=const char* orderOfSPD - MEMBERS=const char* numberOfPoints - MEMBERS=const char* dataFlag - MEMBERS=double* dvalues - MEMBERS=float* fvalues - MEMBERS=int double_dirty - MEMBERS=int float_dirty - MEMBERS=size_t size - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g1second_order_general_extended_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_general_extended_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* firstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* codedNumberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* groupWidths; - const char* widthOfWidths; - const char* groupLengths; - const char* widthOfLengths; - const char* NL; - const char* SPD; - const char* widthOfSPD; - const char* orderOfSPD; - const char* numberOfPoints; - const char* dataFlag; - double* dvalues; - float* fvalues; - int double_dirty; - int float_dirty; - size_t size; -} grib_accessor_data_g1second_order_general_extended_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_general_extended_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_general_extended_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_general_extended_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g1second_order_general_extended_packing.h" +#include "grib_scaling.h" +grib_accessor_class_data_g1second_order_general_extended_packing_t _grib_accessor_class_data_g1second_order_general_extended_packing{"data_g1second_order_general_extended_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing = &_grib_accessor_class_data_g1second_order_general_extended_packing; -/* END_CLASS_IMP */ #define MAX_NUMBER_OF_GROUPS 65534 #define EFDEBUG 0 @@ -203,8 +39,7 @@ static const unsigned long nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -static long number_of_bits(grib_handle* h, unsigned long x) -{ +long number_of_bits(grib_handle* h, unsigned long x){ const unsigned long* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); long i = 0; @@ -220,9 +55,8 @@ static long number_of_bits(grib_handle* h, unsigned long x) return i; } -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; +void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; grib_handle* handle = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(handle, args, self->carg++); @@ -256,9 +90,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; +int grib_accessor_class_data_g1second_order_general_extended_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; long numberOfCodedValues = 0; long numberOfGroups = 0; size_t ngroups; @@ -293,8 +126,7 @@ static int value_count(grib_accessor* a, long* count) return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ size_t size; double* values; int err = 0; @@ -317,8 +149,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ size_t size = 0, i = 0; double* values; int err = 0; @@ -345,9 +176,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len) -{ - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; +int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len){ + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* firstOrderValues = 0; @@ -396,8 +226,9 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len self->float_dirty = 0; } - buf += grib_byte_offset(a); - ret = value_count(a, &numberOfValues); + buf += a->byte_offset(); + ret = a->value_count(&numberOfValues); + if (ret) return ret; @@ -565,13 +396,11 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ return unpack(a, NULL, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ return unpack(a, values, NULL, len); } @@ -684,8 +513,7 @@ static void grib_split_long_groups(grib_handle* hand, grib_context* c, long* num grib_context_free(c, localFirstOrderValues); } -static int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bits_per_value) -{ +int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bits_per_value){ int err = 0; if ((err = grib_get_long_internal(h, bits_per_value_str, bits_per_value)) != GRIB_SUCCESS) return err; @@ -708,9 +536,8 @@ static int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, lo // For the old implementation of pack_double, see // src/deprecated/grib_accessor_class_data_g1second_order_general_extended_packing.pack_double.cc // See ECC-441 and ECC-261 -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; +int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; int ret = 0; int grib2 = 0; long bits_per_value, orderOfSPD, binary_scale_factor; @@ -1365,9 +1192,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static void destroy(grib_context* context, grib_accessor* a) -{ - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; +void grib_accessor_class_data_g1second_order_general_extended_packing_t::destroy(grib_context* context, grib_accessor* a){ + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; if (self->dvalues != NULL) { grib_context_free(context, self->dvalues); self->dvalues = NULL; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h new file mode 100644 index 000000000..a870edcf6 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -0,0 +1,65 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_general_extended_packing_h +#define eccodes_accessor_data_g1second_order_general_extended_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_extended_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* firstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* codedNumberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* groupWidths; + const char* widthOfWidths; + const char* groupLengths; + const char* widthOfLengths; + const char* NL; + const char* SPD; + const char* widthOfSPD; + const char* orderOfSPD; + const char* numberOfPoints; + const char* dataFlag; + double* dvalues; + float* fvalues; + int double_dirty; + int float_dirty; + size_t size; +}; + +class grib_accessor_class_data_g1second_order_general_extended_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_extended_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_extended_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_g1second_order_general_extended_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc similarity index 55% rename from src/accessor/todo/grib_accessor_class_data_g1second_order_general_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index 3e41fd3e0..e9d620f52 100644 --- a/src/accessor/todo/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,156 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" -#include - - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidths - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1second_order_general_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_general_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -} grib_accessor_data_g1second_order_general_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_general_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_general_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_general_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g1second_order_general_packing.h" +#include "grib_scaling.h" +grib_accessor_class_data_g1second_order_general_packing_t _grib_accessor_class_data_g1second_order_general_packing{"data_g1second_order_general_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing = &_grib_accessor_class_data_g1second_order_general_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; +void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(hand, args, self->carg++); @@ -180,10 +41,9 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) -{ +int grib_accessor_class_data_g1second_order_general_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues){ int err = 0; - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; *numberOfSecondOrderPackedValues = 0; err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); @@ -192,10 +52,9 @@ static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) } template -static int unpack(grib_accessor* a, T* values, size_t* len) -{ +int unpack(grib_accessor* a, T* values, size_t* len){ static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* groupWidths = 0; @@ -213,8 +72,7 @@ static int unpack(grib_accessor* a, T* values, size_t* len) long groupLength, j; size_t groupWidthsSize; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -296,18 +154,15 @@ static int unpack(grib_accessor* a, T* values, size_t* len) return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ return unpack(a, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ return unpack(a, values, len); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ +int grib_accessor_class_data_g1second_order_general_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ /* return GRIB_NOT_IMPLEMENTED; */ int err = 0; char type[] = "grid_second_order"; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h new file mode 100644 index 000000000..5161324f0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h @@ -0,0 +1,51 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_general_packing_h +#define eccodes_accessor_data_g1second_order_general_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_general_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_general_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1second_order_general_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc similarity index 64% rename from src/accessor/todo/grib_accessor_class_data_g1second_order_row_by_row_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index b801b3b1c..10dc06079 100644 --- a/src/accessor/todo/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,154 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_data_g1second_order_row_by_row_packing.h" +#include "grib_scaling.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidths - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1second_order_row_by_row_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_row_by_row_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -} grib_accessor_data_g1second_order_row_by_row_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_row_by_row_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_row_by_row_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_row_by_row_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_g1second_order_row_by_row_packing_t _grib_accessor_class_data_g1second_order_row_by_row_packing{"data_g1second_order_row_by_row_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing = &_grib_accessor_class_data_g1second_order_row_by_row_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; +void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(gh, args, self->carg++); @@ -178,9 +41,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); long n = 0, i = 0; long numberOfRows = 0; @@ -254,9 +116,8 @@ static int value_count(grib_accessor* a, long* count) } template -static int unpack(grib_accessor* a, T* values, size_t* len) -{ - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; +int unpack(grib_accessor* a, T* values, size_t* len){ + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; @@ -279,8 +140,7 @@ static int unpack(grib_accessor* a, T* values, size_t* len) size_t plSize = 0; long* pl = 0; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -421,18 +281,15 @@ static int unpack(grib_accessor* a, T* values, size_t* len) return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ return unpack(a, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) -{ +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ return unpack(a, values, len); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ int err = 0; grib_handle* gh = grib_handle_of_accessor(a); char type[] = "grid_second_order"; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h new file mode 100644 index 000000000..1e9c27f39 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h @@ -0,0 +1,51 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_row_by_row_packing_h +#define eccodes_accessor_data_g1second_order_row_by_row_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_row_by_row_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_row_by_row_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_row_by_row_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_row_by_row_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_row_by_row_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1second_order_row_by_row_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc new file mode 100644 index 000000000..cbabc9cf1 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -0,0 +1,128 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g1secondary_bitmap.h" + +grib_accessor_class_data_g1secondary_bitmap_t _grib_accessor_class_data_g1secondary_bitmap{"data_g1secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap = &_grib_accessor_class_data_g1secondary_bitmap; + + +void grib_accessor_class_data_g1secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + self->number_of_ones = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); +} + +int grib_accessor_class_data_g1secondary_bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + size_t len = 0; + int err = 0; + long expand_by; + *count = 0; + + err = grib_get_long_internal(grib_handle_of_accessor(a), self->expand_by, &expand_by); + if (err) + return err; + + err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &len); + if (err) + return err; + + *count = expand_by * len; + return GRIB_SUCCESS; +} + +int grib_accessor_class_data_g1secondary_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + + int err = 0; + + long primary_len = 0; + long secondary_len = 0; + double* primary_bitmap = NULL; + double* secondary_bitmap = NULL; + long i = 0; + long j = 0; + long on = 0; + long k; + long m; + double missing_value = 0; + double present_value = 0; + long expand_by = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + if (expand_by <= 0) + return GRIB_ENCODING_ERROR; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len % expand_by) { + /*TODO: issue warning */ + return GRIB_ENCODING_ERROR; + } + + primary_len = *len / expand_by; + primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); + if (!primary_bitmap) + return GRIB_OUT_OF_MEMORY; + + secondary_len = *len; + secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); + if (!secondary_bitmap) { + grib_context_free(a->context, primary_bitmap); + return GRIB_OUT_OF_MEMORY; + } + + if (missing_value == 0) + present_value = 1; + else + present_value = 0; + + k = 0; + m = 0; + for (i = 0; i < *len; i += expand_by) { + int cnt = 0; + for (j = 0; j < expand_by; j++) + if (val[i + j] == missing_value) + cnt++; + + if (cnt == expand_by) /* all expand_by values are missing */ + primary_bitmap[k++] = missing_value; + else { + primary_bitmap[k++] = present_value; + for (j = 0; j < expand_by; j++) + secondary_bitmap[m++] = val[i + j]; + on++; + } + } + + *len = k; + + /*printf("QQQQQQQ %ld %ld second=%ld\n",primary_len,on,m);*/ + Assert(k == primary_len); + + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); + if (err == GRIB_SUCCESS) + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); + + grib_context_free(a->context, primary_bitmap); + grib_context_free(a->context, secondary_bitmap); + + if (err == GRIB_SUCCESS) + err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_ones, on); + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h new file mode 100644 index 000000000..e963d6f44 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1secondary_bitmap_h +#define eccodes_accessor_data_g1secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g1secondary_bitmap */ + const char* number_of_ones; +}; + +class grib_accessor_class_data_g1secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g1secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc new file mode 100644 index 000000000..d6a8a6562 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc @@ -0,0 +1,64 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g1shsimple_packing.h" + +grib_accessor_class_data_g1shsimple_packing_t _grib_accessor_class_data_g1shsimple_packing{"data_g1shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_g1shsimple_packing = &_grib_accessor_class_data_g1shsimple_packing; + + + +int grib_accessor_class_data_g1shsimple_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1shsimple_packing_t* self = (grib_accessor_data_g1shsimple_packing_t*)a; + size_t len = 0; + int err = 0; + + err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &len); + len += 1; + + *count = len; + return err; +} + +int grib_accessor_class_data_g1shsimple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g1shsimple_packing_t* self = (grib_accessor_data_g1shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = 0; + size_t n_vals = 0; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + n_vals = coded_n_vals + 1; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_data_g1shsimple_packing_t_bitmap : unpack_double : creating %s, %d values", + a->name, n_vals); + + *len = n_vals; + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h new file mode 100644 index 000000000..0c8efffa1 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1shsimple_packing_h +#define eccodes_accessor_data_g1shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g1shsimple_packing */ +}; + +class grib_accessor_class_data_g1shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g1shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1shsimple_packing_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; +}; +#endif /* eccodes_accessor_data_g1shsimple_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc similarity index 64% rename from src/accessor/todo/grib_accessor_class_data_g1simple_packing.cc rename to src/accessor/grib_accessor_class_data_g1simple_packing.cc index cc810e4ae..a3320a810 100644 --- a/src/accessor/todo/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,126 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_data_g1simple_packing.h" +#include "grib_scaling.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1simple_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -} grib_accessor_data_g1simple_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1simple_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1simple_packing", /* name */ - sizeof(grib_accessor_data_g1simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_g1simple_packing_t _grib_accessor_class_data_g1simple_packing{"data_g1simple_packing"}; grib_accessor_class* grib_accessor_class_data_g1simple_packing = &_grib_accessor_class_data_g1simple_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; +void grib_accessor_class_data_g1simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); @@ -137,9 +28,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* number_of_values) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; +int grib_accessor_class_data_g1simple_packing_t::value_count(grib_accessor* a, long* number_of_values){ + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; *number_of_values = 0; /* Special case for when values are cleared */ @@ -149,10 +39,8 @@ static int value_count(grib_accessor* a, long* number_of_values) return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; - grib_accessor_class* super = *(a->cclass->super); +int grib_accessor_class_data_g1simple_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; size_t n_vals = *len; long half_byte = 0; @@ -234,7 +122,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) } } - ret = super->pack_double(a, val, len); + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, val, len); switch (ret) { case GRIB_CONSTANT_FIELD: ret = grib_get_long(grib_handle_of_accessor(a), "constantFieldHalfByte", &constantFieldHalfByte); @@ -319,7 +207,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) grib_encode_double_array(n_vals, val, bits_per_value, reference_value, decimal, divisor, encoded, &off); grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g1simple_packing : pack_double : packing %s, %d values", a->name, n_vals); + "grib_accessor_data_g1simple_packing_t : pack_double : packing %s, %d values", a->name, n_vals); ret = grib_buffer_replace(a, buf, buflen, 1, 1); if (ret != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h b/src/accessor/grib_accessor_class_data_g1simple_packing.h new file mode 100644 index 000000000..3a351d17f --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1simple_packing_h +#define eccodes_accessor_data_g1simple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1simple_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1simple_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc similarity index 88% rename from src/accessor/todo/grib_accessor_class_data_g22order_packing.cc rename to src/accessor/grib_accessor_class_data_g22order_packing.cc index 4ed535d29..e8e9aed36 100644 --- a/src/accessor/todo/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,157 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ - -#include "grib_scaling.h" #include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* numberOfValues - MEMBERS=const char* bits_per_value - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scale_factor - MEMBERS=const char* typeOfOriginalFieldValues - MEMBERS=const char* groupSplittingMethodUsed - MEMBERS=const char* missingValueManagementUsed - MEMBERS=const char* primaryMissingValueSubstitute - MEMBERS=const char* secondaryMissingValueSubstitute - MEMBERS=const char* numberOfGroupsOfDataValues - MEMBERS=const char* referenceForGroupWidths - MEMBERS=const char* numberOfBitsUsedForTheGroupWidths - MEMBERS=const char* referenceForGroupLengths - MEMBERS=const char* lengthIncrementForTheGroupLengths - MEMBERS=const char* trueLengthOfLastGroup - MEMBERS=const char* numberOfBitsUsedForTheScaledGroupLengths - MEMBERS=const char* orderOfSpatialDifferencing - MEMBERS=const char* numberOfOctetsExtraDescriptors - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g22order_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_g22order_packing */ - const char* numberOfValues; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scale_factor; - const char* typeOfOriginalFieldValues; - const char* groupSplittingMethodUsed; - const char* missingValueManagementUsed; - const char* primaryMissingValueSubstitute; - const char* secondaryMissingValueSubstitute; - const char* numberOfGroupsOfDataValues; - const char* referenceForGroupWidths; - const char* numberOfBitsUsedForTheGroupWidths; - const char* referenceForGroupLengths; - const char* lengthIncrementForTheGroupLengths; - const char* trueLengthOfLastGroup; - const char* numberOfBitsUsedForTheScaledGroupLengths; - const char* orderOfSpatialDifferencing; - const char* numberOfOctetsExtraDescriptors; -} grib_accessor_data_g22order_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_g22order_packing = { - &grib_accessor_class_values, /* super */ - "data_g22order_packing", /* name */ - sizeof(grib_accessor_data_g22order_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g22order_packing.h" +#include "../grib_scaling.h" +grib_accessor_class_data_g22order_packing_t _grib_accessor_class_data_g22order_packing{"data_g22order_packing"}; grib_accessor_class* grib_accessor_class_data_g22order_packing = &_grib_accessor_class_data_g22order_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); +void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); grib_handle* gh = grib_handle_of_accessor(a); self->numberOfValues = grib_arguments_get_name(gh, args, self->carg++); @@ -206,14 +66,12 @@ struct bitstream_context { int n_bitstream; }; -static void init_bitstream(bitstream_context *ctx, unsigned char* new_bitstream) -{ +void init_bitstream(bitstream_context *ctx, unsigned char* new_bitstream){ ctx->bitstream = new_bitstream; ctx->n_bitstream = ctx->reg = ctx->rbits = 0; } -static void finish_bitstream(bitstream_context *ctx) -{ +void finish_bitstream(bitstream_context *ctx){ if (ctx->rbits) { ctx->n_bitstream++; *ctx->bitstream++ = (ctx->reg << (8 - ctx->rbits)) & 255; @@ -221,8 +79,7 @@ static void finish_bitstream(bitstream_context *ctx) } } -static void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, int n, int n_bits) -{ +void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, int n, int n_bits){ unsigned int jmask; int i; const int max_numbits = 25; @@ -245,8 +102,7 @@ static void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, } } -static void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n_bits) -{ +void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n_bits){ unsigned int jmask; const int max_numbits = 25; @@ -270,8 +126,7 @@ static void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n // find min/max of an integer array // return 0: if min max found // return 1: if min max not found, min = max = 0 -static int int_min_max_array(int* data, unsigned int n, int* min, int* max) -{ +int int_min_max_array(int* data, unsigned int n, int* min, int* max){ unsigned int first; int mn, mx; @@ -312,8 +167,7 @@ static int int_min_max_array(int* data, unsigned int n, int* min, int* max) return 0; } -static double Int_Power(double x, int y) -{ +double Int_Power(double x, int y){ double value; if (y < 0) { @@ -332,8 +186,7 @@ static double Int_Power(double x, int y) return value; } -static int min_max_array(double* data, unsigned int n, double* min, double* max) -{ +int min_max_array(double* data, unsigned int n, double* min, double* max){ unsigned int first; double mn, mx; @@ -445,8 +298,7 @@ static int min_max_array(double* data, unsigned int n, double* min, double* max) // return bms; // } -static int post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]) -{ +int post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]){ unsigned long last, penultimate = 0, j = 0; Assert(order > 0); Assert(order <= 3); @@ -507,10 +359,9 @@ static int post_process(grib_context* c, long* vals, long len, long order, long } template -static int unpack(grib_accessor* a, T* val, const size_t* len) -{ +int unpack(grib_accessor* a, T* val, const size_t* len){ static_assert(std::is_floating_point::value, "Requires floating points numbers"); - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); const char* cclass_name = a->cclass->name; grib_handle* gh = grib_handle_of_accessor(a); @@ -557,8 +408,7 @@ static int unpack(grib_accessor* a, T* val, const size_t* len) long numberOfOctetsExtraDescriptors = 0; double missingValue = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < static_cast(n_vals)) @@ -755,8 +605,7 @@ static int unpack(grib_accessor* a, T* val, const size_t* len) return err; } -static int find_nbits(unsigned int i) -{ +int find_nbits(unsigned int i){ #if !defined __GNUC__ || __GNUC__ < 4 int j; j = 0; @@ -794,8 +643,7 @@ struct section struct section *head, *tail; }; -static int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef) -{ +int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef){ if (s->mn == INT_MAX) { // all undef return ref_bits + width_bits; } @@ -823,8 +671,7 @@ static int sizeofsection2(int mn, int mx, int n, int ref_bits, int width_bits, return find_nbits(mx - mn + has_undef) * n + ref_bits + width_bits; } -static int size_all(struct section* s, int ref_bits, int width_bits, int has_undef) -{ +int size_all(struct section* s, int ref_bits, int width_bits, int has_undef){ int bits; bits = 0; @@ -835,8 +682,7 @@ static int size_all(struct section* s, int ref_bits, int width_bits, int has_und return (bits + 7) / 8; } -static void move_one_left(struct section* s, int* v) -{ +void move_one_left(struct section* s, int* v){ struct section* t; int val, i, j, k; @@ -901,8 +747,7 @@ static void move_one_left(struct section* s, int* v) } } -static void move_one_right(struct section* s, int* v) -{ +void move_one_right(struct section* s, int* v){ struct section* t; int val, i, j, k; @@ -983,8 +828,7 @@ static void move_one_right(struct section* s, int* v) return; } -static void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) -{ +void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX){ struct section* t; int val0, val1, nbit_s, nbit_t; @@ -1059,8 +903,7 @@ static void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) } } -static void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX) -{ +void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX){ struct section *t, *m; int size_head, size_mid, size_tail, saving_mt, saving_hm; int min0, max0, min1, max1; @@ -1164,9 +1007,8 @@ static void merge_j(struct section* h, int ref_bits, int width_bits, int has_und } } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); +int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -1850,18 +1692,15 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_g22order_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_g22order_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_g22order_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ size_t size = 0; double* values = NULL; int err = grib_get_size(grib_handle_of_accessor(a), "codedValues", &size); @@ -1881,8 +1720,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_g22order_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ size_t size = 0, i = 0; double* values; int err = 0; @@ -1909,9 +1747,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); +int grib_accessor_class_data_g22order_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, count); } diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h b/src/accessor/grib_accessor_class_data_g22order_packing.h new file mode 100644 index 000000000..87d7e3a8d --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h @@ -0,0 +1,57 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g22order_packing_h +#define eccodes_accessor_data_g22order_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_g22order_packing */ + const char* numberOfValues; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scale_factor; + const char* typeOfOriginalFieldValues; + const char* groupSplittingMethodUsed; + const char* missingValueManagementUsed; + const char* primaryMissingValueSubstitute; + const char* secondaryMissingValueSubstitute; + const char* numberOfGroupsOfDataValues; + const char* referenceForGroupWidths; + const char* numberOfBitsUsedForTheGroupWidths; + const char* referenceForGroupLengths; + const char* lengthIncrementForTheGroupLengths; + const char* trueLengthOfLastGroup; + const char* numberOfBitsUsedForTheScaledGroupLengths; + const char* orderOfSpatialDifferencing; + const char* numberOfOctetsExtraDescriptors; +}; + +class grib_accessor_class_data_g22order_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_g22order_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g22order_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_g22order_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc similarity index 77% rename from src/accessor/todo/grib_accessor_class_data_g2bifourier_packing.cc rename to src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index 86275d470..f4196a36c 100644 --- a/src/accessor/todo/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,156 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/******************************** - * philippe.marguinaud@meteo.fr - *******************************/ - -#include "grib_scaling.h" #include "grib_api_internal.h" -#include "grib_optimize_decimal_factor.h" -#include -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* biFourierTruncationType - MEMBERS= const char* sub_i - MEMBERS= const char* sub_j - MEMBERS= const char* bif_i - MEMBERS= const char* bif_j - MEMBERS= const char* biFourierSubTruncationType - MEMBERS= const char* biFourierDoNotPackAxes - MEMBERS= const char* biFourierMakeTemplate - MEMBERS= const char* totalNumberOfValuesInUnpackedSubset - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2bifourier_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2bifourier_packing */ - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* biFourierTruncationType; - const char* sub_i; - const char* sub_j; - const char* bif_i; - const char* bif_j; - const char* biFourierSubTruncationType; - const char* biFourierDoNotPackAxes; - const char* biFourierMakeTemplate; - const char* totalNumberOfValuesInUnpackedSubset; - const char* numberOfValues; -} grib_accessor_data_g2bifourier_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2bifourier_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g2bifourier_packing", /* name */ - sizeof(grib_accessor_data_g2bifourier_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g2bifourier_packing.h" +#include "grib_scaling.h" +grib_accessor_class_data_g2bifourier_packing_t _grib_accessor_class_data_g2bifourier_packing{"data_g2bifourier_packing"}; grib_accessor_class* grib_accessor_class_data_g2bifourier_packing = &_grib_accessor_class_data_g2bifourier_packing; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +void grib_accessor_class_data_g2bifourier_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->ieee_floats = grib_arguments_get_name(gh, args, self->carg++); @@ -178,17 +42,15 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) self->dirty = 1; } -static int value_count(grib_accessor* a, long* numberOfValues) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::value_count(grib_accessor* a, long* numberOfValues){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); *numberOfValues = 0; return grib_get_long_internal(gh, self->number_of_values, numberOfValues); } -static void ellipse(long ni, long nj, long itrunc[], long jtrunc[]) -{ +void ellipse(long ni, long nj, long itrunc[], long jtrunc[]){ const double zeps = 1.E-10; const double zauxil = 0.; int i, j; @@ -229,8 +91,7 @@ static void ellipse(long ni, long nj, long itrunc[], long jtrunc[]) } } -static void rectangle(long ni, long nj, long itrunc[], long jtrunc[]) -{ +void rectangle(long ni, long nj, long itrunc[], long jtrunc[]){ int i, j; /* @@ -248,8 +109,7 @@ static void rectangle(long ni, long nj, long itrunc[], long jtrunc[]) jtrunc[i] = nj; } -static void diamond(long ni, long nj, long itrunc[], long jtrunc[]) -{ +void diamond(long ni, long nj, long itrunc[], long jtrunc[]){ int i, j; if (nj == 0) @@ -311,8 +171,7 @@ typedef struct bif_trunc_t /* * Total number of coefficients */ -static size_t size_bif(bif_trunc_t* bt) -{ +size_t size_bif(bif_trunc_t* bt){ size_t n_vals = 0; int j; for (j = 0; j <= bt->bif_j; j++) @@ -323,8 +182,7 @@ static size_t size_bif(bif_trunc_t* bt) /* * Number of unpacked coefficients */ -static size_t size_sub(bif_trunc_t* bt) -{ +size_t size_sub(bif_trunc_t* bt){ size_t n_vals = 0; int i, j; for_ij() @@ -339,8 +197,7 @@ static size_t size_sub(bif_trunc_t* bt) return n_vals; } -static double laplam(bif_trunc_t* bt, const double val[]) -{ +double laplam(bif_trunc_t* bt, const double val[]){ /* * For bi-Fourier spectral fields, the Laplacian operator is a multiplication by (i*i+j*j) */ @@ -476,8 +333,7 @@ static double laplam(bif_trunc_t* bt, const double val[]) return zp; } -static void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a) -{ +void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a){ grib_handle* gh = grib_handle_of_accessor(a); if (bt == NULL) return; @@ -496,7 +352,7 @@ static void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a) static bif_trunc_t* new_bif_trunc(grib_accessor* a) { int ret; - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); bif_trunc_t* bt = (bif_trunc_t*)grib_context_malloc(gh->context, sizeof(bif_trunc_t)); @@ -607,9 +463,8 @@ cleanup: return NULL; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); unsigned char* buf = NULL; @@ -633,7 +488,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) int ret = GRIB_SUCCESS; int i, j, k; - if ((ret = grib_value_count(a, &count)) != GRIB_SUCCESS) + if ((ret = a->value_count(&count)) != GRIB_SUCCESS) goto cleanup; bt = new_bif_trunc(a); @@ -659,8 +514,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) self->dirty = 0; buf = (unsigned char*)gh->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); s = codes_power(bt->binary_scale_factor, 2); d = codes_power(-bt->decimal_scale_factor, 10); @@ -670,7 +524,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) hres = buf; lres = buf; - packed_offset = grib_byte_offset(a) + bt->bytes * bt->n_vals_sub; + packed_offset = a->byte_offset() + bt->bytes * bt->n_vals_sub; lpos = 8 * (packed_offset - offsetdata); hpos = 0; @@ -706,9 +560,8 @@ cleanup: return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h new file mode 100644 index 000000000..f4033a1ba --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2bifourier_packing_h +#define eccodes_accessor_data_g2bifourier_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g2bifourier_packing */ + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* biFourierTruncationType; + const char* sub_i; + const char* sub_j; + const char* bif_i; + const char* bif_j; + const char* biFourierSubTruncationType; + const char* biFourierDoNotPackAxes; + const char* biFourierMakeTemplate; + const char* totalNumberOfValuesInUnpackedSubset; + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2bifourier_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2bifourier_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2bifourier_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2bifourier_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/grib_accessor_class_data_g2complex_packing.cc new file mode 100644 index 000000000..28958de56 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g2complex_packing.h" + +grib_accessor_class_data_g2complex_packing_t _grib_accessor_class_data_g2complex_packing{"data_g2complex_packing"}; +grib_accessor_class* grib_accessor_class_data_g2complex_packing = &_grib_accessor_class_data_g2complex_packing; + + +void grib_accessor_class_data_g2complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->edition = 2; + + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2complex_packing_t::value_count(grib_accessor* a, long* numberOfValues){ + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + *numberOfValues = 0; + + return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, numberOfValues); +} + +int grib_accessor_class_data_g2complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + int ret = GRIB_SUCCESS; + + if (*len == 0) + return GRIB_NO_VALUES; + + ret = grib_accessor_class_data_complex_packing_t::pack_double(a, val, len); + + if (ret == GRIB_SUCCESS) + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h b/src/accessor/grib_accessor_class_data_g2complex_packing.h new file mode 100644 index 000000000..e77b89276 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2complex_packing_h +#define eccodes_accessor_data_g2complex_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g2complex_packing */ + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g2complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc new file mode 100644 index 000000000..bce04078b --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g2secondary_bitmap.h" + +grib_accessor_class_data_g2secondary_bitmap_t _grib_accessor_class_data_g2secondary_bitmap{"data_g2secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_accessor_class_data_g2secondary_bitmap; + + +void grib_accessor_class_data_g2secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); +} + +int grib_accessor_class_data_g2secondary_bitmap_t::value_count(grib_accessor* a, long* len){ + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + *len = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, len); +} + +int grib_accessor_class_data_g2secondary_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + int err = 0; + + long primary_len = 0, secondary_len = 0; + double* primary_bitmap = NULL; + double* secondary_bitmap = NULL; + long i = 0, j = 0, k = 0, m = 0; + double missing_value = 0, present_value = 0; + long expand_by = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + if (expand_by <= 0) + return GRIB_ENCODING_ERROR; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len % expand_by) { + /*TODO: issue warning */ + return GRIB_ENCODING_ERROR; + } + + primary_len = *len / expand_by; + primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); + if (!primary_bitmap) + return GRIB_OUT_OF_MEMORY; + + secondary_len = *len; + secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); + if (!secondary_bitmap) { + grib_context_free(a->context, primary_bitmap); + return GRIB_OUT_OF_MEMORY; + } + + if (missing_value == 0) + present_value = 1; + else + present_value = 0; + + k = 0; + m = 0; + for (i = 0; i < *len; i += expand_by) { + int cnt = 0; + for (j = 0; j < expand_by; j++) + if (val[i + j] == missing_value) + cnt++; + + if (cnt == expand_by) /* all expand_by values are missing */ + primary_bitmap[k++] = missing_value; + else { + primary_bitmap[k++] = present_value; + for (j = 0; j < expand_by; j++) + secondary_bitmap[m++] = val[i + j]; + //on++; + } + } + + *len = k; + + Assert(k == primary_len); + + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); + if (err == GRIB_SUCCESS) + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); + + grib_context_free(a->context, primary_bitmap); + grib_context_free(a->context, secondary_bitmap); + + if (err == GRIB_SUCCESS) + err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len * expand_by); + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h new file mode 100644 index 000000000..394c79bfa --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2secondary_bitmap_h +#define eccodes_accessor_data_g2secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g2secondary_bitmap */ + const char* number_of_values; +}; + +class grib_accessor_class_data_g2secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g2secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc new file mode 100644 index 000000000..e765539ee --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc @@ -0,0 +1,92 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g2shsimple_packing.h" + +grib_accessor_class_data_g2shsimple_packing_t _grib_accessor_class_data_g2shsimple_packing{"data_g2shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_g2shsimple_packing = &_grib_accessor_class_data_g2shsimple_packing; + + +void grib_accessor_class_data_g2shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); + self->numberOfDataPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2shsimple_packing_t::value_count(grib_accessor* a, long* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + *len = 0; + return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, len); +} + +int grib_accessor_class_data_g2shsimple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t n_vals = 0; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &n_vals)) != GRIB_SUCCESS) + return err; + + self->dirty = 0; + + /* n_vals = coded_n_vals+1; */ + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + return err; +} + +int grib_accessor_class_data_g2shsimple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = *len - 1; + size_t n_vals = *len; + + if (*len == 0) + return GRIB_NO_VALUES; + + self->dirty = 1; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, (long)n_vals)) != GRIB_SUCCESS) + return err; + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfDataPoints, (long)n_vals)) != GRIB_SUCCESS) + return err; + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h new file mode 100644 index 000000000..28e7a7c06 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2shsimple_packing_h +#define eccodes_accessor_data_g2shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g2shsimple_packing */ + const char* numberOfValues; + const char* numberOfDataPoints; +}; + +class grib_accessor_class_data_g2shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g2shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2shsimple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2shsimple_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_data_g2simple_packing.cc rename to src/accessor/grib_accessor_class_data_g2simple_packing.cc index 56441fc96..051239cbc 100644 --- a/src/accessor/todo/grib_accessor_class_data_g2simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,135 +9,29 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_data_g2simple_packing.h" +#include "grib_scaling.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = pack_bytes - IMPLEMENTS = value_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2simple_packing */ -} grib_accessor_data_g2simple_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2simple_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g2simple_packing", /* name */ - sizeof(grib_accessor_data_g2simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_g2simple_packing_t _grib_accessor_class_data_g2simple_packing{"data_g2simple_packing"}; grib_accessor_class* grib_accessor_class_data_g2simple_packing = &_grib_accessor_class_data_g2simple_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; +void grib_accessor_class_data_g2simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; a->flags |= GRIB_ACCESSOR_FLAG_DATA; self->edition = 2; } -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; +int grib_accessor_class_data_g2simple_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; - grib_accessor_class* super = *(a->cclass->super); +int grib_accessor_class_data_g2simple_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; + //grib_accessor_class* super = *(a->cclass->super); size_t n_vals = *len; double reference_value = 0; long binary_scale_factor = 0; @@ -209,17 +104,20 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) return grib_set_double_array(h, "values", val, *len); } - if (super != grib_accessor_class_data_g2simple_packing) { - /* Normal case: parent not same as me! */ - ret = super->pack_double(a, val, len); - } - else { - /* GRIB-364: simple packing with logarithm pre-processing */ - grib_accessor_class* super2 = NULL; - Assert(super->super); - super2 = *(super->super); - ret = super2->pack_double(a, val, len); - } + // ==== TODO(maee): Fix this ==== + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, cval, len); + //if (super != grib_accessor_class_data_g2simple_packing) { + // [> Normal case: parent not same as me! <] + // ret = super->pack_double(a, val, len); + //} + //else { + // [> GRIB-364: simple packing with logarithm pre-processing <] + // grib_accessor_class* super2 = NULL; + // Assert(super->super); + // super2 = *(super->super); + // ret = super2->pack_double(a, val, len); + //} + // ============================= switch (ret) { case GRIB_CONSTANT_FIELD: grib_buffer_replace(a, NULL, 0, 1, 1); @@ -253,7 +151,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) grib_encode_double_array(n_vals, val, bits_per_value, reference_value, decimal, divisor, encoded, &off); grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g2simple_packing : pack_double : packing %s, %d values", a->name, n_vals); + "grib_accessor_data_g2simple_packing_t : pack_double : packing %s, %d values", a->name, n_vals); grib_buffer_replace(a, buf, buflen, 1, 1); @@ -262,8 +160,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) return ret; } -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ +int grib_accessor_class_data_g2simple_packing_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len){ size_t length = *len; grib_buffer_replace(a, val, length, 1, 1); return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h b/src/accessor/grib_accessor_class_data_g2simple_packing.h new file mode 100644 index 000000000..b3982c40d --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2simple_packing_h +#define eccodes_accessor_data_g2simple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g2simple_packing */ +}; + +class grib_accessor_class_data_g2simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_t{}; } + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc new file mode 100644 index 000000000..21493c113 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -0,0 +1,179 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_g2simple_packing_with_preprocessing.h" +#define DIRECT 0 +#define INVERSE 1 + +grib_accessor_class_data_g2simple_packing_with_preprocessing_t _grib_accessor_class_data_g2simple_packing_with_preprocessing{"data_g2simple_packing_with_preprocessing"}; +grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing = &_grib_accessor_class_data_g2simple_packing_with_preprocessing; + + +void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->pre_processing_parameter = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + *n_vals = 0; + + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); +} + +static int pre_processing_func(double* values, long length, long pre_processing, + double* pre_processing_parameter, int mode) +{ + int i = 0, ret = 0; + double min = values[0]; + double next_min = values[0]; + Assert(length > 0); + + switch (pre_processing) { + /* NONE */ + case 0: + break; + /* LOGARITHM */ + case 1: + if (mode == DIRECT) { + for (i = 0; i < length; i++) { + if (values[i] < min) + min = values[i]; + if (values[i] > next_min) + next_min = values[i]; + } + for (i = 0; i < length; i++) { + if (values[i] > min && values[i] < next_min) + next_min = values[i]; + } + if (min > 0) { + *pre_processing_parameter = 0; + for (i = 0; i < length; i++) { + DEBUG_ASSERT(values[i] > 0); + values[i] = log(values[i]); + } + } + else { + double ppp = 0; + *pre_processing_parameter = next_min - 2 * min; + if (next_min == min) + return ret; + ppp = *pre_processing_parameter; + for (i = 0; i < length; i++) { + DEBUG_ASSERT((values[i] + ppp) > 0); + values[i] = log(values[i] + ppp); + } + } + } + else { + Assert(mode == INVERSE); + if (*pre_processing_parameter == 0) { + for (i = 0; i < length; i++) + values[i] = exp(values[i]); + } + else { + for (i = 0; i < length; i++) + values[i] = exp(values[i]) - *pre_processing_parameter; + } + } + break; + default: + ret = GRIB_NOT_IMPLEMENTED; + break; + } + + return ret; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + //grib_accessor_class* super = *(a->cclass->super); + //grib_accessor_class* super2 = NULL; + + size_t n_vals = 0; + long nn = 0; + int err = 0; + + long pre_processing; + double pre_processing_parameter; + + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if (n_vals == 0) { + *len = 0; + return GRIB_SUCCESS; + } + + self->dirty = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) { + return err; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, &pre_processing_parameter)) != GRIB_SUCCESS) { + return err; + } + + // TODO(maee): fix this + //Assert(super->super); + //super2 = *(super->super); + //err = super2->unpack_double(a, val, &n_vals); [> GRIB-364 <] + err = grib_accessor_class_data_simple_packing_t::unpack_double(a, val, &n_vals); + if (err != GRIB_SUCCESS) + return err; + + err = pre_processing_func(val, n_vals, pre_processing, &pre_processing_parameter, INVERSE); + if (err != GRIB_SUCCESS) + return err; + + *len = (long)n_vals; + + return err; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + //grib_accessor_class* super = *(a->cclass->super); + + size_t n_vals = *len; + int err = 0; + + long pre_processing = 0; + double pre_processing_parameter = 0; + + self->dirty = 1; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) + return err; + + err = pre_processing_func((double*)val, n_vals, pre_processing, &pre_processing_parameter, DIRECT); + if (err != GRIB_SUCCESS) + return err; + + // TOOD(maee): fix this + //err = super->pack_double(a, val, len); + err = grib_accessor_class_data_g2simple_packing_t::pack_double(a, val, len); + if (err != GRIB_SUCCESS) + return err; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, pre_processing_parameter)) != GRIB_SUCCESS) + return err; + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals)) != GRIB_SUCCESS) + return err; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h new file mode 100644 index 000000000..ac2bc2d27 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2simple_packing_with_preprocessing_h +#define eccodes_accessor_data_g2simple_packing_with_preprocessing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_g2simple_packing.h" + +class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t +{ +public: + /* Members defined in data_g2simple_packing_with_preprocessing */ + const char* pre_processing; + const char* pre_processing_parameter; +}; + +class grib_accessor_class_data_g2simple_packing_with_preprocessing_t : public grib_accessor_class_data_g2simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_with_preprocessing_t(const char* name) : grib_accessor_class_data_g2simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_with_preprocessing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2simple_packing_with_preprocessing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc similarity index 73% rename from src/accessor/todo/grib_accessor_class_data_jpeg2000_packing.cc rename to src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index a1a43b6f7..d5f3eaaf4 100644 --- a/src/accessor/todo/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,148 +9,21 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "grib_accessor_class_data_jpeg2000_packing.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* type_of_compression_used - MEMBERS=const char* target_compression_ratio - MEMBERS=const char* ni - MEMBERS=const char* nj - MEMBERS=const char* list_defining_points - MEMBERS=const char* number_of_data_points - MEMBERS=const char* scanning_mode - MEMBERS=int jpeg_lib - MEMBERS=const char* dump_jpg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_jpeg2000_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_jpeg2000_packing */ - const char* type_of_compression_used; - const char* target_compression_ratio; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; - int jpeg_lib; - const char* dump_jpg; -} grib_accessor_data_jpeg2000_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_jpeg2000_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_jpeg2000_packing", /* name */ - sizeof(grib_accessor_data_jpeg2000_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_jpeg2000_packing_t _grib_accessor_class_data_jpeg2000_packing{"data_jpeg2000_packing"}; grib_accessor_class* grib_accessor_class_data_jpeg2000_packing = &_grib_accessor_class_data_jpeg2000_packing; -/* END_CLASS_IMP */ static int first = 1; #define JASPER_LIB 1 #define OPENJPEG_LIB 2 -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ +void grib_accessor_class_data_jpeg2000_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ const char* user_lib = NULL; - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->jpeg_lib = 0; @@ -204,9 +78,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) } } -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); @@ -215,19 +88,16 @@ static int value_count(grib_accessor* a, long* n_vals) #define EXTRA_BUFFER_SIZE 10240 #if HAVE_JPEG -static int unpack_float(grib_accessor*, float* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_float(grib_accessor*, float* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; int err = GRIB_SUCCESS; size_t i = 0; - size_t buflen = grib_byte_count(a); - + size_t buflen = a->byte_count(); double bscale = 0; double dscale = 0; unsigned char* buf = NULL; @@ -242,8 +112,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) double units_bias = 0.0; n_vals = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -282,8 +151,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); switch (self->jpeg_lib) { case OPENJPEG_LIB: if ((err = grib_openjpeg_decode(a->context, buf, &buflen, val, &n_vals)) != GRIB_SUCCESS) @@ -323,9 +191,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_accessor_class* super = *(a->cclass->super); size_t n_vals = *len; int err = 0; @@ -561,33 +428,28 @@ cleanup: } #else -static void print_error_feature_not_enabled(grib_context* c) -{ +void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "JPEG support not enabled. Please rebuild with -DENABLE_JPG=ON"); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } #endif -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0; double* values = NULL; @@ -624,9 +486,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; double* values = NULL; diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h new file mode 100644 index 000000000..a04ee58d5 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h @@ -0,0 +1,46 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_jpeg2000_packing_h +#define eccodes_accessor_data_jpeg2000_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_jpeg2000_packing */ + const char* type_of_compression_used; + const char* target_compression_ratio; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; + int jpeg_lib; + const char* dump_jpg; +}; + +class grib_accessor_class_data_jpeg2000_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_jpeg2000_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_jpeg2000_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_jpeg2000_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc similarity index 75% rename from src/accessor/todo/grib_accessor_class_data_png_packing.cc rename to src/accessor/grib_accessor_class_data_png_packing.cc index e9747b19d..8c1c62bb3 100644 --- a/src/accessor/todo/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,134 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" -#define PNG_ANYBITS - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = unpack_double_element;unpack_double_element_set - MEMBERS=const char* number_of_values - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* bits_per_value - MEMBERS=const char* ni - MEMBERS=const char* nj - MEMBERS=const char* list_defining_points - MEMBERS=const char* number_of_data_points - MEMBERS=const char* scanning_mode - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_png_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_png_packing */ - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* bits_per_value; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; -} grib_accessor_data_png_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_png_packing = { - &grib_accessor_class_values, /* super */ - "data_png_packing", /* name */ - sizeof(grib_accessor_data_png_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_png_packing.h" +grib_accessor_class_data_png_packing_t _grib_accessor_class_data_png_packing{"data_png_packing"}; grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_class_data_png_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +void grib_accessor_class_data_png_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* h = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(h, args, self->carg++); @@ -151,9 +33,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); } @@ -169,16 +50,14 @@ typedef struct png_read_callback_data size_t offset; } png_read_callback_data; -static void png_read_callback(png_structp png, png_bytep data, png_size_t length) -{ +void png_read_callback(png_structp png, png_bytep data, png_size_t length){ png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); Assert(p->offset + length <= p->length); memcpy(data, p->buffer + p->offset, length); p->offset += length; } -static void png_write_callback(png_structp png, png_bytep data, png_size_t length) -{ +void png_write_callback(png_structp png, png_bytep data, png_size_t length){ png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); /* printf("p.offset=%zu len=%zu p.len=%zu\n", p->offset, length, p->length); */ /* Assert(p->offset + length <= p->length); */ @@ -191,19 +70,16 @@ static void png_write_callback(png_structp png, png_bytep data, png_size_t lengt p->offset += length; } -static void png_flush_callback(png_structp png) -{ +void png_flush_callback(png_structp png){ /* Empty */ } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; int err = GRIB_SUCCESS; int i, j; - size_t buflen = grib_byte_count(a); - + size_t buflen = a->byte_count(); double bscale = 0; double dscale = 0; unsigned char* buf = NULL; @@ -227,8 +103,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) self->dirty = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -257,8 +132,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if (png_sig_cmp(buf, 0, 8) != 0) return GRIB_INVALID_MESSAGE; @@ -341,8 +215,7 @@ cleanup: return err; } -static bool is_constant(const double* values, size_t n_vals) -{ +bool is_constant(const double* values, size_t n_vals){ bool isConstant = true; double v = 0; size_t i; @@ -356,9 +229,8 @@ static bool is_constant(const double* values, size_t n_vals) return isConstant; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; @@ -545,7 +417,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) } /* buflen = n_vals*(bits_per_value/8); */ grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_png_packing : pack_double : packing %s, %d values", a->name, n_vals); + "grib_accessor_data_png_packing_t : pack_double : packing %s, %d values", a->name, n_vals); buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); if (!buf) { @@ -652,10 +524,9 @@ cleanup: return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ /* The index idx relates to codedValues NOT values! */ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; size_t size = 0; @@ -688,10 +559,9 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ /* The index idx relates to codedValues NOT values! */ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; size_t size = 0, i = 0; @@ -735,29 +605,24 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array #else -static void print_error_feature_not_enabled(grib_context* c) -{ +static void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "PNG support not enabled. Please rebuild with -DENABLE_PNG=ON"); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_png_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_data_png_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/src/accessor/grib_accessor_class_data_png_packing.h b/src/accessor/grib_accessor_class_data_png_packing.h new file mode 100644 index 000000000..d8c9211a3 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_png_packing.h @@ -0,0 +1,46 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_png_packing_h +#define eccodes_accessor_data_png_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_png_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_png_packing */ + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* bits_per_value; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; +}; + +class grib_accessor_class_data_png_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_png_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_png_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_png_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc new file mode 100644 index 000000000..943359f47 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -0,0 +1,194 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_raw_packing.h" +#include "grib_ieeefloat.h" + +grib_accessor_class_data_raw_packing_t _grib_accessor_class_data_raw_packing{"data_raw_packing"}; +grib_accessor_class* grib_accessor_class_data_raw_packing = &_grib_accessor_class_data_raw_packing; + + +void grib_accessor_class_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + + self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_raw_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + *n_vals = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); +} + +int grib_accessor_class_data_raw_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + unsigned char* buf = NULL; + int bytes = 0; + size_t nvals = 0; + long inlen = a->byte_count(); + long precision = 0; + + int code = GRIB_SUCCESS; + + if ((code = grib_get_long(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return code; + + self->dirty = 0; + + buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + buf += a->byte_offset(); + switch (precision) { + case 1: + bytes = 4; + break; + case 2: + bytes = 8; + break; + default: + return GRIB_NOT_IMPLEMENTED; + } + + nvals = inlen / bytes; + + if (*len < nvals) + return GRIB_ARRAY_TOO_SMALL; + + code = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); + + *len = nvals; + + return code; +} + +int grib_accessor_class_data_raw_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + + int bytes = 0; + unsigned char* buffer = NULL; + + long precision = 0; + + double* values = (double*)val; + size_t inlen = *len; + + /*int free_buffer = 0; + *int free_values = 0;*/ + + int code = GRIB_SUCCESS; + + size_t bufsize = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((code = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return code; + + self->dirty = 1; + + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + code = GRIB_NOT_IMPLEMENTED; + goto clean_up; + } + + bufsize = bytes * inlen; + + buffer = (unsigned char*)grib_context_malloc(a->context, bufsize); + + if (!buffer) { + code = GRIB_OUT_OF_MEMORY; + goto clean_up; + } + + code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer); + +clean_up: + /*if (free_buffer) + * free(buffer); + * if (free_values) + * free(values); + */ + + grib_buffer_replace(a, buffer, bufsize, 1, 1); + + grib_context_buffer_free(a->context, buffer); + + if (code == GRIB_SUCCESS) { + code = grib_set_long(grib_handle_of_accessor(a), self->number_of_values, inlen); + if (code == GRIB_READ_ONLY) + code = 0; + } + + return code; +} + +int grib_accessor_class_data_raw_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + int ret = 0; + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + unsigned char* buf = NULL; + int bytes = 0; + size_t nvals = 0; + long inlen = a->byte_count(); long pos = 0; + long precision = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return ret; + + self->dirty = 0; + + buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + buf += a->byte_offset(); + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + pos = bytes * idx; + + Assert(pos <= inlen); + + nvals = 1; + buf += pos; + + ret = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); + + return ret; +} + +int grib_accessor_class_data_raw_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + int err = 0; + size_t i = 0; + for (i=0; inumber_of_values = grib_arguments_get_name(gh, args, self->carg++); self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); @@ -133,16 +29,14 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* number_of_values) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::value_count(grib_accessor* a, long* number_of_values){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; *number_of_values = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; @@ -204,8 +98,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } compressed_values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * number_of_compressed_values); buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - offsetBeforeData = grib_byte_offset(a); - buf += offsetBeforeData; + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; pos = 0; grib_decode_long_array(buf, &pos, bits_per_value, number_of_compressed_values, compressed_values); j = 0; @@ -246,9 +139,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h b/src/accessor/grib_accessor_class_data_run_length_packing.h new file mode 100644 index 000000000..3125fdcf4 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_run_length_packing_h +#define eccodes_accessor_data_run_length_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_run_length_packing */ + const char* number_of_values; + const char* bits_per_value; + const char* max_level_value; + const char* number_of_level_values; + const char* decimal_scale_factor; + const char* level_values; +}; + +class grib_accessor_class_data_run_length_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_run_length_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_run_length_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_run_length_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc new file mode 100644 index 000000000..51bfb4afc --- /dev/null +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -0,0 +1,118 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_secondary_bitmap.h" + +grib_accessor_class_data_secondary_bitmap_t _grib_accessor_class_data_secondary_bitmap{"data_secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_secondary_bitmap = &_grib_accessor_class_data_secondary_bitmap; + + +void grib_accessor_class_data_secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + self->primary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->secondary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); + self->expand_by = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); + + a->length = 0; +} + +void grib_accessor_class_data_secondary_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_data_secondary_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + + size_t i = 0; + size_t j = 0; + size_t k = 0; + size_t m = 0; + size_t n_vals = 0; + long nn = 0; + long expand_by = 0; + int err = 0; + size_t primary_len; + size_t secondary_len; + double* primary_vals; + double* secondary_vals; + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &primary_len)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->secondary_bitmap, &secondary_len)) != GRIB_SUCCESS) + return err; + + primary_vals = (double*)grib_context_malloc(a->context, primary_len * sizeof(double)); + if (!primary_vals) + return GRIB_OUT_OF_MEMORY; + + secondary_vals = (double*)grib_context_malloc(a->context, secondary_len * sizeof(double)); + if (!secondary_vals) { + grib_context_free(a->context, primary_vals); + return GRIB_OUT_OF_MEMORY; + } + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_vals, &primary_len)) != GRIB_SUCCESS) { + grib_context_free(a->context, secondary_vals); + grib_context_free(a->context, primary_vals); + return err; + } + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_vals, &secondary_len)) != GRIB_SUCCESS) { + grib_context_free(a->context, secondary_vals); + grib_context_free(a->context, primary_vals); + return err; + } + + k = 0; + m = 0; + for (i = 0; i < primary_len; i++) { + /* if(primary_vals[i]) f++; */ + if (primary_vals[i]) { + for (j = 0; j < expand_by; j++) + val[k++] = secondary_vals[m++]; + } + else { + for (j = 0; j < expand_by; j++) + val[k++] = 0; + } + } + + Assert(k <= *len); + Assert(m <= secondary_len); + + /*printf("FOOBAR %d %d %ld %d\n",f,primary_len,expand_by,n_vals);*/ + + *len = n_vals; + + grib_context_free(a->context, primary_vals); + grib_context_free(a->context, secondary_vals); + return err; +} + +int grib_accessor_class_data_secondary_bitmap_t::get_native_type(grib_accessor* a){ + // grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h b/src/accessor/grib_accessor_class_data_secondary_bitmap.h new file mode 100644 index 000000000..3ac86e324 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_secondary_bitmap_h +#define eccodes_accessor_data_secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_secondary_bitmap */ + const char* primary_bitmap; + const char* secondary_bitmap; + const char* missing_value; + const char* expand_by; +}; + +class grib_accessor_class_data_secondary_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_secondary_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_secondary_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_secondary_bitmap_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc similarity index 63% rename from src/accessor/todo/grib_accessor_class_data_sh_packed.cc rename to src/accessor/grib_accessor_class_data_sh_packed.cc index 25687d262..a1cb7a7ba 100644 --- a/src/accessor/todo/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,142 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_sh_packed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_sh_packed */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_sh_packed; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_sh_packed = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_sh_packed", /* name */ - sizeof(grib_accessor_data_sh_packed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_sh_packed.h" +#include "grib_scaling.h" +grib_accessor_class_data_sh_packed_t _grib_accessor_class_data_sh_packed{"data_sh_packed"}; grib_accessor_class* grib_accessor_class_data_sh_packed = &_grib_accessor_class_data_sh_packed; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +void grib_accessor_class_data_sh_packed_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(hand, args, self->carg++); @@ -161,9 +39,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +int grib_accessor_class_data_sh_packed_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; const char* cclass_name = a->cclass->name; @@ -198,9 +75,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +int grib_accessor_class_data_sh_packed_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; size_t i = 0; int ret = GRIB_SUCCESS; @@ -234,8 +110,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) decode_float_proc decode_float = NULL; n_vals = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < n_vals) { diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h b/src/accessor/grib_accessor_class_data_sh_packed.h new file mode 100644 index 000000000..2d7cbdf47 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_packed.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_sh_packed_h +#define eccodes_accessor_data_sh_packed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_packed */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_packed_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_packed_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_packed_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_sh_packed_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc similarity index 61% rename from src/accessor/todo/grib_accessor_class_data_sh_unpacked.cc rename to src/accessor/grib_accessor_class_data_sh_unpacked.cc index 394793612..842411f26 100644 --- a/src/accessor/todo/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,142 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" #include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_sh_unpacked -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_sh_unpacked */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_sh_unpacked; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_sh_unpacked = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_sh_unpacked", /* name */ - sizeof(grib_accessor_data_sh_unpacked), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_sh_unpacked.h" +#include "grib_scaling.h" +grib_accessor_class_data_sh_unpacked_t _grib_accessor_class_data_sh_unpacked{"data_sh_unpacked"}; grib_accessor_class* grib_accessor_class_data_sh_unpacked = &_grib_accessor_class_data_sh_unpacked; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +void grib_accessor_class_data_sh_unpacked_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(hand, args, self->carg++); @@ -161,9 +39,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +int grib_accessor_class_data_sh_unpacked_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; int ret = 0; long sub_j = 0; @@ -185,9 +62,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +int grib_accessor_class_data_sh_unpacked_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; size_t i = 0; int ret = GRIB_SUCCESS; @@ -234,8 +110,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) decode_float_proc decode_float = NULL; n_vals = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < n_vals) { diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h b/src/accessor/grib_accessor_class_data_sh_unpacked.h new file mode 100644 index 000000000..4b1e893c0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_sh_unpacked_h +#define eccodes_accessor_data_sh_unpacked_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_unpacked */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_unpacked_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_unpacked_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_unpacked_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_sh_unpacked_h */ diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/grib_accessor_class_data_shsimple_packing.cc new file mode 100644 index 000000000..68fc83a7b --- /dev/null +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_data_shsimple_packing.h" + +grib_accessor_class_data_shsimple_packing_t _grib_accessor_class_data_shsimple_packing{"data_shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_shsimple_packing = &_grib_accessor_class_data_shsimple_packing; + + +void grib_accessor_class_data_shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_shsimple_packing_t* self = (grib_accessor_data_shsimple_packing_t*)a; + + self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->real_part = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; + + a->length = 0; +} + +void grib_accessor_class_data_shsimple_packing_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_data_shsimple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_shsimple_packing_t* self = (grib_accessor_data_shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = *len - 1; + size_t n_vals = *len; + + self->dirty = 1; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + return err; +} + +int grib_accessor_class_data_shsimple_packing_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h b/src/accessor/grib_accessor_class_data_shsimple_packing.h new file mode 100644 index 000000000..851907eb9 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_shsimple_packing_h +#define eccodes_accessor_data_shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_shsimple_packing */ + const char* coded_values; + const char* real_part; + int dirty; +}; + +class grib_accessor_class_data_shsimple_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_shsimple_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_shsimple_packing_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_shsimple_packing_h */ diff --git a/src/accessor/todo/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc similarity index 79% rename from src/accessor/todo/grib_accessor_class_data_simple_packing.cc rename to src/accessor/grib_accessor_class_data_simple_packing.cc index e78bda53c..f01a2c612 100644 --- a/src/accessor/todo/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,138 +9,20 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" #include "grib_scaling.h" #include "grib_bits_any_endian_simple.h" #include "grib_optimize_decimal_factor.h" #include #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_double_subarray - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=int edition - MEMBERS=const char* units_factor - MEMBERS=const char* units_bias - MEMBERS=const char* changing_precision - MEMBERS=const char* number_of_values - MEMBERS=const char* bits_per_value - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scaling_factor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); -static int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len); - -typedef struct grib_accessor_data_simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; -} grib_accessor_data_simple_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_simple_packing = { - &grib_accessor_class_values, /* super */ - "data_simple_packing", /* name */ - sizeof(grib_accessor_data_simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - &unpack_double_subarray, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_simple_packing_t _grib_accessor_class_data_simple_packing{"data_simple_packing"}; grib_accessor_class* grib_accessor_class_data_simple_packing = &_grib_accessor_class_data_simple_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +void grib_accessor_class_data_simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->units_factor = grib_arguments_get_name(gh, args, self->carg++); self->units_bias = grib_arguments_get_name(gh, args, self->carg++); @@ -163,8 +46,7 @@ static const unsigned long nbits[32] = { 0x40000000, 0x80000000 }; -static int number_of_bits(unsigned long x, long* result) -{ +static int number_of_bits(unsigned long x, long* result){ const int count = sizeof(nbits) / sizeof(nbits[0]); const unsigned long* n = nbits; *result = 0; @@ -178,17 +60,15 @@ static int number_of_bits(unsigned long x, long* result) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* number_of_values) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +int grib_accessor_class_data_simple_packing_t::value_count(grib_accessor* a, long* number_of_values){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; *number_of_values = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; const char* cclass_name = a->cclass->name; long n_vals; @@ -205,8 +85,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) long pos = 0; n_vals = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -237,8 +116,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) "%s: %s: creating %s, %ld values (idx=%zu)", cclass_name, __func__, a->name, n_vals, idx); - buf += grib_byte_offset(a); - + buf += a->byte_offset(); /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ if (bits_per_value % 8) { @@ -270,8 +148,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return err; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_simple_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ int err = 0; size_t i = 0; for (i=0; i -static int unpack(grib_accessor* a, T* val, size_t* len) -{ +int unpack(grib_accessor* a, T* val, size_t* len){ static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; const char* cclass_name = a->cclass->name; grib_handle* gh = grib_handle_of_accessor(a); unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; @@ -307,8 +183,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) double units_factor = 1.0; double units_bias = 0.0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; n_vals = count; @@ -369,8 +244,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) grib_context_log(a->context, GRIB_LOG_DEBUG, "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - offsetBeforeData = grib_byte_offset(a); - buf += offsetBeforeData; + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ @@ -424,19 +298,16 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_simple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_simple_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ return unpack(a, val, len); } -static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* buf, long pos, size_t n_vals) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* buf, long pos, size_t n_vals){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -510,8 +381,7 @@ static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned c grib_context_log(a->context, GRIB_LOG_DEBUG, "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - offsetBeforeData = grib_byte_offset(a); - buf += offsetBeforeData; + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ @@ -561,9 +431,8 @@ static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned c return err; } -static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +int grib_accessor_class_data_simple_packing_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; size_t nvals = len; size_t* plen = &len; @@ -580,9 +449,8 @@ static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, s return _unpack_double(a, val, plen, buf, pos, nvals); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; +int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h b/src/accessor/grib_accessor_class_data_simple_packing.h new file mode 100644 index 000000000..9187f37eb --- /dev/null +++ b/src/accessor/grib_accessor_class_data_simple_packing.h @@ -0,0 +1,48 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_simple_packing_h +#define eccodes_accessor_data_simple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_simple_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_simple_packing */ + int edition; + const char* units_factor; + const char* units_bias; + const char* changing_precision; + const char* number_of_values; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; +}; + +class grib_accessor_class_data_simple_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_simple_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; +}; +#endif /* eccodes_accessor_data_simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_decimal_precision.cc b/src/accessor/grib_accessor_class_decimal_precision.cc new file mode 100644 index 000000000..0ffe7b0c1 --- /dev/null +++ b/src/accessor/grib_accessor_class_decimal_precision.cc @@ -0,0 +1,103 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_decimal_precision.h" + +grib_accessor_class_decimal_precision_t _grib_accessor_class_decimal_precision{"decimal_precision"}; +grib_accessor_class* grib_accessor_class_decimal_precision = &_grib_accessor_class_decimal_precision; + + +void grib_accessor_class_decimal_precision_t::init(grib_accessor* a, const long l, grib_arguments* args){ + int n = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + + self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->decimal_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->changing_precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_decimal_precision_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->decimal_scale_factor, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + return ret; +} + +int grib_accessor_class_decimal_precision_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + long bitsPerValue = 0; + double* values = NULL; + size_t size = 0; + int ret = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (!self->values) { + if ((ret = grib_set_long_internal(h, self->bits_per_value, 0)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + return GRIB_SUCCESS; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->bits_per_value, bitsPerValue)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_decimal_precision.h b/src/accessor/grib_accessor_class_decimal_precision.h new file mode 100644 index 000000000..455d77946 --- /dev/null +++ b/src/accessor/grib_accessor_class_decimal_precision.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_decimal_precision_h +#define eccodes_accessor_decimal_precision_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_decimal_precision_t : public grib_accessor_long_t +{ +public: + /* Members defined in decimal_precision */ + const char* values; + const char* bits_per_value; + const char* changing_precision; + const char* decimal_scale_factor; +}; + +class grib_accessor_class_decimal_precision_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_decimal_precision_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_decimal_precision_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_decimal_precision_h */ diff --git a/src/accessor/todo/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc similarity index 62% rename from src/accessor/todo/grib_accessor_class_dictionary.cc rename to src/accessor/grib_accessor_class_dictionary.cc index dde22abdc..e078cde45 100644 --- a/src/accessor/todo/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,113 +10,15 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_dictionary.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;unpack_string;unpack_long;unpack_double - IMPLEMENTS = value_count; get_native_type; - MEMBERS = const char* dictionary - MEMBERS = const char* key - MEMBERS = long column - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_dictionary -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in dictionary */ - const char* dictionary; - const char* key; - long column; - const char* masterDir; - const char* localDir; -} grib_accessor_dictionary; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_dictionary = { - &grib_accessor_class_gen, /* super */ - "dictionary", /* name */ - sizeof(grib_accessor_dictionary), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_dictionary_t _grib_accessor_class_dictionary{"dictionary"}; grib_accessor_class* grib_accessor_class_dictionary = &_grib_accessor_class_dictionary; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ +void grib_accessor_class_dictionary_t::init(grib_accessor* a, const long len, grib_arguments* params){ int n = 0; - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; self->dictionary = grib_arguments_get_string(grib_handle_of_accessor(a), params, n++); self->key = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); @@ -129,7 +32,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) static grib_trie* load_dictionary(grib_accessor* a, int* err) { - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; char* filename = NULL; char line[1024] = {0,}; @@ -243,8 +146,7 @@ static grib_trie* load_dictionary(grib_accessor* a, int* err) return dictionary; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_dictionary_t::dump(grib_accessor* a, grib_dumper* dumper){ switch (get_native_type(a)) { case GRIB_TYPE_STRING: grib_dump_string(dumper, a, NULL); @@ -258,9 +160,8 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; +int grib_accessor_class_dictionary_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; int err = GRIB_SUCCESS; char key[1024] = {0,}; size_t size = 1024; @@ -313,14 +214,12 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) return err; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_dictionary_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_dictionary_t::get_native_type(grib_accessor* a){ int type = GRIB_TYPE_DOUBLE; if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) type = GRIB_TYPE_LONG; @@ -329,8 +228,7 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_dictionary_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int err = 0; char buffer[1024] = {0,}; size_t size = 1024; @@ -345,8 +243,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_dictionary_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int err = 0; char buffer[1024] = {0,}; size_t size = 1024; diff --git a/src/accessor/grib_accessor_class_dictionary.h b/src/accessor/grib_accessor_class_dictionary.h new file mode 100644 index 000000000..7f86a44ae --- /dev/null +++ b/src/accessor/grib_accessor_class_dictionary.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_dictionary_h +#define eccodes_accessor_dictionary_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_dictionary_t : public grib_accessor_gen_t +{ +public: + /* Members defined in dictionary */ + const char* dictionary; + const char* key; + long column; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_dictionary_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_dictionary_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dictionary_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_dictionary_h */ diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc new file mode 100644 index 000000000..633c3dee2 --- /dev/null +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_dirty.h" + +grib_accessor_class_dirty_t _grib_accessor_class_dirty{"dirty"}; +grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; + + +void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + + if (x) + x->dirty = *val; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + + if (x) + x->dirty = 1; + + *val = 1; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_dirty.h b/src/accessor/grib_accessor_class_dirty.h new file mode 100644 index 000000000..7a008ce29 --- /dev/null +++ b/src/accessor/grib_accessor_class_dirty.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_dirty_h +#define eccodes_accessor_dirty_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_dirty_t : public grib_accessor_long_t +{ +public: + /* Members defined in dirty */ + const char* accessor; +}; + +class grib_accessor_class_dirty_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_dirty_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dirty_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_dirty_h */ diff --git a/src/accessor/grib_accessor_class_divdouble.cc b/src/accessor/grib_accessor_class_divdouble.cc new file mode 100644 index 000000000..03a1b63b5 --- /dev/null +++ b/src/accessor/grib_accessor_class_divdouble.cc @@ -0,0 +1,43 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_divdouble.h" + +grib_accessor_class_divdouble_t _grib_accessor_class_divdouble{"divdouble"}; +grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdouble; + + +void grib_accessor_class_divdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_divdouble_t* self = (grib_accessor_divdouble_t*)a; + int n = 0; + + self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_divdouble_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_divdouble_t* self = (grib_accessor_divdouble_t*)a; + int ret = GRIB_SUCCESS; + double value = 0; + + ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); + if (ret != GRIB_SUCCESS) + return ret; + + if (self->divisor == 0) { + return GRIB_INVALID_ARGUMENT; + } + *val = value / self->divisor; + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_divdouble.h b/src/accessor/grib_accessor_class_divdouble.h new file mode 100644 index 000000000..e10239676 --- /dev/null +++ b/src/accessor/grib_accessor_class_divdouble.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_divdouble_h +#define eccodes_accessor_divdouble_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_divdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in divdouble */ + const char* val; + double divisor; +}; + +class grib_accessor_class_divdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_divdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_divdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_divdouble_h */ diff --git a/src/accessor/grib_accessor_class_double.cc b/src/accessor/grib_accessor_class_double.cc new file mode 100644 index 000000000..2d8e019a7 --- /dev/null +++ b/src/accessor/grib_accessor_class_double.cc @@ -0,0 +1,105 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_double.h" + +grib_accessor_class_double_t _grib_accessor_class_double{"double"}; +grib_accessor_class* grib_accessor_class_double = &_grib_accessor_class_double; + + +int grib_accessor_class_double_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} + +int grib_accessor_class_double_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + double val = 0; + size_t l = 1; + char repres[1024]; + char format[32] = "%g"; + grib_handle* h = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + a->unpack_double(&val, &l); + if ((val == GRIB_MISSING_DOUBLE) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { + snprintf(repres, sizeof(repres), "MISSING"); + } else { + size_t size = sizeof(format); + grib_get_string(h, "formatForDoubles", format, &size); + snprintf(repres, sizeof(repres), format, val); + } + + l = strlen(repres) + 1; + + if (l > *len) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name); + + *len = l; + + strcpy(v, repres); + return GRIB_SUCCESS; +} + +void grib_accessor_class_double_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_double_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = 0; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + long count = 0; + int err = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + while (alen != 0) { + if (*bval != *aval) + retval = GRIB_DOUBLE_VALUE_MISMATCH; + alen--; + } + + grib_context_free(a->context, aval); + grib_context_free(b->context, bval); + + return retval; +} + +int grib_accessor_class_double_t::pack_missing(grib_accessor* a){ + size_t len = 1; + double value = GRIB_MISSING_DOUBLE; + + if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) + return a->pack_double(&value, &len); return GRIB_VALUE_CANNOT_BE_MISSING; +} diff --git a/src/accessor/grib_accessor_class_double.h b/src/accessor/grib_accessor_class_double.h new file mode 100644 index 000000000..865bab9bc --- /dev/null +++ b/src/accessor/grib_accessor_class_double.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_double_h +#define eccodes_accessor_double_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_double_t : public grib_accessor_gen_t +{ +public: + /* Members defined in double */ +}; + +class grib_accessor_class_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_double_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_double_h */ diff --git a/src/accessor/todo/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc similarity index 55% rename from src/accessor/todo/grib_accessor_class_element.cc rename to src/accessor/grib_accessor_class_element.cc index 2041cd62d..a393a57aa 100644 --- a/src/accessor/todo/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,104 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long; - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* array - MEMBERS=long element - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_element -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in element */ - const char* array; - long element; -} grib_accessor_element; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_element = { - &grib_accessor_class_long, /* super */ - "element", /* name */ - sizeof(grib_accessor_element), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_element.h" +grib_accessor_class_element_t _grib_accessor_class_element{"element"}; grib_accessor_class* grib_accessor_class_element = &_grib_accessor_class_element; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_element* self = (grib_accessor_element*)a; +void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_element_t* self = (grib_accessor_element_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -114,8 +25,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->element = grib_arguments_get_long(hand, c, n++); } -static int check_element_index(const char* func, const char* array_name, long index, size_t size) -{ +int check_element_index(const char* func, const char* array_name, long index, size_t size){ const grib_context* c = grib_context_get_default(); if (index < 0 || index >= size) { grib_context_log(c, GRIB_LOG_ERROR, "%s: Invalid element index %ld for array '%s'. Value must be between 0 and %zu", @@ -125,9 +35,8 @@ static int check_element_index(const char* func, const char* array_name, long in return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_element* self = (grib_accessor_element*)a; +int grib_accessor_class_element_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; long* ar = NULL; @@ -168,9 +77,8 @@ the_end: return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_element* self = (grib_accessor_element*)a; +int grib_accessor_class_element_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; long* ar = NULL; @@ -216,9 +124,8 @@ the_end: return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_element* self = (grib_accessor_element*)a; +int grib_accessor_class_element_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; double* ar = NULL; diff --git a/src/accessor/grib_accessor_class_element.h b/src/accessor/grib_accessor_class_element.h new file mode 100644 index 000000000..f22109be2 --- /dev/null +++ b/src/accessor/grib_accessor_class_element.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_element_h +#define eccodes_accessor_element_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_element_t : public grib_accessor_long_t +{ +public: + /* Members defined in element */ + const char* array; + long element; +}; + +class grib_accessor_class_element_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_element_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_element_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_element_h */ diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc new file mode 100644 index 000000000..62228b065 --- /dev/null +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_evaluate.h" + +grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{"evaluate"}; +grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; + + +void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; + self->arg = c; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; + grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); + + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_evaluate.h b/src/accessor/grib_accessor_class_evaluate.h new file mode 100644 index 000000000..e65c6473b --- /dev/null +++ b/src/accessor/grib_accessor_class_evaluate.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_evaluate_h +#define eccodes_accessor_evaluate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_evaluate_t : public grib_accessor_long_t +{ +public: + /* Members defined in evaluate */ + grib_arguments* arg; +}; + +class grib_accessor_class_evaluate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_evaluate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_evaluate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_evaluate_h */ diff --git a/src/accessor/todo/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc similarity index 80% rename from src/accessor/todo/grib_accessor_class_expanded_descriptors.cc rename to src/accessor/grib_accessor_class_expanded_descriptors.cc index 11f4ba73b..8a12d93ff 100644 --- a/src/accessor/todo/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -1,137 +1,21 @@ + /* -* (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. -*/ + * (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. + */ -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ - -#include "grib_scaling.h" #include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_long -IMPLEMENTS = unpack_long;pack_long -IMPLEMENTS = unpack_double -IMPLEMENTS = unpack_string_array -IMPLEMENTS = init;destroy -IMPLEMENTS = value_count; get_native_type -MEMBERS = const char* unexpandedDescriptors -MEMBERS = const char* sequence -MEMBERS = const char* expandedName -MEMBERS = const char* tablesAccessorName -MEMBERS = bufr_descriptors_array* expanded -MEMBERS = int rank -MEMBERS = grib_accessor* expandedAccessor -MEMBERS = int do_expand -MEMBERS = grib_accessor* tablesAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_expanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in expanded_descriptors */ - const char* unexpandedDescriptors; - const char* sequence; - const char* expandedName; - const char* tablesAccessorName; - bufr_descriptors_array* expanded; - int rank; - grib_accessor* expandedAccessor; - int do_expand; - grib_accessor* tablesAccessor; -} grib_accessor_expanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_expanded_descriptors = { - &grib_accessor_class_long, /* super */ - "expanded_descriptors", /* name */ - sizeof(grib_accessor_expanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_expanded_descriptors.h" +#include "grib_scaling.h" +grib_accessor_class_expanded_descriptors_t _grib_accessor_class_expanded_descriptors{"expanded_descriptors"}; grib_accessor_class* grib_accessor_class_expanded_descriptors = &_grib_accessor_class_expanded_descriptors; -/* END_CLASS_IMP */ #define MYDEBUG 0 #define DESC_SIZE_INIT 400 /* Initial size for grib_bufr_descriptors_array_new */ @@ -158,9 +42,8 @@ typedef struct change_coding_params result = grib_bufr_descriptors_array_pop_front(array); \ } -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +void grib_accessor_class_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); self->tablesAccessorName = grib_arguments_get_name(hand, args, n++); @@ -205,10 +88,9 @@ static char* descriptor_type_name(int dtype) } #endif -static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded, change_coding_params* ccp, int* err) -{ +void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded, change_coding_params* ccp, int* err){ int k, j, i; - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; size_t size = 0; long* v_array = NULL; bufr_descriptor* u = NULL; @@ -581,9 +463,8 @@ static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_arra return expanded; } -static int expand(grib_accessor* a) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int expand(grib_accessor* a){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int err = 0; size_t unexpandedSize = 0; /* grib_iarray* unexp=0; */ @@ -605,7 +486,7 @@ static int expand(grib_accessor* a) self->do_expand = 0; if (self->rank != 0) { err = expand(self->expandedAccessor); - self->expanded = ((grib_accessor_expanded_descriptors*)self->expandedAccessor)->expanded; + self->expanded = ((grib_accessor_expanded_descriptors_t*)self->expandedAccessor)->expanded; return err; } @@ -706,21 +587,20 @@ static int expand(grib_accessor* a) int grib_accessor_class_expanded_descriptors_set_do_expand(grib_accessor* a, long do_expand) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; self->do_expand = do_expand; return 0; } bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a, int* err) { - const grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + const grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; *err = expand(a); return self->expanded; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int grib_accessor_class_expanded_descriptors_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int ret = 0; size_t i = 0; size_t expandedSize; @@ -753,9 +633,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int grib_accessor_class_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int ret = 0; size_t rlen = 0; size_t i = 0; @@ -799,8 +678,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ +int grib_accessor_class_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ int err = 0; long* v = NULL; char buf[25] = {0,}; @@ -808,13 +686,11 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) size_t i = 0, size = 0; const grib_context* c = a->context; - err = grib_value_count(a, &llen); - if (err) return err; + err = a->value_count(&llen); if (err) return err; size = llen; v = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = grib_unpack_long(a, v, &size); - if (err) return err; + err = a->unpack_long(v, &size); if (err) return err; for (i = 0; i < size; i++) { snprintf(buf, sizeof(buf), "%06ld", v[i]); @@ -826,16 +702,14 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int grib_accessor_class_expanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; self->do_expand = 1; return GRIB_NOT_IMPLEMENTED; } -static int value_count(grib_accessor* a, long* rlen) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int err = 0; *rlen = 0; @@ -849,16 +723,14 @@ static int value_count(grib_accessor* a, long* rlen) return err; } -static void destroy(grib_context* c, grib_accessor* a) -{ - // grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +void grib_accessor_class_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ + // grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; // if (self->rank==0 && self->expanded) // grib_bufr_descriptors_array_delete(self->expanded); } -static int get_native_type(grib_accessor* a) -{ - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; +int grib_accessor_class_expanded_descriptors_t::get_native_type(grib_accessor* a){ + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; if (self->rank == 2) return GRIB_TYPE_DOUBLE; else diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h b/src/accessor/grib_accessor_class_expanded_descriptors.h new file mode 100644 index 000000000..be2094d4f --- /dev/null +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_expanded_descriptors_h +#define eccodes_accessor_expanded_descriptors_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in expanded_descriptors */ + const char* unexpandedDescriptors; + const char* sequence; + const char* expandedName; + const char* tablesAccessorName; + bufr_descriptors_array* expanded; + int rank; + grib_accessor* expandedAccessor; + int do_expand; + grib_accessor* tablesAccessor; +}; + +class grib_accessor_class_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_expanded_descriptors_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_expanded_descriptors_h */ diff --git a/src/accessor/todo/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc similarity index 59% rename from src/accessor/todo/grib_accessor_class_from_scale_factor_scaled_value.cc rename to src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc index 53784e172..3ba6e198e 100644 --- a/src/accessor/todo/grib_accessor_class_from_scale_factor_scaled_value.cc +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,110 +10,14 @@ */ #include "grib_api_internal.h" -#include -#ifdef ECCODES_ON_WINDOWS - #include -#endif - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* scaleFactor - MEMBERS=const char* scaledValue - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_from_scale_factor_scaled_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in from_scale_factor_scaled_value */ - const char* scaleFactor; - const char* scaledValue; -} grib_accessor_from_scale_factor_scaled_value; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_from_scale_factor_scaled_value = { - &grib_accessor_class_double, /* super */ - "from_scale_factor_scaled_value", /* name */ - sizeof(grib_accessor_from_scale_factor_scaled_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_from_scale_factor_scaled_value.h" +grib_accessor_class_from_scale_factor_scaled_value_t _grib_accessor_class_from_scale_factor_scaled_value{"from_scale_factor_scaled_value"}; grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value = &_grib_accessor_class_from_scale_factor_scaled_value; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +void grib_accessor_class_from_scale_factor_scaled_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -123,11 +28,10 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) // a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_from_scale_factor_scaled_value_t::pack_double(grib_accessor* a, const double* val, size_t* len){ // See ECC-979 and ECC-1416 // Evaluate self->scaleFactor and self->scaledValue from input double '*val' - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; int64_t factor = 0; @@ -181,9 +85,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int err = 0; long scaleFactor = 0, scaledValue = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -257,9 +160,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int is_missing(grib_accessor* a) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::is_missing(grib_accessor* a){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; long scaleFactor = 0, scaledValue = 0; @@ -273,9 +175,8 @@ static int is_missing(grib_accessor* a) return ((scaleFactor == GRIB_MISSING_LONG) || (scaledValue == GRIB_MISSING_LONG)); } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::value_count(grib_accessor* a, long* len){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int err = 0; grib_handle* hand = grib_handle_of_accessor(a); size_t vsize; diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h new file mode 100644 index 000000000..1874c559f --- /dev/null +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_from_scale_factor_scaled_value_h +#define eccodes_accessor_from_scale_factor_scaled_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t +{ +public: + /* Members defined in from_scale_factor_scaled_value */ + const char* scaleFactor; + const char* scaledValue; +}; + +class grib_accessor_class_from_scale_factor_scaled_value_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_from_scale_factor_scaled_value_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_from_scale_factor_scaled_value_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_from_scale_factor_scaled_value_h */ diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc new file mode 100644 index 000000000..cf115535f --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1_half_byte_codeflag.h" + +grib_accessor_class_g1_half_byte_codeflag_t _grib_accessor_class_g1_half_byte_codeflag{"g1_half_byte_codeflag"}; +grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor_class_g1_half_byte_codeflag; + + +void grib_accessor_class_g1_half_byte_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +void grib_accessor_class_g1_half_byte_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_g1_half_byte_codeflag_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + unsigned char dat = 0; + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; + + *val = dat; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1_half_byte_codeflag_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int ret = 0; + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ + grib_handle_of_accessor(a)->buffer->data[a->offset] = (a->parent->h->buffer->data[a->offset] & 0xf0) | (*val & 0x0f); + /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ + + *len = 1; + return ret; +} + +int grib_accessor_class_g1_half_byte_codeflag_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h new file mode 100644 index 000000000..9c5890aa3 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_half_byte_codeflag_h +#define eccodes_accessor_g1_half_byte_codeflag_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g1_half_byte_codeflag */ +}; + +class grib_accessor_class_g1_half_byte_codeflag_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g1_half_byte_codeflag_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_half_byte_codeflag_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_half_byte_codeflag_h */ diff --git a/src/accessor/todo/grib_accessor_class_g1_message_length.cc b/src/accessor/grib_accessor_class_g1_message_length.cc similarity index 53% rename from src/accessor/todo/grib_accessor_class_g1_message_length.cc rename to src/accessor/grib_accessor_class_g1_message_length.cc index 1d38e7ea4..9b318b6a0 100644 --- a/src/accessor/todo/grib_accessor_class_g1_message_length.cc +++ b/src/accessor/grib_accessor_class_g1_message_length.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,103 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_section_length - IMPLEMENTS = init;unpack_long;pack_long - MEMBERS = const char *sec4_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_message_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ - /* Members defined in g1_message_length */ - const char *sec4_length; -} grib_accessor_g1_message_length; - -extern grib_accessor_class* grib_accessor_class_section_length; - -static grib_accessor_class _grib_accessor_class_g1_message_length = { - &grib_accessor_class_section_length, /* super */ - "g1_message_length", /* name */ - sizeof(grib_accessor_g1_message_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g1_message_length.h" +grib_accessor_class_g1_message_length_t _grib_accessor_class_g1_message_length{"g1_message_length"}; grib_accessor_class* grib_accessor_class_g1_message_length = &_grib_accessor_class_g1_message_length; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +void grib_accessor_class_g1_message_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; self->sec4_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); } @@ -148,9 +60,8 @@ int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +int grib_accessor_class_g1_message_length_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; /*grib_accessor_class* super = *(a->cclass->super);*/ /* Here we assume that the totalLength will be coded AFTER the section4 length, and @@ -182,7 +93,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) tlen = 0x800000 | t120; *len = 1; - if ((ret = grib_pack_long(s4, &slen, len)) != GRIB_SUCCESS) + if ((ret = s4->pack_long(&slen, len)) != GRIB_SUCCESS) return ret; *len = 1; @@ -211,9 +122,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +int grib_accessor_class_g1_message_length_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; int ret; long total_length, sec4_length; diff --git a/src/accessor/grib_accessor_class_g1_message_length.h b/src/accessor/grib_accessor_class_g1_message_length.h new file mode 100644 index 000000000..c3b865ec0 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_message_length.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_message_length_h +#define eccodes_accessor_g1_message_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_message_length */ + const char *sec4_length; +}; + +class grib_accessor_class_g1_message_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_message_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_message_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_message_length_h */ diff --git a/src/accessor/grib_accessor_class_g1_section4_length.cc b/src/accessor/grib_accessor_class_g1_section4_length.cc new file mode 100644 index 000000000..858ef0d69 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_section4_length.cc @@ -0,0 +1,53 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1_section4_length.h" + +grib_accessor_class_g1_section4_length_t _grib_accessor_class_g1_section4_length{"g1_section4_length"}; +grib_accessor_class* grib_accessor_class_g1_section4_length = &_grib_accessor_class_g1_section4_length; + + +void grib_accessor_class_g1_section4_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_g1_section4_length_t* self = (grib_accessor_g1_section4_length_t*)a; + self->total_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); +} + +int grib_accessor_class_g1_section4_length_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + // Old implementation: + // Here we assume that the totalLength will be coded AFTER the section4 length, and + // the section4 length will be overwritten by the totalLength accessor for large GRIBs + // grib_accessor_class* super = *(a->cclass->super); + // return super->pack_long(a,val,len); + + // Note: Do not directly call pack_long on base class + // because in this special case we want to skip the checks. + // So we call the helper function which has an extra argument + return pack_long_unsigned_helper(a, val, len, /*check=*/0); +} + +int grib_accessor_class_g1_section4_length_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1_section4_length_t* self = (grib_accessor_g1_section4_length_t*)a; + int ret = 0; + long total_length = 0, sec4_length = 0; + + if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), + grib_find_accessor(grib_handle_of_accessor(a), self->total_length), + a, + &total_length, + &sec4_length)) != GRIB_SUCCESS) { + return ret; + } + + *val = sec4_length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h b/src/accessor/grib_accessor_class_g1_section4_length.h new file mode 100644 index 000000000..0a1b0c768 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_section4_length.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_section4_length_h +#define eccodes_accessor_g1_section4_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_section4_length */ + const char* total_length; +}; + +class grib_accessor_class_g1_section4_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_section4_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_section4_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_section4_length_h */ diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc new file mode 100644 index 000000000..ad186dff0 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -0,0 +1,98 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1bitmap.h" +#include "shared_functions.h" + +grib_accessor_class_g1bitmap_t _grib_accessor_class_g1bitmap{"g1bitmap"}; +grib_accessor_class* grib_accessor_class_g1bitmap = &_grib_accessor_class_g1bitmap; + + +void grib_accessor_class_g1bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); +} + +int grib_accessor_class_g1bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + size_t tlen; + + unsigned char* buf = NULL; + size_t i; + int err = 0; + long pos = 0; + //long bmaplen = 0; + const int bit_padding = 16; + double miss_values = 0; + tlen = ((*len + bit_padding - 1) / bit_padding * bit_padding) / 8; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) + return err; + + buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + pos = 0; + for (i = 0; i < *len; i++) { + if (val[i] == miss_values) + pos++; + else { + //bmaplen++; + grib_set_bit_on(buf, &pos); + } + } + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->unusedBits, tlen * 8 - *len)) != GRIB_SUCCESS) + return err; + + err = grib_buffer_replace(a, buf, tlen, 1, 1); + if (err) return err; + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + long tlen; + int err; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d", self->unusedBits, err); + + *count = (a->length * 8) - tlen; + return err; +} + +int grib_accessor_class_g1bitmap_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len){ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + long tlen; + int err; + long length = a->byte_count(); long offset = a->byte_offset(); + if (*len < (size_t)length) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %ld bytes long\n", a->name, length); + *len = length; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) + grib_context_log(a->context, GRIB_LOG_ERROR, + "grib_accessor_class_bitmap.unpack_bytes : cannot get %s err=%d", self->unusedBits, err); + + length -= tlen / 8; + memcpy(val, buf + offset, length); + *len = length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1bitmap.h b/src/accessor/grib_accessor_class_g1bitmap.h new file mode 100644 index 000000000..b34344d1f --- /dev/null +++ b/src/accessor/grib_accessor_class_g1bitmap.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1bitmap_h +#define eccodes_accessor_g1bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g1bitmap */ + const char* unusedBits; +}; + +class grib_accessor_class_g1bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g1bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1bitmap_h */ diff --git a/src/accessor/todo/grib_accessor_class_g1date.cc b/src/accessor/grib_accessor_class_g1date.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_g1date.cc rename to src/accessor/grib_accessor_class_g1date.cc index c53b3768a..de787abba 100644 --- a/src/accessor/todo/grib_accessor_class_g1date.cc +++ b/src/accessor/grib_accessor_class_g1date.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,109 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_g1date.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long;unpack_string - IMPLEMENTS = init;value_count - MEMBERS=const char* century - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1date */ - const char* century; - const char* year; - const char* month; - const char* day; -} grib_accessor_g1date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1date = { - &grib_accessor_class_long, /* super */ - "g1date", /* name */ - sizeof(grib_accessor_g1date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g1date_t _grib_accessor_class_g1date{"g1date"}; grib_accessor_class* grib_accessor_class_g1date = &_grib_accessor_class_g1date; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1date* self = (grib_accessor_g1date*)a; +void grib_accessor_class_g1date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -121,9 +27,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->day = grib_arguments_get_name(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1date* self = (grib_accessor_g1date*)a; +int grib_accessor_class_g1date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; @@ -154,9 +59,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g1date* self = (grib_accessor_g1date*)a; +int grib_accessor_class_g1date_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; @@ -168,7 +72,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) long d = grib_julian_to_date(grib_date_to_julian(v)); if (v != d) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g1date: pack_long invalid date %ld, changed to %ld", v, d); + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g1date_t: pack_long invalid date %ld, changed to %ld", v, d); return GRIB_ENCODING_ERROR; } @@ -212,9 +116,8 @@ static const char* months[] = { "dec", }; -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g1date* self = (grib_accessor_g1date*)a; +int grib_accessor_class_g1date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; @@ -256,8 +159,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g1date_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_g1date.h b/src/accessor/grib_accessor_class_g1date.h new file mode 100644 index 000000000..27e71189f --- /dev/null +++ b/src/accessor/grib_accessor_class_g1date.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1date_h +#define eccodes_accessor_g1date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g1date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1date_h */ diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc new file mode 100644 index 000000000..9bf107e94 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1day_of_the_year_date.h" + +grib_accessor_class_g1day_of_the_year_date_t _grib_accessor_class_g1day_of_the_year_date{"g1day_of_the_year_date"}; +grib_accessor_class* grib_accessor_class_g1day_of_the_year_date = &_grib_accessor_class_g1day_of_the_year_date; + + + +void grib_accessor_class_g1day_of_the_year_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_g1day_of_the_year_date_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_g1day_of_the_year_date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + /* special clim case where each mont have 30 days.. to comply with mars*/ + grib_accessor_g1day_of_the_year_date_t* self = (grib_accessor_g1day_of_the_year_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + char tmp[1024]; + + long year = 0; + long century = 0; + long month = 0; + long day = 0; + long fullyear = 0; + long fake_day_of_year = 0; + + grib_get_long_internal(hand, self->century, ¢ury); + grib_get_long_internal(hand, self->day, &day); + grib_get_long_internal(hand, self->month, &month); + grib_get_long_internal(hand, self->year, &year); + + fullyear = ((century - 1) * 100 + year); + fake_day_of_year = ((month - 1) * 30) + day; + snprintf(tmp, sizeof(tmp), "%04ld-%03ld", fullyear, fake_day_of_year); + + size_t l = strlen(tmp) + 1; + if (*len < l) { + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + *len = l; + strcpy(val, tmp); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h new file mode 100644 index 000000000..1563cdb9d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1day_of_the_year_date_h +#define eccodes_accessor_g1day_of_the_year_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_g1date.h" + +class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t +{ +public: + /* Members defined in g1day_of_the_year_date */ +}; + +class grib_accessor_class_g1day_of_the_year_date_t : public grib_accessor_class_g1date_t +{ +public: + grib_accessor_class_g1day_of_the_year_date_t(const char* name) : grib_accessor_class_g1date_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1day_of_the_year_date_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1day_of_the_year_date_h */ diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc new file mode 100644 index 000000000..c362016b1 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -0,0 +1,135 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1end_of_interval_monthly.h" + +grib_accessor_class_g1end_of_interval_monthly_t _grib_accessor_class_g1end_of_interval_monthly{"g1end_of_interval_monthly"}; +grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly = &_grib_accessor_class_g1end_of_interval_monthly; + + +void grib_accessor_class_g1end_of_interval_monthly_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + int n = 0; + + self->verifyingMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + + self->number_of_elements = 6; + self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); + + a->length = 0; + a->dirty = 1; +} + +int grib_accessor_class_g1end_of_interval_monthly_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + int ret = 0; + char verifyingMonth[7] = {0,}; + size_t slen = 7; + long year = 0, month = 0, date = 0; + const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + long days = 0; + + if (!a->dirty) + return GRIB_SUCCESS; + + if (*len != (size_t)self->number_of_elements) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) + return ret; + + date = atoi(verifyingMonth); + if (date < 0) { + return GRIB_INVALID_ARGUMENT; + } + year = date / 100; + month = date - year * 100; + if (month == 2) { + days = 28; + if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) + days = 29; + } + else { + if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT; + days = mdays[month - 1]; + } + self->v[0] = year; + self->v[1] = month; + + self->v[2] = days; + self->v[3] = 24; + self->v[4] = 00; + self->v[5] = 00; + + a->dirty = 0; + + val[0] = self->v[0]; + val[1] = self->v[1]; + val[2] = self->v[2]; + val[3] = self->v[3]; + val[4] = self->v[4]; + val[5] = self->v[5]; + + return ret; +} + +int grib_accessor_class_g1end_of_interval_monthly_t::value_count(grib_accessor* a, long* count){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + *count = self->number_of_elements; + return 0; +} + +void grib_accessor_class_g1end_of_interval_monthly_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + grib_context_free(c, self->v); +} + +int grib_accessor_class_g1end_of_interval_monthly_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + double* aval = 0; + double* bval = 0; + + long count = 0; + size_t alen = 0; + size_t blen = 0; + int err = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + b->dirty = 1; + a->dirty = 1; + + err = a->unpack_double(aval, &alen); err = b->unpack_double(bval, &blen); + for(size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h new file mode 100644 index 000000000..a1e29a76c --- /dev/null +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1end_of_interval_monthly_h +#define eccodes_accessor_g1end_of_interval_monthly_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in g1end_of_interval_monthly */ + const char* verifyingMonth; +}; + +class grib_accessor_class_g1end_of_interval_monthly_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_g1end_of_interval_monthly_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1end_of_interval_monthly_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_g1end_of_interval_monthly_h */ diff --git a/src/accessor/grib_accessor_class_g1fcperiod.cc b/src/accessor/grib_accessor_class_g1fcperiod.cc new file mode 100644 index 000000000..143a381e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1fcperiod.cc @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1fcperiod.h" + +grib_accessor_class_g1fcperiod_t _grib_accessor_class_g1fcperiod{"g1fcperiod"}; +grib_accessor_class* grib_accessor_class_g1fcperiod = &_grib_accessor_class_g1fcperiod; + + +int grib_accessor_class_g1fcperiod_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long start = 0, theEnd = 0; + char tmp[1024]; + const size_t tmpLen = sizeof(tmp); + int err = grib_g1_step_get_steps(a, &start, &theEnd); + size_t l = 0; + + if (err) + return err; + + snprintf(tmp, tmpLen, "%ld-%ld", start / 24, theEnd / 24); + /*printf("---- FCPERIOD %s [start:%g, end:%g]",tmp,start,end);*/ + + l = strlen(tmp) + 1; + if (*len < l) { + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + *len = l; + strcpy(val, tmp); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h b/src/accessor/grib_accessor_class_g1fcperiod.h new file mode 100644 index 000000000..3c0ff2c49 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1fcperiod.h @@ -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. + */ + +#ifndef eccodes_accessor_g1fcperiod_h +#define eccodes_accessor_g1fcperiod_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_g1step_range.h" + +class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t +{ +public: + /* Members defined in g1fcperiod */ +}; + +class grib_accessor_class_g1fcperiod_t : public grib_accessor_class_g1step_range_t +{ +public: + grib_accessor_class_g1fcperiod_t(const char* name) : grib_accessor_class_g1step_range_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1fcperiod_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; +#endif /* eccodes_accessor_g1fcperiod_h */ diff --git a/src/accessor/todo/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc similarity index 58% rename from src/accessor/todo/grib_accessor_class_g1forecastmonth.cc rename to src/accessor/grib_accessor_class_g1forecastmonth.cc index e25db6930..f0a0e86db 100644 --- a/src/accessor/todo/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,112 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_g1forecastmonth.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - MEMBERS=const char* verification_yearmonth - MEMBERS=const char* base_date - MEMBERS=const char* day - MEMBERS=const char* hour - MEMBERS=const char* fcmonth - MEMBERS=const char* check - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1forecastmonth -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1forecastmonth */ - const char* verification_yearmonth; - const char* base_date; - const char* day; - const char* hour; - const char* fcmonth; - const char* check; -} grib_accessor_g1forecastmonth; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1forecastmonth = { - &grib_accessor_class_long, /* super */ - "g1forecastmonth", /* name */ - sizeof(grib_accessor_g1forecastmonth), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g1forecastmonth_t _grib_accessor_class_g1forecastmonth{"g1forecastmonth"}; grib_accessor_class* grib_accessor_class_g1forecastmonth = &_grib_accessor_class_g1forecastmonth; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; +void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; const int count = grib_arguments_get_count(c); @@ -128,13 +31,11 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) } } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_g1forecastmonth_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_long(dumper, a, NULL); } -static int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result) -{ +int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result){ long base_yearmonth = 0; long vyear = 0; long vmonth = 0; @@ -157,8 +58,7 @@ static int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long return GRIB_SUCCESS; } -static int unpack_long_edition2(grib_accessor* a, long* val, size_t* len) -{ +int unpack_long_edition2(grib_accessor* a, long* val, size_t* len){ int err = 0; grib_handle* h = grib_handle_of_accessor(a); long dataDate, verification_yearmonth; @@ -202,10 +102,9 @@ static int unpack_long_edition2(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) -{ +int unpack_long_edition1(grib_accessor* a, long* val, size_t* len){ int err = 0; - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; long verification_yearmonth = 0; long base_date = 0; @@ -249,8 +148,7 @@ static int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_g1forecastmonth_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int err = 0; grib_handle* hand = grib_handle_of_accessor(a); long edition = 0; @@ -267,8 +165,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* TODO: Check for a valid date */ -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; +int grib_accessor_class_g1forecastmonth_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; return grib_set_long_internal(grib_handle_of_accessor(a), self->fcmonth, *val); } diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h b/src/accessor/grib_accessor_class_g1forecastmonth.h new file mode 100644 index 000000000..6d2b9ee63 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1forecastmonth_h +#define eccodes_accessor_g1forecastmonth_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1forecastmonth */ + const char* verification_yearmonth; + const char* base_date; + const char* day; + const char* hour; + const char* fcmonth; + const char* check; +}; + +class grib_accessor_class_g1forecastmonth_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1forecastmonth_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1forecastmonth_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1forecastmonth_h */ diff --git a/src/accessor/grib_accessor_class_g1monthlydate.cc b/src/accessor/grib_accessor_class_g1monthlydate.cc new file mode 100644 index 000000000..3a184669b --- /dev/null +++ b/src/accessor/grib_accessor_class_g1monthlydate.cc @@ -0,0 +1,41 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1monthlydate.h" + +grib_accessor_class_g1monthlydate_t _grib_accessor_class_g1monthlydate{"g1monthlydate"}; +grib_accessor_class* grib_accessor_class_g1monthlydate = &_grib_accessor_class_g1monthlydate; + + +void grib_accessor_class_g1monthlydate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1monthlydate_t* self = (grib_accessor_g1monthlydate_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_g1monthlydate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1monthlydate_t* self = (grib_accessor_g1monthlydate_t*)a; + + long date = 0; + + grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); + + date /= 100; + date *= 100; + date += 1; + + *val = date; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h b/src/accessor/grib_accessor_class_g1monthlydate.h new file mode 100644 index 000000000..8efa9cf16 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1monthlydate.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1monthlydate_h +#define eccodes_accessor_g1monthlydate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1monthlydate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1monthlydate */ + const char* date; +}; + +class grib_accessor_class_g1monthlydate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1monthlydate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1monthlydate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1monthlydate_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc new file mode 100644 index 000000000..17d36f908 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc @@ -0,0 +1,81 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1number_of_coded_values_sh_complex.h" + +grib_accessor_class_g1number_of_coded_values_sh_complex_t _grib_accessor_class_g1number_of_coded_values_sh_complex{"g1number_of_coded_values_sh_complex"}; +grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex = &_grib_accessor_class_g1number_of_coded_values_sh_complex; + + +void grib_accessor_class_g1number_of_coded_values_sh_complex_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_g1number_of_coded_values_sh_complex_t* self = (grib_accessor_g1number_of_coded_values_sh_complex_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->KS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->MS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_g1number_of_coded_values_sh_complex_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + long JS = 0, KS = 0, MS = 0, NS = 0; + + grib_accessor_g1number_of_coded_values_sh_complex_t* self = (grib_accessor_g1number_of_coded_values_sh_complex_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->JS, &JS)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->KS, &KS)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->MS, &MS)) != GRIB_SUCCESS) + return ret; + + if (JS != KS || KS != MS) + return GRIB_NOT_IMPLEMENTED; + + NS = (MS + 1) * (MS + 2); + + if (bpv != 0) { + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits + NS * (bpv - 32)) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h new file mode 100644 index 000000000..764bfa04d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h +#define eccodes_accessor_g1number_of_coded_values_sh_complex_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_complex */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; + const char* JS; + const char* KS; + const char* MS; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_complex_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_complex_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_complex_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1number_of_coded_values_sh_complex_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc new file mode 100644 index 000000000..c2d9801f8 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc @@ -0,0 +1,62 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1number_of_coded_values_sh_simple.h" + +grib_accessor_class_g1number_of_coded_values_sh_simple_t _grib_accessor_class_g1number_of_coded_values_sh_simple{"g1number_of_coded_values_sh_simple"}; +grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple = &_grib_accessor_class_g1number_of_coded_values_sh_simple; + + +void grib_accessor_class_g1number_of_coded_values_sh_simple_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_g1number_of_coded_values_sh_simple_t* self = (grib_accessor_g1number_of_coded_values_sh_simple_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_g1number_of_coded_values_sh_simple_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + + grib_accessor_g1number_of_coded_values_sh_simple_t* self = (grib_accessor_g1number_of_coded_values_sh_simple_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if (bpv != 0) { + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h new file mode 100644 index 000000000..fb5ab298d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h +#define eccodes_accessor_g1number_of_coded_values_sh_simple_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_simple */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_simple_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_simple_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_simple_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1number_of_coded_values_sh_simple_h */ diff --git a/src/accessor/todo/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc similarity index 79% rename from src/accessor/todo/grib_accessor_class_g1step_range.cc rename to src/accessor/grib_accessor_class_g1step_range.cc index 46c7a3cc8..f2444486a 100644 --- a/src/accessor/todo/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,131 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/********************************************* - * Enrico Fucile - *******************************************/ - #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_long_vector - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = pack_long;unpack_long;dump - IMPLEMENTS = get_native_type;string_length - IMPLEMENTS = init; destroy - MEMBERS = const char* p1 - MEMBERS = const char* p2 - MEMBERS = const char* timeRangeIndicator - MEMBERS = const char *unit - MEMBERS = const char *step_unit - MEMBERS = const char *stepType - MEMBERS = const char *patch_fp_precip - MEMBERS = int error_on_units - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1step_range -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in g1step_range */ - const char* p1; - const char* p2; - const char* timeRangeIndicator; - const char *unit; - const char *step_unit; - const char *stepType; - const char *patch_fp_precip; - int error_on_units; -} grib_accessor_g1step_range; - -extern grib_accessor_class* grib_accessor_class_abstract_long_vector; - -static grib_accessor_class _grib_accessor_class_g1step_range = { - &grib_accessor_class_abstract_long_vector, /* super */ - "g1step_range", /* name */ - sizeof(grib_accessor_g1step_range), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g1step_range.h" +grib_accessor_class_g1step_range_t _grib_accessor_class_g1step_range{"g1step_range"}; grib_accessor_class* grib_accessor_class_g1step_range = &_grib_accessor_class_g1step_range; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +void grib_accessor_class_g1step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; self->p1 = grib_arguments_get_name(h, c, n++); @@ -153,8 +38,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_g1step_range_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } @@ -203,7 +87,7 @@ static const int u2s[] = { int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd) { - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; int err = 0; long p1 = 0, p2 = 0, unit = 0, timeRangeIndicator = 0, timeRangeIndicatorFromStepRange = 0; long step_unit = 1; @@ -298,9 +182,8 @@ int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd) return 0; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char buf[100]; size_t size = 0; long start = 0, theEnd = 0; @@ -450,9 +333,8 @@ static int grib_g1_step_apply_units( return GRIB_WRONG_STEP; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); long timeRangeIndicator = 0, P1 = 0, P2 = 0; long start = 0, theEnd = -1, unit = 0, ounit = 0, step_unit = 1; @@ -631,25 +513,22 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g1step_range_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_g1step_range_t::string_length(grib_accessor* a){ return 255; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_g1step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len){ char buff[256]; size_t bufflen = 100; char sval[100] = { 0 }; char* p = sval; size_t svallen = 100; - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char stepType[20] = {0,}; size_t stepTypeLen = 20; long step_unit = 0; @@ -718,9 +597,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_INTERNAL_ERROR; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char buff[100]; size_t bufflen = 100; long start, theEnd; @@ -749,13 +627,11 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_g1step_range_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +void grib_accessor_class_g1step_range_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_context_free(c, self->v); } diff --git a/src/accessor/grib_accessor_class_g1step_range.h b/src/accessor/grib_accessor_class_g1step_range.h new file mode 100644 index 000000000..c9c3dd911 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1step_range.h @@ -0,0 +1,48 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1step_range_h +#define eccodes_accessor_g1step_range_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in g1step_range */ + const char* p1; + const char* p2; + const char* timeRangeIndicator; + const char *unit; + const char *step_unit; + const char *stepType; + const char *patch_fp_precip; + int error_on_units; +}; + +class grib_accessor_class_g1step_range_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_g1step_range_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1step_range_h */ diff --git a/src/accessor/grib_accessor_class_g1verificationdate.cc b/src/accessor/grib_accessor_class_g1verificationdate.cc new file mode 100644 index 000000000..7f91c5b99 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1verificationdate.cc @@ -0,0 +1,64 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g1verificationdate.h" + +grib_accessor_class_g1verificationdate_t _grib_accessor_class_g1verificationdate{"g1verificationdate"}; +grib_accessor_class* grib_accessor_class_g1verificationdate = &_grib_accessor_class_g1verificationdate; + + +void grib_accessor_class_g1verificationdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g1verificationdate_t* self = (grib_accessor_g1verificationdate_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->time = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_g1verificationdate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1verificationdate_t* self = (grib_accessor_g1verificationdate_t*)a; + int ret = 0; + long date = 0; + long time = 0; + long cdate = 0; + long step = 0; + long vtime = 0; + long vdate = 0; + long vd = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->step, &step)) != GRIB_SUCCESS) + return ret; + + time /= 100; + + cdate = (long)grib_date_to_julian(date); + vtime = cdate * 24 + time + step; + vd = vtime / 24; + vdate = grib_julian_to_date(vd); + + /* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */ + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = vdate; + + /* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h b/src/accessor/grib_accessor_class_g1verificationdate.h new file mode 100644 index 000000000..198801aba --- /dev/null +++ b/src/accessor/grib_accessor_class_g1verificationdate.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1verificationdate_h +#define eccodes_accessor_g1verificationdate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1verificationdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1verificationdate */ + const char* date; + const char* time; + const char* step; +}; + +class grib_accessor_class_g1verificationdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1verificationdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1verificationdate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1verificationdate_h */ diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc new file mode 100644 index 000000000..654c0e97a --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -0,0 +1,114 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2_aerosol.h" + +grib_accessor_class_g2_aerosol_t _grib_accessor_class_g2_aerosol{"g2_aerosol"}; +grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_aerosol; + + +void grib_accessor_class_g2_aerosol_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++); + self->stepType = grib_arguments_get_name(hand, c, n++); + self->optical = grib_arguments_get_long(hand, c, n++); +} + +int grib_accessor_class_g2_aerosol_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + long productDefinitionTemplateNumber = 0; + grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); + + if (self->optical) + *val = grib2_is_PDTN_AerosolOptical(productDefinitionTemplateNumber); + else + *val = grib2_is_PDTN_Aerosol(productDefinitionTemplateNumber); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + long productDefinitionTemplateNumber = -1; + long productDefinitionTemplateNumberNew = -1; + /*long type=-1; + long stream=-1;*/ + long eps = -1; + char stepType[15] = {0,}; + size_t slen = 15; + /*int aerosol = *val;*/ + int isInstant = 0; + /*long derivedForecast=-1;*/ + int ret = 0; + + if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS) + return GRIB_SUCCESS; + + /* + grib_get_long(hand, self->type,&type); + grib_get_long(hand, self->stream,&stream); + */ + ret = grib_get_string(hand, self->stepType, stepType, &slen); + Assert(ret == GRIB_SUCCESS); + + //eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); + eps = grib_is_defined(hand, "perturbationNumber"); + + if (!strcmp(stepType, "instant")) + isInstant = 1; + + if (eps == 1) { + if (isInstant) { + productDefinitionTemplateNumberNew = 45; + } + else { + /*productDefinitionTemplateNumberNew = 47; PDT deprecated*/ + productDefinitionTemplateNumberNew = 85; + } + } + else { + if (isInstant) { + productDefinitionTemplateNumberNew = 48; /*44 is deprecated*/ + } + else { + productDefinitionTemplateNumberNew = 46; + } + } + + if (self->optical) { + /* Note: There is no interval based template for optical properties of aerosol! */ + if (eps) + productDefinitionTemplateNumberNew = 49; + else + productDefinitionTemplateNumberNew = 48; + if (!isInstant) { + grib_context_log(hand->context, GRIB_LOG_ERROR, + "The product definition templates for optical properties of aerosol are for a point-in-time only"); + } + } + + if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { + grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew); + /*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/ + } + + return 0; +} + +int grib_accessor_class_g2_aerosol_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h b/src/accessor/grib_accessor_class_g2_aerosol.h new file mode 100644 index 000000000..fb29a9561 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_aerosol.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_aerosol_h +#define eccodes_accessor_g2_aerosol_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_aerosol */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int optical; +}; + +class grib_accessor_class_g2_aerosol_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_aerosol_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_aerosol_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_aerosol_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc similarity index 54% rename from src/accessor/todo/grib_accessor_class_g2_chemical.cc rename to src/accessor/grib_accessor_class_g2_chemical.cc index 16d8e6f33..72d7581e1 100644 --- a/src/accessor/todo/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,108 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=int chemical_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_chemical -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_chemical */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int chemical_type; -} grib_accessor_g2_chemical; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_chemical = { - &grib_accessor_class_unsigned, /* super */ - "g2_chemical", /* name */ - sizeof(grib_accessor_g2_chemical), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2_chemical.h" +grib_accessor_class_g2_chemical_t _grib_accessor_class_g2_chemical{"g2_chemical"}; grib_accessor_class* grib_accessor_class_g2_chemical = &_grib_accessor_class_g2_chemical; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +void grib_accessor_class_g2_chemical_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -119,9 +26,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->chemical_type = grib_arguments_get_long(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +int grib_accessor_class_g2_chemical_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; long productDefinitionTemplateNumber = 0; grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); @@ -141,9 +47,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +int grib_accessor_class_g2_chemical_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberNew = -1; @@ -214,8 +119,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2_chemical_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_g2_chemical.h b/src/accessor/grib_accessor_class_g2_chemical.h new file mode 100644 index 000000000..9cfe4f8bc --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_chemical.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_chemical_h +#define eccodes_accessor_g2_chemical_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_chemical */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int chemical_type; +}; + +class grib_accessor_class_g2_chemical_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_chemical_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_chemical_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_chemical_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2_eps.cc b/src/accessor/grib_accessor_class_g2_eps.cc similarity index 58% rename from src/accessor/todo/grib_accessor_class_g2_eps.cc rename to src/accessor/grib_accessor_class_g2_eps.cc index fc202a572..336245721 100644 --- a/src/accessor/todo/grib_accessor_class_g2_eps.cc +++ b/src/accessor/grib_accessor_class_g2_eps.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,113 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_g2_eps.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stream - MEMBERS=const char* type - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_eps -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_eps */ - const char* productDefinitionTemplateNumber; - const char* stream; - const char* type; - const char* stepType; - const char* derivedForecast; -} grib_accessor_g2_eps; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_eps = { - &grib_accessor_class_unsigned, /* super */ - "g2_eps", /* name */ - sizeof(grib_accessor_g2_eps), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g2_eps_t _grib_accessor_class_g2_eps{"g2_eps"}; grib_accessor_class* grib_accessor_class_g2_eps = &_grib_accessor_class_g2_eps; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +void grib_accessor_class_g2_eps_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; int n = 0; self->productDefinitionTemplateNumber = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -125,9 +27,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->derivedForecast = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +int grib_accessor_class_g2_eps_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; long productDefinitionTemplateNumber = 0; int err = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -145,9 +46,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +int grib_accessor_class_g2_eps_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberNew = -1; @@ -266,8 +166,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2_eps_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_g2_eps.h b/src/accessor/grib_accessor_class_g2_eps.h new file mode 100644 index 000000000..7c39dd580 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_eps.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_eps_h +#define eccodes_accessor_g2_eps_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_eps */ + const char* productDefinitionTemplateNumber; + const char* stream; + const char* type; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_g2_eps_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_eps_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_eps_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_eps_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc similarity index 75% rename from src/accessor/todo/grib_accessor_class_g2_mars_labeling.cc rename to src/accessor/grib_accessor_class_g2_mars_labeling.cc index ad0647e30..4de889cfa 100644 --- a/src/accessor/todo/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,129 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init; get_native_type - MEMBERS=int index - MEMBERS=const char* the_class - MEMBERS=const char* stream - MEMBERS=const char* type - MEMBERS=const char* expver - MEMBERS=const char* typeOfProcessedData - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - MEMBERS=const char* typeOfGeneratingProcess - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_mars_labeling -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g2_mars_labeling */ - int index; - const char* the_class; - const char* stream; - const char* type; - const char* expver; - const char* typeOfProcessedData; - const char* productDefinitionTemplateNumber; - const char* stepType; - const char* derivedForecast; - const char* typeOfGeneratingProcess; -} grib_accessor_g2_mars_labeling; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g2_mars_labeling = { - &grib_accessor_class_gen, /* super */ - "g2_mars_labeling", /* name */ - sizeof(grib_accessor_g2_mars_labeling), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2_mars_labeling.h" +grib_accessor_class_g2_mars_labeling_t _grib_accessor_class_g2_mars_labeling{"g2_mars_labeling"}; grib_accessor_class* grib_accessor_class_g2_mars_labeling = &_grib_accessor_class_g2_mars_labeling; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -146,9 +33,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->typeOfGeneratingProcess = grib_arguments_get_name(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +int grib_accessor_class_g2_mars_labeling_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; char* key = NULL; switch (self->index) { @@ -170,9 +56,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return grib_get_long(grib_handle_of_accessor(a), key, val); } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +int grib_accessor_class_g2_mars_labeling_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; char* key = NULL; switch (self->index) { @@ -194,10 +79,9 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return grib_get_string(grib_handle_of_accessor(a), key, val, len); } -static int extra_set(grib_accessor* a, long val) -{ +int extra_set(grib_accessor* a, long val){ int ret = 0; - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; grib_handle* hand = grib_handle_of_accessor(a); char stepType[30] = {0,}; size_t stepTypelen = 30; @@ -417,9 +301,8 @@ static int extra_set(grib_accessor* a, long val) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +int grib_accessor_class_g2_mars_labeling_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; char* key = NULL; int ret = 0; long lval = 0; @@ -451,9 +334,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return extra_set(a, lval); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +int grib_accessor_class_g2_mars_labeling_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; char* key = NULL; int ret = 0; @@ -480,15 +362,13 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return extra_set(a, *val); } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2_mars_labeling_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static int get_native_type(grib_accessor* a) -{ - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; +int grib_accessor_class_g2_mars_labeling_t::get_native_type(grib_accessor* a){ + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; char* key = NULL; int ret = 0; int type = 0; @@ -509,8 +389,7 @@ static int get_native_type(grib_accessor* a) return GRIB_INTERNAL_ERROR; } - ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); - if (ret) + ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); if (ret) grib_context_log(a->context, GRIB_LOG_ERROR, "unable to get native type for %s", key); return type; diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h b/src/accessor/grib_accessor_class_g2_mars_labeling.h new file mode 100644 index 000000000..0a678174f --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_mars_labeling_h +#define eccodes_accessor_g2_mars_labeling_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2_mars_labeling */ + int index; + const char* the_class; + const char* stream; + const char* type; + const char* expver; + const char* typeOfProcessedData; + const char* productDefinitionTemplateNumber; + const char* stepType; + const char* derivedForecast; + const char* typeOfGeneratingProcess; +}; + +class grib_accessor_class_g2_mars_labeling_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2_mars_labeling_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_mars_labeling_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_mars_labeling_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap.cc b/src/accessor/grib_accessor_class_g2bitmap.cc new file mode 100644 index 000000000..f6ed3f1c8 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap.cc @@ -0,0 +1,75 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2bitmap.h" +#include "shared_functions.h" + +grib_accessor_class_g2bitmap_t _grib_accessor_class_g2bitmap{"g2bitmap"}; +grib_accessor_class* grib_accessor_class_g2bitmap = &_grib_accessor_class_g2bitmap; + + +void grib_accessor_class_g2bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); +} + +int grib_accessor_class_g2bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + + size_t tlen; + + unsigned char* buf = NULL; + size_t i; + int err = 0; + long pos = 0; + // long bmaplen = 0; + double miss_values = 0; + tlen = (*len + 7) / 8; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) + return err; + + buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + pos = 0; + for (i = 0; i < *len; i++) { + if (val[i] == miss_values) + pos++; + else { + // bmaplen++; + grib_set_bit_on(buf, &pos); + } + } + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len)) != GRIB_SUCCESS) { + grib_context_free(a->context, buf); + return err; + } + + grib_buffer_replace(a, buf, tlen, 1, 1); + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + + +int grib_accessor_class_g2bitmap_t::value_count(grib_accessor* a, long* tlen){ + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + int err; + *tlen = 0; + + err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, tlen); + return err; +} diff --git a/src/accessor/grib_accessor_class_g2bitmap.h b/src/accessor/grib_accessor_class_g2bitmap.h new file mode 100644 index 000000000..9af7a3b27 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2bitmap_h +#define eccodes_accessor_g2bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g2bitmap */ + const char* numberOfValues; +}; + +class grib_accessor_class_g2bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g2bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.cc b/src/accessor/grib_accessor_class_g2bitmap_present.cc new file mode 100644 index 000000000..b4dfb5cf5 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap_present.cc @@ -0,0 +1,59 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2bitmap_present.h" + +grib_accessor_class_g2bitmap_present_t _grib_accessor_class_g2bitmap_present{"g2bitmap_present"}; +grib_accessor_class* grib_accessor_class_g2bitmap_present = &_grib_accessor_class_g2bitmap_present; + + +void grib_accessor_class_g2bitmap_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + self->bitmapIndicator = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +int grib_accessor_class_g2bitmap_present_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bitmapIndicator = 0; + + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapIndicator, &bitmapIndicator); + if (ret) { + if (ret == GRIB_NOT_FOUND) { + *val = 0; + return 0; + } + else + return ret; + } + + *val = 1; + if (bitmapIndicator == 255) + *val = 0; + + *len = 1; + return ret; +} + +int grib_accessor_class_g2bitmap_present_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + long bitmapIndicator = 0; + + if (*val == 0) + bitmapIndicator = 255; + + return grib_set_long(grib_handle_of_accessor(a), self->bitmapIndicator, bitmapIndicator); +} diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h b/src/accessor/grib_accessor_class_g2bitmap_present.h new file mode 100644 index 000000000..7b5cd3f66 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2bitmap_present_h +#define eccodes_accessor_g2bitmap_present_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2bitmap_present */ + const char* bitmapIndicator; +}; + +class grib_accessor_class_g2bitmap_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2bitmap_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2bitmap_present_h */ diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc new file mode 100644 index 000000000..5b54ccc83 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -0,0 +1,82 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2date.h" + +grib_accessor_class_g2date_t _grib_accessor_class_g2date{"g2date"}; +grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; + +void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + int n = 0; + + self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + + int ret = 0; + long year = 0; + long month = 0; + long day = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + val[0] = year * 10000 + month * 100 + day; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2date_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + + int ret = GRIB_SUCCESS; + long v = val[0]; + long year = 0; + long month = 0; + long day = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + year = v / 10000; + v %= 10000; + month = v / 100; + v %= 100; + day = v; + + if (!is_date_valid(year, month, day, 0, 0, 0)) { + // ECC-1777: For now just a warning. Will later change to an error + fprintf(stderr, "ECCODES WARNING : %s:%s: Date is not valid! year=%ld month=%ld day=%ld\n", + a->cclass->name, __func__, year, month, day); + } + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) + return ret; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g2date.h b/src/accessor/grib_accessor_class_g2date.h new file mode 100644 index 000000000..20276c6fe --- /dev/null +++ b/src/accessor/grib_accessor_class_g2date.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2date_h +#define eccodes_accessor_g2date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g2date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2date_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc similarity index 76% rename from src/accessor/todo/grib_accessor_class_g2end_step.cc rename to src/accessor/grib_accessor_class_g2end_step.cc index a86733eb3..947b867fd 100644 --- a/src/accessor/todo/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,150 +10,17 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_g2end_step.h" #include "step.h" #include "step_utilities.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - MEMBERS = const char* start_step_value - MEMBERS = const char* step_units - - MEMBERS = const char* year - MEMBERS = const char* month - MEMBERS = const char* day - MEMBERS = const char* hour - MEMBERS = const char* minute - MEMBERS = const char* second - - MEMBERS = const char* year_of_end_of_interval - MEMBERS = const char* month_of_end_of_interval - MEMBERS = const char* day_of_end_of_interval - MEMBERS = const char* hour_of_end_of_interval - MEMBERS = const char* minute_of_end_of_interval - MEMBERS = const char* second_of_end_of_interval - - MEMBERS = const char* time_range_unit - MEMBERS = const char* time_range_value - MEMBERS = const char* typeOfTimeIncrement - MEMBERS = const char* numberOfTimeRange - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2end_step -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2end_step */ - const char* start_step_value; - const char* step_units; - const char* year; - const char* month; - const char* day; - const char* hour; - const char* minute; - const char* second; - const char* year_of_end_of_interval; - const char* month_of_end_of_interval; - const char* day_of_end_of_interval; - const char* hour_of_end_of_interval; - const char* minute_of_end_of_interval; - const char* second_of_end_of_interval; - const char* time_range_unit; - const char* time_range_value; - const char* typeOfTimeIncrement; - const char* numberOfTimeRange; -} grib_accessor_g2end_step; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2end_step = { - &grib_accessor_class_long, /* super */ - "g2end_step", /* name */ - sizeof(grib_accessor_g2end_step), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g2end_step_t _grib_accessor_class_g2end_step{"g2end_step"}; grib_accessor_class* grib_accessor_class_g2end_step = &_grib_accessor_class_g2end_step; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -179,14 +47,12 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->numberOfTimeRange = grib_arguments_get_name(h, c, n++); } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_g2end_step_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_double(dumper, a, NULL); } // See GRIB-488 -static bool is_special_expver(const grib_handle* h) -{ +bool is_special_expver(const grib_handle* h){ int ret = 0; char strMarsExpVer[50] = {0,}; char strMarsClass[50] = {0,}; @@ -225,9 +91,8 @@ static int convert_time_range_long_( return GRIB_SUCCESS; } -static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int err = 0; long start_step_value; long step_units; @@ -270,9 +135,8 @@ static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int err = 0; double start_step_value; long start_step_unit; @@ -319,9 +183,8 @@ static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* } #define MAX_NUM_TIME_RANGES 16 /* maximum number of time range specifications */ -static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0, step_units = 0, start_step_value = 0; @@ -372,9 +235,8 @@ static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t return GRIB_DECODING_ERROR; } -static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0; @@ -435,9 +297,8 @@ static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, si // For the old implementation of unpack_long, see // src/deprecated/grib_accessor_class_g2end_step.unpack_long.cc // -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long start_step_value; @@ -466,16 +327,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_long: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_long: %s", e.what()); ret = GRIB_DECODING_ERROR; } return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long start_step_value; @@ -504,16 +364,15 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_double: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_double: %s", e.what()); ret = GRIB_DECODING_ERROR; } return ret; } -static int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; grib_handle* h = grib_handle_of_accessor(a); int err = 0; @@ -641,9 +500,8 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en return GRIB_SUCCESS; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; +int grib_accessor_class_g2end_step_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; char fp_format[128] = "%g"; @@ -678,15 +536,14 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) memcpy(val, ss.str().c_str(), size); } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_string: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_string: %s", e.what()); return GRIB_DECODING_ERROR; } return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); int ret; @@ -709,14 +566,13 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) ret = pack_long_(a, *val, end_step_unit); } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::pack_long: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::pack_long: %s", e.what()); return GRIB_DECODING_ERROR; } return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_g2end_step_t::pack_string(grib_accessor* a, const char* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long force_step_units; @@ -734,14 +590,13 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::pack_string: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::pack_string: %s", e.what()); return GRIB_DECODING_ERROR; } return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_g2end_step_t::get_native_type(grib_accessor* a){ grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; diff --git a/src/accessor/grib_accessor_class_g2end_step.h b/src/accessor/grib_accessor_class_g2end_step.h new file mode 100644 index 000000000..7a2d8ab21 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2end_step.h @@ -0,0 +1,56 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2end_step_h +#define eccodes_accessor_g2end_step_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2end_step_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2end_step */ + const char* start_step_value; + const char* step_units; + const char* year; + const char* month; + const char* day; + const char* hour; + const char* minute; + const char* second; + const char* year_of_end_of_interval; + const char* month_of_end_of_interval; + const char* day_of_end_of_interval; + const char* hour_of_end_of_interval; + const char* minute_of_end_of_interval; + const char* second_of_end_of_interval; + const char* time_range_unit; + const char* time_range_value; + const char* typeOfTimeIncrement; + const char* numberOfTimeRange; +}; + +class grib_accessor_class_g2end_step_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2end_step_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2end_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2end_step_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc similarity index 58% rename from src/accessor/todo/grib_accessor_class_g2grid.cc rename to src/accessor/grib_accessor_class_g2grid.cc index 40aaca628..74f276c62 100644 --- a/src/accessor/todo/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,116 +10,14 @@ */ #include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;value_count - IMPLEMENTS = init - MEMBERS=const char* latitude_first - MEMBERS=const char* longitude_first - MEMBERS=const char* latitude_last - MEMBERS=const char* longitude_last - MEMBERS=const char* i_increment - MEMBERS=const char* j_increment - MEMBERS=const char* basic_angle - MEMBERS=const char* sub_division - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2grid -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2grid */ - const char* latitude_first; - const char* longitude_first; - const char* latitude_last; - const char* longitude_last; - const char* i_increment; - const char* j_increment; - const char* basic_angle; - const char* sub_division; -} grib_accessor_g2grid; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2grid = { - &grib_accessor_class_double, /* super */ - "g2grid", /* name */ - sizeof(grib_accessor_g2grid), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2grid.h" +grib_accessor_class_g2grid_t _grib_accessor_class_g2grid{"g2grid"}; grib_accessor_class* grib_accessor_class_g2grid = &_grib_accessor_class_g2grid; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; +void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -136,8 +35,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2grid_t::value_count(grib_accessor* a, long* count){ *count = 6; return 0; } @@ -145,9 +43,8 @@ static int value_count(grib_accessor* a, long* count) // GRIB edition 2 uses microdegrees #define ANGLE_SUBDIVISIONS (1000 * 1000) -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; +int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; @@ -208,8 +105,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static long gcd(long a, long b) -{ +long gcd(long a, long b){ if (b > a) return gcd(b, a); if (b == 0) @@ -217,13 +113,11 @@ static long gcd(long a, long b) return gcd(b, a % b); } -static long lcm(long a, long b) -{ +long lcm(long a, long b){ return a * b / gcd(a, b); } -static int is_ok(const double* val, long v[6], double basic_angle, double sub_division) -{ +int is_ok(const double* val, long v[6], double basic_angle, double sub_division){ int i; int ok = 1; @@ -247,8 +141,7 @@ static int is_ok(const double* val, long v[6], double basic_angle, double sub_di return ok; } -static int trial(const double* val, long v[6], long* basic_angle, long* sub_division) -{ +int trial(const double* val, long v[6], long* basic_angle, long* sub_division){ int i = 0; long ni, nj; @@ -278,9 +171,8 @@ static int trial(const double* val, long v[6], long* basic_angle, long* sub_divi return is_ok(val, v, *basic_angle, *sub_division); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; +int grib_accessor_class_g2grid_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret; long v[6]; diff --git a/src/accessor/grib_accessor_class_g2grid.h b/src/accessor/grib_accessor_class_g2grid.h new file mode 100644 index 000000000..0cd177ce5 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2grid.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2grid_h +#define eccodes_accessor_g2grid_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2grid_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2grid */ + const char* latitude_first; + const char* longitude_first; + const char* latitude_last; + const char* longitude_last; + const char* i_increment; + const char* j_increment; + const char* basic_angle; + const char* sub_division; +}; + +class grib_accessor_class_g2grid_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2grid_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2grid_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2grid_h */ diff --git a/src/accessor/grib_accessor_class_g2latlon.cc b/src/accessor/grib_accessor_class_g2latlon.cc new file mode 100644 index 000000000..f3d64f1e6 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2latlon.cc @@ -0,0 +1,115 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2latlon.h" + +grib_accessor_class_g2latlon_t _grib_accessor_class_g2latlon{"g2latlon"}; +grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latlon; + + +void grib_accessor_class_g2latlon_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int n = 0; + + self->grid = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + self->given = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2latlon_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int ret = 0; + + long given = 1; + double grid[6]; + size_t size = 6; + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + return ret; + } + + if (self->given) + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given)) != GRIB_SUCCESS) + return ret; + + if (!given) { + *val = GRIB_MISSING_DOUBLE; + return GRIB_SUCCESS; + } + + if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, &size)) != GRIB_SUCCESS) + return ret; + + *val = grid[self->index]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2latlon_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int ret = 0; + double grid[6]; + size_t size = 6; + double new_val = *val; + grib_handle* hand = grib_handle_of_accessor(a); + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + return ret; + } + + if (self->given) { + long given = *val != GRIB_MISSING_DOUBLE; + if ((ret = grib_set_long_internal(hand, self->given, given)) != GRIB_SUCCESS) + return ret; + } + + if ((ret = grib_get_double_array_internal(hand, self->grid, grid, &size)) != GRIB_SUCCESS) + return ret; + + /* index 1 is longitudeOfFirstGridPointInDegrees + * index 3 is longitudeOfLastGridPointInDegrees + */ + if ((self->index == 1 || self->index == 3)) { + /* WMO regulation for GRIB edition 2: + * The longitude values shall be limited to the range 0 to 360 degrees inclusive */ + new_val = normalise_longitude_in_degrees(*val); + if (hand->context->debug && new_val != *val) { + fprintf(stderr, "ECCODES DEBUG pack_double g2latlon: normalise longitude %g -> %g\n", *val, new_val); + } + } + grid[self->index] = new_val; + + return grib_set_double_array_internal(hand, self->grid, grid, size); +} + +int grib_accessor_class_g2latlon_t::pack_missing(grib_accessor* a){ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + double missing = GRIB_MISSING_DOUBLE; + size_t size = 1; + + if (!self->given) + return GRIB_NOT_IMPLEMENTED; + + return pack_double(a, &missing, &size); +} + +int grib_accessor_class_g2latlon_t::is_missing(grib_accessor* a){ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + long given = 1; + + if (self->given) + grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); + + return !given; +} diff --git a/src/accessor/grib_accessor_class_g2latlon.h b/src/accessor/grib_accessor_class_g2latlon.h new file mode 100644 index 000000000..f16e2623e --- /dev/null +++ b/src/accessor/grib_accessor_class_g2latlon.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2latlon_h +#define eccodes_accessor_g2latlon_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2latlon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2latlon */ + const char* grid; + int index; + const char* given; +}; + +class grib_accessor_class_g2latlon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2latlon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2latlon_t{}; } + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2latlon_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2level.cc b/src/accessor/grib_accessor_class_g2level.cc similarity index 66% rename from src/accessor/todo/grib_accessor_class_g2level.cc rename to src/accessor/grib_accessor_class_g2level.cc index 39bd79033..084b6eba9 100644 --- a/src/accessor/todo/grib_accessor_class_g2level.cc +++ b/src/accessor/grib_accessor_class_g2level.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,110 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_g2level.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_long;pack_long;init;is_missing - MEMBERS=const char* type_first - MEMBERS=const char* scale_first - MEMBERS=const char* value_first - MEMBERS=const char* pressure_units - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2level -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2level */ - const char* type_first; - const char* scale_first; - const char* value_first; - const char* pressure_units; -} grib_accessor_g2level; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2level = { - &grib_accessor_class_long, /* super */ - "g2level", /* name */ - sizeof(grib_accessor_g2level), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g2level_t _grib_accessor_class_g2level{"g2level"}; grib_accessor_class* grib_accessor_class_g2level = &_grib_accessor_class_g2level; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2level* self = (grib_accessor_g2level*)a; +void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -125,18 +30,16 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION; } -static bool is_tigge(grib_handle* h) -{ +bool is_tigge(grib_handle* h){ long productionStatus = 0; int err = grib_get_long(h, "productionStatusOfProcessedData", &productionStatus); if (err) return false; return (productionStatus == 4 || productionStatus == 5); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int ret = 0; - grib_accessor_g2level* self = (grib_accessor_g2level*)a; + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long type_first = 0; @@ -211,8 +114,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_g2level_t::unpack_long(grib_accessor* a, long* val, size_t* len){ double dval = 0; int ret = unpack_double(a, &dval, len); if (ret == GRIB_SUCCESS) { @@ -221,9 +123,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2level* self = (grib_accessor_g2level*)a; +int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; double value_first = *val; @@ -284,8 +185,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, size_t* len){ int ret = 0; long value_first = *val; long scale_first = 0; @@ -293,7 +193,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) char pressure_units[10] = {0,}; size_t pressure_units_len = 10; - grib_accessor_g2level* self = (grib_accessor_g2level*)a; + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int change_scale_and_value = 1; bool tigge = is_tigge(hand); @@ -359,14 +259,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int is_missing(grib_accessor* a) -{ - grib_accessor_g2level* self = (grib_accessor_g2level*)a; +int grib_accessor_class_g2level_t::is_missing(grib_accessor* a){ + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; int ret = 0; ret = grib_is_missing(hand, self->scale_first, &err) + - grib_is_missing(hand, self->value_first, &err); - return ret; + grib_is_missing(hand, self->value_first, &err); return ret; } diff --git a/src/accessor/grib_accessor_class_g2level.h b/src/accessor/grib_accessor_class_g2level.h new file mode 100644 index 000000000..567b8c1b4 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2level.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2level_h +#define eccodes_accessor_g2level_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2level_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2level */ + const char* type_first; + const char* scale_first; + const char* value_first; + const char* pressure_units; +}; + +class grib_accessor_class_g2level_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2level_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2level_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2level_h */ diff --git a/src/accessor/grib_accessor_class_g2lon.cc b/src/accessor/grib_accessor_class_g2lon.cc new file mode 100644 index 000000000..1ef641a89 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2lon.cc @@ -0,0 +1,58 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_g2lon.h" + +grib_accessor_class_g2lon_t _grib_accessor_class_g2lon{"g2lon"}; +grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; + + +void grib_accessor_class_g2lon_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + int n = 0; + + self->longitude = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2lon_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + int ret = 0; + long longitude; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->longitude, &longitude)) != GRIB_SUCCESS) + return ret; + + if (longitude == GRIB_MISSING_LONG) { + *val = GRIB_MISSING_DOUBLE; + return GRIB_SUCCESS; + } + + *val = ((double)longitude) / 1000000.0; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2lon_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + long longitude; + double value = *val; + + if (value == GRIB_MISSING_DOUBLE) { + longitude = GRIB_MISSING_LONG; + } + else { + if (value < 0) + value += 360; + longitude = (long)(value * 1000000); + } + return grib_set_long(grib_handle_of_accessor(a), self->longitude, longitude); +} diff --git a/src/accessor/grib_accessor_class_g2lon.h b/src/accessor/grib_accessor_class_g2lon.h new file mode 100644 index 000000000..d17a68c14 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2lon.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2lon_h +#define eccodes_accessor_g2lon_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2lon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2lon */ + const char* longitude; +}; + +class grib_accessor_class_g2lon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2lon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2lon_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2lon_h */ diff --git a/src/accessor/todo/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc similarity index 64% rename from src/accessor/todo/grib_accessor_class_g2step_range.cc rename to src/accessor/grib_accessor_class_g2step_range.cc index c39601a40..ca7595ace 100644 --- a/src/accessor/todo/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,116 +10,20 @@ */ #include "grib_api_internal.h" -#include "step.h" -#include "step_utilities.h" +#include "grib_accessor_class_g2step_range.h" +#include "../step.h" +#include "../step_utilities.h" #include #include #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = get_native_type;string_length - IMPLEMENTS = init - MEMBERS = const char* start_step - MEMBERS = const char* end_step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2step_range -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g2step_range */ - const char* start_step; - const char* end_step; -} grib_accessor_g2step_range; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g2step_range = { - &grib_accessor_class_gen, /* super */ - "g2step_range", /* name */ - sizeof(grib_accessor_g2step_range), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; +grib_accessor_class_g2step_range_t _grib_accessor_class_g2step_range{"g2step_range"}; grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2step_range; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; +void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; int n = 0; @@ -133,9 +38,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) //grib_dump_string(dumper, a, NULL); //} -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; +int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; size_t size = 0; @@ -189,7 +93,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) memcpy(val, ss.str().c_str(), size); } catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g2step_range::unpack_string: %s", e.what()); + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g2step_range_t::unpack_string: %s", e.what()); return GRIB_DECODING_ERROR; } @@ -201,9 +105,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) // and can be in different units // stepRange="X" in instantaneous field is equivalent to set step=X // stepRange="X" in accumulated field is equivalent to startStep=X, endStep=startStep -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; +int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; @@ -259,19 +162,16 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2step_range_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_g2step_range_t::string_length(grib_accessor* a){ return 255; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_g2step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len){ char buff[100]; size_t bufflen = 100; @@ -280,9 +180,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; +int grib_accessor_class_g2step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; long end_start_value = 0; @@ -319,9 +218,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; +int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = 0; double end_start_value = 0; @@ -359,7 +257,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_g2step_range_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } diff --git a/src/accessor/grib_accessor_class_g2step_range.h b/src/accessor/grib_accessor_class_g2step_range.h new file mode 100644 index 000000000..c5a007806 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2step_range.h @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2step_range_h +#define eccodes_accessor_g2step_range_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2step_range_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2step_range */ + const char* start_step; + const char* end_step; +}; + +class grib_accessor_class_g2step_range_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2step_range_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2step_range_h */ diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/grib_accessor_class_gaussian_grid_name.cc new file mode 100644 index 000000000..7b27f2c05 --- /dev/null +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.cc @@ -0,0 +1,84 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_gaussian_grid_name.h" + +grib_accessor_class_gaussian_grid_name_t _grib_accessor_class_gaussian_grid_name{"gaussian_grid_name"}; +grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_class_gaussian_grid_name; + + +void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; + int n = 0; + + self->N = grib_arguments_get_name(a->parent->h, arg, n++); + self->Ni = grib_arguments_get_name(a->parent->h, arg, n++); + self->isOctahedral = grib_arguments_get_name(a->parent->h, arg, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +int grib_accessor_class_gaussian_grid_name_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +#define MAX_GRIDNAME_LEN 16 + +int grib_accessor_class_gaussian_grid_name_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; + + long N = 0, Ni = 0; + char tmp[MAX_GRIDNAME_LEN] = {0,}; + size_t length = 0; + int ret = GRIB_SUCCESS; + + if ((ret = grib_get_long_internal(a->parent->h, self->N, &N)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + + if (Ni == GRIB_MISSING_LONG) { + /* Reduced gaussian grid */ + long isOctahedral = 0; + if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS) + return ret; + if (isOctahedral == 1) { + snprintf(tmp, sizeof(tmp), "O%ld", N); + } + else { + snprintf(tmp, sizeof(tmp), "N%ld", N); /* Classic */ + } + } + else { + /* Regular gaussian grid */ + snprintf(tmp, sizeof(tmp), "F%ld", N); + } + length = strlen(tmp) + 1; + + if (*len < length) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length, *len); + *len = length; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(v, tmp); + *len = length; + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_gaussian_grid_name_t::string_length(grib_accessor* a){ + return MAX_GRIDNAME_LEN; +} diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h b/src/accessor/grib_accessor_class_gaussian_grid_name.h new file mode 100644 index 000000000..1c12bfacd --- /dev/null +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gaussian_grid_name_h +#define eccodes_accessor_gaussian_grid_name_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gaussian_grid_name */ + const char* N; + const char* Ni; + const char* isOctahedral; +}; + +class grib_accessor_class_gaussian_grid_name_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gaussian_grid_name_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gaussian_grid_name_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gaussian_grid_name_h */ diff --git a/src/accessor/grib_accessor_class_gds_is_present.cc b/src/accessor/grib_accessor_class_gds_is_present.cc new file mode 100644 index 000000000..4939d0949 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_is_present.cc @@ -0,0 +1,86 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_gds_is_present.h" + +grib_accessor_class_gds_is_present_t _grib_accessor_class_gds_is_present{"gds_is_present"}; +grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_gds_is_present; + + +void grib_accessor_class_gds_is_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + self->gds_present = grib_arguments_get_name(h, c, n++); + self->grid_definition = grib_arguments_get_name(h, c, n++); + self->bitmap_present = grib_arguments_get_name(h, c, n++); + self->values = grib_arguments_get_name(h, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_gds_is_present_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + long missing = 255; + int ret = 0; + size_t size = 0; + double* values = NULL; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val != 1) + return GRIB_NOT_IMPLEMENTED; + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->gds_present, *val)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->bitmap_present, *val)) != GRIB_SUCCESS) + return ret; + + + if ((ret = grib_set_long_internal(h, self->grid_definition, missing)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) + return ret; + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gds_is_present_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + + if ((ret = grib_get_long_internal(h, self->gds_present, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_gds_is_present.h b/src/accessor/grib_accessor_class_gds_is_present.h new file mode 100644 index 000000000..fa1c5ca55 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_is_present.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gds_is_present_h +#define eccodes_accessor_gds_is_present_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_gds_is_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in gds_is_present */ + const char* gds_present; + const char* grid_definition; + const char* bitmap_present; + const char* values; +}; + +class grib_accessor_class_gds_is_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_gds_is_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_is_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gds_is_present_h */ diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc new file mode 100644 index 000000000..368f112d4 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc @@ -0,0 +1,109 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_gds_not_present_bitmap.h" + +grib_accessor_class_gds_not_present_bitmap_t _grib_accessor_class_gds_not_present_bitmap{"gds_not_present_bitmap"}; +grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accessor_class_gds_not_present_bitmap; + + +void grib_accessor_class_gds_not_present_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + int n = 0; + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + self->missing_value = grib_arguments_get_name(hand, args, n++); + self->number_of_values = grib_arguments_get_name(hand, args, n++); + self->number_of_points = grib_arguments_get_name(hand, args, n++); + self->latitude_of_first_point = grib_arguments_get_name(hand, args, n++); + self->ni = grib_arguments_get_name(hand, args, n++); + a->length = 0; +} + +int grib_accessor_class_gds_not_present_bitmap_t::value_count(grib_accessor* a, long* number_of_points){ + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + *number_of_points = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); +} + +int grib_accessor_class_gds_not_present_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + long number_of_points = 0, number_of_values = 0, ni = 0; + long latitude_of_first_point = 0; + size_t i = 0; + size_t n_vals = 0; + long nn = 0; + long missing_value; + + int err = 0; + double* coded_vals = NULL; + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if ((err = grib_get_long(hand, self->number_of_points, &number_of_points)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->number_of_values, &number_of_values)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->latitude_of_first_point, &latitude_of_first_point)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->ni, &ni)) != GRIB_SUCCESS) + return err; + + if (*len < number_of_points) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if (number_of_values > 0) { + coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double)); + + if (coded_vals == NULL) + return GRIB_OUT_OF_MEMORY; + } + + if (latitude_of_first_point == 0) { + for (i = 0; i < number_of_values; i++) + val[i] = 1; + for (i = number_of_values; i < number_of_points; i++) + val[i] = 0; + } + else { + for (i = 0; i < ni - 1; i++) + val[i] = 0; + for (i = ni - 1; i < number_of_points; i++) + val[i] = 1; + } + + *len = number_of_points; + + grib_context_free(a->context, coded_vals); + return err; +} + +int grib_accessor_class_gds_not_present_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + // See deprecated/grib_accessor_class_gds_not_present_bitmap.cc for + // a possible implementation + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gds_not_present_bitmap_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h new file mode 100644 index 000000000..68641a8e2 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gds_not_present_bitmap_h +#define eccodes_accessor_gds_not_present_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gds_not_present_bitmap */ + const char* missing_value; + const char* number_of_values; + const char* number_of_points; + const char* latitude_of_first_point; + const char* ni; +}; + +class grib_accessor_class_gds_not_present_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gds_not_present_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_not_present_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gds_not_present_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc new file mode 100644 index 000000000..2c714767d --- /dev/null +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -0,0 +1,62 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_getenv.h" + +grib_accessor_class_getenv_t _grib_accessor_class_getenv{"getenv"}; +grib_accessor_class* grib_accessor_class_getenv = &_grib_accessor_class_getenv; + + +void grib_accessor_class_getenv_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; + static char undefined[] = "undefined"; + + self->name = grib_arguments_get_string(grib_handle_of_accessor(a), args, 0); + self->default_value = grib_arguments_get_string(grib_handle_of_accessor(a), args, 1); + if (!self->default_value) + self->default_value = undefined; + self->value = 0; +} + +int grib_accessor_class_getenv_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_getenv_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; + char* v = 0; + size_t l = 0; + + if (!self->value) { + v = getenv(self->name); + if (!v) + v = (char*)self->default_value; + self->value = v; + } + + l = strlen(self->value); + if (*len < l) + return GRIB_BUFFER_TOO_SMALL; + snprintf(val, 1024, "%s", self->value); + *len = strlen(self->value); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_getenv_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_getenv_t::string_length(grib_accessor* a){ + return 1024; +} diff --git a/src/accessor/grib_accessor_class_getenv.h b/src/accessor/grib_accessor_class_getenv.h new file mode 100644 index 000000000..8ddf7db14 --- /dev/null +++ b/src/accessor/grib_accessor_class_getenv.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_getenv_h +#define eccodes_accessor_getenv_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_getenv_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in getenv */ + const char* name; + char* value; + const char* default_value; +}; + +class grib_accessor_class_getenv_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_getenv_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_getenv_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_getenv_h */ diff --git a/src/accessor/todo/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc similarity index 64% rename from src/accessor/todo/grib_accessor_class_global_gaussian.cc rename to src/accessor/grib_accessor_class_global_gaussian.cc index b39677da2..a26b77252 100644 --- a/src/accessor/todo/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,121 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_global_gaussian.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* N - MEMBERS=const char* Ni - MEMBERS=const char* di - MEMBERS=const char* latfirst - MEMBERS=const char* lonfirst - MEMBERS=const char* latlast - MEMBERS=const char* lonlast - MEMBERS=const char* plpresent - MEMBERS=const char* pl - MEMBERS=const char* basic_angle - MEMBERS=const char* subdivision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_global_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in global_gaussian */ - const char* N; - const char* Ni; - const char* di; - const char* latfirst; - const char* lonfirst; - const char* latlast; - const char* lonlast; - const char* plpresent; - const char* pl; - const char* basic_angle; - const char* subdivision; -} grib_accessor_global_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_global_gaussian = { - &grib_accessor_class_long, /* super */ - "global_gaussian", /* name */ - sizeof(grib_accessor_global_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_global_gaussian_t _grib_accessor_class_global_gaussian{"global_gaussian"}; grib_accessor_class* grib_accessor_class_global_gaussian = &_grib_accessor_class_global_gaussian; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +void grib_accessor_class_global_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -140,9 +34,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->subdivision = grib_arguments_get_name(h, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +int grib_accessor_class_global_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int ret = GRIB_SUCCESS; long latfirst, latlast, lonfirst, lonlast, basic_angle, subdivision, N, Ni; double dlatfirst, dlatlast, dlonfirst, dlonlast; @@ -247,9 +140,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +int grib_accessor_class_global_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int ret = GRIB_SUCCESS; long latfirst, latlast, lonfirst, lonlast, di, diold, basic_angle = 0, N, Ni; long factor; diff --git a/src/accessor/grib_accessor_class_global_gaussian.h b/src/accessor/grib_accessor_class_global_gaussian.h new file mode 100644 index 000000000..f1e8bf53b --- /dev/null +++ b/src/accessor/grib_accessor_class_global_gaussian.h @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_global_gaussian_h +#define eccodes_accessor_global_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_global_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in global_gaussian */ + const char* N; + const char* Ni; + const char* di; + const char* latfirst; + const char* lonfirst; + const char* latlast; + const char* lonlast; + const char* plpresent; + const char* pl; + const char* basic_angle; + const char* subdivision; +}; + +class grib_accessor_class_global_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_global_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_global_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_global_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc new file mode 100644 index 000000000..20ca66ae2 --- /dev/null +++ b/src/accessor/grib_accessor_class_group.cc @@ -0,0 +1,160 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_group.h" + +grib_accessor_class_group_t _grib_accessor_class_group{"group"}; +grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; + + +void grib_accessor_class_group_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + grib_accessor_group_t* self = (grib_accessor_group_t*)a; + + size_t i = 0; + unsigned char* v; + const char* s = grib_arguments_get_string(grib_handle_of_accessor(a), arg, 0); + + if (s && strlen(s) > 1) { + grib_context_log(a->context, GRIB_LOG_WARNING, + "Using only first character as group end of %s not the string %s", a->name, s); + } + + self->endCharacter = s ? s[0] : 0; + + v = buffer->data + a->offset; + i = 0; + if (s) { + while (*v != self->endCharacter && i <= buffer->ulength) { + if (*v > 126) + *v = 32; + v++; + i++; + } + } + else { + while (*v > 32 && *v != 61 && *v < 127 && i <= buffer->ulength) { + v++; + i++; + } + } + a->length = i; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_group_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_group_t::string_length(grib_accessor* a){ + return a->length; +} + +void grib_accessor_class_group_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_group_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_group_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long i = 0; + size_t l = a->length + 1; + grib_handle* h = grib_handle_of_accessor(a); + + if (*len < l) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, l, *len); + *len = l; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + val[i] = h->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_group_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; +} + +int grib_accessor_class_group_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + *v = strtod(val, &last); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_group_t::compare(grib_accessor* a, grib_accessor* b){ + grib_context_log(a->context, GRIB_LOG_ERROR, "%s:%s not implemented", __func__, a->name); + return GRIB_NOT_IMPLEMENTED; + + // int retval = 0; + // char* aval = 0; + // char* bval = 0; + // int err = 0; + // size_t alen = 0; + // size_t blen = 0; + // long count = 0; + // err = a->value_count(&count); // if (err) return err; + // alen = count; + // err = b->value_count(&count); // if (err) return err; + // blen = count; + // if (alen != blen) return GRIB_COUNT_MISMATCH; + // aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); + // bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); + // a->unpack_string(aval, &alen); // b->unpack_string(bval, &blen); // retval = GRIB_SUCCESS; + // if (strcmp(aval, bval)) retval = GRIB_STRING_VALUE_MISMATCH; + // grib_context_free(a->context, aval); + // grib_context_free(b->context, bval); + // return retval; +} + +long grib_accessor_class_group_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_group.h b/src/accessor/grib_accessor_class_group.h new file mode 100644 index 000000000..085b91a8a --- /dev/null +++ b/src/accessor/grib_accessor_class_group.h @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_group_h +#define eccodes_accessor_group_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_group_t : public grib_accessor_gen_t +{ +public: + /* Members defined in group */ + char endCharacter; +}; + +class grib_accessor_class_group_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_group_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_group_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_group_h */ diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc new file mode 100644 index 000000000..4d24c8835 --- /dev/null +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -0,0 +1,61 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_gts_header.h" + +grib_accessor_class_gts_header_t _grib_accessor_class_gts_header{"gts_header"}; +grib_accessor_class* grib_accessor_class_gts_header = &_grib_accessor_class_gts_header; + + +void grib_accessor_class_gts_header_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_gts_header_t* self = (grib_accessor_gts_header_t*)a; + self->gts_offset = -1; + self->gts_length = -1; + self->gts_offset = grib_arguments_get_long(grib_handle_of_accessor(a), c, 0); + self->gts_length = grib_arguments_get_long(grib_handle_of_accessor(a), c, 1); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_gts_header_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_gts_header_t* self = (grib_accessor_gts_header_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int offset = 0; + size_t length = 0; + + if (h->gts_header == NULL || h->gts_header_len < 8) { + if (*len < 8) + return GRIB_BUFFER_TOO_SMALL; + snprintf(val, 1024, "missing"); + return GRIB_SUCCESS; + } + if (*len < h->gts_header_len) + return GRIB_BUFFER_TOO_SMALL; + + offset = self->gts_offset > 0 ? self->gts_offset : 0; + length = self->gts_length > 0 ? self->gts_length : h->gts_header_len; + + memcpy(val, h->gts_header + offset, length); + + *len = length; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gts_header_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_gts_header_t::string_length(grib_accessor* a){ + grib_handle* h = grib_handle_of_accessor(a); + return h->gts_header_len; +} diff --git a/src/accessor/grib_accessor_class_gts_header.h b/src/accessor/grib_accessor_class_gts_header.h new file mode 100644 index 000000000..c164a9df9 --- /dev/null +++ b/src/accessor/grib_accessor_class_gts_header.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gts_header_h +#define eccodes_accessor_gts_header_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_gts_header_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in gts_header */ + int gts_offset; + int gts_length; +}; + +class grib_accessor_class_gts_header_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_gts_header_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gts_header_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gts_header_h */ diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc new file mode 100644 index 000000000..d2fd1a8ef --- /dev/null +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -0,0 +1,176 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_hash_array.h" + +grib_accessor_class_hash_array_t _grib_accessor_class_hash_array{"hash_array"}; +grib_accessor_class* grib_accessor_class_hash_array = &_grib_accessor_class_hash_array; + + +#define MAX_HASH_ARRAY_STRING_LENGTH 255 + +void grib_accessor_class_hash_array_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + a->length = 0; + self->key = 0; + self->ha = NULL; +} + +void grib_accessor_class_hash_array_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_hash_array_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + char s[200] = {0,}; + snprintf(s, sizeof(s), "%g", *val); + self->key = grib_context_strdup(a->context, s); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + char s[200] = {0,}; + snprintf(s, sizeof(s), "%ld", *val); + if (self->key) + grib_context_free(a->context, self->key); + self->key = grib_context_strdup(a->context, s); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::pack_string(grib_accessor* a, const char* v, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + self->key = grib_context_strdup(a->context, v); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +static grib_hash_array_value* find_hash_value(grib_accessor* a, int* err) +{ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + grib_hash_array_value* ha_ret = 0; + grib_hash_array_value* ha = NULL; + + ha = get_hash_array(grib_handle_of_accessor(a), a->creator); + if (!ha) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "unable to get hash value for %s", a->creator->name); + *err = GRIB_HASH_ARRAY_NO_MATCH; + return NULL; + } + + *err = GRIB_SUCCESS; + + Assert(ha != NULL); + if (!self->key) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "unable to get hash value for %s, set before getting", a->creator->name); + *err = GRIB_HASH_ARRAY_NO_MATCH; + return NULL; + } + + ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, self->key); + if (!ha_ret) + ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, "default"); + + if (!ha_ret) { + *err = GRIB_HASH_ARRAY_NO_MATCH; + grib_context_log(a->context, GRIB_LOG_ERROR, + "hash_array: no match for %s=%s", + a->creator->name, self->key); + const char* full_path = get_hash_array_full_path(a->creator); + if (full_path) { + grib_context_log(a->context, GRIB_LOG_ERROR, "hash_array: file path = %s", full_path); + } + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Check the key 'masterTablesVersionNumber'"); + return NULL; + } + return ha_ret; +} + +int grib_accessor_class_hash_array_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_hash_array_value* ha = 0; + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + int err = 0; + size_t i = 0; + + if (!self->ha) { + ha = find_hash_value(a, &err); + if (err) + return err; + self->ha = ha; + } + + switch (self->ha->type) { + case GRIB_HASH_ARRAY_TYPE_INTEGER: + if (*len < self->ha->iarray->n) { + return GRIB_ARRAY_TOO_SMALL; + } + *len = self->ha->iarray->n; + for (i = 0; i < *len; i++) + val[i] = self->ha->iarray->v[i]; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::get_native_type(grib_accessor* a){ + int type = GRIB_TYPE_STRING; + if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) + type = GRIB_TYPE_LONG; + + return type; +} + +void grib_accessor_class_hash_array_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + if (self->key) + grib_context_free(c, self->key); +} + +int grib_accessor_class_hash_array_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +size_t grib_accessor_class_hash_array_t::string_length(grib_accessor* a){ + return MAX_HASH_ARRAY_STRING_LENGTH; +} + +int grib_accessor_class_hash_array_t::value_count(grib_accessor* a, long* count){ + int err = 0; + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + grib_hash_array_value* ha = 0; + + if (!self->ha) { + ha = find_hash_value(a, &err); + if (err) + return err; + self->ha = ha; + } + + *count = self->ha->iarray->n; + return err; +} + +int grib_accessor_class_hash_array_t::compare(grib_accessor* a, grib_accessor* b){ + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_hash_array.h b/src/accessor/grib_accessor_class_hash_array.h new file mode 100644 index 000000000..78856c7e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_hash_array.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_hash_array_h +#define eccodes_accessor_hash_array_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_hash_array_t : public grib_accessor_gen_t +{ +public: + /* Members defined in hash_array */ + char* key; + grib_hash_array_value* ha; +}; + +class grib_accessor_class_hash_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_hash_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_hash_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_hash_array_h */ diff --git a/src/accessor/grib_accessor_class_headers_only.cc b/src/accessor/grib_accessor_class_headers_only.cc new file mode 100644 index 000000000..b1c00a529 --- /dev/null +++ b/src/accessor/grib_accessor_class_headers_only.cc @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_headers_only.h" + +grib_accessor_class_headers_only_t _grib_accessor_class_headers_only{"headers_only"}; +grib_accessor_class* grib_accessor_class_headers_only = &_grib_accessor_class_headers_only; + + +void grib_accessor_class_headers_only_t::init(grib_accessor* a, const long l, grib_arguments* c){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_headers_only_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + *val = grib_handle_of_accessor(a)->partial; + *len = 1; + return 0; +} + +int grib_accessor_class_headers_only_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_headers_only.h b/src/accessor/grib_accessor_class_headers_only.h new file mode 100644 index 000000000..29d7e8bf5 --- /dev/null +++ b/src/accessor/grib_accessor_class_headers_only.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_headers_only_h +#define eccodes_accessor_headers_only_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_headers_only_t : public grib_accessor_gen_t +{ +public: + /* Members defined in headers_only */ +}; + +class grib_accessor_class_headers_only_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_headers_only_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_headers_only_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_headers_only_h */ diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc new file mode 100644 index 000000000..4528c0807 --- /dev/null +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -0,0 +1,150 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_ibmfloat.h" + +grib_accessor_class_ibmfloat_t _grib_accessor_class_ibmfloat{"ibmfloat"}; +grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmfloat; + + +void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + long count = 0; + + self->arg = arg; + a->value_count(&count); a->length = 4 * count; + Assert(a->length >= 0); +} + +template +int unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + unsigned long rlen = 0; + long count = 0; + int err = 0; + unsigned long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&count); if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ibmfloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return unpack(a, val, len); +} + +int grib_accessor_class_ibmfloat_t::unpack_float(grib_accessor* a, float* val, size_t* len){ + return unpack(a, val, len); +} + +int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + int ret = 0; + unsigned long i = 0; + unsigned long rlen = *len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (rlen == 1) { + + //double x = 0; + //grib_nearest_smaller_ibm_float(val[0],&x); + //double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); + //printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); + + off = byte_offset(a) * 8; + ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); + if (*len > 1) + grib_context_log(a->context, GRIB_LOG_WARNING, "ibmfloat: Trying to pack %zu values in a scalar %s, packing first value", + *len, a->name); + if (ret == GRIB_SUCCESS) + len[0] = 1; + return ret; + } + + buflen = rlen * 4; + + buf = (unsigned char*)grib_context_malloc(a->context, buflen); + + for (i = 0; i < rlen; i++) { + grib_encode_unsigned_longb(buf, grib_ibm_to_long(val[i]), &off, 32); + } + ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); + + if (ret == GRIB_SUCCESS) + grib_buffer_replace(a, buf, buflen, 1, 1); + else + *len = 0; + + grib_context_free(a->context, buf); + + a->length = byte_count(a); + + return ret; +} + +long grib_accessor_class_ibmfloat_t::byte_count(grib_accessor* a){ + return a->length; +} + +int grib_accessor_class_ibmfloat_t::value_count(grib_accessor* a, long* len){ + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + *len = 0; + if (!self->arg) { + *len = 1; + return 0; + } + return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); +} + +long grib_accessor_class_ibmfloat_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_ibmfloat_t::update_size(grib_accessor* a, size_t s){ + a->length = (long)s; + Assert(a->length >= 0); +} + +long grib_accessor_class_ibmfloat_t::next_offset(grib_accessor* a){ + return a->byte_offset() + a->byte_count();} + +int grib_accessor_class_ibmfloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest){ + int ret = 0; + if (grib_nearest_smaller_ibm_float(val, nearest) == GRIB_INTERNAL_ERROR) { + grib_context_log(a->context, GRIB_LOG_ERROR, "ibm_float:nearest_smaller_value overflow value=%g", val); + grib_dump_content(grib_handle_of_accessor(a), stderr, "wmo", GRIB_DUMP_FLAG_HEXADECIMAL, 0); + ret = GRIB_INTERNAL_ERROR; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_ibmfloat.h b/src/accessor/grib_accessor_class_ibmfloat.h new file mode 100644 index 000000000..4a82dda63 --- /dev/null +++ b/src/accessor/grib_accessor_class_ibmfloat.h @@ -0,0 +1,40 @@ +/* + * (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. + */ + +#ifndef eccodes_accessor_ibmfloat_h +#define eccodes_accessor_ibmfloat_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_ibmfloat_t : public grib_accessor_double_t +{ +public: + /* Members defined in ibmfloat */ + grib_arguments* arg; +}; + +class grib_accessor_class_ibmfloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ibmfloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ibmfloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; +}; +#endif /* eccodes_accessor_ibmfloat_h */ diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc new file mode 100644 index 000000000..1433bd8d5 --- /dev/null +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -0,0 +1,123 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_ieeefloat.h" + +grib_accessor_class_ieeefloat_t _grib_accessor_class_ieeefloat{"ieeefloat"}; +grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeefloat; + + +void grib_accessor_class_ieeefloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + long count = 0; + self->arg = arg; + a->value_count(&count); a->length = 4 * count; + Assert(a->length >= 0); +} + +int grib_accessor_class_ieeefloat_t::value_count(grib_accessor* a, long* len){ + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + *len = 0; + + if (!self->arg) { + *len = 1; + return 0; + } + return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); +} + +int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + int ret = 0; + unsigned long i = 0; + unsigned long rlen = (unsigned long)*len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (rlen == 1) { + off = a->offset * 8; + ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ieee_to_long(val[0]), &off, 32); + if (*len > 1) + grib_context_log(a->context, GRIB_LOG_WARNING, "ieeefloat: Trying to pack %zu values in a scalar %s, packing first value", + *len, a->name); + if (ret == GRIB_SUCCESS) + len[0] = 1; + return ret; + } + + buflen = rlen * 4; + + buf = (unsigned char*)grib_context_malloc(a->context, buflen); + + for (i = 0; i < rlen; i++) { + grib_encode_unsigned_longb(buf, grib_ieee_to_long(val[i]), &off, 32); + } + ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); + + if (ret == GRIB_SUCCESS) + grib_buffer_replace(a, buf, buflen, 1, 1); + else + *len = 0; + + grib_context_free(a->context, buf); + + return ret; +} + +template +int unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + long rlen = 0; + int err = 0; + long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&rlen); if (err) + return err; + + if (*len < (size_t)rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ieeefloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return unpack(a, val, len); +} + +int grib_accessor_class_ieeefloat_t::unpack_float(grib_accessor* a, float* val, size_t* len){ + return unpack(a, val, len); +} + +void grib_accessor_class_ieeefloat_t::update_size(grib_accessor* a, size_t s){ + a->length = (long)s; + Assert(a->length >= 0); +} + +int grib_accessor_class_ieeefloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest){ + return grib_nearest_smaller_ieee_float(val, nearest); +} diff --git a/src/accessor/grib_accessor_class_ieeefloat.h b/src/accessor/grib_accessor_class_ieeefloat.h new file mode 100644 index 000000000..b59357d72 --- /dev/null +++ b/src/accessor/grib_accessor_class_ieeefloat.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ieeefloat_h +#define eccodes_accessor_ieeefloat_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_ieeefloat_t : public grib_accessor_double_t +{ +public: + grib_arguments* arg; +}; + +class grib_accessor_class_ieeefloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ieeefloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ieeefloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; +}; +#endif /* eccodes_accessor_ieeefloat_h */ diff --git a/src/accessor/grib_accessor_class_ifs_param.cc b/src/accessor/grib_accessor_class_ifs_param.cc new file mode 100644 index 000000000..291849046 --- /dev/null +++ b/src/accessor/grib_accessor_class_ifs_param.cc @@ -0,0 +1,93 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_ifs_param.h" + +grib_accessor_class_ifs_param_t _grib_accessor_class_ifs_param{"ifs_param"}; +grib_accessor_class* grib_accessor_class_ifs_param = &_grib_accessor_class_ifs_param; + + +void grib_accessor_class_ifs_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + int n = 0; + + self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->type = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_ifs_param_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + int ret = 0; + long paramId = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->paramId, ¶mId)) != GRIB_SUCCESS) + return ret; + + if (paramId > 129000 && paramId < 129999) + *val = paramId - 129000; + else if (paramId > 200000 && paramId < 200999) + *val = paramId - 200000; + else if (paramId > 211000 && paramId < 211999) + *val = paramId - 1000; + else + *val = paramId; + + return ret; +} + +int grib_accessor_class_ifs_param_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + long type = 0; + long table = 128; + long paramId = *val; + long param; + + grib_get_long(grib_handle_of_accessor(a), self->type, &type); + + if (type == 33 || type == 35) { + if (paramId > 1000) { + table = paramId / 1000; + param = paramId - table * 1000; + paramId = param; + } + switch (table) { + case 210: + paramId += 211000; + break; + case 128: + paramId += 200000; + break; + default: + break; + } + } + if (type == 50 || type == 52) { + if (paramId > 1000) { + table = paramId / 1000; + param = paramId - table * 1000; + paramId = param; + } + switch (table) { + case 128: + paramId += 129000; + break; + default: + break; + } + } + + return grib_set_long_internal(grib_handle_of_accessor(a), self->paramId, paramId); +} + +int grib_accessor_class_ifs_param_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_ifs_param.h b/src/accessor/grib_accessor_class_ifs_param.h new file mode 100644 index 000000000..d41da1723 --- /dev/null +++ b/src/accessor/grib_accessor_class_ifs_param.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ifs_param_h +#define eccodes_accessor_ifs_param_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_ifs_param_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ifs_param */ + const char* paramId; + const char* type; +}; + +class grib_accessor_class_ifs_param_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ifs_param_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ifs_param_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_ifs_param_h */ diff --git a/src/accessor/todo/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc similarity index 66% rename from src/accessor/todo/grib_accessor_class_julian_date.cc rename to src/accessor/grib_accessor_class_julian_date.cc index 61fd6959c..966dc2d66 100644 --- a/src/accessor/todo/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,128 +10,15 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_julian_date.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = unpack_string; pack_string - IMPLEMENTS = dump - IMPLEMENTS = init - IMPLEMENTS = pack_expression - MEMBERS = const char *year - MEMBERS = const char *month - MEMBERS = const char *day - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - MEMBERS = const char *ymd - MEMBERS = const char *hms - MEMBERS = char sep[5] - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_julian_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in julian_date */ - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; - const char *ymd; - const char *hms; - char sep[5]; -} grib_accessor_julian_date; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_julian_date = { - &grib_accessor_class_double, /* super */ - "julian_date", /* name */ - sizeof(grib_accessor_julian_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_julian_date_t _grib_accessor_class_julian_date{"julian_date"}; grib_accessor_class* grib_accessor_class_julian_date = &_grib_accessor_class_julian_date; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; +void grib_accessor_class_julian_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -163,18 +51,16 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_julian_date_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; if (self->ymd == NULL) { ret = grib_get_long(h, self->year, &year); @@ -222,9 +108,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; +int grib_accessor_class_julian_date_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; int ret = 0; long hour = 0; long minute = 0; @@ -272,12 +157,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; char* sep = self->sep; grib_handle* h = grib_handle_of_accessor(a); @@ -338,12 +222,11 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::pack_string(grib_accessor* a, const char* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; char* sep = self->sep; grib_handle* h = grib_handle_of_accessor(a); @@ -409,19 +292,16 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ grib_context_log(a->context, GRIB_LOG_ERROR, " Cannot unpack %s as long", a->name); return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ +int grib_accessor_class_julian_date_t::pack_long(grib_accessor* a, const long* v, size_t* len){ grib_context_log(a->context, GRIB_LOG_ERROR, " Cannot pack %s as long", a->name); return GRIB_NOT_IMPLEMENTED; } -static int pack_expression(grib_accessor* a, grib_expression* e) -{ +int grib_accessor_class_julian_date_t::pack_expression(grib_accessor* a, grib_expression* e){ size_t len = 1; long lval = 0; double dval = 0; @@ -439,16 +319,14 @@ static int pack_expression(grib_accessor* a, grib_expression* e) } /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %ld\n", a->name,lval);*/ - return grib_pack_long(a, &lval, &len); - } + return a->pack_long(&lval, &len); } case GRIB_TYPE_DOUBLE: { len = 1; ret = grib_expression_evaluate_double(hand, e, &dval); /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %g\n", a->name, dval);*/ - return grib_pack_double(a, &dval, &len); - } + return a->pack_double(&dval, &len); } case GRIB_TYPE_STRING: { char tmp[1024]; @@ -461,8 +339,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e) len = strlen(cval); /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %s\n", a->name, cval);*/ - return grib_pack_string(a, cval, &len); - } + return a->pack_string(cval, &len); } } return GRIB_NOT_IMPLEMENTED; diff --git a/src/accessor/grib_accessor_class_julian_date.h b/src/accessor/grib_accessor_class_julian_date.h new file mode 100644 index 000000000..68008fec6 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_date.h @@ -0,0 +1,48 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_julian_date_h +#define eccodes_accessor_julian_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_date */ + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; + const char *ymd; + const char *hms; + char sep[5]; +}; + +class grib_accessor_class_julian_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_date_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_julian_date_h */ diff --git a/src/accessor/grib_accessor_class_julian_day.cc b/src/accessor/grib_accessor_class_julian_day.cc new file mode 100644 index 000000000..4e978c20e --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_day.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_julian_day.h" + +grib_accessor_class_julian_day_t _grib_accessor_class_julian_day{"julian_day"}; +grib_accessor_class* grib_accessor_class_julian_day = &_grib_accessor_class_julian_day; + + +void grib_accessor_class_julian_day_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->hour = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->minute = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->second = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +void grib_accessor_class_julian_day_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_julian_day_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const double v = *val; + return pack_double(a, &v, len); +} + +int grib_accessor_class_julian_day_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + int ret = 0; + long hour = 0; + long minute = 0; + long second = 0; + long date = 0; + long year, month, day; + + ret = grib_julian_to_datetime(*val, &year, &month, &day, &hour, &minute, &second); + if (ret != 0) + return ret; + + date = year * 10000 + month * 100 + day; + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->date, date); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->hour, hour); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->minute, minute); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->second, second); + + return ret; +} + +int grib_accessor_class_julian_day_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + double v = 0; + + ret = unpack_double(a, &v, len); + *val = (long)v; + + return ret; +} + +int grib_accessor_class_julian_day_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int ret = 0; + long date, hour, minute, second; + long year, month, day; + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->hour, &hour); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->minute, &minute); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->second, &second); + if (ret != GRIB_SUCCESS) + return ret; + + year = date / 10000; + date %= 10000; + month = date / 100; + date %= 100; + day = date; + + ret = grib_datetime_to_julian(year, month, day, hour, minute, second, val); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_julian_day.h b/src/accessor/grib_accessor_class_julian_day.h new file mode 100644 index 000000000..1d21fb920 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_day.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_julian_day_h +#define eccodes_accessor_julian_day_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_day_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_day */ + const char *date; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_julian_day_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_day_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_day_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_julian_day_h */ diff --git a/src/accessor/grib_accessor_class_ksec1expver.cc b/src/accessor/grib_accessor_class_ksec1expver.cc new file mode 100644 index 000000000..dcd3c336e --- /dev/null +++ b/src/accessor/grib_accessor_class_ksec1expver.cc @@ -0,0 +1,95 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_ksec1expver.h" + +grib_accessor_class_ksec1expver_t _grib_accessor_class_ksec1expver{"ksec1expver"}; +grib_accessor_class* grib_accessor_class_ksec1expver = &_grib_accessor_class_ksec1expver; + + +void grib_accessor_class_ksec1expver_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_ksec1expver_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset * 8; + char* intc = NULL; + char* pTemp = NULL; + char expver[5]; + char refexpver[5]; + size_t llen = a->length + 1; + Assert(a->length == 4); + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + value = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, a->length * 8); + + a->unpack_string(refexpver, &llen); + /* test for endian */ + intc = (char*)&value; + pTemp = intc; + + expver[0] = *pTemp++; + expver[1] = *pTemp++; + expver[2] = *pTemp++; + expver[3] = *pTemp++; + expver[4] = 0; + +// expver[0] = intc[0]; +// expver[1] = intc[1]; +// expver[2] = intc[2]; +// expver[3] = intc[3]; +// expver[4] = 0; + + /* if there is a difference, have to reverse*/ + if (strcmp(refexpver, expver)) { + intc[0] = expver[3]; + intc[1] = expver[2]; + intc[2] = expver[1]; + intc[3] = expver[0]; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ksec1expver_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + int i = 0; + if (len[0] != 4) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4", a->name); + return GRIB_INVALID_KEY_VALUE; + } + if (len[0] > (a->length) + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%lu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + grib_handle_of_accessor(a)->buffer->data[a->offset + i] = val[i]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_ksec1expver_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + char sval[5] = {0,}; + size_t slen = 4; + snprintf(sval, sizeof(sval), "%04d", (int)(*val)); + return pack_string(a, sval, &slen); +} diff --git a/src/accessor/grib_accessor_class_ksec1expver.h b/src/accessor/grib_accessor_class_ksec1expver.h new file mode 100644 index 000000000..3884a7709 --- /dev/null +++ b/src/accessor/grib_accessor_class_ksec1expver.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ksec1expver_h +#define eccodes_accessor_ksec1expver_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in ksec1expver */ +}; + +class grib_accessor_class_ksec1expver_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_ksec1expver_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ksec1expver_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_ksec1expver_h */ diff --git a/src/accessor/grib_accessor_class_label.cc b/src/accessor/grib_accessor_class_label.cc new file mode 100644 index 000000000..547bdb11a --- /dev/null +++ b/src/accessor/grib_accessor_class_label.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_label.h" + +grib_accessor_class_label_t _grib_accessor_class_label{"label"}; +grib_accessor_class* grib_accessor_class_label = &_grib_accessor_class_label; + + +void grib_accessor_class_label_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->length = 0; +} + +void grib_accessor_class_label_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_label(dumper, a, NULL); +} + +int grib_accessor_class_label_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LABEL; +} + +int grib_accessor_class_label_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + size_t vlen = strlen(a->name); + if (vlen > *len) + return GRIB_BUFFER_TOO_SMALL; + *len = vlen; + strcpy(val, a->name); + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_label.h b/src/accessor/grib_accessor_class_label.h new file mode 100644 index 000000000..c4e64b322 --- /dev/null +++ b/src/accessor/grib_accessor_class_label.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_label_h +#define eccodes_accessor_label_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_label_t : public grib_accessor_gen_t +{ +public: + /* Members defined in label */ +}; + +class grib_accessor_class_label_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_label_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_label_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_label_h */ diff --git a/src/accessor/todo/grib_accessor_class_latitudes.cc b/src/accessor/grib_accessor_class_latitudes.cc similarity index 59% rename from src/accessor/todo/grib_accessor_class_latitudes.cc rename to src/accessor/grib_accessor_class_latitudes.cc index 4131ff066..65fcf65a8 100644 --- a/src/accessor/todo/grib_accessor_class_latitudes.cc +++ b/src/accessor/grib_accessor_class_latitudes.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,111 +10,15 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - MEMBERS =long distinct - MEMBERS =double* lats - MEMBERS =long size - MEMBERS =int save - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latitudes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latitudes */ - const char* values; - long distinct; - double* lats; - long size; - int save; -} grib_accessor_latitudes; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latitudes = { - &grib_accessor_class_double, /* super */ - "latitudes", /* name */ - sizeof(grib_accessor_latitudes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_latitudes.h" +grib_accessor_class_latitudes_t _grib_accessor_class_latitudes{"latitudes"}; grib_accessor_class* grib_accessor_class_latitudes = &_grib_accessor_class_latitudes; -/* END_CLASS_IMP */ static int get_distinct(grib_accessor* a, double** val, long* len); - -static int compare_doubles(const void* a, const void* b, int ascending) -{ +int compare_doubles(const void* a, const void* b, int ascending){ /* ascending is a boolean: 0 or 1 */ double* arg1 = (double*)a; double* arg2 = (double*)b; @@ -130,18 +35,15 @@ static int compare_doubles(const void* a, const void* b, int ascending) else return 1; } -static int compare_doubles_ascending(const void* a, const void* b) -{ +int compare_doubles_ascending(const void* a, const void* b){ return compare_doubles(a, b, 1); } -static int compare_doubles_descending(const void* a, const void* b) -{ +int compare_doubles_descending(const void* a, const void* b){ return compare_doubles(a, b, 0); } -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; +void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -151,10 +53,9 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_latitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len){ grib_context* c = a->context; - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; int ret = 0; double* v = val; double dummyLon = 0; @@ -205,9 +106,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; +int grib_accessor_class_latitudes_t::value_count(grib_accessor* a, long* len){ + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = a->context; double* val = NULL; @@ -237,8 +137,7 @@ static int value_count(grib_accessor* a, long* len) return ret; } -static int get_distinct(grib_accessor* a, double** val, long* len) -{ +static int get_distinct(grib_accessor* a, double** val, long* len){ long count = 0; double prev; double* v = NULL; diff --git a/src/accessor/grib_accessor_class_latitudes.h b/src/accessor/grib_accessor_class_latitudes.h new file mode 100644 index 000000000..10344c7cb --- /dev/null +++ b/src/accessor/grib_accessor_class_latitudes.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latitudes_h +#define eccodes_accessor_latitudes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in latitudes */ + const char* values; + long distinct; + double* lats; + long size; + int save; +}; + +class grib_accessor_class_latitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latitudes_h */ diff --git a/src/accessor/todo/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc similarity index 61% rename from src/accessor/todo/grib_accessor_class_latlon_increment.cc rename to src/accessor/grib_accessor_class_latlon_increment.cc index de43e60c9..3ecff170a 100644 --- a/src/accessor/todo/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,117 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = init - MEMBERS=const char* directionIncrementGiven - MEMBERS=const char* directionIncrement - MEMBERS=const char* scansPositively - MEMBERS=const char* first - MEMBERS=const char* last - MEMBERS=const char* numberOfPoints - MEMBERS=const char* angleMultiplier - MEMBERS=const char* angleDivisor - MEMBERS=long isLongitude - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latlon_increment -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latlon_increment */ - const char* directionIncrementGiven; - const char* directionIncrement; - const char* scansPositively; - const char* first; - const char* last; - const char* numberOfPoints; - const char* angleMultiplier; - const char* angleDivisor; - long isLongitude; -} grib_accessor_latlon_increment; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latlon_increment = { - &grib_accessor_class_double, /* super */ - "latlon_increment", /* name */ - sizeof(grib_accessor_latlon_increment), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_latlon_increment.h" +grib_accessor_class_latlon_increment_t _grib_accessor_class_latlon_increment{"latlon_increment"}; grib_accessor_class* grib_accessor_class_latlon_increment = &_grib_accessor_class_latlon_increment; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +void grib_accessor_class_latlon_increment_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -134,9 +32,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->isLongitude = grib_arguments_get_long(hand, c, n++); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +int grib_accessor_class_latlon_increment_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int ret = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -221,9 +118,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +int grib_accessor_class_latlon_increment_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int ret = 0; long codedNumberOfPoints = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -305,8 +201,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int is_missing(grib_accessor* a) -{ +int grib_accessor_class_latlon_increment_t::is_missing(grib_accessor* a){ size_t len = 1; double val = 0; diff --git a/src/accessor/grib_accessor_class_latlon_increment.h b/src/accessor/grib_accessor_class_latlon_increment.h new file mode 100644 index 000000000..4f5402e6a --- /dev/null +++ b/src/accessor/grib_accessor_class_latlon_increment.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latlon_increment_h +#define eccodes_accessor_latlon_increment_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latlon_increment_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlon_increment */ + const char* directionIncrementGiven; + const char* directionIncrement; + const char* scansPositively; + const char* first; + const char* last; + const char* numberOfPoints; + const char* angleMultiplier; + const char* angleDivisor; + long isLongitude; +}; + +class grib_accessor_class_latlon_increment_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlon_increment_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlon_increment_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latlon_increment_h */ diff --git a/src/accessor/grib_accessor_class_latlonvalues.cc b/src/accessor/grib_accessor_class_latlonvalues.cc new file mode 100644 index 000000000..ca52ffb6d --- /dev/null +++ b/src/accessor/grib_accessor_class_latlonvalues.cc @@ -0,0 +1,76 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_latlonvalues.h" + +grib_accessor_class_latlonvalues_t _grib_accessor_class_latlonvalues{"latlonvalues"}; +grib_accessor_class* grib_accessor_class_latlonvalues = &_grib_accessor_class_latlonvalues; + + +void grib_accessor_class_latlonvalues_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_latlonvalues_t* self = (grib_accessor_latlonvalues_t*)a; + int n = 0; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_latlonvalues_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_context* c = a->context; + int err = 0; + double* v = val; + double lat, lon, value; + size_t size = 0; + long count = 0; + grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), 0, &err); + if (err) { + if (iter) grib_iterator_delete(iter); + grib_context_log(c, GRIB_LOG_ERROR, "latlonvalues: Unable to create iterator"); + return err; + } + + err = value_count(a, &count); + if (err) return err; + size = count; + + if (*len < size) { + if (iter) grib_iterator_delete(iter); + return GRIB_ARRAY_TOO_SMALL; + } + + while (grib_iterator_next(iter, &lat, &lon, &value)) { + *(v++) = lat; + *(v++) = lon; + *(v++) = value; + } + + grib_iterator_delete(iter); + + *len = size; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_latlonvalues_t::value_count(grib_accessor* a, long* count){ + grib_accessor_latlonvalues_t* self = (grib_accessor_latlonvalues_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = GRIB_SUCCESS; + size_t size; + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, "latlonvalues: Unable to get size of %s", self->values); + return ret; + } + + *count = 3 * size; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_latlonvalues.h b/src/accessor/grib_accessor_class_latlonvalues.h new file mode 100644 index 000000000..ed040f543 --- /dev/null +++ b/src/accessor/grib_accessor_class_latlonvalues.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latlonvalues_h +#define eccodes_accessor_latlonvalues_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latlonvalues_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlonvalues */ + const char* values; +}; + +class grib_accessor_class_latlonvalues_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlonvalues_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlonvalues_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latlonvalues_h */ diff --git a/src/accessor/grib_accessor_class_library_version.cc b/src/accessor/grib_accessor_class_library_version.cc new file mode 100644 index 000000000..61fafe279 --- /dev/null +++ b/src/accessor/grib_accessor_class_library_version.cc @@ -0,0 +1,46 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_library_version.h" + +grib_accessor_class_library_version_t _grib_accessor_class_library_version{"library_version"}; +grib_accessor_class* grib_accessor_class_library_version = &_grib_accessor_class_library_version; + + +int grib_accessor_class_library_version_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + char result[30] = {0,}; + size_t size; + + int major = ECCODES_MAJOR_VERSION; + int minor = ECCODES_MINOR_VERSION; + int revision = ECCODES_REVISION_VERSION; + + snprintf(result, sizeof(result), "%d.%d.%d", major, minor, revision); + size = sizeof(result); + + if (*len < size) + return GRIB_ARRAY_TOO_SMALL; + strcpy(val, result); + + *len = size; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_library_version_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_library_version_t::string_length(grib_accessor* a){ + return 255; +} diff --git a/src/accessor/grib_accessor_class_library_version.h b/src/accessor/grib_accessor_class_library_version.h new file mode 100644 index 000000000..28de10364 --- /dev/null +++ b/src/accessor/grib_accessor_class_library_version.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_library_version_h +#define eccodes_accessor_library_version_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_library_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in library_version */ +}; + +class grib_accessor_class_library_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_library_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_library_version_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; +}; +#endif /* eccodes_accessor_library_version_h */ diff --git a/src/accessor/todo/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc similarity index 72% rename from src/accessor/todo/grib_accessor_class_local_definition.cc rename to src/accessor/grib_accessor_class_local_definition.cc index 782ce5fde..c216ddb2a 100644 --- a/src/accessor/todo/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,125 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * This pertains to GRIB edition 2 - **************************************/ - #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* productDefinitionTemplateNumberInternal - MEMBERS=const char* grib2LocalSectionNumber - MEMBERS=const char* type - MEMBERS=const char* stream - MEMBERS=const char* the_class - MEMBERS=const char* eps - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_local_definition -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in local_definition */ - const char* productDefinitionTemplateNumber; - const char* productDefinitionTemplateNumberInternal; - const char* grib2LocalSectionNumber; - const char* type; - const char* stream; - const char* the_class; - const char* eps; - const char* stepType; - const char* derivedForecast; -} grib_accessor_local_definition; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_local_definition = { - &grib_accessor_class_unsigned, /* super */ - "local_definition", /* name */ - sizeof(grib_accessor_local_definition), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_local_definition.h" +grib_accessor_class_local_definition_t _grib_accessor_class_local_definition{"local_definition"}; grib_accessor_class* grib_accessor_class_local_definition = &_grib_accessor_class_local_definition; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +void grib_accessor_class_local_definition_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -141,16 +32,14 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->derivedForecast = grib_arguments_get_name(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +int grib_accessor_class_local_definition_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; return grib_get_long(grib_handle_of_accessor(a), self->grib2LocalSectionNumber, val); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +int grib_accessor_class_local_definition_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberInternal = -1; @@ -316,7 +205,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) #ifdef DEBUG // In test & development mode, fail so we remember to adjust PDTN grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_local_definition: Invalid localDefinitionNumber %d", localDefinitionNumber); + "grib_accessor_local_definition_t: Invalid localDefinitionNumber %d", localDefinitionNumber); return GRIB_ENCODING_ERROR; #endif // ECC-1253: Do not fail in operations. Leave PDTN as is @@ -419,7 +308,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { if (a->context->debug) { - fprintf(stderr, "ECCODES DEBUG grib_accessor_local_definition: ldNumber=%d, newPDTN=%ld\n", + fprintf(stderr, "ECCODES DEBUG grib_accessor_local_definition_t: ldNumber=%d, newPDTN=%ld\n", localDefinitionNumber, productDefinitionTemplateNumberNew); } if (tooEarly) @@ -435,8 +324,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_local_definition_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_local_definition.h b/src/accessor/grib_accessor_class_local_definition.h new file mode 100644 index 000000000..296bab69d --- /dev/null +++ b/src/accessor/grib_accessor_class_local_definition.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_local_definition_h +#define eccodes_accessor_local_definition_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_local_definition_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in local_definition */ + const char* productDefinitionTemplateNumber; + const char* productDefinitionTemplateNumberInternal; + const char* grib2LocalSectionNumber; + const char* type; + const char* stream; + const char* the_class; + const char* eps; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_local_definition_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_local_definition_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_local_definition_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_local_definition_h */ diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc new file mode 100644 index 000000000..d99b6e860 --- /dev/null +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -0,0 +1,95 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_long_vector.h" +#include "grib_accessor_class_abstract_long_vector.h" + +grib_accessor_class_long_vector_t _grib_accessor_class_long_vector{"long_vector"}; +grib_accessor_class* grib_accessor_class_long_vector = &_grib_accessor_class_long_vector; + + +void grib_accessor_class_long_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + int n = 0; + + self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + /* check self->index on init and never change it */ + Assert(self->index < v->number_of_elements && self->index >= 0); + + a->length = 0; +} + +int grib_accessor_class_long_vector_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + size_t size = 0; + int err = 0; + long* vector; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + /*TODO implement the dirty mechanism to avoid to unpack every time */ + err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size); + if (err) return err; + DEBUG_ASSERT(size > 0); + vector = (long*)grib_context_malloc(a->context, sizeof(long) * size); + err = va->unpack_long(vector, &size); grib_context_free(a->context, vector); + if (err) return err; + + *val = v->v[self->index]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_long_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + long lval = 0; + int err = 0; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + err = unpack_long(a, &lval, len); + + *val = (double)v->v[self->index]; + + return err; +} + +int grib_accessor_class_long_vector_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int err = 0; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + v->pack_index = self->index; + + err = va->pack_long(val, len); + return err; +} + +int grib_accessor_class_long_vector_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_long_vector.h b/src/accessor/grib_accessor_class_long_vector.h new file mode 100644 index 000000000..66fab29e6 --- /dev/null +++ b/src/accessor/grib_accessor_class_long_vector.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_long_vector_h +#define eccodes_accessor_long_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in long_vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_long_vector_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_long_vector_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_vector_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_long_vector_h */ diff --git a/src/accessor/todo/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc similarity index 56% rename from src/accessor/todo/grib_accessor_class_longitudes.cc rename to src/accessor/grib_accessor_class_longitudes.cc index 083d40138..09fd4a4e6 100644 --- a/src/accessor/todo/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,113 +10,17 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - MEMBERS =long distinct - MEMBERS =double* lons - MEMBERS =long size - MEMBERS =int save - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_longitudes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in longitudes */ - const char* values; - long distinct; - double* lons; - long size; - int save; -} grib_accessor_longitudes; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_longitudes = { - &grib_accessor_class_double, /* super */ - "longitudes", /* name */ - sizeof(grib_accessor_longitudes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_longitudes.h" +grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{"longitudes"}; grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_longitudes; -/* END_CLASS_IMP */ static int get_distinct(grib_accessor* a, double** val, long* len); -static int compare_doubles(const void* a, const void* b); - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; +int compare_doubles(const void* a, const void* b); +void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -126,10 +31,9 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_longitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len){ grib_context* c = a->context; - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int ret = 0; double* v = val; double dummyLat = 0; @@ -181,9 +85,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; +int grib_accessor_class_longitudes_t::value_count(grib_accessor* a, long* len){ + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = a->context; double* val = NULL; @@ -212,8 +115,7 @@ static int value_count(grib_accessor* a, long* len) return ret; } -static int get_distinct(grib_accessor* a, double** val, long* len) -{ +static int get_distinct(grib_accessor* a, double** val, long* len){ long count = 0; double prev; double* v = NULL; @@ -270,8 +172,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len) return GRIB_SUCCESS; } -static int compare_doubles(const void* a, const void* b) -{ +int compare_doubles(const void* a, const void* b){ double* arg1 = (double*)a; double* arg2 = (double*)b; if (*arg1 < *arg2) diff --git a/src/accessor/grib_accessor_class_longitudes.h b/src/accessor/grib_accessor_class_longitudes.h new file mode 100644 index 000000000..782b4d764 --- /dev/null +++ b/src/accessor/grib_accessor_class_longitudes.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_longitudes_h +#define eccodes_accessor_longitudes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_longitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in longitudes */ + const char* values; + long distinct; + double* lons; + long size; + int save; +}; + +class grib_accessor_class_longitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_longitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_longitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_longitudes_h */ diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc new file mode 100644 index 000000000..d480866c5 --- /dev/null +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -0,0 +1,133 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_lookup.h" + +grib_accessor_class_lookup_t _grib_accessor_class_lookup{"lookup"}; +grib_accessor_class* grib_accessor_class_lookup = &_grib_accessor_class_lookup; + + +void grib_accessor_class_lookup_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + a->length = 0; + self->llength = len; + self->loffset = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 0); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + self->real_name = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); +} + +void grib_accessor_class_lookup_t::post_init(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + if (self->real_name) { + grib_dependency_observe_expression(a, self->real_name); + } +} + +void grib_accessor_class_lookup_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + unsigned char bytes[1024] = {0,}; + char msg[1024] = {0,}; + char buf[2048]; + int i; + unsigned long v = 0; + + size_t llen = self->llength; + a->unpack_bytes(bytes, &llen); + bytes[llen] = 0; + for (i = 0; i < llen; i++) { + msg[i] = isprint(bytes[i]) ? bytes[i] : '?'; + v <<= 8; + v |= bytes[i]; + } + + msg[llen] = 0; + + snprintf(buf, sizeof(buf), "%s %lu %ld-%ld", msg, v, (long)a->offset + self->loffset, (long)self->llength); + + grib_dump_long(dumper, a, buf); +} + +int grib_accessor_class_lookup_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + unsigned char bytes[1024] = {0,}; + int i; + + size_t llen = self->llength; + a->unpack_bytes(bytes, &llen); + bytes[llen] = 0; + + for (i = 0; i < llen; i++) { + v[i] = isprint(bytes[i]) ? bytes[i] : '?'; + } + + v[llen] = 0; + if (llen == 1 && v[0] == '?') { + /* Try unpack as long */ + size_t length = 10; + long lval = 0; + int err = unpack_long(a, &lval, &length); + if (!err) { + char str[5]; + int conv = snprintf(str, sizeof(str), "%ld", lval); + if (conv == 1) { + v[0] = str[0]; + } + } + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_lookup_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + long pos = (a->offset + self->loffset) * 8; + + if (len[0] < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + len[0] = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + /* This is used when reparsing or rebuilding */ + if (h->loader) { + Assert(*len == 1); + return h->loader->lookup_long(h->context, h->loader, a->name, val); + } + + val[0] = grib_decode_unsigned_long(h->buffer->data, &pos, self->llength * 8); + len[0] = 1; + + /*printf("###########lookup unpack_long: %s %ld %ld\n",a->name, pos/8, val[0]);*/ + + return GRIB_SUCCESS; +} + +int grib_accessor_class_lookup_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +long grib_accessor_class_lookup_t::byte_count(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + return self->llength; +} + +long grib_accessor_class_lookup_t::byte_offset(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + return self->loffset; +} + +int grib_accessor_class_lookup_t::notify_change(grib_accessor* self, grib_accessor* changed){ + /* Forward changes */ + return grib_dependency_notify_change(self); +} diff --git a/src/accessor/grib_accessor_class_lookup.h b/src/accessor/grib_accessor_class_lookup.h new file mode 100644 index 000000000..4237d4517 --- /dev/null +++ b/src/accessor/grib_accessor_class_lookup.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_lookup_h +#define eccodes_accessor_lookup_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_lookup_t : public grib_accessor_long_t +{ +public: + /* Members defined in lookup */ + long llength; + long loffset; + grib_expression* real_name; +}; + +class grib_accessor_class_lookup_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_lookup_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_lookup_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_lookup_h */ diff --git a/src/accessor/grib_accessor_class_mars_param.cc b/src/accessor/grib_accessor_class_mars_param.cc new file mode 100644 index 000000000..76b55a1fe --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_param.cc @@ -0,0 +1,53 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_mars_param.h" + +grib_accessor_class_mars_param_t _grib_accessor_class_mars_param{"mars_param"}; +grib_accessor_class* grib_accessor_class_mars_param = &_grib_accessor_class_mars_param; + + +void grib_accessor_class_mars_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_mars_param_t* self = (grib_accessor_mars_param_t*)a; + self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->table = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->param = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +// For an implementation of pack_string, see +// src/deprecated/grib_accessor_class_mars_param.cc + +// For an alternative implementation of unpack_string, see +// src/deprecated/grib_accessor_class_mars_param.cc +// +int grib_accessor_class_mars_param_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_mars_param_t* self = (grib_accessor_mars_param_t*)a; + long param = 0; + long table = 0; + int ret = 0; + + if (self->table != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->table, &table)) != GRIB_SUCCESS) + return ret; + if (self->param != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->param, ¶m)) != GRIB_SUCCESS) + return ret; + + /*if (table==200) table=128;*/ + snprintf(val, 32, "%ld.%ld", param, table); + *len = strlen(val) + 1; + + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_mars_param_t::string_length(grib_accessor* a){ + return 7; +} diff --git a/src/accessor/grib_accessor_class_mars_param.h b/src/accessor/grib_accessor_class_mars_param.h new file mode 100644 index 000000000..87bcaad41 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_param.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_mars_param_h +#define eccodes_accessor_mars_param_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_param_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_param */ + const char* paramId; + const char* table; + const char* param; +}; + +class grib_accessor_class_mars_param_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_param_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_param_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_mars_param_h */ diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc new file mode 100644 index 000000000..05a5120c2 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -0,0 +1,115 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_mars_step.h" + +grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{"mars_step"}; +grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; + + +void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + char stepType[100]; + size_t stepTypeLen = 100; + char buf[100] = {0,}; + int ret; + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + + if (!stepRangeAcc) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); + return GRIB_NOT_FOUND; + } + + if ((ret = grib_get_string(grib_handle_of_accessor(a), self->stepType, stepType, &stepTypeLen)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(stepType, "instant")) + snprintf(buf, sizeof(buf), "%s", val); + else + snprintf(buf, sizeof(buf), "0-%s", val); + + return stepRangeAcc->pack_string(buf, len);} + +int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + int ret = 0; + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + char buf[100] = {0,}; + char* p = NULL; + size_t buflen = 100; + long step; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + const char* cclass_name = a->cclass->name; + + if (!stepRangeAcc) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); + return GRIB_NOT_FOUND; + } + + if ((ret = stepRangeAcc->unpack_string(buf, &buflen)) != GRIB_SUCCESS) + return ret; + + if (*len < buflen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, buflen, *len); + *len = buflen; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(val, buf); + step = strtol(buf, &p, 10); + + if (p != NULL && *p == '-' && step == 0) + strcpy(val, ++p); + + *len = strlen(val); + + return ret; +} + +int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + char buff[100] = {0,}; + size_t bufflen = 100; + + snprintf(buff, sizeof(buff), "%ld", *val); + + return pack_string(a, buff, &bufflen); +} + +int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + + if (!stepRangeAcc) + return GRIB_NOT_FOUND; + + return stepRangeAcc->unpack_long(val, len);} + +int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a){ + return 16; +} + +int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_mars_step.h b/src/accessor/grib_accessor_class_mars_step.h new file mode 100644 index 000000000..db3042648 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_step.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_mars_step_h +#define eccodes_accessor_mars_step_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_step_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_step */ + const char* stepRange; + const char* stepType; +}; + +class grib_accessor_class_mars_step_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_step_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_mars_step_h */ diff --git a/src/accessor/todo/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_md5.cc rename to src/accessor/grib_accessor_class_md5.cc index 6a57c1329..f19836aea 100644 --- a/src/accessor/todo/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,107 +10,15 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_md5.h" #include "md5.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = compare;unpack_string;value_count;destroy - MEMBERS = const char* offset - MEMBERS = grib_expression* length - MEMBERS = grib_string_list* blocklist - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_md5 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in md5 */ - const char* offset; - grib_expression* length; - grib_string_list* blocklist; -} grib_accessor_md5; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_md5 = { - &grib_accessor_class_gen, /* super */ - "md5", /* name */ - sizeof(grib_accessor_md5), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_md5_t _grib_accessor_class_md5{"md5"}; grib_accessor_class* grib_accessor_class_md5 = &_grib_accessor_class_md5; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_md5* self = (grib_accessor_md5*)a; +void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; char* b = 0; int n = 0; grib_string_list* current = 0; @@ -138,13 +47,11 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_md5_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } -static int compare(grib_accessor* a, grib_accessor* b) -{ +int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b){ int retval = GRIB_SUCCESS; size_t alen = 0; @@ -152,13 +59,11 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); - if (err) + err = b->value_count(&count); if (err) return err; blen = count; @@ -168,9 +73,8 @@ static int compare(grib_accessor* a, grib_accessor* b) return retval; } -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_md5* self = (grib_accessor_md5*)a; +int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; unsigned mess_len; unsigned char* mess; unsigned char* p; @@ -226,9 +130,8 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) return ret; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_md5* self = (grib_accessor_md5*)a; +void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; if (self->blocklist) { grib_string_list* next = self->blocklist; grib_string_list* cur = NULL; @@ -241,8 +144,7 @@ static void destroy(grib_context* c, grib_accessor* a) } } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_md5_t::value_count(grib_accessor* a, long* count){ *count = 1; /* ECC-1475 */ return 0; } diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h new file mode 100644 index 000000000..8d819cc9d --- /dev/null +++ b/src/accessor/grib_accessor_class_md5.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_md5_h +#define eccodes_accessor_md5_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_md5_t : public grib_accessor_gen_t +{ +public: + /* Members defined in md5 */ + const char* offset; + grib_expression* length; + grib_string_list* blocklist; +}; + +class grib_accessor_class_md5_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_md5_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_md5_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_md5_h */ diff --git a/src/accessor/grib_accessor_class_message.cc b/src/accessor/grib_accessor_class_message.cc new file mode 100644 index 000000000..76fcb7be7 --- /dev/null +++ b/src/accessor/grib_accessor_class_message.cc @@ -0,0 +1,75 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_message.h" + +grib_accessor_class_message_t _grib_accessor_class_message{"message"}; +grib_accessor_class* grib_accessor_class_message = &_grib_accessor_class_message; + + + +void grib_accessor_class_message_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset; +} + +// static int compare(grib_accessor* a, grib_accessor* b) +// { +// if (a->length != b->length) +// return GRIB_COUNT_MISMATCH; +// return GRIB_SUCCESS; +// } + +void grib_accessor_class_message_t::update_size(grib_accessor* a, size_t new_size){ + a->length = new_size; +} + +void grib_accessor_class_message_t::resize(grib_accessor* a, size_t new_size){ + grib_context_log(a->context, GRIB_LOG_FATAL, "%s %s: Not supported", a->cclass->name, __func__); + + // void* zero = grib_context_malloc_clear(a->context, new_size); + // grib_buffer_replace(a, (const unsigned char*)zero, new_size, 1, 0); + // grib_context_free(a->context, zero); + // grib_context_log(a->context, GRIB_LOG_DEBUG, "resize: grib_accessor_class_message %ld %ld %s %s", + // (long)new_size, (long)a->length, a->cclass->name, a->name); + // Assert(new_size == a->length); +} + +int grib_accessor_class_message_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +int grib_accessor_class_message_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long i = 0; + size_t l = string_length(a) + 1; + grib_handle* h = grib_handle_of_accessor(a); + + if (*len < l) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + val[i] = h->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_message_t::string_length(grib_accessor* a){ + return a->length; +} diff --git a/src/accessor/grib_accessor_class_message.h b/src/accessor/grib_accessor_class_message.h new file mode 100644 index 000000000..912e8be4b --- /dev/null +++ b/src/accessor/grib_accessor_class_message.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_message_h +#define eccodes_accessor_message_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_message_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in message */ +}; + +class grib_accessor_class_message_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_message_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; +}; +#endif /* eccodes_accessor_message_h */ diff --git a/src/accessor/grib_accessor_class_message_copy.cc b/src/accessor/grib_accessor_class_message_copy.cc new file mode 100644 index 000000000..e32d39355 --- /dev/null +++ b/src/accessor/grib_accessor_class_message_copy.cc @@ -0,0 +1,59 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_message_copy.h" + +grib_accessor_class_message_copy_t _grib_accessor_class_message_copy{"message_copy"}; +grib_accessor_class* grib_accessor_class_message_copy = &_grib_accessor_class_message_copy; + + +void grib_accessor_class_message_copy_t::init(grib_accessor* a, const long length, grib_arguments* args){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +void grib_accessor_class_message_copy_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_message_copy_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_message_copy_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + size_t slen = grib_handle_of_accessor(a)->buffer->ulength; + size_t i; + unsigned char* v = 0; + + if (*len < slen) { + return GRIB_ARRAY_TOO_SMALL; + } + v = grib_handle_of_accessor(a)->buffer->data; + /* replace unprintable characters with space */ + for (i = 0; i < slen; i++) + if (v[i] > 126) + v[i] = 32; + memcpy(val, grib_handle_of_accessor(a)->buffer->data, slen); + val[i] = 0; + + *len = slen; + + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_message_copy_t::string_length(grib_accessor* a){ + return grib_handle_of_accessor(a)->buffer->ulength; +} + +long grib_accessor_class_message_copy_t::byte_count(grib_accessor* a){ + return a->length; +} diff --git a/src/accessor/grib_accessor_class_message_copy.h b/src/accessor/grib_accessor_class_message_copy.h new file mode 100644 index 000000000..37072c685 --- /dev/null +++ b/src/accessor/grib_accessor_class_message_copy.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_message_copy_h +#define eccodes_accessor_message_copy_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_message_copy_t : public grib_accessor_gen_t +{ +public: + /* Members defined in message_copy */ +}; + +class grib_accessor_class_message_copy_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_message_copy_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_copy_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_message_copy_h */ diff --git a/src/accessor/grib_accessor_class_multdouble.cc b/src/accessor/grib_accessor_class_multdouble.cc new file mode 100644 index 000000000..3b8b42bd5 --- /dev/null +++ b/src/accessor/grib_accessor_class_multdouble.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_multdouble.h" + +grib_accessor_class_multdouble_t _grib_accessor_class_multdouble{"multdouble"}; +grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble; + + +void grib_accessor_class_multdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_multdouble_t* self = (grib_accessor_multdouble_t*)a; + int n = 0; + + self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_multdouble_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_multdouble_t* self = (grib_accessor_multdouble_t*)a; + int ret = GRIB_SUCCESS; + double value = 0; + + ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); + if (ret != GRIB_SUCCESS) + return ret; + + *val = value * self->multiplier; + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_multdouble.h b/src/accessor/grib_accessor_class_multdouble.h new file mode 100644 index 000000000..9d6d76285 --- /dev/null +++ b/src/accessor/grib_accessor_class_multdouble.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_multdouble_h +#define eccodes_accessor_multdouble_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_multdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in multdouble */ + const char* val; + double multiplier; +}; + +class grib_accessor_class_multdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_multdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_multdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_multdouble_h */ diff --git a/src/accessor/grib_accessor_class_non_alpha.cc b/src/accessor/grib_accessor_class_non_alpha.cc new file mode 100644 index 000000000..05f8ca01c --- /dev/null +++ b/src/accessor/grib_accessor_class_non_alpha.cc @@ -0,0 +1,112 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_non_alpha.h" + +grib_accessor_class_non_alpha_t _grib_accessor_class_non_alpha{"non_alpha"}; +grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_alpha; + + +void grib_accessor_class_non_alpha_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + size_t i = 0; + unsigned char* v; + + v = buffer->data + a->offset; + i = 0; + while ((*v < 33 || *v > 126) && i <= buffer->ulength) { + v++; + i++; + } + a->length = i; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_non_alpha_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_non_alpha_t::string_length(grib_accessor* a){ + return a->length; +} + +void grib_accessor_class_non_alpha_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_non_alpha_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_non_alpha_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_handle* hand = grib_handle_of_accessor(a); + long i = 0; + + if (*len < (a->length + 1)) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + *len, a->name, a->length + 1); + *len = a->length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) { + val[i] = hand->buffer->data[a->offset + i]; + } + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_non_alpha_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_non_alpha_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + *v = strtod(val, &last); + + if (*last == 0) { + return GRIB_SUCCESS; + } + + return GRIB_NOT_IMPLEMENTED; +} + +long grib_accessor_class_non_alpha_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_non_alpha.h b/src/accessor/grib_accessor_class_non_alpha.h new file mode 100644 index 000000000..1b1b9d830 --- /dev/null +++ b/src/accessor/grib_accessor_class_non_alpha.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_non_alpha_h +#define eccodes_accessor_non_alpha_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_non_alpha_t : public grib_accessor_gen_t +{ +public: + /* Members defined in non_alpha */ +}; + +class grib_accessor_class_non_alpha_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_non_alpha_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_non_alpha_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_non_alpha_h */ diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.cc b/src/accessor/grib_accessor_class_number_of_coded_values.cc new file mode 100644 index 000000000..b77769898 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_coded_values.cc @@ -0,0 +1,66 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_number_of_coded_values.h" + +grib_accessor_class_number_of_coded_values_t _grib_accessor_class_number_of_coded_values{"number_of_coded_values"}; +grib_accessor_class* grib_accessor_class_number_of_coded_values = &_grib_accessor_class_number_of_coded_values; + + +void grib_accessor_class_number_of_coded_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_number_of_coded_values_t* self = (grib_accessor_number_of_coded_values_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_number_of_coded_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + + grib_accessor_number_of_coded_values_t* self = (grib_accessor_number_of_coded_values_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if (bpv != 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_number_of_coded_values_t: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n", + offsetAfterData, offsetBeforeData, unusedBits, bpv); + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h b/src/accessor/grib_accessor_class_number_of_coded_values.h new file mode 100644 index 000000000..de5e3b76b --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_coded_values_h +#define eccodes_accessor_number_of_coded_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_coded_values */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_number_of_coded_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_coded_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_coded_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_coded_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc new file mode 100644 index 000000000..abd4af786 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -0,0 +1,80 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_number_of_points.h" + +grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{"number_of_points"}; +grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_class_number_of_points; + + +void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; + self->ni = grib_arguments_get_name(hand, c, n++); + self->nj = grib_arguments_get_name(hand, c, n++); + self->plpresent = grib_arguments_get_name(hand, c, n++); + self->pl = grib_arguments_get_name(hand, c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_number_of_points_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; + + int ret = GRIB_SUCCESS; + long ni = 0, nj = 0, plpresent = 0; + size_t plsize = 0; + long* pl = NULL; + int i = 0; + grib_context* c = a->context; + grib_handle* hand = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(hand, self->nj, &nj)) != GRIB_SUCCESS) + return ret; + + if (self->plpresent && + ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS)) + return ret; + + if (grib_is_missing(hand, self->nj, &ret) && ret == GRIB_SUCCESS) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 'missing'!", self->nj); + return GRIB_GEOCALCULUS_PROBLEM; + } + + if (nj == 0) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 0!", self->nj); + return GRIB_GEOCALCULUS_PROBLEM; + } + + if (plpresent) { + /*reduced*/ + plsize = nj; + pl = (long*)grib_context_malloc(c, sizeof(long) * plsize); + grib_get_long_array_internal(hand, self->pl, pl, &plsize); + *val = 0; + for (i = 0; i < plsize; i++) + *val += pl[i]; + grib_context_free(c, pl); + } + else { + /*regular*/ + *val = ni * nj; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_points.h b/src/accessor/grib_accessor_class_number_of_points.h new file mode 100644 index 000000000..db3521c05 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_points_h +#define eccodes_accessor_number_of_points_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_number_of_points_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_points_h */ diff --git a/src/accessor/todo/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc similarity index 72% rename from src/accessor/todo/grib_accessor_class_number_of_points_gaussian.cc rename to src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 2114a9c87..c7fd4e4b8 100644 --- a/src/accessor/todo/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,127 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - ************************************/ - #include "grib_api_internal.h" +#include "grib_accessor_class_number_of_points_gaussian.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* ni - MEMBERS = const char* nj - MEMBERS = const char* plpresent - MEMBERS = const char* pl - MEMBERS = const char* order - MEMBERS = const char* lat_first - MEMBERS = const char* lon_first - MEMBERS = const char* lat_last - MEMBERS = const char* lon_last - MEMBERS = const char* support_legacy - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_points_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_points_gaussian */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; - const char* order; - const char* lat_first; - const char* lon_first; - const char* lat_last; - const char* lon_last; - const char* support_legacy; -} grib_accessor_number_of_points_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_points_gaussian = { - &grib_accessor_class_long, /* super */ - "number_of_points_gaussian", /* name */ - sizeof(grib_accessor_number_of_points_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_number_of_points_gaussian_t _grib_accessor_class_number_of_points_gaussian{"number_of_points_gaussian"}; grib_accessor_class* grib_accessor_class_number_of_points_gaussian = &_grib_accessor_class_number_of_points_gaussian; -/* END_CLASS_IMP */ #define EFDEBUG 0 -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ +void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ int n = 0; grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; self->ni = grib_arguments_get_name(h, c, n++); self->nj = grib_arguments_get_name(h, c, n++); self->plpresent = grib_arguments_get_name(h, c, n++); @@ -148,13 +41,11 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) // See src/deprecated/grib_accessor_class_number_of_points_gaussian.cc // -static int angleApproximatelyEqual(double A, double B, double angular_precision) -{ +int angleApproximatelyEqual(double A, double B, double angular_precision){ return angular_precision > 0 ? (fabs(A - B) <= angular_precision) : (A == B); } -static double longitude_normalise(double lon, double minimum) -{ +double longitude_normalise(double lon, double minimum){ while (lon < minimum) { lon += 360; } @@ -164,8 +55,7 @@ static double longitude_normalise(double lon, double minimum) return lon; } -static void correctWestEast(long max_pl, double angular_precision, double* pWest, double* pEast) -{ +void correctWestEast(long max_pl, double angular_precision, double* pWest, double* pEast){ double w, e; const double inc = 360.0 / max_pl; /*smallest increment*/ if (*pWest > *pEast) @@ -186,8 +76,7 @@ static void correctWestEast(long max_pl, double angular_precision, double* pWest } } -static int get_number_of_data_values(grib_handle* h, size_t* numDataValues) -{ +int get_number_of_data_values(grib_handle* h, size_t* numDataValues){ int err = 0; long bpv = 0, bitmapPresent = 0; size_t bitmapLength = 0; @@ -218,14 +107,13 @@ static int get_number_of_data_values(grib_handle* h, size_t* numDataValues) return err; } -static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len); -static int unpack_long_new(grib_accessor* a, long* val, size_t* len); +int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len); +int unpack_long_new(grib_accessor* a, long* val, size_t* len); -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_number_of_points_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int err = GRIB_SUCCESS; long support_legacy = 1; - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; grib_handle* h = grib_handle_of_accessor(a); if ((err = grib_get_long_internal(h, self->support_legacy, &support_legacy)) != GRIB_SUCCESS) @@ -238,8 +126,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* New algorithm */ -static int unpack_long_new(grib_accessor* a, long* val, size_t* len) -{ +int unpack_long_new(grib_accessor* a, long* val, size_t* len){ int err = GRIB_SUCCESS; int is_global = 0; long ni = 0, nj = 0, plpresent = 0, order = 0; @@ -253,7 +140,7 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) long angleSubdivisions = 0; grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) @@ -347,8 +234,7 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) } /* With Legacy support */ -static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len) -{ +int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len){ int err = GRIB_SUCCESS; int is_global = 0; long ni = 0, nj = 0, plpresent = 0, order = 0; @@ -363,7 +249,7 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* grib_handle* h = grib_handle_of_accessor(a); size_t numDataValues = 0; - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h b/src/accessor/grib_accessor_class_number_of_points_gaussian.h new file mode 100644 index 000000000..f01224f17 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_points_gaussian_h +#define eccodes_accessor_number_of_points_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points_gaussian */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; + const char* order; + const char* lat_first; + const char* lon_first; + const char* lat_last; + const char* lon_last; + const char* support_legacy; +}; + +class grib_accessor_class_number_of_points_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_gaussian_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_points_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values.cc b/src/accessor/grib_accessor_class_number_of_values.cc new file mode 100644 index 000000000..3472eb68d --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values.cc @@ -0,0 +1,67 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_number_of_values.h" + +grib_accessor_class_number_of_values_t _grib_accessor_class_number_of_values{"number_of_values"}; +grib_accessor_class* grib_accessor_class_number_of_values = &_grib_accessor_class_number_of_values; + + +void grib_accessor_class_number_of_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + int n = 0; + grib_accessor_number_of_values_t* self = (grib_accessor_number_of_values_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + self->values = grib_arguments_get_name(hand, c, n++); + self->bitsPerValue = grib_arguments_get_name(hand, c, n++); + self->numberOfPoints = grib_arguments_get_name(hand, c, n++); + self->bitmapPresent = grib_arguments_get_name(hand, c, n++); + self->bitmap = grib_arguments_get_name(hand, c, n++); + self->numberOfCodedValues = grib_arguments_get_name(hand, c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + + a->length = 0; +} + +int grib_accessor_class_number_of_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_number_of_values_t* self = (grib_accessor_number_of_values_t*)a; + int ret = GRIB_SUCCESS, i; + long npoints = 0, bitmap_present = 0; + size_t size = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &npoints)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapPresent, &bitmap_present)) != GRIB_SUCCESS) + return ret; + + if (bitmap_present) { + double* bitmap; + size = npoints; + bitmap = (double*)grib_context_malloc(a->context, sizeof(double) * size); + if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->bitmap, bitmap, &size)) != GRIB_SUCCESS) { + grib_context_free(a->context, bitmap); + return ret; + } + *val = 0; + for (i = 0; i < size; i++) + if (bitmap[i] != 0) + (*val)++; + + grib_context_free(a->context, bitmap); + } + else { + *val = npoints; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_values.h b/src/accessor/grib_accessor_class_number_of_values.h new file mode 100644 index 000000000..88b18cd6f --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_values_h +#define eccodes_accessor_number_of_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_values */ + const char* values; + const char* bitsPerValue; + const char* numberOfPoints; + const char* bitmapPresent; + const char* bitmap; + const char* numberOfCodedValues; +}; + +class grib_accessor_class_number_of_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc new file mode 100644 index 000000000..ecfe11b22 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -0,0 +1,63 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_number_of_values_data_raw_packing.h" + +grib_accessor_class_number_of_values_data_raw_packing_t _grib_accessor_class_number_of_values_data_raw_packing{"number_of_values_data_raw_packing"}; +grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing = &_grib_accessor_class_number_of_values_data_raw_packing; + + +void grib_accessor_class_number_of_values_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + int n = 0; + grib_accessor_number_of_values_data_raw_packing_t* self = (grib_accessor_number_of_values_data_raw_packing_t*)a; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_number_of_values_data_raw_packing_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int err = 0; + grib_accessor_number_of_values_data_raw_packing_t* self = (grib_accessor_number_of_values_data_raw_packing_t*)a; + grib_accessor* adata = NULL; + long precision = 0; + int bytes = 0; + long byte_count = 0; + + adata = grib_find_accessor(grib_handle_of_accessor(a), self->values); + Assert(adata != NULL); + byte_count = adata->byte_count(); + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return err; + + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + *val = byte_count / bytes; + + return err; +} + +int grib_accessor_class_number_of_values_data_raw_packing_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h new file mode 100644 index 000000000..c0a6e9fcb --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_values_data_raw_packing_h +#define eccodes_accessor_number_of_values_data_raw_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in number_of_values_data_raw_packing */ + const char* values; + const char* precision; +}; + +class grib_accessor_class_number_of_values_data_raw_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_number_of_values_data_raw_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_data_raw_packing_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_values_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc new file mode 100644 index 000000000..259f97375 --- /dev/null +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -0,0 +1,120 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_octahedral_gaussian.h" + +grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussian{"octahedral_gaussian"}; +grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_class_octahedral_gaussian; + + +void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + self->N = grib_arguments_get_name(hand, c, n++); + self->Ni = grib_arguments_get_name(hand, c, n++); + self->plpresent = grib_arguments_get_name(hand, c, n++); + self->pl = grib_arguments_get_name(hand, c, n++); +} + +/* Returns 1 (=true) if input pl array is Octahedral, 0 otherwise. + * Possible cases for the deltas in an octahedral pl array: + * +4 .. +4 Top part, above equator + * +4 .. 0 Top part, above and including equator + * +4.. 0 -4.. Middle part, above, equator and below + * 0 -4.. Equator and below + * -4 ..-4 All below equator + * Anything else is considered not octahedral + */ +int is_pl_octahedral(const long pl[], size_t size){ + long i; + long prev_diff = -1; + for (i = 1; i < size; ++i) { + const long diff = pl[i] - pl[i - 1]; + if (diff == 0) { + /* prev must be +4 or undef */ + if (!(prev_diff == +4 || i == 1)) { + return 0; + } + } + else { + if (labs(diff) != 4) { + return 0; + } + if (diff == +4) { + /* prev must be +4 or undef */ + if (!(prev_diff == +4 || i == 1)) { + return 0; + } + } + if (diff == -4) { + /* prev must be 0, -4 or undef */ + if (!(prev_diff == -4 || prev_diff == 0 || i == 1)) { + return 0; + } + } + } + prev_diff = diff; + } + return 1; /* it's octahedral */ +} + +int grib_accessor_class_octahedral_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; + int ret = GRIB_SUCCESS; + long Ni; + long plpresent = 0; + long* pl = NULL; /* pl array */ + size_t plsize = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_context* c = a->context; + + if ((ret = grib_get_long_internal(hand, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + + /* If Ni is not missing, then this is a plain gaussian grid and not reduced. */ + /* So it cannot be an octahedral grid */ + if (Ni != GRIB_MISSING_LONG) { + *val = 0; + return GRIB_SUCCESS; + } + + if ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS) + return ret; + if (!plpresent) { + *val = 0; /* Not octahedral */ + return GRIB_SUCCESS; + } + + if ((ret = grib_get_size(hand, self->pl, &plsize)) != GRIB_SUCCESS) + return ret; + Assert(plsize); /* pl array must have at least one element */ + + pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); + if (!pl) { + return GRIB_OUT_OF_MEMORY; + } + if ((ret = grib_get_long_array_internal(hand, self->pl, pl, &plsize)) != GRIB_SUCCESS) + return ret; + + /* pl[0] is guaranteed to exist. Have already asserted previously */ + *val = is_pl_octahedral(pl, plsize); + grib_context_free(c, pl); + + return ret; +} + +int grib_accessor_class_octahedral_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h b/src/accessor/grib_accessor_class_octahedral_gaussian.h new file mode 100644 index 000000000..31784d000 --- /dev/null +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_octahedral_gaussian_h +#define eccodes_accessor_octahedral_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in octahedral_gaussian */ + const char* N; + const char* Ni; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_octahedral_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octahedral_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octahedral_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_octahedral_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_octet_number.cc b/src/accessor/grib_accessor_class_octet_number.cc new file mode 100644 index 000000000..4a4c28ad7 --- /dev/null +++ b/src/accessor/grib_accessor_class_octet_number.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_octet_number.h" + +grib_accessor_class_octet_number_t _grib_accessor_class_octet_number{"octet_number"}; +grib_accessor_class* grib_accessor_class_octet_number = &_grib_accessor_class_octet_number; + + +void grib_accessor_class_octet_number_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_octet_number_t* self = (grib_accessor_octet_number_t*)a; + + int n = 0; + self->left = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->right = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +int grib_accessor_class_octet_number_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_octet_number_t* self = (grib_accessor_octet_number_t*)a; + int ret = GRIB_SUCCESS; + long offset; + + offset = a->offset + self->right; + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->left, offset)) != GRIB_SUCCESS) + return ret; + + *val = offset; + *len = 1; + + return ret; +} + +int grib_accessor_class_octet_number_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_octet_number.h b/src/accessor/grib_accessor_class_octet_number.h new file mode 100644 index 000000000..4d6145742 --- /dev/null +++ b/src/accessor/grib_accessor_class_octet_number.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_octet_number_h +#define eccodes_accessor_octet_number_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_octet_number_t : public grib_accessor_long_t +{ +public: + /* Members defined in octet_number */ + const char* left; + long right; +}; + +class grib_accessor_class_octet_number_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octet_number_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octet_number_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_octet_number_h */ diff --git a/src/accessor/grib_accessor_class_offset_file.cc b/src/accessor/grib_accessor_class_offset_file.cc new file mode 100644 index 000000000..ab9c79a11 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_file.cc @@ -0,0 +1,55 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_offset_file.h" + +grib_accessor_class_offset_file_t _grib_accessor_class_offset_file{"offset_file"}; +grib_accessor_class* grib_accessor_class_offset_file = &_grib_accessor_class_offset_file; + + +void grib_accessor_class_offset_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_offset_file_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + *val = (double)grib_handle_of_accessor(a)->offset; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_offset_file_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + double val = 0; + size_t l = 1; + char repres[1024] = {0,}; + int err = 0; + const char* cclass_name = a->cclass->name; + + err = a->unpack_double(&val, &l); if (err) return err; + + snprintf(repres, sizeof(repres), "%.0f", val); + + l = strlen(repres) + 1; + if (l > *len) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + grib_context_log(a->context, GRIB_LOG_DEBUG, "%s: Casting double %s to string", __func__, a->name); + + *len = l; + + strcpy(v, repres); + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_offset_file.h b/src/accessor/grib_accessor_class_offset_file.h new file mode 100644 index 000000000..34243b5a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_file.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_offset_file_h +#define eccodes_accessor_offset_file_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_file_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_file */ +}; + +class grib_accessor_class_offset_file_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_file_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_file_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_offset_file_h */ diff --git a/src/accessor/grib_accessor_class_offset_values.cc b/src/accessor/grib_accessor_class_offset_values.cc new file mode 100644 index 000000000..bbd0139c9 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_values.cc @@ -0,0 +1,83 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_offset_values.h" + +grib_accessor_class_offset_values_t _grib_accessor_class_offset_values{"offset_values"}; +grib_accessor_class* grib_accessor_class_offset_values = &_grib_accessor_class_offset_values; + + +void grib_accessor_class_offset_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ + int n = 0; + grib_accessor_offset_values_t* self = (grib_accessor_offset_values_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_offset_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int ret = 0; + *val = 0; + *len = 1; + return ret; +} + +int grib_accessor_class_offset_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + double* values = NULL; + size_t size = 0; + double missingValue = 0; + long missingValuesPresent = 0; + int ret = 0, i = 0; + grib_accessor_offset_values_t* self = (grib_accessor_offset_values_t*)a; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val == 0) + return GRIB_SUCCESS; + + if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { + return ret; + } + if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { + return ret; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + for (i = 0; i < size; i++) { + if (missingValuesPresent) { + if (values[i] != missingValue) + values[i] += *val; + } + else { + values[i] += *val; + } + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) + return ret; + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_offset_values.h b/src/accessor/grib_accessor_class_offset_values.h new file mode 100644 index 000000000..51e0f0f16 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_values.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_offset_values_h +#define eccodes_accessor_offset_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_offset_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_offset_values_h */ diff --git a/src/accessor/todo/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc similarity index 54% rename from src/accessor/todo/grib_accessor_class_optimal_step_units.cc rename to src/accessor/grib_accessor_class_optimal_step_units.cc index 261ff4c80..7a4802045 100644 --- a/src/accessor/todo/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,116 +10,16 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_optimal_step_units.h" #include "step.h" #include "step_utilities.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long;unpack_long;dump - IMPLEMENTS = pack_string;unpack_string;dump - IMPLEMENTS = string_length;pack_expression;get_native_type;is_missing - IMPLEMENTS = init - MEMBERS = const char* forecast_time_value - MEMBERS = const char* forecast_time_unit - MEMBERS = const char* time_range_value - MEMBERS = const char* time_range_unit - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_optimal_step_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in optimal_step_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* time_range_value; - const char* time_range_unit; -} grib_accessor_optimal_step_units; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_optimal_step_units = { - &grib_accessor_class_gen, /* super */ - "optimal_step_units", /* name */ - sizeof(grib_accessor_optimal_step_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_optimal_step_units_t _grib_accessor_class_optimal_step_units{"optimal_step_units"}; grib_accessor_class* grib_accessor_class_optimal_step_units = &_grib_accessor_class_optimal_step_units; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_optimal_step_units* self = (grib_accessor_optimal_step_units*)a; +void grib_accessor_class_optimal_step_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -129,18 +30,15 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_optimal_step_units_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_optimal_step_units_t::string_length(grib_accessor* a){ return 255; } -static int pack_expression(grib_accessor* a, grib_expression* e) -{ +int grib_accessor_class_optimal_step_units_t::pack_expression(grib_accessor* a, grib_expression* e){ const char* cval = NULL; int ret = 0; long lval = 0; @@ -150,8 +48,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e) if (strcmp(e->cclass->name, "long") == 0) { grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ - ret = grib_pack_long(a, &lval, &len); - } + ret = a->pack_long(&lval, &len); } else { char tmp[1024]; len = sizeof(tmp); @@ -165,16 +62,14 @@ static int pack_expression(grib_accessor* a, grib_expression* e) len = strlen(cval) + 1; //if (hand->context->debug) // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval); - ret = grib_pack_string(a, cval, &len); - } + ret = a->pack_string(cval, &len); } return ret; } static long staticStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); static long staticForceStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_optimal_step_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); auto supported_units = eccodes::Unit::list_supported_units(); try { @@ -205,15 +100,14 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_optimal_step_units_t::unpack_long(grib_accessor* a, long* val, size_t* len){ try { if (eccodes::Unit{staticStepUnits} != eccodes::Unit{eccodes::Unit::Value::MISSING}) { *val = staticStepUnits; return GRIB_SUCCESS; } - const grib_accessor_optimal_step_units* self = (grib_accessor_optimal_step_units*)a; + const grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); auto forecast_time_opt = get_step(h, self->forecast_time_value, self->forecast_time_unit); @@ -242,8 +136,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_optimal_step_units_t::pack_string(grib_accessor* a, const char* val, size_t* len){ try { long unit = eccodes::Unit{val}.value(); pack_long(a, &unit, len); @@ -263,8 +156,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ +int grib_accessor_class_optimal_step_units_t::unpack_string(grib_accessor* a, char* val, size_t* len){ int ret = 0; long unit = 0; size_t unit_len = 0; @@ -276,12 +168,10 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) // Step units are never missing // If the user does not specify a step unit, we default to hours -static int is_missing(grib_accessor* a) -{ +int grib_accessor_class_optimal_step_units_t::is_missing(grib_accessor* a){ return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_optimal_step_units_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_LONG; } diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h b/src/accessor/grib_accessor_class_optimal_step_units.h new file mode 100644 index 000000000..96383b291 --- /dev/null +++ b/src/accessor/grib_accessor_class_optimal_step_units.h @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_optimal_step_units_h +#define eccodes_accessor_optimal_step_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_optimal_step_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in optimal_step_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* time_range_value; + const char* time_range_unit; +}; + +class grib_accessor_class_optimal_step_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_optimal_step_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_optimal_step_units_t{}; } + int get_native_type(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_optimal_step_units_h */ diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc new file mode 100644 index 000000000..803491932 --- /dev/null +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -0,0 +1,69 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_pack_bufr_values.h" + +grib_accessor_class_pack_bufr_values_t _grib_accessor_class_pack_bufr_values{"pack_bufr_values"}; +grib_accessor_class* grib_accessor_class_pack_bufr_values = &_grib_accessor_class_pack_bufr_values; + + +void grib_accessor_class_pack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ + char* key; + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + + a->length = 0; +} + +void grib_accessor_class_pack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +} + +int grib_accessor_class_pack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +void grib_accessor_class_pack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ +} + +int grib_accessor_class_pack_bufr_values_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_pack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->pack_double(0, 0);} + +int grib_accessor_class_pack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->pack_double(0, 0);} diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h b/src/accessor/grib_accessor_class_pack_bufr_values.h new file mode 100644 index 000000000..b4bdaf43c --- /dev/null +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_pack_bufr_values_h +#define eccodes_accessor_pack_bufr_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in pack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_pack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_pack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_pack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_packing_type.cc b/src/accessor/grib_accessor_class_packing_type.cc new file mode 100644 index 000000000..845400a00 --- /dev/null +++ b/src/accessor/grib_accessor_class_packing_type.cc @@ -0,0 +1,74 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_packing_type.h" + +grib_accessor_class_packing_type_t _grib_accessor_class_packing_type{"packing_type"}; +grib_accessor_class* grib_accessor_class_packing_type = &_grib_accessor_class_packing_type; + + +void grib_accessor_class_packing_type_t::init(grib_accessor* a, const long l, grib_arguments* args){ + int n = 0; + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->packing_type = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +size_t grib_accessor_class_packing_type_t::string_length(grib_accessor* a){ + return 1024; +} + +int grib_accessor_class_packing_type_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_packing_type_t::pack_string(grib_accessor*a, const char* sval, size_t* len){ + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + double* values = NULL; + grib_context* c = a->context; + size_t size = 0; + int err = 0; + + if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return err; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_string_internal(h, self->packing_type, sval, len)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + grib_context_free(c, values); + return GRIB_SUCCESS; +} + +int grib_accessor_class_packing_type_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + return grib_get_string(h, self->packing_type, val, len); +} diff --git a/src/accessor/grib_accessor_class_packing_type.h b/src/accessor/grib_accessor_class_packing_type.h new file mode 100644 index 000000000..3451db189 --- /dev/null +++ b/src/accessor/grib_accessor_class_packing_type.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_packing_type_h +#define eccodes_accessor_packing_type_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_packing_type_t : public grib_accessor_gen_t +{ +public: + /* Members defined in packing_type */ + const char* values; + const char* packing_type; +}; + +class grib_accessor_class_packing_type_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_packing_type_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_packing_type_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_packing_type_h */ diff --git a/src/accessor/grib_accessor_class_pad.cc b/src/accessor/grib_accessor_class_pad.cc new file mode 100644 index 000000000..10ceda53c --- /dev/null +++ b/src/accessor/grib_accessor_class_pad.cc @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_pad.h" + +grib_accessor_class_pad_t _grib_accessor_class_pad{"pad"}; +grib_accessor_class* grib_accessor_class_pad = &_grib_accessor_class_pad; + + + +size_t grib_accessor_class_pad_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_pad_t* self = (grib_accessor_pad_t*)a; + + long length = 0; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &length); + + return length > 0 ? length : 0; +} + + +void grib_accessor_class_pad_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_pad_t* self = (grib_accessor_pad_t*)a; + + self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_pad.h b/src/accessor/grib_accessor_class_pad.h new file mode 100644 index 000000000..8ca8bb09b --- /dev/null +++ b/src/accessor/grib_accessor_class_pad.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_pad_h +#define eccodes_accessor_pad_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_pad_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padding */ + /* Members defined in pad */ + grib_expression* expression; +}; + +class grib_accessor_class_pad_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_pad_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pad_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_pad_h */ diff --git a/src/accessor/grib_accessor_class_padding.cc b/src/accessor/grib_accessor_class_padding.cc new file mode 100644 index 000000000..5a1699124 --- /dev/null +++ b/src/accessor/grib_accessor_class_padding.cc @@ -0,0 +1,58 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +grib_accessor_class_padding_t _grib_accessor_class_padding{"padding"}; +grib_accessor_class* grib_accessor_class_padding = &_grib_accessor_class_padding; + + +void grib_accessor_class_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_padding_t::compare(grib_accessor* a, grib_accessor* b){ + if (a->length != b->length) + return GRIB_COUNT_MISMATCH; + return GRIB_SUCCESS; +} + +void grib_accessor_class_padding_t::update_size(grib_accessor* a, size_t new_size){ + a->length = new_size; +} + +void grib_accessor_class_padding_t::resize(grib_accessor* a, size_t new_size){ + void* zero = grib_context_malloc_clear(a->context, new_size); + + grib_buffer_replace(a, (const unsigned char*)zero, new_size, + /*update_lengths=*/1, /*update_paddings=*/0); + grib_context_free(a->context, zero); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_class_padding::resize new_size=%zu a->length=%ld %s %s", + new_size, a->length, a->cclass->name, a->name); + Assert(new_size == a->length); +} + +int grib_accessor_class_padding_t::value_count(grib_accessor* a, long* c){ + *c = a->length; + return 0; +} + +long grib_accessor_class_padding_t::byte_count(grib_accessor* a){ + return a->length; +} + +size_t grib_accessor_class_padding_t::string_length(grib_accessor* a){ + return (size_t)a->length; +} diff --git a/src/accessor/grib_accessor_class_padding.h b/src/accessor/grib_accessor_class_padding.h new file mode 100644 index 000000000..65a416c4c --- /dev/null +++ b/src/accessor/grib_accessor_class_padding.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padding_h +#define eccodes_accessor_padding_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_padding_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in padding */ +}; + +class grib_accessor_class_padding_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_padding_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padding_t{}; } + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_padding_h */ diff --git a/src/accessor/grib_accessor_class_padto.cc b/src/accessor/grib_accessor_class_padto.cc new file mode 100644 index 000000000..79207c8a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_padto.cc @@ -0,0 +1,45 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_padto.h" + +grib_accessor_class_padto_t _grib_accessor_class_padto{"padto"}; +grib_accessor_class* grib_accessor_class_padto = &_grib_accessor_class_padto; + + + +size_t grib_accessor_class_padto_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padto_t* self = (grib_accessor_padto_t*)a; + + long length = 0; + long theEnd; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &theEnd); + + length = theEnd - a->offset; + + /* printf("preferred_size: prefered: %ld current:%ld %s %s %ld\n", (long)length,(long)a->length,a->cclass->name,a->name,(long)a->offset); */ + + return length > 0 ? length : 0; +} + + +void grib_accessor_class_padto_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_padto_t* self = (grib_accessor_padto_t*)a; + + self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + a->length = preferred_size(a, 1); +} + +void grib_accessor_class_padto_t::dump(grib_accessor* a, grib_dumper* dumper){ + /*grib_dump_string(dumper,a,NULL);*/ +} diff --git a/src/accessor/grib_accessor_class_padto.h b/src/accessor/grib_accessor_class_padto.h new file mode 100644 index 000000000..f7203b2cb --- /dev/null +++ b/src/accessor/grib_accessor_class_padto.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padto_h +#define eccodes_accessor_padto_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padto_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padto */ + grib_expression* expression; +}; + +class grib_accessor_class_padto_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padto_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padto_t{}; } + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padto_h */ diff --git a/src/accessor/grib_accessor_class_padtoeven.cc b/src/accessor/grib_accessor_class_padtoeven.cc new file mode 100644 index 000000000..5d3dfba45 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtoeven.cc @@ -0,0 +1,48 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_padtoeven.h" + +grib_accessor_class_padtoeven_t _grib_accessor_class_padtoeven{"padtoeven"}; +grib_accessor_class* grib_accessor_class_padtoeven = &_grib_accessor_class_padtoeven; + + +size_t grib_accessor_class_padtoeven_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padtoeven_t* self = (grib_accessor_padtoeven_t*)a; + long offset = 0; + long length = 0; + long seclen; + + grib_get_long_internal(grib_handle_of_accessor(a), self->section_offset, &offset); + grib_get_long_internal(grib_handle_of_accessor(a), self->section_length, &length); + + if ((length % 2) && from_handle) { + // grib_context_log(a->context, + // GRIB_LOG_ERROR,"GRIB message has an odd length section (%ld, %s)", + // (long)length,a->name); + return 0; + } + + /* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/ + seclen = a->offset - offset; + + return (seclen % 2) ? 1 : 0; +} + +void grib_accessor_class_padtoeven_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_padtoeven_t* self = (grib_accessor_padtoeven_t*)a; + + self->section_offset = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->section_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_padtoeven.h b/src/accessor/grib_accessor_class_padtoeven.h new file mode 100644 index 000000000..08f8fc072 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtoeven.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padtoeven_h +#define eccodes_accessor_padtoeven_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtoeven_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtoeven */ + const char* section_offset; + const char* section_length; +}; + +class grib_accessor_class_padtoeven_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtoeven_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtoeven_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padtoeven_h */ diff --git a/src/accessor/grib_accessor_class_padtomultiple.cc b/src/accessor/grib_accessor_class_padtomultiple.cc new file mode 100644 index 000000000..3f92f8409 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtomultiple.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_padtomultiple.h" + +grib_accessor_class_padtomultiple_t _grib_accessor_class_padtomultiple{"padtomultiple"}; +grib_accessor_class* grib_accessor_class_padtomultiple = &_grib_accessor_class_padtomultiple; + + +size_t grib_accessor_class_padtomultiple_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padtomultiple_t* self = (grib_accessor_padtomultiple_t*)a; + long padding = 0; + long begin = 0; + long multiple = 0; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->begin, &begin); + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->multiple, &multiple); + + padding = a->offset - begin; + padding = ((padding + multiple - 1) / multiple) * multiple - padding; + + return padding == 0 ? multiple : padding; +} + +void grib_accessor_class_padtomultiple_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_padtomultiple_t* self = (grib_accessor_padtomultiple_t*)a; + + self->begin = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + self->multiple = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_padtomultiple.h b/src/accessor/grib_accessor_class_padtomultiple.h new file mode 100644 index 000000000..f57afad37 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtomultiple.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padtomultiple_h +#define eccodes_accessor_padtomultiple_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtomultiple_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtomultiple */ + grib_expression* begin; + grib_expression* multiple; +}; + +class grib_accessor_class_padtomultiple_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtomultiple_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtomultiple_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padtomultiple_h */ diff --git a/src/accessor/grib_accessor_class_position.cc b/src/accessor/grib_accessor_class_position.cc new file mode 100644 index 000000000..fb00740f3 --- /dev/null +++ b/src/accessor/grib_accessor_class_position.cc @@ -0,0 +1,50 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_position.h" + +grib_accessor_class_position_t _grib_accessor_class_position{"position"}; +grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position; + + +void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +int grib_accessor_class_position_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *val = a->offset; + *len = 1; + return GRIB_SUCCESS; +} + +// static int compare(grib_accessor* a, grib_accessor* b) +// { +// if (a->offset != b->offset) +// return GRIB_OFFSET_MISMATCH; +// return GRIB_SUCCESS; +// } diff --git a/src/accessor/grib_accessor_class_position.h b/src/accessor/grib_accessor_class_position.h new file mode 100644 index 000000000..40d690694 --- /dev/null +++ b/src/accessor/grib_accessor_class_position.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_position_h +#define eccodes_accessor_position_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_position_t : public grib_accessor_gen_t +{ +public: + /* Members defined in position */ +}; + +class grib_accessor_class_position_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_position_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_position_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_position_h */ diff --git a/src/accessor/todo/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc similarity index 67% rename from src/accessor/todo/grib_accessor_class_proj_string.cc rename to src/accessor/grib_accessor_class_proj_string.cc index 7edfbf5be..ab03465fb 100644 --- a/src/accessor/todo/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,101 +10,14 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = unpack_string - MEMBERS = const char* grid_type - MEMBERS = int endpoint - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_proj_string -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in proj_string */ - const char* grid_type; - int endpoint; -} grib_accessor_proj_string; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_proj_string = { - &grib_accessor_class_gen, /* super */ - "proj_string", /* name */ - sizeof(grib_accessor_proj_string), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_proj_string.h" +grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{"proj_string"}; grib_accessor_class* grib_accessor_class_proj_string = &_grib_accessor_class_proj_string; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_proj_string* self = (grib_accessor_proj_string*)a; +void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; grib_handle* h = grib_handle_of_accessor(a); self->grid_type = grib_arguments_get_name(h, arg, 0); @@ -113,8 +27,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } @@ -128,8 +41,7 @@ struct proj_mapping typedef struct proj_mapping proj_mapping; // This should only be called for GRID POINT data (not spherical harmonics etc) -static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor) -{ +int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ int err = 0; if (grib_is_earth_oblate(h)) { if ((err = grib_get_double_internal(h, "earthMinorAxisInMetres", pMinor)) != GRIB_SUCCESS) return err; @@ -144,8 +56,7 @@ static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor) } // Caller must have allocated enough space in the 'result' argument -static int get_earth_shape(grib_handle* h, char* result) -{ +int get_earth_shape(grib_handle* h, char* result){ int err = 0; double major = 0, minor = 0; if ((err = get_major_minor_axes(h, &major, &minor)) != GRIB_SUCCESS) @@ -157,8 +68,7 @@ static int get_earth_shape(grib_handle* h, char* result) return err; } -static int proj_space_view(grib_handle* h, char* result) -{ +int proj_space_view(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; // int err = 0; // char shape[128] = {0,}; @@ -174,21 +84,17 @@ static int proj_space_view(grib_handle* h, char* result) // return err; } -static int proj_albers(grib_handle* h, char* result) -{ +int proj_albers(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -static int proj_transverse_mercator(grib_handle* h, char* result) -{ +int proj_transverse_mercator(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result) -{ +int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -static int proj_lambert_conformal(grib_handle* h, char* result) -{ +int proj_lambert_conformal(grib_handle* h, char* result){ int err = 0; char shape[128] = {0,}; double LoVInDegrees = 0, LaDInDegrees = 0, Latin1InDegrees = 0, Latin2InDegrees = 0; @@ -208,8 +114,7 @@ static int proj_lambert_conformal(grib_handle* h, char* result) return err; } -static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result) -{ +int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ int err = 0; char shape[128] = {0,}; double standardParallel = 0, centralLongitude = 0; @@ -225,8 +130,7 @@ static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result) return err; } -static int proj_polar_stereographic(grib_handle* h, char* result) -{ +int proj_polar_stereographic(grib_handle* h, char* result){ int err = 0; double centralLongitude = 0, centralLatitude = 0; int has_northPole = 0; @@ -249,8 +153,7 @@ static int proj_polar_stereographic(grib_handle* h, char* result) // ECC-1552: This is for regular_ll, regular_gg, reduced_ll, reduced_gg // These are not 'projected' grids! -static int proj_unprojected(grib_handle* h, char* result) -{ +int proj_unprojected(grib_handle* h, char* result){ int err = 0; //char shape[128] = {0,}; //if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; @@ -260,8 +163,7 @@ static int proj_unprojected(grib_handle* h, char* result) return err; } -static int proj_mercator(grib_handle* h, char* result) -{ +int proj_mercator(grib_handle* h, char* result){ int err = 0; double LaDInDegrees = 0; char shape[128] = {0,}; @@ -293,9 +195,8 @@ static proj_mapping proj_mappings[] = { #define ENDPOINT_SOURCE 0 #define ENDPOINT_TARGET 1 -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_proj_string* self = (grib_accessor_proj_string*)a; +int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; int err = 0, found = 0; size_t i = 0; char grid_type[64] = {0,}; diff --git a/src/accessor/grib_accessor_class_proj_string.h b/src/accessor/grib_accessor_class_proj_string.h new file mode 100644 index 000000000..c49c0f868 --- /dev/null +++ b/src/accessor/grib_accessor_class_proj_string.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_proj_string_h +#define eccodes_accessor_proj_string_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_proj_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in proj_string */ + const char* grid_type; + int endpoint; +}; + +class grib_accessor_class_proj_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_proj_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_proj_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_proj_string_h */ diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc new file mode 100644 index 000000000..310d887e3 --- /dev/null +++ b/src/accessor/grib_accessor_class_raw.cc @@ -0,0 +1,117 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_raw.h" + +grib_accessor_class_raw_t _grib_accessor_class_raw{"raw"}; +grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; + + +void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + int n = 0; + int err = 0; + long sectionLength; + grib_accessor_raw_t* self = (grib_accessor_raw_t*)a; + grib_expression* e; + grib_handle* hand = grib_handle_of_accessor(a); + + a->length = 0; + self->totalLength = grib_arguments_get_name(hand, arg, n++); + self->sectionLength = grib_arguments_get_name(hand, arg, n++); + + e = grib_arguments_get_expression(hand, arg, n++); + err = grib_expression_evaluate_long(hand, e, &(self->relativeOffset)); + if (err) + grib_context_log(hand->context, GRIB_LOG_ERROR, "Unable to evaluate relativeOffset"); + + grib_get_long(hand, self->sectionLength, §ionLength); + + a->length = sectionLength - self->relativeOffset; + if (a->length < 0) + a->length = 0; + + /* Assert(a->length>=0); */ +} + +int grib_accessor_class_raw_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + + +int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + + size_t alen = (size_t)a->byte_count(); size_t blen = (size_t)b->byte_count(); + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + return retval; +} + +long grib_accessor_class_raw_t::byte_count(grib_accessor* a){ + return a->length; +} + +int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len){ + *len = a->length; + return 0; +} + +int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ + if (*len < a->length) { + *len = a->length; + return GRIB_ARRAY_TOO_SMALL; + } + *len = a->length; + + memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); + + return GRIB_SUCCESS; +} + +void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s){ + grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); + a->length = s; + Assert(a->length >= 0); +} + +void accessor_raw_set_length(grib_accessor* a, size_t len) +{ + a->length = len; +} + +long accessor_raw_get_offset(grib_accessor* a) +{ + return a->offset; +} + +int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len){ + size_t length = *len; + long totalLength; + long sectionLength; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_raw_t* self = (grib_accessor_raw_t*)a; + long dlen = length - a->length; + + grib_get_long(h, self->totalLength, &totalLength); + totalLength += dlen; + grib_get_long(h, self->sectionLength, §ionLength); + sectionLength += dlen; + + grib_buffer_replace(a, val, length, 1, 1); + + grib_set_long(h, self->totalLength, totalLength); + grib_set_long(h, self->sectionLength, sectionLength); + a->length = length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_raw.h b/src/accessor/grib_accessor_class_raw.h new file mode 100644 index 000000000..30a2603e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_raw.h @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_raw_h +#define eccodes_accessor_raw_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_raw_t : public grib_accessor_gen_t +{ +public: + /* Members defined in raw */ + const char* totalLength; + const char* sectionLength; + long relativeOffset; +}; + +class grib_accessor_class_raw_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_raw_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_raw_t{}; } + int get_native_type(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_raw_h */ diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc new file mode 100644 index 000000000..346288ad2 --- /dev/null +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -0,0 +1,76 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_rdbtime_guess_date.h" + +grib_accessor_class_rdbtime_guess_date_t _grib_accessor_class_rdbtime_guess_date{"rdbtime_guess_date"}; +grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date; + + +void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; + int n = 0; + + self->typicalYear = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->typicalMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->typicalDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->rdbDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->yearOrMonth = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ +} + +int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + long typicalYear, typicalMonth, typicalDay, rdbDay; + long rdbYear, rdbMonth; + + ret = grib_get_long(h, self->typicalYear, &typicalYear); + if (ret) + return ret; + ret = grib_get_long(h, self->typicalMonth, &typicalMonth); + if (ret) + return ret; + ret = grib_get_long(h, self->typicalDay, &typicalDay); + if (ret) + return ret; + ret = grib_get_long(h, self->rdbDay, &rdbDay); + if (ret) + return ret; + + if (rdbDay < typicalDay) { + if (typicalDay == 31 && typicalMonth == 12) { + rdbYear = typicalYear + 1; + rdbMonth = 1; + } + else { + rdbYear = typicalYear; + rdbMonth = typicalMonth + 1; + } + } + else { + rdbYear = typicalYear; + rdbMonth = typicalMonth; + } + + *val = self->yearOrMonth == 1 ? rdbYear : rdbMonth; + *len = 1; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len){ + /* do nothing*/ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h b/src/accessor/grib_accessor_class_rdbtime_guess_date.h new file mode 100644 index 000000000..e9ef0b4d3 --- /dev/null +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_rdbtime_guess_date_h +#define eccodes_accessor_rdbtime_guess_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in rdbtime_guess_date */ + const char* typicalYear; + const char* typicalMonth; + const char* typicalDay; + const char* rdbDay; + long yearOrMonth; +}; + +class grib_accessor_class_rdbtime_guess_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_rdbtime_guess_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_rdbtime_guess_date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_rdbtime_guess_date_h */ diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc new file mode 100644 index 000000000..8d4f3a1cc --- /dev/null +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -0,0 +1,50 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_reference_value_error.h" + +grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{"reference_value_error"}; +grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error; + + +void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; + int n = 0; + + self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; + int ret = 0; + double referenceValue = 0; + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), + self->referenceValue, &referenceValue)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(self->floatType, "ibm")) + *val = grib_ibmfloat_error(referenceValue); + else if (!strcmp(self->floatType, "ieee")) + *val = grib_ieeefloat_error(referenceValue); + else + Assert(1 == 0); + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_reference_value_error.h b/src/accessor/grib_accessor_class_reference_value_error.h new file mode 100644 index 000000000..e0b948e97 --- /dev/null +++ b/src/accessor/grib_accessor_class_reference_value_error.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_reference_value_error_h +#define eccodes_accessor_reference_value_error_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_reference_value_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in reference_value_error */ + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_reference_value_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_reference_value_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_reference_value_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_reference_value_error_h */ diff --git a/src/accessor/grib_accessor_class_round.cc b/src/accessor/grib_accessor_class_round.cc new file mode 100644 index 000000000..b1a114d0e --- /dev/null +++ b/src/accessor/grib_accessor_class_round.cc @@ -0,0 +1,69 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_round.h" + +grib_accessor_class_round_t _grib_accessor_class_round{"round"}; +grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round; + + +int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_round_t* self = (grib_accessor_round_t*)a; + + int ret = GRIB_SUCCESS; + + size_t replen = 0; + double rounding_precision = 0; + double rounded = 0; + double toround = 0; + + const char* oval = NULL; + oval = grib_arguments_get_name(grib_handle_of_accessor(a), self->arg, 0); + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), oval, &toround)) != 0) + return ret; + + rounding_precision = grib_arguments_get_long(grib_handle_of_accessor(a), self->arg, 1); + + rounded = floor(rounding_precision * toround + 0.5) / rounding_precision; + + *len = replen; + + *val = rounded; + + return ret; +} + +int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + char result[1024]; + int ret = GRIB_SUCCESS; + size_t replen = 1; + + double value = 0; + + ret = unpack_double(a, &value, &replen); + + snprintf(result, sizeof(result), "%.3f", value); + + replen = strlen(result) + 1; + + if (*len < replen) { + *len = replen; + return GRIB_ARRAY_TOO_SMALL; + } + + *len = replen; + + snprintf(val, 1024, "%s", result); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_round.h b/src/accessor/grib_accessor_class_round.h new file mode 100644 index 000000000..c38d7b6e8 --- /dev/null +++ b/src/accessor/grib_accessor_class_round.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_round_h +#define eccodes_accessor_round_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_evaluate.h" + +class grib_accessor_round_t : public grib_accessor_evaluate_t +{ +public: + /* Members defined in round */ +}; + +class grib_accessor_class_round_t : public grib_accessor_class_evaluate_t +{ +public: + grib_accessor_class_round_t(const char* name) : grib_accessor_class_evaluate_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_round_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; +#endif /* eccodes_accessor_round_h */ diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc new file mode 100644 index 000000000..a90f31862 --- /dev/null +++ b/src/accessor/grib_accessor_class_scale.cc @@ -0,0 +1,134 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_scale.h" + +grib_accessor_class_scale_t _grib_accessor_class_scale{"scale"}; +grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; + + +void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int n = 0; + + self->value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->multiplier = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->divisor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int ret = 0; + long value = 0; + long multiplier = 0; + long divisor = 0; + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s cannot gather value for %s and/or %s", + a->name, self->multiplier, self->divisor); + return ret; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->value, &value)) != GRIB_SUCCESS) + return ret; + + if (value == GRIB_MISSING_LONG) + *val = GRIB_MISSING_DOUBLE; + else + *val = ((double)(value * multiplier)) / divisor; + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} + +int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const double dval = (double)*val; + return pack_double(a, &dval, len); +} + +int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int ret = 0; + + long value = 0; + long divisor = 0; + long multiplier = 0; + long truncating = 0; + double x; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor); + if (ret != GRIB_SUCCESS) return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier); + if (ret != GRIB_SUCCESS) return ret; + + if (self->truncating) { + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->truncating, &truncating); + if (ret != GRIB_SUCCESS) return ret; + } + + if (multiplier == 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s: cannot divide by a zero multiplier %s", + a->name, self->multiplier); + return GRIB_ENCODING_ERROR; + } + + x = *val * (double)divisor / (double)multiplier; + if (*val == GRIB_MISSING_DOUBLE) + value = GRIB_MISSING_LONG; + else if (truncating) { + value = (long)x; + } + else { + value = x > 0 ? (long)(x + 0.5) : (long)(x - 0.5); + } + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->value, value); + if (ret) + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s: cannot pack value for %s (%s)\n", + a->name, self->value, grib_get_error_message(ret)); + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} + +int grib_accessor_class_scale_t::is_missing(grib_accessor* a){ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); + + if (!av) + return GRIB_NOT_FOUND; + return av->is_missing_internal(); + // int ret=0; + // long value=0; + // if((ret = grib_get_long_internal(grib_handle_of_accessor(a),self->value, &value))!= GRIB_SUCCESS){ + // grib_context_log(a->context, GRIB_LOG_ERROR, + // "Accessor %s cannot gather value for %s error %d \n", a->name, + // self->value, ret); + // return 0; + // } + // return (value == GRIB_MISSING_LONG); +} diff --git a/src/accessor/grib_accessor_class_scale.h b/src/accessor/grib_accessor_class_scale.h new file mode 100644 index 000000000..7e1f0d80d --- /dev/null +++ b/src/accessor/grib_accessor_class_scale.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_scale_h +#define eccodes_accessor_scale_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale */ + const char* value; + const char* multiplier; + const char* divisor; + const char* truncating; +}; + +class grib_accessor_class_scale_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_scale_h */ diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc new file mode 100644 index 000000000..0496bd1e4 --- /dev/null +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -0,0 +1,85 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_scale_values.h" + +grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{"scale_values"}; +grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values; + + +void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ + int n = 0; + grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int ret = 0; + *val = 1; + *len = 1; + return ret; +} + +int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + double* values = NULL; + double missingValue = 0; + long missingValuesPresent = 0; + size_t size = 0; + int ret = 0, i = 0; + grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; + const grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val == 1) + return GRIB_SUCCESS; + + if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { + return ret; + } + if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { + return ret; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + for (i = 0; i < size; i++) { + if (missingValuesPresent) { + if (values[i] != missingValue) + values[i] *= *val; + } + else { + values[i] *= *val; + } + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_scale_values.h b/src/accessor/grib_accessor_class_scale_values.h new file mode 100644 index 000000000..cb94e16b8 --- /dev/null +++ b/src/accessor/grib_accessor_class_scale_values.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_scale_values_h +#define eccodes_accessor_scale_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_scale_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_scale_values_h */ diff --git a/src/accessor/todo/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_second_order_bits_per_value.cc rename to src/accessor/grib_accessor_class_second_order_bits_per_value.cc index 74c4b4c05..a42496716 100644 --- a/src/accessor/todo/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,108 +9,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/********************************** - * Enrico Fucile - **********************************/ - -#include "grib_scaling.h" #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* binaryScaleFactor - MEMBERS = const char* decimalScaleFactor - MEMBERS = long bitsPerValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_second_order_bits_per_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in second_order_bits_per_value */ - const char* values; - const char* binaryScaleFactor; - const char* decimalScaleFactor; - long bitsPerValue; -} grib_accessor_second_order_bits_per_value; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_second_order_bits_per_value = { - &grib_accessor_class_long, /* super */ - "second_order_bits_per_value", /* name */ - sizeof(grib_accessor_second_order_bits_per_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_second_order_bits_per_value.h" +#include "grib_scaling.h" +grib_accessor_class_second_order_bits_per_value_t _grib_accessor_class_second_order_bits_per_value{"second_order_bits_per_value"}; grib_accessor_class* grib_accessor_class_second_order_bits_per_value = &_grib_accessor_class_second_order_bits_per_value; -/* END_CLASS_IMP */ static const size_t nbits[64] = { 0x1, 0x2, 0x4, 0x8, @@ -130,8 +36,7 @@ static const size_t nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -static int number_of_bits(size_t x, long* result) -{ +int number_of_bits(size_t x, long* result){ const size_t* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); *result = 0; @@ -145,10 +50,9 @@ static int number_of_bits(size_t x, long* result) return GRIB_SUCCESS; } -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ +void grib_accessor_class_second_order_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ int n = 0; - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->binaryScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->decimalScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -157,17 +61,15 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; +int grib_accessor_class_second_order_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; self->bitsPerValue = (long)*val; *len = 1; return 0; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_second_order_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int ret = GRIB_SUCCESS; size_t size = 0; size_t i; @@ -175,7 +77,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) double* values = 0; long binaryScaleFactor, decimalScaleFactor; - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; if (self->bitsPerValue) { *val = self->bitsPerValue; return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h b/src/accessor/grib_accessor_class_second_order_bits_per_value.h new file mode 100644 index 000000000..370b364dd --- /dev/null +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_second_order_bits_per_value_h +#define eccodes_accessor_second_order_bits_per_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in second_order_bits_per_value */ + const char* values; + const char* binaryScaleFactor; + const char* decimalScaleFactor; + long bitsPerValue; +}; + +class grib_accessor_class_second_order_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_second_order_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_second_order_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_second_order_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc new file mode 100644 index 000000000..b6222a551 --- /dev/null +++ b/src/accessor/grib_accessor_class_section.cc @@ -0,0 +1,95 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_section.h" + +grib_accessor_class_section_t _grib_accessor_class_section{"section"}; +grib_accessor_class* grib_accessor_class_section = &_grib_accessor_class_section; + + +void grib_accessor_class_section_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->sub_section = grib_section_create(grib_handle_of_accessor(a), a); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_section_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_section(dumper, a, a->sub_section->block); +} + +long grib_accessor_class_section_t::byte_count(grib_accessor* a){ + if (!a->length || grib_handle_of_accessor(a)->loader) { + if (a->name[1] == '_') + return 0; + + /* printf("adjusting sizes SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ + grib_section_adjust_sizes(a->sub_section, grib_handle_of_accessor(a)->loader != NULL, 0); + /* printf(" SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ + } + + /* printf("SECTION %s is %ld %d\n",a->name,a->length,a->sub_section->aclength != NULL); */ + return a->length; +} + +long grib_accessor_class_section_t::next_offset(grib_accessor* a){ + return a->offset + byte_count(a); +} + +void grib_accessor_class_section_t::destroy(grib_context* ct, grib_accessor* a){ + grib_section_delete(ct, a->sub_section); +} + +int grib_accessor_class_section_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_SECTION; +} + +static grib_section* sub_section(grib_accessor* a) +{ + return a->sub_section; +} + +void grib_accessor_class_section_t::update_size(grib_accessor* a, size_t length){ + size_t size = 1; + long len = length; + Assert(length <= 0x7fffffff); + if (a->sub_section->aclength) { + int e = a->sub_section->aclength->pack_long(&len, &size); Assert(e == GRIB_SUCCESS); + // printf("update_length %s %ld %ld\n", a->sub_section->aclength->name, + // (long)a->sub_section->aclength->offset, + // (long)a->sub_section->aclength->length); + } + + a->sub_section->length = a->length = length; + a->sub_section->padding = 0; + + // printf("update_size %s %ld\n", a->name, a->length); + + Assert(a->length >= 0); +} + +static grib_accessor* next(grib_accessor* a, int explore) +{ + grib_accessor* next = NULL; + if (explore) { + next = a->sub_section->block->first; + if (!next) + next = a->next; + } + else { + next = a->next; + } + if (!next) { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} diff --git a/src/accessor/grib_accessor_class_section.h b/src/accessor/grib_accessor_class_section.h new file mode 100644 index 000000000..b755b8b27 --- /dev/null +++ b/src/accessor/grib_accessor_class_section.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_h +#define eccodes_accessor_section_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_t : public grib_accessor_gen_t +{ +public: + /* Members defined in section */ +}; + +class grib_accessor_class_section_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_t{}; } + int get_native_type(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_section_h */ diff --git a/src/accessor/grib_accessor_class_section_length.cc b/src/accessor/grib_accessor_class_section_length.cc new file mode 100644 index 000000000..4d78f5f19 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_length.cc @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_section_length.h" + +grib_accessor_class_section_length_t _grib_accessor_class_section_length{"section_length"}; +grib_accessor_class* grib_accessor_class_section_length = &_grib_accessor_class_section_length; + + +void grib_accessor_class_section_length_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->parent->aclength = a; + a->length = len; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + Assert(a->length >= 0); +} + +void grib_accessor_class_section_length_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_section_length_t::value_count(grib_accessor* a, long* c){ + *c = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_section_length.h b/src/accessor/grib_accessor_class_section_length.h new file mode 100644 index 000000000..09490bebd --- /dev/null +++ b/src/accessor/grib_accessor_class_section_length.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_length_h +#define eccodes_accessor_section_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_section_length_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in section_length */ +}; + +class grib_accessor_class_section_length_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_section_length_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_length_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_section_length_h */ diff --git a/src/accessor/grib_accessor_class_section_padding.cc b/src/accessor/grib_accessor_class_section_padding.cc new file mode 100644 index 000000000..53cd22c06 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_padding.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_section_padding.h" + +grib_accessor_class_section_padding_t _grib_accessor_class_section_padding{"section_padding"}; +grib_accessor_class* grib_accessor_class_section_padding = &_grib_accessor_class_section_padding; + + +size_t grib_accessor_class_section_padding_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_section_padding_t* self = (grib_accessor_section_padding_t*)a; + grib_accessor* b = a; + grib_accessor* section_length = 0; + long length = 0; + size_t size = 1; + + long alength = 0; + + if (!from_handle) { + if (self->preserve) + return a->length; + else + return 0; + } + + /* The section length should be a parameter */ + while (section_length == NULL && b != NULL) { + section_length = b->parent->aclength; + b = b->parent->owner; + } + + if (!section_length) { + /* printf("PADDING is no !section_length\n"); */ + return 0; + } + + if (section_length->unpack_long(&length, &size) == GRIB_SUCCESS) { + if (length) + alength = length - a->offset + section_length->parent->owner->offset; + else + alength = 0; + + /*Assert(a->length>=0);*/ + + if (alength < 0) + alength = 0; + + /* printf("PADDING is %ld\n",a->length); */ + } + else { + /* printf("PADDING unpack fails\n"); */ + } + + return alength; +} + +void grib_accessor_class_section_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_section_padding_t* self = (grib_accessor_section_padding_t*)a; + self->preserve = 1; /* This should be a parameter */ + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_section_padding.h b/src/accessor/grib_accessor_class_section_padding.h new file mode 100644 index 000000000..b6fce7f34 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_padding.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_padding_h +#define eccodes_accessor_section_padding_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_section_padding_t : public grib_accessor_padding_t +{ +public: + /* Members defined in section_padding */ + int preserve; +}; + +class grib_accessor_class_section_padding_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_section_padding_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_padding_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_section_padding_h */ diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc new file mode 100644 index 000000000..553deb30f --- /dev/null +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -0,0 +1,97 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_section_pointer.h" + +grib_accessor_class_section_pointer_t _grib_accessor_class_section_pointer{"section_pointer"}; +grib_accessor_class* grib_accessor_class_section_pointer = &_grib_accessor_class_section_pointer; + + +void grib_accessor_class_section_pointer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + int n = 0; + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + + self->sectionOffset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->sectionLength = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->sectionNumber = grib_arguments_get_long(grib_handle_of_accessor(a), arg, n++); + + Assert(self->sectionNumber < MAX_NUM_SECTIONS); + + grib_handle_of_accessor(a)->section_offset[self->sectionNumber] = (char*)self->sectionOffset; + grib_handle_of_accessor(a)->section_length[self->sectionNumber] = (char*)self->sectionLength; + + /* printf("++++++++++++++ GRIB_API: creating section_pointer%d %s %s\n", */ + /* self->sectionNumber,self->sectionLength,self->sectionLength); */ + + if (grib_handle_of_accessor(a)->sections_count < self->sectionNumber) + grib_handle_of_accessor(a)->sections_count = self->sectionNumber; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->length = 0; +} + +int grib_accessor_class_section_pointer_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_section_pointer_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + /* + unsigned char* p=NULL; + char* s=v; + int i; + long length=a->byte_count(); + if (*len < length) return GRIB_ARRAY_TOO_SMALL; + + p = grib_handle_of_accessor(a)->buffer->data + a->byte_offset(); + for (i = 0; i < length; i++) { + snprintf (s,64,"%02x", *(p++)); + s+=2; + } + *len=length; + */ + snprintf(v, 64, "%ld_%ld", a->byte_offset(), a->byte_count()); return GRIB_SUCCESS; +} + +long grib_accessor_class_section_pointer_t::byte_count(grib_accessor* a){ + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + long sectionLength = 0; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->sectionLength, §ionLength); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to get %s %s", + self->sectionLength, grib_get_error_message(ret)); + return -1; + } + + return sectionLength; +} + +long grib_accessor_class_section_pointer_t::byte_offset(grib_accessor* a){ + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + long sectionOffset = 0; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->sectionOffset, §ionOffset); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to get %s %s", + self->sectionOffset, grib_get_error_message(ret)); + return -1; + } + + return sectionOffset; +} diff --git a/src/accessor/grib_accessor_class_section_pointer.h b/src/accessor/grib_accessor_class_section_pointer.h new file mode 100644 index 000000000..45e77fbb9 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_pointer.h @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_pointer_h +#define eccodes_accessor_section_pointer_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_pointer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in section_pointer */ + const char* sectionOffset; + const char* sectionLength; + long sectionNumber; +}; + +class grib_accessor_class_section_pointer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_pointer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_pointer_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_section_pointer_h */ diff --git a/src/accessor/todo/grib_accessor_class_select_step_template.cc b/src/accessor/grib_accessor_class_select_step_template.cc similarity index 60% rename from src/accessor/todo/grib_accessor_class_select_step_template.cc rename to src/accessor/grib_accessor_class_select_step_template.cc index 7a0e76c23..fd4578d41 100644 --- a/src/accessor/todo/grib_accessor_class_select_step_template.cc +++ b/src/accessor/grib_accessor_class_select_step_template.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,107 +10,14 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_select_step_template.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=int instant - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_select_step_template -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in select_step_template */ - const char* productDefinitionTemplateNumber; - int instant; -} grib_accessor_select_step_template; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_select_step_template = { - &grib_accessor_class_unsigned, /* super */ - "select_step_template", /* name */ - sizeof(grib_accessor_select_step_template), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_select_step_template_t _grib_accessor_class_select_step_template{"select_step_template"}; grib_accessor_class* grib_accessor_class_select_step_template = &_grib_accessor_class_select_step_template; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_select_step_template* self = (grib_accessor_select_step_template*)a; +void grib_accessor_class_select_step_template_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_select_step_template_t* self = (grib_accessor_select_step_template_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -117,15 +25,13 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->instant = grib_arguments_get_long(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_select_step_template_t::unpack_long(grib_accessor* a, long* val, size_t* len){ *val = 1; return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_select_step_template* self = (grib_accessor_select_step_template*)a; +int grib_accessor_class_select_step_template_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_select_step_template_t* self = (grib_accessor_select_step_template_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = 0; long productDefinitionTemplateNumberNew = 0; @@ -266,8 +172,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* c) -{ +int grib_accessor_class_select_step_template_t::value_count(grib_accessor* a, long* c){ *c = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_select_step_template.h b/src/accessor/grib_accessor_class_select_step_template.h new file mode 100644 index 000000000..a83d3ddfd --- /dev/null +++ b/src/accessor/grib_accessor_class_select_step_template.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_select_step_template_h +#define eccodes_accessor_select_step_template_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in select_step_template */ + const char* productDefinitionTemplateNumber; + int instant; +}; + +class grib_accessor_class_select_step_template_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_select_step_template_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_select_step_template_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_select_step_template_h */ diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc new file mode 100644 index 000000000..7b3a7dbfb --- /dev/null +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc @@ -0,0 +1,146 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_sexagesimal2decimal.h" + +grib_accessor_class_sexagesimal2decimal_t _grib_accessor_class_sexagesimal2decimal{"sexagesimal2decimal"}; +grib_accessor_class* grib_accessor_class_sexagesimal2decimal = &_grib_accessor_class_sexagesimal2decimal; + + +void grib_accessor_class_sexagesimal2decimal_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_sexagesimal2decimal_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_double(dumper, a, NULL); +} + +int grib_accessor_class_sexagesimal2decimal_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} + +int grib_accessor_class_sexagesimal2decimal_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + int err = 0; + grib_accessor_sexagesimal2decimal_t* self = (grib_accessor_sexagesimal2decimal_t*)a; + char buff[512] = {0,}; + size_t length = 0; + size_t size = 512; + char* p; + char* q; + double dd, mm = 0, ss = 0; + int dd_sign = 1; + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + q = buff + self->start; + if (self->length) + q[length] = 0; + p = q; + + while (*p != '-' && *p != ':' && *p != ' ' && *p != 0) { + p++; + } + + if (*p == 0) { + return GRIB_WRONG_CONVERSION; + } + *p = 0; + + dd = atoi(q); + p++; + q = p; + while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { + p++; + } + switch (*p) { + case ' ': + case '-': + case ':': + *p = 0; + mm = atoi(q) / 60.0; + dd += mm; + p++; + q = p; + break; + case 'N': + case 'E': + *p = 0; + dd_sign = 1; + mm = atoi(q) / 60.0; + dd += mm; + p++; + q = p; + break; + case 'S': + case 'W': + *p = 0; + mm = atoi(q) / 60.0; + dd += mm; + dd_sign = -1; + p++; + q = p; + break; + case 0: + break; + default: + return GRIB_WRONG_CONVERSION; + } + if (*p) { + while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { + p++; + } + switch (*p) { + case ' ': + case '-': + case ':': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + break; + case 'N': + case 'E': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + dd_sign = 1; + break; + case 'S': + case 'W': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + dd_sign = -1; + break; + case 0: + break; + default: + return GRIB_WRONG_CONVERSION; + } + } + dd *= dd_sign; + + snprintf(buff, sizeof(buff), "%.2f", dd); + length = strlen(buff); + + if (len[0] < length + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + strcpy(val, buff); + + len[0] = length; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h b/src/accessor/grib_accessor_class_sexagesimal2decimal.h new file mode 100644 index 000000000..c9009293e --- /dev/null +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sexagesimal2decimal_h +#define eccodes_accessor_sexagesimal2decimal_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_to_double.h" + +class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t +{ +public: + /* Members defined in sexagesimal2decimal */ +}; + +class grib_accessor_class_sexagesimal2decimal_t : public grib_accessor_class_to_double_t +{ +public: + grib_accessor_class_sexagesimal2decimal_t(const char* name) : grib_accessor_class_to_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sexagesimal2decimal_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sexagesimal2decimal_h */ diff --git a/src/accessor/todo/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc similarity index 51% rename from src/accessor/todo/grib_accessor_class_signed.cc rename to src/accessor/grib_accessor_class_signed.cc index 3439934e1..ac2f7757c 100644 --- a/src/accessor/todo/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,129 +10,25 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_signed.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size; is_missing - MEMBERS = grib_arguments* arg - MEMBERS = int nbytes; - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_signed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in signed */ - grib_arguments* arg; - int nbytes; -} grib_accessor_signed; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_signed = { - &grib_accessor_class_long, /* super */ - "signed", /* name */ - sizeof(grib_accessor_signed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_signed_t _grib_accessor_class_signed{"signed"}; grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; +void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; long count = 0; self->arg = arg; - grib_value_count(a, &count); - a->length = len * count; + a->value_count(&count); a->length = len * count; self->nbytes = len; Assert(a->length >= 0); } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper){ long rlen = 0; - grib_value_count(a, &rlen); - if (rlen == 1) + a->value_count(&rlen); if (rlen == 1) grib_dump_long(dumper, a, NULL); else grib_dump_values(dumper, a); @@ -145,9 +42,8 @@ static const long ones[] = { -0x7fffffff, }; -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; +int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; unsigned long rlen = 0; int err = 0; long count = 0; @@ -156,8 +52,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) long pos = a->offset; long missing = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; rlen = count; @@ -184,9 +79,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; +int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; int ret = 0; long off = 0; unsigned long rlen = 0; @@ -197,8 +91,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) unsigned long i = 0; long missing = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; rlen = count; @@ -237,7 +130,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) if (ret == GRIB_SUCCESS) len[0] = 1; if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_signed : Trying to pack %d values in a scalar %s, packing first value", *len, a->name); + grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_signed_t : Trying to pack %d values in a scalar %s, packing first value", *len, a->name); len[0] = 1; return ret; } @@ -263,14 +156,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; } -static long byte_count(grib_accessor* a) -{ +long grib_accessor_class_signed_t::byte_count(grib_accessor* a){ return a->length; } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; +int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len){ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; *len = 0; if (!self->arg) { *len = 1; @@ -279,24 +170,19 @@ static int value_count(grib_accessor* a, long* len) return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -static long byte_offset(grib_accessor* a) -{ +long grib_accessor_class_signed_t::byte_offset(grib_accessor* a){ return a->offset; } -static void update_size(grib_accessor* a, size_t s) -{ +void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s){ a->length = s; Assert(a->length >= 0); } -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} +long grib_accessor_class_signed_t::next_offset(grib_accessor* a){ + return a->byte_offset() + a->byte_count();} -static int is_missing(grib_accessor* a) -{ +int grib_accessor_class_signed_t::is_missing(grib_accessor* a){ int i = 0; unsigned char ff = 0xff; unsigned long offset = a->offset; diff --git a/src/accessor/grib_accessor_class_signed.h b/src/accessor/grib_accessor_class_signed.h new file mode 100644 index 000000000..23c9829a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_signed_h +#define eccodes_accessor_signed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed */ + grib_arguments* arg; + int nbytes; +}; + +class grib_accessor_class_signed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_t{}; } + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_signed_h */ diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc new file mode 100644 index 000000000..85a764628 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -0,0 +1,152 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_signed_bits.h" + +grib_accessor_class_signed_bits_t _grib_accessor_class_signed_bits{"signed_bits"}; +grib_accessor_class* grib_accessor_class_signed_bits = &_grib_accessor_class_signed_bits; + + +long grib_accessor_class_signed_bits_t::byte_count(grib_accessor* a){ + return a->length; +} + +static long compute_byte_count(grib_accessor* a){ + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + long numberOfBits; + long numberOfElements; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + + return (numberOfBits * numberOfElements + 7) / 8; +} + +void grib_accessor_class_signed_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_signed_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +#if 0 + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int i; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + if (numberOfBits == 0) { + for (i = 0; i < rlen; i++) + val[i] = 0; + return GRIB_SUCCESS; + } + + for (i = 0; i < rlen; i++) + val[i] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + *len = rlen; + + return GRIB_SUCCESS; +#endif +} + +int grib_accessor_class_signed_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +#if 0 + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + unsigned long rlen = 0; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + rlen = count; + if (*len != rlen) { + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, rlen); + if (ret) + return ret; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); + + for (i = 0; i < rlen; i++) + grib_encode_signed_longb(buf, val[i], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return ret; +#endif +} + +int grib_accessor_class_signed_bits_t::value_count(grib_accessor* a, long* numberOfElements){ + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + *numberOfElements = 0; + + return grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); +} + +long grib_accessor_class_signed_bits_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_signed_bits_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_signed_bits_t::next_offset(grib_accessor* a){ + return byte_offset(a) + byte_count(a); +} diff --git a/src/accessor/grib_accessor_class_signed_bits.h b/src/accessor/grib_accessor_class_signed_bits.h new file mode 100644 index 000000000..96ba5f592 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed_bits.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_signed_bits_h +#define eccodes_accessor_signed_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_signed_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_signed_bits_h */ diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc new file mode 100644 index 000000000..41cfddacb --- /dev/null +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_simple_packing_error.h" +#include "grib_scaling.h" + +grib_accessor_class_simple_packing_error_t _grib_accessor_class_simple_packing_error{"simple_packing_error"}; +grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_class_simple_packing_error; + + +void grib_accessor_class_simple_packing_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_simple_packing_error_t* self = (grib_accessor_simple_packing_error_t*)a; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + + self->bitsPerValue = grib_arguments_get_name(h, c, n++); + self->binaryScaleFactor = grib_arguments_get_name(h, c, n++); + self->decimalScaleFactor = grib_arguments_get_name(h, c, n++); + self->referenceValue = grib_arguments_get_name(h, c, n++); + self->floatType = grib_arguments_get_name(h, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_simple_packing_error_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_simple_packing_error_t* self = (grib_accessor_simple_packing_error_t*)a; + + int ret = 0; + long binaryScaleFactor = 0; + long bitsPerValue = 0; + long decimalScaleFactor = 0; + double referenceValue = 0; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(h, self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(h, self->referenceValue, &referenceValue)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(self->floatType, "ibm")) + *val = grib_ibmfloat_error(referenceValue); + else if (!strcmp(self->floatType, "ieee")) + *val = grib_ieeefloat_error(referenceValue); + else + Assert(1 == 0); + + if (bitsPerValue != 0) + *val = (*val + codes_power(binaryScaleFactor, 2)) * codes_power(-decimalScaleFactor, 10) * 0.5; + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h b/src/accessor/grib_accessor_class_simple_packing_error.h new file mode 100644 index 000000000..6c90188c5 --- /dev/null +++ b/src/accessor/grib_accessor_class_simple_packing_error.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_simple_packing_error_h +#define eccodes_accessor_simple_packing_error_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_simple_packing_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in simple_packing_error */ + const char* binaryScaleFactor; + const char* bitsPerValue; + const char* decimalScaleFactor; + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_simple_packing_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_simple_packing_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_simple_packing_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_simple_packing_error_h */ diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc new file mode 100644 index 000000000..7fbeac212 --- /dev/null +++ b/src/accessor/grib_accessor_class_size.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_size.h" + +grib_accessor_class_size_t _grib_accessor_class_size{"size"}; +grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; + + +void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_size_t* self = (grib_accessor_size_t*)a; + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + size_t size = 0; + grib_accessor_size_t* self = (grib_accessor_size_t*)a; + ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); + *val = (long)size; + *len = 1; + return ret; +} diff --git a/src/accessor/grib_accessor_class_size.h b/src/accessor/grib_accessor_class_size.h new file mode 100644 index 000000000..dbf47f8bd --- /dev/null +++ b/src/accessor/grib_accessor_class_size.h @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_size_h +#define eccodes_accessor_size_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_size_t : public grib_accessor_long_t +{ +public: + /* Members defined in size */ + const char* accessor; +}; + +class grib_accessor_class_size_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_size_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_size_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_size_h */ diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc new file mode 100644 index 000000000..d8a5e267f --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -0,0 +1,177 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_smart_table_column.h" +#include "grib_accessor_class_smart_table.h" + +grib_accessor_class_smart_table_column_t _grib_accessor_class_smart_table_column{"smart_table_column"}; +grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_class_smart_table_column; + + + +void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long len, grib_arguments* params){ + int n = 0; + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + + self->smartTable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); + + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_smart_table_column_t::dump(grib_accessor* a, grib_dumper* dumper){ + int type = get_native_type(a); + + switch (type) { + case GRIB_TYPE_LONG: + grib_dump_long(dumper, a, NULL); + break; + case GRIB_TYPE_STRING: + grib_dump_string_array(dumper, a, NULL); + break; + } +} + +int grib_accessor_class_smart_table_column_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + grib_accessor_smart_table_t* tableAccessor = NULL; + grib_smart_table* table = NULL; + + size_t size = 1; + long* code; + int err = GRIB_SUCCESS; + char tmp[1024] = {0,}; + int i = 0; + + tableAccessor = (grib_accessor_smart_table_t*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); + if (!tableAccessor) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to find accessor %s", self->smartTable); + return GRIB_NOT_FOUND; + } + + err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); + if (err) + return err; + if (*len < size) { + return GRIB_BUFFER_TOO_SMALL; + } + + code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!code) { + grib_context_log(a->context, GRIB_LOG_FATAL, "%s: Memory allocation error: %zu bytes", a->name, size); + return GRIB_OUT_OF_MEMORY; + } + + if ((err = ((grib_accessor*)tableAccessor)->unpack_long(code, &size)) != GRIB_SUCCESS) + return err; + + table = tableAccessor->table; + + for (i = 0; i < size; i++) { + if (table && (code[i] >= 0) && + (code[i] < table->numberOfEntries) && + table->entries[code[i]].column[self->index]) { + strcpy(tmp, table->entries[code[i]].column[self->index]); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)code[i]); + } + + buffer[i] = grib_context_strdup(a->context, tmp); + } + *len = size; + grib_context_free(a->context, code); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_smart_table_column_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + grib_accessor_smart_table_t* tableAccessor = NULL; + grib_smart_table* table = NULL; + + size_t size = 1; + long* code; + int err = GRIB_SUCCESS; + int i = 0; + + for (i = 0; i < *len; i++) + val[i] = GRIB_MISSING_LONG; + + tableAccessor = (grib_accessor_smart_table_t*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); + if (!tableAccessor) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to find accessor %s", self->smartTable); + return GRIB_NOT_FOUND; + } + + err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); + if (err) + return err; + if (*len < size) { + return GRIB_BUFFER_TOO_SMALL; + } + + code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!code) return GRIB_OUT_OF_MEMORY; + + if ((err = ((grib_accessor*)tableAccessor)->unpack_long(code, &size)) != GRIB_SUCCESS) { + grib_context_free(a->context, code); + return err; + } + + table = tableAccessor->table; + + for (i = 0; i < size; i++) { + if (table && (code[i] >= 0) && + (code[i] < table->numberOfEntries) && + table->entries[code[i]].column[self->index]) { + val[i] = atol(table->entries[code[i]].column[self->index]); + } + } + *len = size; + grib_context_free(a->context, code); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_smart_table_column_t::value_count(grib_accessor* a, long* count){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + size_t size = 0; + int err = 0; + *count = 0; + + if (!self->smartTable) + return 0; + + err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); + *count = size; + return err; +} + +void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, grib_accessor* a){ + if (a->vvalue != NULL) { + grib_context_free(context, a->vvalue); + a->vvalue = NULL; + } +} + +int grib_accessor_class_smart_table_column_t::get_native_type(grib_accessor* a){ + int type = GRIB_TYPE_LONG; + /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", + a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ + if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) + type = GRIB_TYPE_STRING; + return type; +} diff --git a/src/accessor/grib_accessor_class_smart_table_column.h b/src/accessor/grib_accessor_class_smart_table_column.h new file mode 100644 index 000000000..0c24454bc --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table_column.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_smart_table_column_h +#define eccodes_accessor_smart_table_column_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_smart_table_column_t : public grib_accessor_gen_t +{ +public: + /* Members defined in smart_table_column */ + const char* smartTable; + int index; +}; + +class grib_accessor_class_smart_table_column_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_smart_table_column_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_column_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_smart_table_column_h */ diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc new file mode 100644 index 000000000..7e1083377 --- /dev/null +++ b/src/accessor/grib_accessor_class_spd.cc @@ -0,0 +1,158 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_spd.h" + +grib_accessor_class_spd_t _grib_accessor_class_spd{"spd"}; +grib_accessor_class* grib_accessor_class_spd = &_grib_accessor_class_spd; + + +long grib_accessor_class_spd_t::byte_count(grib_accessor* a){ + return a->length; +} + +static long compute_byte_count(grib_accessor* a){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + long numberOfBits; + long numberOfElements; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + numberOfElements++; + + return (numberOfBits * numberOfElements + 7) / 8; +} + +void grib_accessor_class_spd_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int i; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = rlen; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + if (numberOfBits > 64) { + grib_context_log(a->context, GRIB_LOG_ERROR,"Invalid number of bits: %ld",numberOfBits); + return GRIB_DECODING_ERROR; + } + + for (i = 0; i < rlen - 1; i++) + val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + *len = rlen; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_spd_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len != rlen) { + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, (*len) - 1); + if (ret) return ret; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + + for (i = 0; i < rlen - 1; i++) { + grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); + } + + grib_encode_signed_longb(buf, val[rlen - 1], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + *len = rlen; + return ret; +} + +int grib_accessor_class_spd_t::value_count(grib_accessor* a, long* numberOfElements){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int ret; + *numberOfElements = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return ret; + } + (*numberOfElements)++; + + return ret; +} + +long grib_accessor_class_spd_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_spd_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_spd_t::next_offset(grib_accessor* a){ + return byte_offset(a) + a->length; +} diff --git a/src/accessor/grib_accessor_class_spd.h b/src/accessor/grib_accessor_class_spd.h new file mode 100644 index 000000000..c35e5c742 --- /dev/null +++ b/src/accessor/grib_accessor_class_spd.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_spd_h +#define eccodes_accessor_spd_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_spd_t : public grib_accessor_long_t +{ +public: + /* Members defined in spd */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_spd_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spd_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spd_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_spd_h */ diff --git a/src/accessor/grib_accessor_class_spectral_truncation.cc b/src/accessor/grib_accessor_class_spectral_truncation.cc new file mode 100644 index 000000000..c10a32d6e --- /dev/null +++ b/src/accessor/grib_accessor_class_spectral_truncation.cc @@ -0,0 +1,81 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_spectral_truncation.h" + +grib_accessor_class_spectral_truncation_t _grib_accessor_class_spectral_truncation{"spectral_truncation"}; +grib_accessor_class* grib_accessor_class_spectral_truncation = &_grib_accessor_class_spectral_truncation; + + +void grib_accessor_class_spectral_truncation_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_spectral_truncation_t* self = (grib_accessor_spectral_truncation_t*)a; + int n = 0; + + self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->T = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_spectral_truncation_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_spectral_truncation_t* self = (grib_accessor_spectral_truncation_t*)a; + int ret = 0; + + long J, K, M, T, Tc; + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) + return ret; + + Tc = -1; + if (J == K && K == M) { + /* Triangular truncation */ + Tc = (M + 1) * (M + 2); + } + if (K == J + M) { + /* Rhomboidal truncation */ + Tc = 2 * J * M; + } + if (J == K && K > M) { + /* Trapezoidal truncation */ + Tc = M * (2 * J - M); + } + *val = Tc; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->T, &T)) != GRIB_SUCCESS) { + if (Tc == -1) + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s. Spectral Truncation Type Unknown: %s=%ld %s=%ld %s=%ld", + a->name, self->J, J, self->K, K, self->M, M); + Tc = 0; + grib_set_long(grib_handle_of_accessor(a), self->T, Tc); + } + else { + if (Tc != -1 && Tc != T) + grib_set_long(grib_handle_of_accessor(a), self->T, Tc); + } + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h b/src/accessor/grib_accessor_class_spectral_truncation.h new file mode 100644 index 000000000..0ab43b1fd --- /dev/null +++ b/src/accessor/grib_accessor_class_spectral_truncation.h @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_spectral_truncation_h +#define eccodes_accessor_spectral_truncation_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_spectral_truncation_t : public grib_accessor_long_t +{ +public: + /* Members defined in spectral_truncation */ + const char* J; + const char* K; + const char* M; + const char* T; +}; + +class grib_accessor_class_spectral_truncation_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spectral_truncation_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spectral_truncation_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_spectral_truncation_h */ diff --git a/src/accessor/todo/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc similarity index 54% rename from src/accessor/todo/grib_accessor_class_sprintf.cc rename to src/accessor/grib_accessor_class_sprintf.cc index 106ce1e4d..8df2bb732 100644 --- a/src/accessor/todo/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,108 +10,20 @@ */ #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS= grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sprintf -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in sprintf */ - grib_arguments* args; -} grib_accessor_sprintf; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_sprintf = { - &grib_accessor_class_ascii, /* super */ - "sprintf", /* name */ - sizeof(grib_accessor_sprintf), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_sprintf.h" +grib_accessor_class_sprintf_t _grib_accessor_class_sprintf{"sprintf"}; grib_accessor_class* grib_accessor_class_sprintf = &_grib_accessor_class_sprintf; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_sprintf* self = (grib_accessor_sprintf*)a; +void grib_accessor_class_sprintf_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_sprintf_t* self = (grib_accessor_sprintf_t*)a; self->args = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_sprintf* self = (grib_accessor_sprintf*)a; +int grib_accessor_class_sprintf_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_sprintf_t* self = (grib_accessor_sprintf_t*)a; char result[1024]; char tempBuffer[2048]; char sres[1024]; @@ -148,8 +61,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), tempname, &ires)) != GRIB_SUCCESS) return ret; /* Bug GRIB-56: Check to see if the key is missing */ - is_missing = grib_is_missing(grib_handle_of_accessor(a), tempname, &ret); - if (ret != GRIB_SUCCESS) + is_missing = grib_is_missing(grib_handle_of_accessor(a), tempname, &ret); if (ret != GRIB_SUCCESS) return ret; if (is_missing) { snprintf(tempBuffer, sizeof(tempBuffer), "%sMISSING", result); @@ -205,13 +117,11 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_sprintf_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_sprintf_t::string_length(grib_accessor* a){ return 1024; } diff --git a/src/accessor/grib_accessor_class_sprintf.h b/src/accessor/grib_accessor_class_sprintf.h new file mode 100644 index 000000000..9bfb1c83e --- /dev/null +++ b/src/accessor/grib_accessor_class_sprintf.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sprintf_h +#define eccodes_accessor_sprintf_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_sprintf_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in sprintf */ + grib_arguments* args; +}; + +class grib_accessor_class_sprintf_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_sprintf_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sprintf_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sprintf_h */ diff --git a/src/accessor/todo/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc similarity index 55% rename from src/accessor/todo/grib_accessor_class_statistics.cc rename to src/accessor/grib_accessor_class_statistics.cc index 915701a3a..9a4eeee20 100644 --- a/src/accessor/todo/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,116 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - #include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = unpack_string - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missing_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_statistics -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in statistics */ - const char* values; - const char* missing_value; -} grib_accessor_statistics; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_statistics = { - &grib_accessor_class_abstract_vector, /* super */ - "statistics", /* name */ - sizeof(grib_accessor_statistics), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_statistics.h" +grib_accessor_class_statistics_t _grib_accessor_class_statistics{"statistics"}; grib_accessor_class* grib_accessor_class_statistics = &_grib_accessor_class_statistics; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int n = 0; self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -134,9 +34,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->dirty = 1; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +int grib_accessor_class_statistics_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int ret = 0; double* values = NULL; size_t i = 0, size = 0, real_size = 0; @@ -157,7 +56,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_statistics: computing statistics for %d values", size); + "grib_accessor_statistics_t: computing statistics for %d values", size); if ((ret = grib_get_double(h, self->missing_value, &missing)) != GRIB_SUCCESS) return ret; @@ -267,21 +166,18 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +int grib_accessor_class_statistics_t::value_count(grib_accessor* a, long* count){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; *count = self->number_of_elements; return 0; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +void grib_accessor_class_statistics_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; grib_context_free(c, self->v); } -static int compare(grib_accessor* a, grib_accessor* b) -{ +int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b){ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -291,13 +187,11 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); - if (err) + err = b->value_count(&count); if (err) return err; blen = count; @@ -310,9 +204,7 @@ static int compare(grib_accessor* a, grib_accessor* b) b->dirty = 1; a->dirty = 1; - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + + self->number_of_elements = 4; + self->v = (double*)grib_context_malloc(a->context, + sizeof(double) * self->number_of_elements); + + a->length = 0; + a->dirty = 1; +} + +int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + int ret = 0, i = 0; + double* values; + size_t size = 0; + long J, K, M, N; + double avg, enorm, sd; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (!a->dirty) + return GRIB_SUCCESS; + + if (*len != self->number_of_elements) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) + return ret; + + if (J != M || M != K) + return GRIB_NOT_IMPLEMENTED; + + N = (M + 1) * (M + 2) / 2; + + if (2 * N != size) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "wrong number of components for spherical harmonics %ld != %ld", 2 * N, size); + return GRIB_WRONG_ARRAY_SIZE; + } + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + avg = values[0]; + sd = 0; + + for (i = 2; i < 2 * J; i += 2) + sd += values[i] * values[i]; + + for (i = 2 * J; i < size; i += 2) + sd += 2 * values[i] * values[i] + 2 * values[i + 1] * values[i + 1]; + + enorm = sd + avg * avg; + + sd = sqrt(sd); + enorm = sqrt(enorm); + + a->dirty = 0; + + grib_context_free(c, values); + + self->v[0] = avg; + self->v[1] = enorm; + self->v[2] = sd; + self->v[3] = sd == 0 ? 1 : 0; + + for (i = 0; i < self->number_of_elements; i++) + val[i] = self->v[i]; + + return ret; +} + +int grib_accessor_class_statistics_spectral_t::value_count(grib_accessor* a, long* count){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + *count = self->number_of_elements; + return 0; +} + +void grib_accessor_class_statistics_spectral_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + grib_context_free(c, self->v); +} + +int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + long count = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + b->dirty = 1; + a->dirty = 1; + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h b/src/accessor/grib_accessor_class_statistics_spectral.h new file mode 100644 index 000000000..8075ddf31 --- /dev/null +++ b/src/accessor/grib_accessor_class_statistics_spectral.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_statistics_spectral_h +#define eccodes_accessor_statistics_spectral_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in statistics_spectral */ + const char* values; + const char* J; + const char* K; + const char* M; + const char* JS; +}; + +class grib_accessor_class_statistics_spectral_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_statistics_spectral_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_spectral_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_statistics_spectral_h */ diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc new file mode 100644 index 000000000..153468565 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -0,0 +1,79 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_step_human_readable.h" + +grib_accessor_class_step_human_readable_t _grib_accessor_class_step_human_readable{"step_human_readable"}; +grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_class_step_human_readable; + + +void grib_accessor_class_step_human_readable_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + + self->stepUnits = grib_arguments_get_name(h, params, n++); + self->step = grib_arguments_get_name(h, params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_step_human_readable_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int get_step_human_readable(grib_handle* h, char* result, size_t* length){ + int err = 0; + size_t slen = 2; + long step, hour, minute, second; + + /* Change units to seconds (highest resolution) + * before computing the step value + */ + if ((err = grib_set_string(h, "stepUnits", "s", &slen)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) + return err; + + hour = step/3600; + minute = step/60 % 60; + second = step % 60; + /* sprintf(result, "%ld:%ld:%ld", hour, minute, second); */ + + if (second) { + snprintf(result, 1024, "%ldh %ldm %lds", hour, minute, second); + } else { + if (minute) snprintf(result, 1024, "%ldh %ldm", hour, minute); + else snprintf(result, 1024, "%ldh", hour); + } + + *length = strlen(result); + return GRIB_SUCCESS; +} + +int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + long stepUnits; + int err = 0; + + /* Save the current value of stepUnits */ + err = grib_get_long_internal(h, self->stepUnits, &stepUnits); + if (err) return err; + + /* This will change stepUnits to seconds for its calculation */ + err = get_step_human_readable(h, buffer, len); + + /* Restore stepUnits */ + grib_set_long(h, self->stepUnits, stepUnits); + return err; +} diff --git a/src/accessor/grib_accessor_class_step_human_readable.h b/src/accessor/grib_accessor_class_step_human_readable.h new file mode 100644 index 000000000..793ecb618 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_human_readable.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_step_human_readable_h +#define eccodes_accessor_step_human_readable_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_step_human_readable_t : public grib_accessor_gen_t +{ +public: + /* Members defined in step_human_readable */ + const char* stepUnits; + const char* step; +}; + +class grib_accessor_class_step_human_readable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_step_human_readable_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_human_readable_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_step_human_readable_h */ diff --git a/src/accessor/todo/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc similarity index 63% rename from src/accessor/todo/grib_accessor_class_step_in_units.cc rename to src/accessor/grib_accessor_class_step_in_units.cc index a25c85aec..4d7cb6cf9 100644 --- a/src/accessor/todo/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,120 +10,17 @@ */ #include "grib_api_internal.h" +#include "grib_accessor_class_step_in_units.h" #include "step.h" #include "step_utilities.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - MEMBERS = const char* forecast_time_value - MEMBERS = const char* forecast_time_unit - MEMBERS = const char* step_units - MEMBERS = const char* time_range_unit - MEMBERS = const char* time_range_value - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_step_in_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in step_in_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* step_units; - const char* time_range_unit; - const char* time_range_value; -} grib_accessor_step_in_units; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_step_in_units = { - &grib_accessor_class_long, /* super */ - "step_in_units", /* name */ - sizeof(grib_accessor_step_in_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_step_in_units_t _grib_accessor_class_step_in_units{"step_in_units"}; grib_accessor_class* grib_accessor_class_step_in_units = &_grib_accessor_class_step_in_units; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; +void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -133,14 +31,12 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->time_range_value = grib_arguments_get_name(hand, c, n++); } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_double(dumper, a, NULL); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; +int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; grib_handle* h = grib_handle_of_accessor(a); @@ -169,9 +65,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double * val, size_t* len) -{ - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; +int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len){ + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; grib_handle* h = grib_handle_of_accessor(a); @@ -199,9 +94,8 @@ static int unpack_double(grib_accessor* a, double * val, size_t* len) return GRIB_SUCCESS; } -static int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units) -{ - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; +int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units){ + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int err = 0; long forecast_time_unit; @@ -211,7 +105,7 @@ static int pack_long_new_(grib_accessor* a, const long start_step_value, const l if ((err = grib_get_long_internal(h, self->forecast_time_unit, &forecast_time_unit)) != GRIB_SUCCESS) return err; - if ((err = unpack_long(a, &start_step_value_old, &len)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&start_step_value_old, &len)) != GRIB_SUCCESS) return err; if ((err = grib_get_long_internal(h, "startStepUnit", &start_step_unit_old)) != GRIB_SUCCESS) return err; @@ -249,8 +143,7 @@ static int pack_long_new_(grib_accessor* a, const long start_step_value, const l return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -281,8 +174,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); //long force_step_units = eccodes::Unit(eccodes::Unit::Value::MISSING).value(); int ret = GRIB_SUCCESS; @@ -303,9 +195,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; +int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; long start_step_value = 0; @@ -347,8 +238,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a){ grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; diff --git a/src/accessor/grib_accessor_class_step_in_units.h b/src/accessor/grib_accessor_class_step_in_units.h new file mode 100644 index 000000000..ba088db79 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_in_units.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_step_in_units_h +#define eccodes_accessor_step_in_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_step_in_units_t : public grib_accessor_long_t +{ +public: + /* Members defined in step_in_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* step_units; + const char* time_range_unit; + const char* time_range_value; +}; + +class grib_accessor_class_step_in_units_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_step_in_units_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_in_units_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_step_in_units_h */ diff --git a/src/accessor/grib_accessor_class_sum.cc b/src/accessor/grib_accessor_class_sum.cc new file mode 100644 index 000000000..5129ade27 --- /dev/null +++ b/src/accessor/grib_accessor_class_sum.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_sum.h" + +grib_accessor_class_sum_t _grib_accessor_class_sum{"sum"}; +grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum; + + +void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int n = 0; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_sum_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int ret = 0; + size_t size = 0; + long* values = 0; + long i; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + size = count; + + if (size == 0) { + *val = 0; + return GRIB_SUCCESS; + } + values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!values) + return GRIB_OUT_OF_MEMORY; + + grib_get_long_array(grib_handle_of_accessor(a), self->values, values, &size); + + *val = 0; + for (i = 0; i < size; i++) + *val += values[i]; + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_sum_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int ret = 0; + size_t size = 0; + double* values = 0; + long i; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + size = count; + + if (size == 0) { + *val = 0; + return GRIB_SUCCESS; + } + values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); + if (!values) + return GRIB_OUT_OF_MEMORY; + + ret = grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size); + if (ret) { + grib_context_free(a->context, values); + return ret; + } + *val = 0; + for (i = 0; i < size; i++) + *val += values[i]; + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_sum_t::value_count(grib_accessor* a, long* count){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + size_t n = 0; + int ret = 0; + + ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n); + *count = n; + + if (ret) + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s is unable to get size of %s", a->name, self->values); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_sum.h b/src/accessor/grib_accessor_class_sum.h new file mode 100644 index 000000000..ceedb788a --- /dev/null +++ b/src/accessor/grib_accessor_class_sum.h @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sum_h +#define eccodes_accessor_sum_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_sum_t : public grib_accessor_double_t +{ +public: + /* Members defined in sum */ + const char* values; +}; + +class grib_accessor_class_sum_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_sum_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sum_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sum_h */ diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc new file mode 100644 index 000000000..a209e8326 --- /dev/null +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -0,0 +1,65 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_suppressed.h" + +grib_accessor_class_suppressed_t _grib_accessor_class_suppressed{"suppressed"}; +grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_suppressed; + + +void grib_accessor_class_suppressed_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; + self->args = c; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +void log_message(grib_accessor* a){ + grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; + int i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_context_log(a->context, GRIB_LOG_ERROR, + "key '%s' is unavailable in this version.", a->name); + grib_context_log(a->context, GRIB_LOG_ERROR, + "Please use the following key(s):"); + while (grib_arguments_get_name(hand, self->args, i)) { + grib_context_log(a->context, GRIB_LOG_ERROR, "\t- %s", + grib_arguments_get_name(hand, self->args, i)); + i++; + } +} + +int grib_accessor_class_suppressed_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +int grib_accessor_class_suppressed_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} diff --git a/src/accessor/grib_accessor_class_suppressed.h b/src/accessor/grib_accessor_class_suppressed.h new file mode 100644 index 000000000..c8a93274e --- /dev/null +++ b/src/accessor/grib_accessor_class_suppressed.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_suppressed_h +#define eccodes_accessor_suppressed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_suppressed_t : public grib_accessor_long_t +{ +public: + /* Members defined in suppressed */ + grib_arguments* args; +}; + +class grib_accessor_class_suppressed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_suppressed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_suppressed_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_suppressed_h */ diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc new file mode 100644 index 000000000..e31de829f --- /dev/null +++ b/src/accessor/grib_accessor_class_time.cc @@ -0,0 +1,113 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_time.h" + +grib_accessor_class_time_t _grib_accessor_class_time{"time"}; +grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; + + +void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_time_t* self = (grib_accessor_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->hour = grib_arguments_get_name(hand, c, n++); + self->minute = grib_arguments_get_name(hand, c, n++); + self->second = grib_arguments_get_name(hand, c, n++); +} + +int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + const grib_accessor_time_t* self = (grib_accessor_time_t*)a; + + int ret = 0; + long hour = 0, minute = 0, second = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(hand, self->hour, &hour)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->minute, &minute)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->second, &second)) != GRIB_SUCCESS) + return ret; + + /* We ignore the 'seconds' in our time calculation! */ + if (second != 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); + } + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + *val = hour * 100 + minute; + + if (hour == 255) { + *val = 12 * 100; + } + if (hour != 255 && minute == 255) { + *val = hour * 100; + } + return GRIB_SUCCESS; +} + +int grib_accessor_class_time_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const grib_accessor_time_t* self = (grib_accessor_time_t*)a; + + int ret = 0; + long v = val[0]; + grib_handle* hand = grib_handle_of_accessor(a); + long hour = 0, minute = 0, second = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + if (!is_time_valid(v)) { + // ECC-1777: For now just a warning. Will later change to an error + fprintf(stderr, "ECCODES WARNING : %s:%s: Time is not valid! hour=%ld min=%ld sec=%ld\n", + a->cclass->name, __func__, hour, minute, second); + // return GRIB_ENCODING_ERROR; + } + + hour = v / 100; + minute = v % 100; + second = 0; /* We ignore the 'seconds' in our time calculation! */ + + if ((ret = grib_set_long_internal(hand, self->hour, hour)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->minute, minute)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->second, second)) != GRIB_SUCCESS) + return ret; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long v = 0; + size_t lsize = 1, lmin = 5; + + unpack_long(a, &v, &lsize); + + if (*len < lmin) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, lmin, *len); + *len = lmin; + return GRIB_BUFFER_TOO_SMALL; + } + + snprintf(val, 64, "%04ld", v); + + len[0] = lmin; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_time.h b/src/accessor/grib_accessor_class_time.h new file mode 100644 index 000000000..b1826e1d6 --- /dev/null +++ b/src/accessor/grib_accessor_class_time.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_time_h +#define eccodes_accessor_time_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in time */ + const char* hour; + const char* minute; + const char* second; +}; + +class grib_accessor_class_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_time_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_time_h */ diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc new file mode 100644 index 000000000..8e9e8a0dc --- /dev/null +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -0,0 +1,130 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_to_double.h" + +grib_accessor_class_to_double_t _grib_accessor_class_to_double{"to_double"}; +grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_double; + + +void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + self->scale = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 3); + if (!self->scale) + self->scale = 1; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_double_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_double_t::string_length(grib_accessor* a){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + size_t size = 0; + + if (self->length) + return self->length; + + grib_get_string_length_acc(a, &size); + return size; +} + +void grib_accessor_class_to_double_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_to_double_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_to_double_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + + int err = 0; + char buff[512] = {0,}; + size_t size = 512; + size_t length = string_length(a); + + if (*len < length + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + *len, a->name, a->length + 1); + *len = length + 1; + return GRIB_ARRAY_TOO_SMALL; + } + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + err = GRIB_STRING_TOO_SMALL; + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return err; +} + +int grib_accessor_class_to_double_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + *v = strtol(val, &last, 10); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + *v /= self->scale; + + return err; +} + +int grib_accessor_class_to_double_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + *v = strtod(val, &last); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + *v /= self->scale; + + return err; +} + +long grib_accessor_class_to_double_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_double.h b/src/accessor/grib_accessor_class_to_double.h new file mode 100644 index 000000000..a2010cc1e --- /dev/null +++ b/src/accessor/grib_accessor_class_to_double.h @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_double_h +#define eccodes_accessor_to_double_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_double_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_double */ + const char* key; + long start; + size_t length; + long scale; +}; + +class grib_accessor_class_to_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_double_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_double_h */ diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc new file mode 100644 index 000000000..06f268974 --- /dev/null +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -0,0 +1,132 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_to_integer.h" + +grib_accessor_class_to_integer_t _grib_accessor_class_to_integer{"to_integer"}; +grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_integer; + + +void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_integer_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_integer_t::string_length(grib_accessor* a){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + size_t size = 0; + + if (self->length) + return self->length; + + grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); + return size; +} + +void grib_accessor_class_to_integer_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_to_integer_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + + int err = 0; + char buff[512] = {0,}; + size_t size = 512; + + size_t length = string_length(a); + + if (*len < length + 1) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length+1, *len); + *len = length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + /*err=GRIB_STRING_TOO_SMALL;*/ + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_integer_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::pack_long(grib_accessor* a, const long* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::pack_double(grib_accessor* a, const double* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = unpack_string(a, val, &l); + + if (err) + return err; + + *v = strtol(val, &last, 10); + /* if (*last) {err=GRIB_WRONG_CONVERSION;} */ + + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_integer_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + size_t l = 1; + long val = 0; + int err = unpack_long(a, &val, &l); + + *v = (double)val; + return err; +} + +long grib_accessor_class_to_integer_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_integer.h b/src/accessor/grib_accessor_class_to_integer.h new file mode 100644 index 000000000..3ee9dd87b --- /dev/null +++ b/src/accessor/grib_accessor_class_to_integer.h @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_integer_h +#define eccodes_accessor_to_integer_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_integer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_integer */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_integer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_integer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_integer_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_integer_h */ diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc new file mode 100644 index 000000000..fd70a7feb --- /dev/null +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -0,0 +1,120 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_to_string.h" + +grib_accessor_class_to_string_t _grib_accessor_class_to_string{"to_string"}; +grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_string; + + +void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_string_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_string_t::string_length(grib_accessor* a){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + if (self->length) + return self->length; + + size_t size = 0; + grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); + return size; +} + +void grib_accessor_class_to_string_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_to_string_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + int err = 0; + char buff[512] = {0,}; + + size_t length = string_length(a); + + if (*len < length + 1) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length+1, *len); + *len = length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + size_t size = sizeof(buff); + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + /*err=GRIB_STRING_TOO_SMALL;*/ + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_string_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = unpack_string(a, val, &l); + + if (err) + return err; + + *v = strtol(val, &last, 10); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + + return err; +} + +int grib_accessor_class_to_string_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + size_t l = 1; + long val = 0; + int err = unpack_long(a, &val, &l); + + *v = (double)val; + return err; +} + +long grib_accessor_class_to_string_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_string.h b/src/accessor/grib_accessor_class_to_string.h new file mode 100644 index 000000000..0907cb82c --- /dev/null +++ b/src/accessor/grib_accessor_class_to_string.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_string_h +#define eccodes_accessor_to_string_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_string */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_string_h */ diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc new file mode 100644 index 000000000..d5372e3ca --- /dev/null +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -0,0 +1,111 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_transient_darray.h" + +grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{"transient_darray"}; +grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; + + +void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long length, grib_arguments* args){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + self->arr = NULL; + self->type = GRIB_TYPE_DOUBLE; + a->length = 0; +} + +void grib_accessor_class_transient_darray_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_double(dumper, a, NULL); +} + +int grib_accessor_class_transient_darray_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + + if (self->arr) + grib_darray_delete(a->context, self->arr); + self->arr = grib_darray_new(a->context, *len, 10); + + for (size_t i = 0; i < *len; i++) + grib_darray_push(a->context, self->arr, val[i]); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + + if (self->arr) + grib_darray_delete(a->context, self->arr); + self->arr = grib_darray_new(a->context, *len, 10); + + for (size_t i = 0; i < *len; i++) + grib_darray_push(a->context, self->arr, (double)val[i]); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + long count = 0; + + value_count(a, &count); + + if (*len < count) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); + return GRIB_ARRAY_TOO_SMALL; + } + + *len = count; + for (size_t i = 0; i < *len; i++) + val[i] = self->arr->v[i]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + long count = 0; + + value_count(a, &count); + + if (*len < count) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); + return GRIB_ARRAY_TOO_SMALL; + } + + *len = count; + for (size_t i = 0; i < *len; i++) + val[i] = (long)self->arr->v[i]; + + return GRIB_SUCCESS; +} + +void grib_accessor_class_transient_darray_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + if (self->arr) + grib_darray_delete(a->context, self->arr); +} + +int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* count){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + if (self->arr) + *count = grib_darray_used_size(self->arr); + else + *count = 0; + + return 0; +} + +int grib_accessor_class_transient_darray_t::get_native_type(grib_accessor* a){ + const grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + return self->type; +} diff --git a/src/accessor/grib_accessor_class_transient_darray.h b/src/accessor/grib_accessor_class_transient_darray.h new file mode 100644 index 000000000..fe918bd55 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient_darray.h @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_transient_darray_h +#define eccodes_accessor_transient_darray_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_transient_darray_t : public grib_accessor_gen_t +{ +public: + /* Members defined in transient_darray */ + grib_darray* arr; + int type; +}; + +class grib_accessor_class_transient_darray_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_transient_darray_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_darray_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_transient_darray_h */ diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc new file mode 100644 index 000000000..8f45138fe --- /dev/null +++ b/src/accessor/grib_accessor_class_trim.cc @@ -0,0 +1,76 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_trim.h" + +grib_accessor_class_trim_t _grib_accessor_class_trim{"trim"}; +grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; + + +void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_arguments* arg){ + int n = 0; + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + self->input = grib_arguments_get_name(h, arg, n++); + self->trim_left = grib_arguments_get_long(h, arg, n++); + self->trim_right= grib_arguments_get_long(h, arg, n++); + DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1); + DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1); +} + +int grib_accessor_class_trim_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + + int err = 0; + grib_handle* h = grib_handle_of_accessor(a); + char input[256] = {0,}; + size_t size = sizeof(input) / sizeof(*input); + char* pInput = input; + + err = grib_get_string(h, self->input, input, &size); + if (err) return err; + + string_lrtrim(&pInput, self->trim_left, self->trim_right); + snprintf(val, 1024, "%s", pInput); + size = strlen(val); + *len = size + 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_trim_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + char input[256] = {0,}; + + size_t inputLen = 256; + char buf[256] = {0,}; + char* pBuf = NULL; + int err; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + grib_accessor* inputAccesstor = grib_find_accessor(h, self->input); + if (!inputAccesstor) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input); + return GRIB_NOT_FOUND; + } + + if ((err = grib_get_string(h, self->input, input, &inputLen)) != GRIB_SUCCESS) + return err; + + snprintf(buf, sizeof(buf), "%s", val); + pBuf = buf; + string_lrtrim(&pBuf, self->trim_left, self->trim_right); + + return inputAccesstor->pack_string(pBuf, len);} + +size_t grib_accessor_class_trim_t::string_length(grib_accessor* a){ + return 1024; +} diff --git a/src/accessor/grib_accessor_class_trim.h b/src/accessor/grib_accessor_class_trim.h new file mode 100644 index 000000000..9fd6b9230 --- /dev/null +++ b/src/accessor/grib_accessor_class_trim.h @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_trim_h +#define eccodes_accessor_trim_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_trim_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in trim */ + const char* input; + int trim_left; + int trim_right; +}; + +class grib_accessor_class_trim_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_trim_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_trim_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_trim_h */ diff --git a/src/accessor/grib_accessor_class_uint16.cc b/src/accessor/grib_accessor_class_uint16.cc new file mode 100644 index 000000000..b8476105c --- /dev/null +++ b/src/accessor/grib_accessor_class_uint16.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint16.h" + +grib_accessor_class_uint16_t _grib_accessor_class_uint16{"uint16"}; +grib_accessor_class* grib_accessor_class_uint16 = &_grib_accessor_class_uint16; + + +int grib_accessor_class_uint16_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /*long pos = a->offset;*/ + /*unsigned char* data = grib_handle_of_accessor(a)->buffer->data;*/ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint16_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint16.h b/src/accessor/grib_accessor_class_uint16.h new file mode 100644 index 000000000..0291df85c --- /dev/null +++ b/src/accessor/grib_accessor_class_uint16.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint16_h +#define eccodes_accessor_uint16_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint16_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint16 */ +}; + +class grib_accessor_class_uint16_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint16_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint16_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint16_h */ diff --git a/src/accessor/grib_accessor_class_uint32.cc b/src/accessor/grib_accessor_class_uint32.cc new file mode 100644 index 000000000..6465375b6 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint32.h" + +grib_accessor_class_uint32_t _grib_accessor_class_uint32{"uint32"}; +grib_accessor_class* grib_accessor_class_uint32 = &_grib_accessor_class_uint32; + + +int grib_accessor_class_uint32_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /* long pos = a->offset; */ + /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint32_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint32.h b/src/accessor/grib_accessor_class_uint32.h new file mode 100644 index 000000000..be0457156 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint32_h +#define eccodes_accessor_uint32_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32 */ +}; + +class grib_accessor_class_uint32_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint32_h */ diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.cc b/src/accessor/grib_accessor_class_uint32_little_endian.cc new file mode 100644 index 000000000..7800d30c0 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32_little_endian.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint32_little_endian.h" + +grib_accessor_class_uint32_little_endian_t _grib_accessor_class_uint32_little_endian{"uint32_little_endian"}; +grib_accessor_class* grib_accessor_class_uint32_little_endian = &_grib_accessor_class_uint32_little_endian; + + +int grib_accessor_class_uint32_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /* long pos = a->offset; */ + /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint32_little_endian_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h b/src/accessor/grib_accessor_class_uint32_little_endian.h new file mode 100644 index 000000000..4f51d3113 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint32_little_endian_h +#define eccodes_accessor_uint32_little_endian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32_little_endian */ +}; + +class grib_accessor_class_uint32_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint32_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint64.cc b/src/accessor/grib_accessor_class_uint64.cc new file mode 100644 index 000000000..302702dab --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64.cc @@ -0,0 +1,51 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint64.h" + +grib_accessor_class_uint64_t _grib_accessor_class_uint64{"uint64"}; +grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64; + + +int grib_accessor_class_uint64_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + unsigned long long result = 0, tmp; + int i; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < 8; i++) { + result <<= 8; + result |= data[pos + i]; + } + + value = result; + tmp = value; + + /* Result does not fit in long */ + if (tmp != result) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); + return GRIB_DECODING_ERROR; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint64_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint64.h b/src/accessor/grib_accessor_class_uint64.h new file mode 100644 index 000000000..04d96b1b8 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint64_h +#define eccodes_accessor_uint64_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64 */ +}; + +class grib_accessor_class_uint64_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint64_h */ diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.cc b/src/accessor/grib_accessor_class_uint64_little_endian.cc new file mode 100644 index 000000000..80da3d903 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64_little_endian.cc @@ -0,0 +1,51 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint64_little_endian.h" + +grib_accessor_class_uint64_little_endian_t _grib_accessor_class_uint64_little_endian{"uint64_little_endian"}; +grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_class_uint64_little_endian; + + +int grib_accessor_class_uint64_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + unsigned long long result = 0, tmp; + int i; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 7; i >= 0; i--) { + result <<= 8; + result |= data[pos + i]; + } + + value = result; + tmp = value; + + /* Result does not fit in long */ + if (tmp != result) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); + return GRIB_DECODING_ERROR; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint64_little_endian_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h b/src/accessor/grib_accessor_class_uint64_little_endian.h new file mode 100644 index 000000000..5eb0068bb --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint64_little_endian_h +#define eccodes_accessor_uint64_little_endian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64_little_endian */ +}; + +class grib_accessor_class_uint64_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint64_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint8.cc b/src/accessor/grib_accessor_class_uint8.cc new file mode 100644 index 000000000..b86079a53 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint8.cc @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_uint8.h" + +grib_accessor_class_uint8_t _grib_accessor_class_uint8{"uint8"}; +grib_accessor_class* grib_accessor_class_uint8 = &_grib_accessor_class_uint8; + + +int grib_accessor_class_uint8_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + value = data[pos]; + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint8_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint8.h b/src/accessor/grib_accessor_class_uint8.h new file mode 100644 index 000000000..8a06d0ceb --- /dev/null +++ b/src/accessor/grib_accessor_class_uint8.h @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint8_h +#define eccodes_accessor_uint8_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint8_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint8 */ +}; + +class grib_accessor_class_uint8_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint8_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint8_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint8_h */ diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc new file mode 100644 index 000000000..e51262387 --- /dev/null +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -0,0 +1,132 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_unexpanded_descriptors.h" + +grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{"unexpanded_descriptors"}; +grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; + + +void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); + self->createNewData = grib_arguments_get_name(hand, args, n++); + a->length = 0; +} + +int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + int ret = 0; + long pos = 0; + long rlen = 0; + long f, x, y; + long* v = val; + long i; + grib_handle* hand = grib_handle_of_accessor(a); + + pos = accessor_raw_get_offset(self->unexpandedDescriptorsEncoded) * 8; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (rlen == 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "No descriptors in section 3. Malformed message."); + return GRIB_MESSAGE_MALFORMED; + } + + if (*len < rlen) { + /* grib_context_log(a->context, GRIB_LOG_ERROR, */ + /* " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen); */ + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) { + f = grib_decode_unsigned_long(hand->buffer->data, &pos, 2); + x = grib_decode_unsigned_long(hand->buffer->data, &pos, 6); + y = grib_decode_unsigned_long(hand->buffer->data, &pos, 8); + *v++ = f * 100000 + x * 1000 + y; + } + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + int ret = 0; + long pos = 0; + unsigned long f, x, y; + unsigned char* buf = NULL; + grib_accessor* expanded = NULL; + size_t buflen = *len * 2; + size_t i = 0, length = *len; + long createNewData = 1; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_get_long(hand, self->createNewData, &createNewData); + + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + + for (i = 0; i < length; i++) { + const long tmp = val[i] % 100000; + f = val[i] / 100000; + x = tmp / 1000; + y = tmp % 1000; + grib_encode_unsigned_longb(buf, f, &pos, 2); + grib_encode_unsigned_longb(buf, x, &pos, 6); + grib_encode_unsigned_longb(buf, y, &pos, 8); + } + + self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); grib_context_free(hand->context, buf); + + if (createNewData == 0) + return ret; + + expanded = grib_find_accessor(hand, "expandedCodes"); + Assert(expanded != NULL); + ret = grib_accessor_class_expanded_descriptors_set_do_expand(expanded, 1); + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_set_long(hand, "unpack", 3); /* BUFR new data */ + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_set_long(hand, "unpack", 1); /* Unpack structure */ + + return ret; +} + +int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors){ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + long n = 0; + + self->unexpandedDescriptorsEncoded->value_count(&n); *numberOfUnexpandedDescriptors = n / 2; + + return 0; +} + +long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a){ + return byte_offset(a) + a->length; +} diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h b/src/accessor/grib_accessor_class_unexpanded_descriptors.h new file mode 100644 index 000000000..12c89f308 --- /dev/null +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unexpanded_descriptors_h +#define eccodes_accessor_unexpanded_descriptors_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in unexpanded_descriptors */ + grib_accessor* unexpandedDescriptorsEncoded; + const char* createNewData; +}; + +class grib_accessor_class_unexpanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unexpanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unexpanded_descriptors_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_unexpanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc new file mode 100644 index 000000000..f7af4f6fa --- /dev/null +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -0,0 +1,98 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_unpack_bufr_values.h" +#include "grib_accessor_class_bufr_data_array.h" + + + +grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{"unpack_bufr_values"}; +grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; + + +void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ + char* key; + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + + a->length = 0; +} + +void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +} + +int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0);} + +int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + strcpy(buffer, "0"); + *len=1; + + return data->unpack_double(0, 0);} + +int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0);} + +int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0);} + +int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ +} + +int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +// static const char* mode_to_str(int p) +// { +// if (p==CODES_BUFR_UNPACK_STRUCTURE) return "CODES_BUFR_UNPACK_STRUCTURE"; +// if (p==CODES_BUFR_UNPACK_FLAT) return "CODES_BUFR_UNPACK_FLAT"; +// if (p==CODES_BUFR_NEW_DATA) return "CODES_BUFR_NEW_DATA"; +// return "unknown proc flag"; +// } + +int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + if (*val == 2) + unpackMode = CODES_BUFR_UNPACK_FLAT; + if (*val == 3) + unpackMode = CODES_BUFR_NEW_DATA; + + accessor_bufr_data_array_set_unpackMode(data, unpackMode); + + return data->unpack_double(0, 0);} + +int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0);} diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h b/src/accessor/grib_accessor_class_unpack_bufr_values.h new file mode 100644 index 000000000..7890e7bad --- /dev/null +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unpack_bufr_values_h +#define eccodes_accessor_unpack_bufr_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in unpack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_unpack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_unpack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unpack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_unpack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc new file mode 100644 index 000000000..25d16fdc3 --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -0,0 +1,159 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_unsigned_bits.h" + +grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{"unsigned_bits"}; +grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; + + + +static long compute_byte_count(grib_accessor* a){ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + long numberOfBits; + long numberOfElements; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + + return (numberOfBits * numberOfElements + 7) / 8; +} + + +void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen); + *len = rlen; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + if (numberOfBits == 0) { + int i; + for (i = 0; i < rlen; i++) + val[i] = 0; + return GRIB_SUCCESS; + } + + grib_decode_long_array(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits, rlen, val); + + *len = rlen; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + ret = value_count(a, &rlen); + if (ret) return ret; + + /* + if(*len < rlen) + { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size for %s it contains %d values ", a->name , rlen ); + return GRIB_ARRAY_TOO_SMALL; + } + */ + if (*len != rlen) + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, *len); + if (ret) return ret; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) return ret; + if (numberOfBits == 0) { + grib_buffer_replace(a, NULL, 0, 1, 1); + return GRIB_SUCCESS; + } + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); + + for (i = 0; i < *len; i++) + grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return ret; +} + +long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a){ + return a->length; +} + +int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements){ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret; + *numberOfElements = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + } + + return ret; +} + +long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a){ + return byte_offset(a) + a->length; +} diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h b/src/accessor/grib_accessor_class_unsigned_bits.h new file mode 100644 index 000000000..62ae48e60 --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned_bits.h @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unsigned_bits_h +#define eccodes_accessor_unsigned_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in unsigned_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_unsigned_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_unsigned_bits_h */ diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc new file mode 100644 index 000000000..5c250964d --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -0,0 +1,96 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_validity_date.h" +#include "shared_functions.h" + +grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{"validity_date"}; +grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; + +void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->date = grib_arguments_get_name(hand, c, n++); + self->time = grib_arguments_get_name(hand, c, n++); + self->step = grib_arguments_get_name(hand, c, n++); + self->stepUnits = grib_arguments_get_name(hand, c, n++); + self->year = grib_arguments_get_name(hand, c, n++); + self->month = grib_arguments_get_name(hand, c, n++); + self->day = grib_arguments_get_name(hand, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; + long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; + + if (self->year) { + long year, month, day; + if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) + return ret; + *val = year * 10000 + month * 100 + day; + return GRIB_SUCCESS; + } + if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { + if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { + return ret; /* See ECC-817 */ + } + } + + if (self->stepUnits) { + if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) + return ret; + step_mins = convert_to_minutes(step, stepUnits); + } + + minutes = time % 100; + hours = time / 100; + tmp = minutes + step_mins; /* add the step to our minutes */ + tmp_hrs = tmp / 60; /* how many hours and mins is that? */ + hours += tmp_hrs; /* increment hours */ + + date = grib_date_to_julian(date); + /* does the new 'hours' exceed 24? if so increment julian */ + while (hours >= 24) { + date++; + hours -= 24; + } + /* GRIB-29: Negative forecast time */ + while (hours < 0) { + date--; + hours += 24; + } + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = grib_julian_to_date(date); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_validity_date.h b/src/accessor/grib_accessor_class_validity_date.h new file mode 100644 index 000000000..7a7eea971 --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_date.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_validity_date_h +#define eccodes_accessor_validity_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_date */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_validity_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_date_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_validity_date_h */ diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc new file mode 100644 index 000000000..074bac88e --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -0,0 +1,116 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_validity_time.h" +#include "shared_functions.h" + +grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{"validity_time"}; +grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; + + +void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->date = grib_arguments_get_name(hand, c, n++); + self->time = grib_arguments_get_name(hand, c, n++); + self->step = grib_arguments_get_name(hand, c, n++); + self->stepUnits = grib_arguments_get_name(hand, c, n++); + self->hours = grib_arguments_get_name(hand, c, n++); + self->minutes = grib_arguments_get_name(hand, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; + long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; + + if (self->hours) { + if ((ret = grib_get_long_internal(hand, self->hours, &hours)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->minutes, &minutes)) != GRIB_SUCCESS) + return ret; + *val = hours * 100 + minutes; + return GRIB_SUCCESS; + } + if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { + if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { + return ret; /* See ECC-817 */ + } + } + + /* Seconds will always be zero. So convert to minutes */ + if (self->stepUnits) { + if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) + return ret; + step_mins = convert_to_minutes(step, stepUnits); + } + + minutes = time % 100; + hours = time / 100; + tmp = minutes + step_mins; /* add the step to our minutes */ + tmp_hrs = tmp / 60; /* how many hours and mins is that? */ + tmp_mins = tmp % 60; + hours += tmp_hrs; /* increment hours */ + if (hours > 0) { + hours = hours % 24; /* wrap round if >= 24 */ + } + else { + /* GRIB-29: Negative forecast time */ + while (hours < 0) { + hours += 24; + } + } + time = hours * 100 + tmp_mins; + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = time; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + int err = 0; + long v = 0; + size_t lsize = 1, lmin = 5; + + err = unpack_long(a, &v, &lsize); + if (err) return err; + + if (*len < lmin) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, lmin, *len); + *len = lmin; + return GRIB_BUFFER_TOO_SMALL; + } + + snprintf(val, 64, "%04ld", v); + + len[0] = lmin; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_validity_time.h b/src/accessor/grib_accessor_class_validity_time.h new file mode 100644 index 000000000..7fe86648a --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_time.h @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_validity_time_h +#define eccodes_accessor_validity_time_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_time */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* hours; + const char* minutes; +}; + +class grib_accessor_class_validity_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_time_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_validity_time_h */ diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc new file mode 100644 index 000000000..e7009129c --- /dev/null +++ b/src/accessor/grib_accessor_class_values.cc @@ -0,0 +1,139 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_values.h" + +grib_accessor_class_values_t _grib_accessor_class_values{"values"}; +grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; + +long init_length(grib_accessor* a){ + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + int ret = 0; + + long seclen = 0; + long offsetsection = 0; + long offsetdata = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen))) + return ret; + + if (seclen == 0) { + /* printf("init_length seclen=0\n"); */ + return 0; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection))) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetdata, &offsetdata))) + return ret; + + /* When reparsing */ + if (offsetdata < offsetsection) { + /* printf("init_length offsetdata < offsetsection=0\n"); */ + Assert(grib_handle_of_accessor(a)->loader); + return 0; + } + + return seclen - (offsetdata - offsetsection); +} + +void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params){ + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + self->carg = 0; + + self->seclen = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->offsetdata = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->offsetsection = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->dirty = 1; + + a->length = init_length(a); + /* Assert(a->length>=0); */ +} + +int grib_accessor_class_values_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} + +void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +long grib_accessor_class_values_t::byte_count(grib_accessor* a){ + grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); + return a->length; +} + +long grib_accessor_class_values_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +long grib_accessor_class_values_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} + +void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s){ + grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); + a->length = s; + Assert(a->length >= 0); +} + +int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = 0; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + long count = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} + +int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); + + for (size_t i = 0; i < *len; i++) + dval[i] = (double)val[i]; + + int ret = a->pack_double(dval, len); + grib_context_free(a->context, dval); + + self->dirty = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_values.h b/src/accessor/grib_accessor_class_values.h new file mode 100644 index 000000000..a77a5e89c --- /dev/null +++ b/src/accessor/grib_accessor_class_values.h @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_values_h +#define eccodes_accessor_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in values */ + int carg; + const char* seclen; + const char* offsetdata; + const char* offsetsection; + int dirty; +}; + +class grib_accessor_class_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_values_h */ diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc new file mode 100644 index 000000000..e48ab1aaf --- /dev/null +++ b/src/accessor/grib_accessor_class_vector.cc @@ -0,0 +1,57 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_vector.h" +#include "grib_accessor_class_abstract_vector.h" + +grib_accessor_class_vector_t _grib_accessor_class_vector{"vector"}; +grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; + + +void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + int n = 0; + + self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int err = 0; + size_t size = 0; + double* stat; + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + grib_accessor_abstract_vector_t* v = (grib_accessor_abstract_vector_t*)va; + + Assert(self->index >= 0); + + if (self->index >= v->number_of_elements) { + grib_context_log(a->context, GRIB_LOG_FATAL, "index=%d number_of_elements=%d for %s", self->index, v->number_of_elements, a->name); + Assert(self->index < v->number_of_elements); + } + + if (va->dirty) { + grib_get_size(grib_handle_of_accessor(a), self->vector, &size); + stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); + err = va->unpack_double(stat, &size); grib_context_free(a->context, stat); + if (err) + return err; + } + + *val = v->v[self->index]; + + return err; +} diff --git a/src/accessor/grib_accessor_class_vector.h b/src/accessor/grib_accessor_class_vector.h new file mode 100644 index 000000000..df12303cd --- /dev/null +++ b/src/accessor/grib_accessor_class_vector.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_vector_h +#define eccodes_accessor_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_vector_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_vector_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_vector_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_vector_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_vector_h */ diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc new file mode 100644 index 000000000..0834d0f86 --- /dev/null +++ b/src/accessor/grib_accessor_class_when.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" +#include "grib_accessor_class_when.h" + +grib_accessor_class_when_t _grib_accessor_class_when{"when"}; +grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; + + +void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper){ + /* grib_dump_when(dumper,a,NULL); */ +} + +int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed){ + return grib_action_notify_change(a->creator, a, changed); +} + +int grib_accessor_class_when_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_UNDEFINED; +} diff --git a/src/accessor/grib_accessor_class_when.h b/src/accessor/grib_accessor_class_when.h new file mode 100644 index 000000000..69f1dffbb --- /dev/null +++ b/src/accessor/grib_accessor_class_when.h @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_when_h +#define eccodes_accessor_when_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_when_t : public grib_accessor_gen_t +{ +public: + /* Members defined in when */ +}; + +class grib_accessor_class_when_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_when_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_when_t{}; } + int get_native_type(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_when_h */ diff --git a/src/accessor/todo/grib_accessor_class_abstract_long_vector.cc b/src/accessor/todo/grib_accessor_class_abstract_long_vector.cc deleted file mode 100644 index 523e0a740..000000000 --- a/src/accessor/todo/grib_accessor_class_abstract_long_vector.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - * (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. - */ - -/****************************************************************** - * Enrico Fucile - ******************************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - MEMBERS = long* v - MEMBERS = long pack_index - MEMBERS = int number_of_elements - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_abstract_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; -} grib_accessor_abstract_long_vector; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_abstract_long_vector = { - &grib_accessor_class_gen, /* super */ - "abstract_long_vector", /* name */ - sizeof(grib_accessor_abstract_long_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_abstract_long_vector = &_grib_accessor_class_abstract_long_vector; - -/* END_CLASS_IMP */ diff --git a/src/accessor/todo/grib_accessor_class_abstract_vector.cc b/src/accessor/todo/grib_accessor_class_abstract_vector.cc deleted file mode 100644 index 1353aeffc..000000000 --- a/src/accessor/todo/grib_accessor_class_abstract_vector.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - MEMBERS = double* v - MEMBERS = int number_of_elements - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_abstract_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; -} grib_accessor_abstract_vector; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_abstract_vector = { - &grib_accessor_class_double, /* super */ - "abstract_vector", /* name */ - sizeof(grib_accessor_abstract_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_abstract_vector = &_grib_accessor_class_abstract_vector; - -/* END_CLASS_IMP */ diff --git a/src/accessor/todo/grib_accessor_class_ascii.cc b/src/accessor/todo/grib_accessor_class_ascii.cc deleted file mode 100644 index b0c90182e..000000000 --- a/src/accessor/todo/grib_accessor_class_ascii.cc +++ /dev/null @@ -1,278 +0,0 @@ -/* - * (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. - */ -/*********************************************************** - * Enrico Fucile - ***********************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = get_native_type - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_ascii -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ -} grib_accessor_ascii; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_ascii = { - &grib_accessor_class_gen, /* super */ - "ascii", /* name */ - sizeof(grib_accessor_ascii), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = len; - Assert(a->length >= 0); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - const size_t alen = a->length; - - if (*len < (alen + 1)) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, alen+1, *len); - *len = alen + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < alen; i++) - val[i] = hand->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - size_t i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - const size_t alen = a->length; - if (len[0] > (alen + 1)) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "pack_string: Wrong size (%zu) for %s, it contains %ld values", len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < alen; i++) { - if (i < len[0]) - hand->buffer->data[a->offset + i] = val[i]; - else - hand->buffer->data[a->offset + i] = 0; - } - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as long (It's a string)", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as double (It's a string)", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - - int err = grib_unpack_string(a, val, &l); - if (err) return err; - - *v = strtod(val, &last); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - - grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot unpack %s as double. Hint: Try unpacking as string", a->name); - - return GRIB_NOT_IMPLEMENTED; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - char* aval = 0; - char* bval = 0; - int err = 0; - - size_t alen = a->length+1; - size_t blen = b->length+1; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); - bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - - err = grib_unpack_string(a, aval, &alen); - if (err) return err; - err = grib_unpack_string(b, bval, &blen); - if (err) return err; - - retval = GRIB_SUCCESS; - if (!STR_EQUAL(aval, bval)) - retval = GRIB_STRING_VALUE_MISMATCH; - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/accessor/todo/grib_accessor_class_bit.cc b/src/accessor/todo/grib_accessor_class_bit.cc deleted file mode 100644 index ab81eecda..000000000 --- a/src/accessor/todo/grib_accessor_class_bit.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS = const char* owner - MEMBERS = int bit_index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bit -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bit */ - const char* owner; - int bit_index; -} grib_accessor_bit; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bit = { - &grib_accessor_class_long, /* super */ - "bit", /* name */ - sizeof(grib_accessor_bit), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - a->length = 0; - self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - int ret = 0; - long data = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: unpack_long: Wrong size for %s, it contains %d values ", a->name, 1); - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->owner, &data)) != GRIB_SUCCESS) { - *len = 0; - return ret; - } - - if (data & (1 << self->bit_index)) - *val = 1; - else - *val = 0; - - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: pack_long: At least one value to pack for %s", a->name); - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - grib_accessor* owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner); - if (!owner) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit: Cannot get the owner %s for computing the bit value of %s", - self->owner, a->name); - *len = 0; - return GRIB_NOT_FOUND; - } - - unsigned char* mdata = grib_handle_of_accessor(a)->buffer->data; - mdata += grib_byte_offset(owner); - - /* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */ - if (a->context->debug) { - /* Print bit positions from 1 (MSB) */ - fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0) ); - } - grib_set_bit(mdata, 7 - self->bit_index, *val > 0); - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_bitmap.cc b/src/accessor/todo/grib_accessor_class_bitmap.cc deleted file mode 100644 index b86b34332..000000000 --- a/src/accessor/todo/grib_accessor_class_bitmap.cc +++ /dev/null @@ -1,297 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = next_offset - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = string_length - IMPLEMENTS = init;dump;update_size - MEMBERS=const char* tableReference - MEMBERS=const char* missing_value - MEMBERS=const char* offsetbsec - MEMBERS=const char* sLength - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; -} grib_accessor_bitmap; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_bitmap = { - &grib_accessor_class_bytes, /* super */ - "bitmap", /* name */ - sizeof(grib_accessor_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; - -/* END_CLASS_IMP */ - - -static void compute_size(grib_accessor* a) -{ - long slen = 0; - long off = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_get_long_internal(hand, self->offsetbsec, &off); - grib_get_long_internal(hand, self->sLength, &slen); - - if (slen == 0) { - grib_accessor* seclen; - size_t size; - /* Assume reparsing */ - Assert(hand->loader != 0); - if (hand->loader != 0) { - seclen = grib_find_accessor(hand, self->sLength); - Assert(seclen); - grib_get_block_length(seclen->parent, &size); - slen = size; - } - } - - // printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset); - - a->length = off + (slen - a->offset); - - if (a->length < 0) { - /* Assume reparsing */ - /*Assert(hand->loader != 0);*/ - a->length = 0; - } - - Assert(a->length >= 0); -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->tableReference = grib_arguments_get_name(hand, arg, n++); - self->missing_value = grib_arguments_get_name(hand, arg, n++); - self->offsetbsec = grib_arguments_get_name(hand, arg, n++); - self->sLength = grib_arguments_get_name(hand, arg, n++); - - compute_size(a); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - long len = 0; - char label[1024]; - - grib_value_count(a, &len); - - snprintf(label, 1024, "Bitmap of %ld values", len); - grib_dump_bytes(dumper, a, label); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long pos = a->offset * 8; - long tlen = 0; - const grib_handle* hand = grib_handle_of_accessor(a); - - int err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = tlen; - return GRIB_ARRAY_TOO_SMALL; - } - - for (long i = 0; i < tlen; i++) { - val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating points numbers"); - long pos = a->offset * 8; - long tlen; - grib_handle* hand = grib_handle_of_accessor(a); - - int err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = tlen; - return GRIB_ARRAY_TOO_SMALL; - } - - for (long i = 0; i < tlen; i++) { - val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - long pos = a->offset * 8; - - pos += idx; - *val = (double)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, 1); - - return GRIB_SUCCESS; -} -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - for (size_t i=0; ilength = s; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_handle* hand = grib_handle_of_accessor(a); - const size_t l = a->length; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - for (long i = 0; i < a->length; i++) { - val[i] = hand->buffer->data[a->offset + i]; - } - - *len = a->length; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_bits_per_value.cc b/src/accessor/todo/grib_accessor_class_bits_per_value.cc deleted file mode 100644 index 5648a9a69..000000000 --- a/src/accessor/todo/grib_accessor_class_bits_per_value.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (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. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bits_per_value - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bits_per_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bits_per_value */ - const char* values; - const char* bits_per_value; -} grib_accessor_bits_per_value; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bits_per_value = { - &grib_accessor_class_long, /* super */ - "bits_per_value", /* name */ - sizeof(grib_accessor_bits_per_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_bits_per_value; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->bits_per_value, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - double* values = NULL; - size_t size = 0; - int ret = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->bits_per_value, *val)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_blob.cc b/src/accessor/todo/grib_accessor_class_blob.cc deleted file mode 100644 index 7e1c1de62..000000000 --- a/src/accessor/todo/grib_accessor_class_blob.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = unpack_bytes;dump - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_blob -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in blob */ -} grib_accessor_blob; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_blob = { - &grib_accessor_class_gen, /* super */ - "blob", /* name */ - sizeof(grib_accessor_blob), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); - Assert(a->length >= 0); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_BYTES; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) -{ - if (*len < (size_t)a->length) { - *len = a->length; - return GRIB_ARRAY_TOO_SMALL; - } - *len = a->length; - - memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); - - return GRIB_SUCCESS; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_bytes(dumper, a, NULL); -} diff --git a/src/accessor/todo/grib_accessor_class_budgdate.cc b/src/accessor/todo/grib_accessor_class_budgdate.cc deleted file mode 100644 index 15fc9b4bd..000000000 --- a/src/accessor/todo/grib_accessor_class_budgdate.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_budgdate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in budgdate */ - const char* year; - const char* month; - const char* day; -} grib_accessor_budgdate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_budgdate = { - &grib_accessor_class_long, /* super */ - "budgdate", /* name */ - sizeof(grib_accessor_budgdate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_budgdate = &_grib_accessor_class_budgdate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - int n = 0; - - self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - - long year = 0; - long month = 0; - long day = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - val[0] = (1900 + year) * 10000 + month * 100 + day; - - return ret; -} - -/* TODO: Check for a valid date */ -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - long v = val[0]; - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - - long year = 0; - long month = 0; - long day = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - year = v / 10000; - v %= 10000; - month = v / 100; - v %= 100; - day = v; - - year -= 1900; - - Assert(year < 255); - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) - return ret; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc deleted file mode 100644 index 567ceb61a..000000000 --- a/src/accessor/todo/grib_accessor_class_bufr_extract_subsets.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* numericValues - MEMBERS = const char* pack - MEMBERS = grib_accessor* numericValuesAccessor - MEMBERS = grib_accessor* packAccessor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_subsets */ - const char* numericValues; - const char* pack; - grib_accessor* numericValuesAccessor; - grib_accessor* packAccessor; -} grib_accessor_bufr_extract_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_extract_subsets = &_grib_accessor_class_bufr_extract_subsets; - -/* END_CLASS_IMP */ - -static void get_accessors(grib_accessor* a) -{ - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - const grib_handle* h = grib_handle_of_accessor(a); - - if (self->packAccessor) - return; - self->numericValuesAccessor = grib_find_accessor(h, self->numericValues); - self->packAccessor = grib_find_accessor(h, self->pack); -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - - a->length = 0; - self->numericValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->pack = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - size_t l = 1; - long v[1]; - - get_accessors(a); - - v[0] = 1; - int err = grib_pack_long(self->packAccessor, v, &l); - if (err) { - if (err == GRIB_ENCODING_ERROR) - grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?"); - return err; - } - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_bufr_group.cc b/src/accessor/todo/grib_accessor_class_bufr_group.cc deleted file mode 100644 index 9af0a5633..000000000 --- a/src/accessor/todo/grib_accessor_class_bufr_group.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - IMPLEMENTS = dump;next - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static grib_accessor* next(grib_accessor*, int); - -typedef struct grib_accessor_bufr_group -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in bufr_group */ -} grib_accessor_bufr_group; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_bufr_group = { - &grib_accessor_class_variable, /* super */ - "bufr_group", /* name */ - sizeof(grib_accessor_bufr_group), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_group = &_grib_accessor_class_bufr_group; - -/* END_CLASS_IMP */ - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_section(dumper, a, a->sub_section->block); -} - -static grib_accessor* next(grib_accessor* a, int explore) -{ - grib_accessor* next = NULL; - if (explore) { - next = a->sub_section->block->first; - if (!next) - next = a->next; - } - else { - next = a->next; - } - if (!next) { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} diff --git a/src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc deleted file mode 100644 index cd0181fe4..000000000 --- a/src/accessor/todo/grib_accessor_class_bufr_simple_thinning.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - MEMBERS = const char* simpleThinningStart - MEMBERS = const char* simpleThinningMissingRadius - MEMBERS = const char* simpleThinningSkip - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_simple_thinning -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_simple_thinning */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* simpleThinningStart; - const char* simpleThinningMissingRadius; - const char* simpleThinningSkip; -} grib_accessor_bufr_simple_thinning; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_simple_thinning = { - &grib_accessor_class_gen, /* super */ - "bufr_simple_thinning", /* name */ - sizeof(grib_accessor_bufr_simple_thinning), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_class_bufr_simple_thinning; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - grib_handle* h = grib_handle_of_accessor(a); - int n = 0; - - a->length = 0; - self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); - self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); - self->extractSubsetList = grib_arguments_get_name(h, arg, n++); - self->simpleThinningStart = grib_arguments_get_name(h, arg, n++); - self->simpleThinningMissingRadius = grib_arguments_get_name(h, arg, n++); - self->simpleThinningSkip = grib_arguments_get_name(h, arg, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int apply_thinning(grib_accessor* a) -{ - const grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - - long skip; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = h->context; - long compressed = 0, nsubsets; - grib_iarray* subsets; - long* subsets_ar = 0; - long start = 0, radius = 0; - - int ret = grib_get_long(h, "compressedData", &compressed); - if (ret) - return ret; - if (compressed) { - long numberOfSubsets = 0; - ret = grib_get_long(h, self->numberOfSubsets, &numberOfSubsets); - if (ret) - return ret; - - ret = grib_get_long(h, self->simpleThinningStart, &start); - if (ret) - return ret; - - ret = grib_get_long(h, self->simpleThinningSkip, &skip); - if (ret) - return ret; - if (skip <= 0) - return GRIB_INVALID_KEY_VALUE; - - ret = grib_get_long(h, self->simpleThinningMissingRadius, &radius); - if (ret) - return ret; - - subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10); - for (long i = 0; i < numberOfSubsets; i += skip + 1) { - grib_iarray_push(subsets, i + 1); - } - - nsubsets = grib_iarray_used_size(subsets); - - if (nsubsets != 0) { - subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); - grib_context_free(c, subsets_ar); - if (ret) - return ret; - - ret = grib_set_long(h, "unpack", 1); - if (ret) - return ret; - - ret = grib_set_long(h, self->doExtractSubsets, 1); - if (ret) - return ret; - } - grib_iarray_delete(subsets); - } - else { - return GRIB_NOT_IMPLEMENTED; - } - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - - if (*len == 0) - return GRIB_SUCCESS; - int err = apply_thinning(a); - if (err) - return err; - - return grib_set_long(a->parent->h, self->doExtractSubsets, 1); -} diff --git a/src/accessor/todo/grib_accessor_class_bufr_string_values.cc b/src/accessor/todo/grib_accessor_class_bufr_string_values.cc deleted file mode 100644 index 02627e763..000000000 --- a/src/accessor/todo/grib_accessor_class_bufr_string_values.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* -* (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. -*/ - -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ - -#include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_ascii -IMPLEMENTS = unpack_string_array -IMPLEMENTS = unpack_string -IMPLEMENTS = init;dump;destroy -IMPLEMENTS = value_count -MEMBERS = const char* dataAccessorName -MEMBERS = grib_accessor* dataAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_string_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in bufr_string_values */ - const char* dataAccessorName; - grib_accessor* dataAccessor; -} grib_accessor_bufr_string_values; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_bufr_string_values = { - &grib_accessor_class_ascii, /* super */ - "bufr_string_values", /* name */ - sizeof(grib_accessor_bufr_string_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_bufr_string_values* self = (grib_accessor_bufr_string_values*)a; - int n = 0; - self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->dataAccessor = NULL; - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string_array(dumper, a, NULL); -} - -static grib_accessor* get_accessor(grib_accessor* a) -{ - grib_accessor_bufr_string_values* self = (grib_accessor_bufr_string_values*)a; - if (!self->dataAccessor) { - self->dataAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->dataAccessorName); - } - return self->dataAccessor; -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor* data = 0; - grib_context* c = a->context; - grib_vsarray* stringValues = NULL; - size_t l = 0, tl; - size_t i, j, n = 0; - char** b = buffer; - - data = get_accessor(a); - if (!data) - return GRIB_NOT_FOUND; - - stringValues = accessor_bufr_data_array_get_stringValues(data); - - n = grib_vsarray_used_size(stringValues); - - tl = 0; - for (j = 0; j < n; j++) { - l = grib_sarray_used_size(stringValues->v[j]); - tl += l; - - if (tl > *len) - return GRIB_ARRAY_TOO_SMALL; - - for (i = 0; i < l; i++) { - *(b++) = grib_context_strdup(c, stringValues->v[j]->v[i]); - } - } - *len = tl; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int value_count(grib_accessor* a, long* rlen) -{ - grib_accessor* descriptors = get_accessor(a); - return grib_value_count(descriptors, rlen); -} - -static void destroy(grib_context* c, grib_accessor* a) -{ -} diff --git a/src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc deleted file mode 100644 index 929e21724..000000000 --- a/src/accessor/todo/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* -* (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. -*/ - -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ - -#include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_long -IMPLEMENTS = unpack_long -IMPLEMENTS = unpack_string_array -IMPLEMENTS = init;destroy -IMPLEMENTS = value_count -MEMBERS = const char* expandedDescriptors -MEMBERS = grib_accessor* expandedDescriptorsAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufrdc_expanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bufrdc_expanded_descriptors */ - const char* expandedDescriptors; - grib_accessor* expandedDescriptorsAccessor; -} grib_accessor_bufrdc_expanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bufrdc_expanded_descriptors = { - &grib_accessor_class_long, /* super */ - "bufrdc_expanded_descriptors", /* name */ - sizeof(grib_accessor_bufrdc_expanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors = &_grib_accessor_class_bufrdc_expanded_descriptors; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a; - int n = 0; - self->expandedDescriptors = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->expandedDescriptorsAccessor = 0; - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static grib_accessor* get_accessor(grib_accessor* a) -{ - grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a; - if (!self->expandedDescriptorsAccessor) { - self->expandedDescriptorsAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->expandedDescriptors); - } - return self->expandedDescriptorsAccessor; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor* descriptors = 0; - size_t rlen = 0, l; - long lenall = 0; - size_t i = 0; - long* v = 0; - grib_context* c = a->context; - - descriptors = get_accessor(a); - if (!descriptors) return GRIB_NOT_FOUND; - - grib_value_count(a, &lenall); - v = (long*)grib_context_malloc_clear(c, sizeof(long) * lenall); - l = lenall; - grib_unpack_long(descriptors, v, &l); - - rlen = 0; - for (i = 0; i < l; i++) { - if ((v[i] < 100000 || v[i] > 221999)) - val[rlen++] = v[i]; - } - *len = rlen; - grib_context_free(c,v); - - return GRIB_SUCCESS; -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - int err = 0; - grib_accessor* descriptors = 0; - size_t l = 0; - long lenall = 0; - size_t i = 0; - long* v = 0; - char buf[25] = {0,}; - grib_context* c = a->context; - - descriptors = get_accessor(a); - if (!descriptors) return GRIB_NOT_FOUND; - - err = grib_value_count(a, &lenall); - if (err) return err; - l = lenall; - if (l > *len) return GRIB_ARRAY_TOO_SMALL; - - v = (long*)grib_context_malloc_clear(c, sizeof(long) * l); - err = grib_unpack_long(descriptors, v, &l); - if (err) return err; - - for (i = 0; i < l; i++) { - snprintf(buf, sizeof(buf), "%06ld", v[i]); - buffer[i] = grib_context_strdup(c, buf); - } - *len = l; - grib_context_free(c,v); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* rlen) -{ - grib_accessor* descriptors = get_accessor(a); - - return grib_value_count(descriptors, rlen); -} - -static void destroy(grib_context* c, grib_accessor* a) -{ -} diff --git a/src/accessor/todo/grib_accessor_class_bytes.cc b/src/accessor/todo/grib_accessor_class_bytes.cc deleted file mode 100644 index 71533095e..000000000 --- a/src/accessor/todo/grib_accessor_class_bytes.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = compare;unpack_string;pack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_bytes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ -} grib_accessor_bytes; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bytes = { - &grib_accessor_class_gen, /* super */ - "bytes", /* name */ - sizeof(grib_accessor_bytes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bytes = &_grib_accessor_class_bytes; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ - a->length = len; - Assert(a->length >= 0); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_BYTES; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - - size_t alen = (size_t)grib_byte_count(a); - size_t blen = (size_t)grib_byte_count(b); - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - return retval; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - unsigned char* p = NULL; - char* s = v; - long i = 0; - const long length = grib_byte_count(a); - const long slength = 2 * length; - - if (*len < (size_t)slength) { - *len = slength; - return GRIB_BUFFER_TOO_SMALL; - } - - p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); - - for (i = 0; i < length; i++) { - snprintf(s, INT_MAX, "%02x", *(p++)); - s += 2; - } - - *len = slength; - - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - /* The string representation (val) of the byte array will have two chars - * per byte e.g. 4C5B means the 2 bytes 0114 and 0133 in octal - * so has to be twice the length of the byte array - */ - int err = 0; - grib_accessor_class* super = *(a->cclass->super); - grib_context* c = a->context; - size_t nbytes = a->length; - const size_t expected_blen = nbytes; - const size_t expected_slen = 2 * expected_blen; - unsigned char* bytearray = NULL; - size_t i = 0, slen = strlen(val); - - if (slen != expected_slen || *len != expected_slen) { - grib_context_log(c, GRIB_LOG_ERROR, - "%s: Key %s is %lu bytes. Expected a string with %lu characters (actual length=%zu)", - __func__, a->name, expected_blen, expected_slen, *len); - return GRIB_WRONG_ARRAY_SIZE; - } - - bytearray = (unsigned char*)grib_context_malloc(c, nbytes * (sizeof(unsigned char))); - if (!bytearray) return GRIB_OUT_OF_MEMORY; - - for (i = 0; i < (slen/2); i++) { - unsigned int byteVal = 0; - if (sscanf(val + 2*i, "%02x", &byteVal) != 1) { - grib_context_log(c, GRIB_LOG_ERROR,"%s: Invalid hex byte specfication '%.2s'", __func__, val + 2*i); - grib_context_free(c, bytearray); - return GRIB_INVALID_KEY_VALUE; - } - Assert(byteVal < 256); - bytearray[i] = (int)byteVal; - } - - /* Forward to base class to pack the byte array */ - err = super->pack_bytes(a, bytearray, &nbytes); - grib_context_free(c, bytearray); - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc deleted file mode 100644 index d8eef0eb4..000000000 --- a/src/accessor/todo/grib_accessor_class_change_alternative_row_scanning.cc +++ /dev/null @@ -1,212 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long; - IMPLEMENTS = unpack_long - IMPLEMENTS = init;get_native_type - MEMBERS = const char* values - MEMBERS = const char* Ni - MEMBERS = const char* Nj - MEMBERS = const char* alternativeRowScanning - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_change_alternative_row_scanning -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in change_alternative_row_scanning */ - const char* values; - const char* Ni; - const char* Nj; - const char* alternativeRowScanning; -} grib_accessor_change_alternative_row_scanning; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_change_alternative_row_scanning = { - &grib_accessor_class_gen, /* super */ - "change_alternative_row_scanning", /* name */ - sizeof(grib_accessor_change_alternative_row_scanning), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_change_alternative_row_scanning = &_grib_accessor_class_change_alternative_row_scanning; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - int n = 0; - grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->alternativeRowScanning = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a; - const grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning; - size_t size = 0; - double* values = NULL; - double tmp = 0.0; - - if (*val == 0) - return 0; - - /* Make sure Ni / Nj are not missing */ - if (grib_is_missing(h, self->Ni, &err) && !err) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Ni); - return GRIB_WRONG_GRID; - } - if (grib_is_missing(h, self->Nj, &err) && !err) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Nj); - return GRIB_WRONG_GRID; - } - - if ((err = grib_get_long_internal(h, self->Ni, &Ni)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(h, self->Nj, &Nj)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(h, self->alternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return err; - - if ( size > (size_t)(Ni * Nj) ) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%zu!=%ld*%ld)", size, Ni, Nj); - return GRIB_WRONG_ARRAY_SIZE; - } - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - theEnd = Ni / 2; - for (j = 0; j < Nj; j++) { - jr = Ni * j; - for (i = 0; i < theEnd; i++) { - if (j % 2 == 1) { - /* Swap first and last value on every odd row */ - k = jr + i; - kp = jr + Ni - i - 1; - tmp = values[k]; - values[k] = values[kp]; - values[kp] = tmp; - } - } - } - alternativeRowScanning = !alternativeRowScanning; - if ((err = grib_set_long_internal(h, self->alternativeRowScanning, alternativeRowScanning)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - /* Decoding this accessor doesn't make sense so we return a dummy value */ - *v = -1; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_check_internal_version.cc b/src/accessor/todo/grib_accessor_class_check_internal_version.cc deleted file mode 100644 index d59f353de..000000000 --- a/src/accessor/todo/grib_accessor_class_check_internal_version.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = value_count;string_length - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_check_internal_version -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in check_internal_version */ -} grib_accessor_check_internal_version; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_check_internal_version = { - &grib_accessor_class_ascii, /* super */ - "check_internal_version", /* name */ - sizeof(grib_accessor_check_internal_version), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_check_internal_version = &_grib_accessor_class_check_internal_version; - -/* END_CLASS_IMP */ - -/* This is the internal engine version number */ -/* We check this against the version number found in the definitions boot.def file */ -/* See the key "internalVersion" */ -#define LATEST_ENGINE_VERSION 30 - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - /* Check version of definition files is compatible with the engine */ - int err = 0; - long defs_file_version = 0; - grib_handle* h = grib_handle_of_accessor(a); - const char* s_defn_version = grib_arguments_get_name(h, args, 0); - Assert(s_defn_version); - - err = grib_get_long_internal(h, s_defn_version, &defs_file_version); - if (!err) { - if (defs_file_version > LATEST_ENGINE_VERSION) { - grib_context_log(h->context, GRIB_LOG_FATAL, - "Definition files version (%d) is greater than engine version (%d)!\n" - " " /* indent for 2nd line */ - "These definition files are for a later version of the ecCodes engine.", - defs_file_version, LATEST_ENGINE_VERSION); - } - } -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} diff --git a/src/accessor/todo/grib_accessor_class_codeflag.cc b/src/accessor/todo/grib_accessor_class_codeflag.cc deleted file mode 100644 index ab86a64b1..000000000 --- a/src/accessor/todo/grib_accessor_class_codeflag.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (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. - */ - -/**************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump - IMPLEMENTS = value_count - MEMBERS = const char* tablename - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codeflag -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codeflag */ - const char* tablename; -} grib_accessor_codeflag; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_codeflag = { - &grib_accessor_class_unsigned, /* super */ - "codeflag", /* name */ - sizeof(grib_accessor_codeflag), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codeflag; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* param) -{ - grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - a->length = len; - self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0); - Assert(a->length >= 0); -} - -static int test_bit(long a, long b) -{ - DEBUG_ASSERT(b>=0); - return a & (1 << b); -} - -static int grib_get_codeflag(grib_accessor* a, long code, char* codename) -{ - const grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - FILE* f = NULL; - char fname[1024]; - char bval[50]; - char num[50]; - char* filename = 0; - char line[1024]; - size_t i = 0; - int j = 0; - int err = 0; - - err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); - if (err) { - strncpy(fname, self->tablename, sizeof(fname)-1); - fname[sizeof(fname)-1] = '\0'; - } - - if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) { - grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot open flag table %s", filename); - strcpy(codename, "Cannot open flag table"); - return GRIB_FILE_NOT_FOUND; - } - - f = codes_fopen(filename, "r"); - if (!f) { - grib_context_log(a->context, (GRIB_LOG_WARNING) | (GRIB_LOG_PERROR), "Cannot open flag table %s", filename); - strcpy(codename, "Cannot open flag table"); - return GRIB_FILE_NOT_FOUND; - } - - // strcpy(codename, self->tablename); - // strcat(codename,": "); - // j = strlen(codename); - - while (fgets(line, sizeof(line) - 1, f)) { - sscanf(line, "%49s %49s", num, bval); - - if (num[0] != '#') { - if ((test_bit(code, a->length * 8 - atol(num)) > 0) == atol(bval)) { - size_t linelen = strlen(line); - codename[j++] = '('; - codename[j++] = num[0]; - codename[j++] = '='; - codename[j++] = bval[0]; - codename[j++] = ')'; - codename[j++] = ' '; - if (j) - codename[j++] = ' '; - - for (i = (strlen(num) + strlen(bval) + 2); i < linelen - 1; i++) - codename[j++] = line[i]; - if (line[i] != '\n') - codename[j++] = line[i]; - codename[j++] = ';'; - } - } - } - - if (j > 1 && codename[j - 1] == ';') - j--; - codename[j] = 0; - - strcat(codename, ":"); - strcat(codename, fname); - - fclose(f); - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - const grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - long v = 0; - char flagname[1024] = {0,}; - char fname[1024] = {0,}; - - size_t llen = 1; - - grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); - grib_unpack_long(a, &v, &llen); - - grib_get_codeflag(a, v, flagname); - - grib_dump_bits(dumper, a, flagname); -} diff --git a/src/accessor/todo/grib_accessor_class_codetable_title.cc b/src/accessor/todo/grib_accessor_class_codetable_title.cc deleted file mode 100644 index 2ddd0f3cb..000000000 --- a/src/accessor/todo/grib_accessor_class_codetable_title.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* codetable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable_title -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in codetable_title */ - const char* codetable; -} grib_accessor_codetable_title; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_codetable_title = { - &grib_accessor_class_gen, /* super */ - "codetable_title", /* name */ - sizeof(grib_accessor_codetable_title), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_codetable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; -} grib_accessor_codetable; - - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_codetable_title* self = (grib_accessor_codetable_title*)a; - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_codetable_title* self = (grib_accessor_codetable_title*)a; - grib_codetable* table = NULL; - - size_t size = 1; - long value; - int err = GRIB_SUCCESS; - char tmp[1024]; - size_t l = 1024; - grib_accessor_codetable* ca = (grib_accessor_codetable*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); - - if ((err = grib_unpack_long((grib_accessor*)ca, &value, &size)) != GRIB_SUCCESS) - return err; - - table = ca->table; - - if (table && (value >= 0) && (value < table->size) && table->entries[value].title) { - strcpy(tmp, table->entries[value].title); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)value); - } - - l = strlen(tmp) + 1; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(buffer, tmp); - *len = l; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_codetable_units.cc b/src/accessor/todo/grib_accessor_class_codetable_units.cc deleted file mode 100644 index de9a9655f..000000000 --- a/src/accessor/todo/grib_accessor_class_codetable_units.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* codetable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in codetable_units */ - const char* codetable; -} grib_accessor_codetable_units; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_codetable_units = { - &grib_accessor_class_gen, /* super */ - "codetable_units", /* name */ - sizeof(grib_accessor_codetable_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_codetable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; -} grib_accessor_codetable; - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_codetable_units* self = (grib_accessor_codetable_units*)a; - - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_codetable_units* self = (grib_accessor_codetable_units*)a; - grib_codetable* table = NULL; - - size_t size = 1; - long value; - int err = GRIB_SUCCESS; - char tmp[1024]; - size_t l = sizeof(tmp); - grib_accessor_codetable* ca = (grib_accessor_codetable*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); - - if ((err = grib_unpack_long((grib_accessor*)ca, &value, &size)) != GRIB_SUCCESS) - return err; - - table = ca->table; - - if (table && (value >= 0) && (value < table->size) && table->entries[value].units) { - strcpy(tmp, table->entries[value].units); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)value); - } - - l = strlen(tmp) + 1; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(buffer, tmp); - *len = l; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_count_file.cc b/src/accessor/todo/grib_accessor_class_count_file.cc deleted file mode 100644 index 196a48038..000000000 --- a/src/accessor/todo/grib_accessor_class_count_file.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * (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. - */ - -/*********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_file -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_file */ -} grib_accessor_count_file; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_file = { - &grib_accessor_class_long, /* super */ - "count_file", /* name */ - sizeof(grib_accessor_count_file), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_context_get_handle_file_count(a->context); - *len = 1; - return 0; -} diff --git a/src/accessor/todo/grib_accessor_class_count_total.cc b/src/accessor/todo/grib_accessor_class_count_total.cc deleted file mode 100644 index 022cc4998..000000000 --- a/src/accessor/todo/grib_accessor_class_count_total.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * (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. - */ - - -/*************************************************** - * Enrico Fucile - **************************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_total -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_total */ -} grib_accessor_count_total; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_total = { - &grib_accessor_class_long, /* super */ - "count_total", /* name */ - sizeof(grib_accessor_count_total), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_context_get_handle_total_count(a->context); - *len = 1; - return 0; -} diff --git a/src/accessor/todo/grib_accessor_class_data_dummy_field.cc b/src/accessor/todo/grib_accessor_class_data_dummy_field.cc deleted file mode 100644 index 65b6d5a8f..000000000 --- a/src/accessor/todo/grib_accessor_class_data_dummy_field.cc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_g1simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = pack_double - MEMBERS=const char* missing_value - MEMBERS=const char* numberOfPoints - MEMBERS=const char* bitmap - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_dummy_field -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1simple_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - /* Members defined in data_dummy_field */ - const char* missing_value; - const char* numberOfPoints; - const char* bitmap; -} grib_accessor_data_dummy_field; - -extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; - -static grib_accessor_class _grib_accessor_class_data_dummy_field = { - &grib_accessor_class_data_g1simple_packing, /* super */ - "data_dummy_field", /* name */ - sizeof(grib_accessor_data_dummy_field), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_class_data_dummy_field; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - size_t i = 0, n_vals = 0; - long numberOfPoints; - double missing_value = 0; - int err = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints)) != GRIB_SUCCESS) - return err; - n_vals = numberOfPoints; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < n_vals; i++) - val[i] = missing_value; - - if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) { - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->bitmap, val, n_vals)) != GRIB_SUCCESS) - return err; - } - - *len = (long)n_vals; - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - - size_t n_vals = *len; - int err = 0; - long bits_per_value = 0; - long half_byte = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - - buflen = (1 + ((bits_per_value * n_vals) / 8)) * sizeof(unsigned char); - - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - - half_byte = (buflen * 8) - ((*len) * bits_per_value); - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte)) != GRIB_SUCCESS) { - grib_context_free(a->context, buf); - return err; - } - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* numberOfPoints) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - int err = 0; - *numberOfPoints = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints)) != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to get count of %s (%s)", a->name, grib_get_error_message(err)); - } - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc deleted file mode 100644 index 6c8fa5cd6..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g1complex_packing.cc +++ /dev/null @@ -1,235 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_complex_packing - IMPLEMENTS = pack_double - IMPLEMENTS = init - MEMBERS= const char* N - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; - /* Members defined in data_g1complex_packing */ - const char* N; - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -} grib_accessor_data_g1complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_complex_packing; - -static grib_accessor_class _grib_accessor_class_data_g1complex_packing = { - &grib_accessor_class_data_complex_packing, /* super */ - "data_g1complex_packing", /* name */ - sizeof(grib_accessor_data_g1complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1complex_packing = &_grib_accessor_class_data_g1complex_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1complex_packing* self = (grib_accessor_data_g1complex_packing*)a; - self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->N = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->ieee_packing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->edition = 1; - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g1complex_packing* self = (grib_accessor_data_g1complex_packing*)a; - int ret = GRIB_SUCCESS; - long seclen = 0; - long sub_j = 0; - long sub_k = 0; - long sub_m = 0; - long n = 0; - long half_byte = 0; - long bits_per_value = 0; - size_t buflen = 0; - grib_accessor_class* super = *(a->cclass->super); - - if (*len == 0) - return GRIB_NO_VALUES; - -// /* TODO: spectral_ieee does not work */ -// if (c->ieee_packing && self->ieee_packing) { -// grib_handle* h = grib_handle_of_accessor(a); -// grib_context* c = a->context; -// char* packingType_s = NULL; -// char* ieee_packing_s = NULL; -// long precision = c->ieee_packing == 32 ? 1 : 2; -// size_t lenstr = strlen(self->ieee_packing); - -// packingType_s = grib_context_strdup(c, self->packingType); -// ieee_packing_s = grib_context_strdup(c, self->ieee_packing); -// precision_s = grib_context_strdup(c, self->precision); - -// grib_set_string(h, packingType_s, ieee_packing_s, &lenstr); -// grib_set_long(h, precision_s, precision); - -// grib_context_free(c, packingType_s); -// grib_context_free(c, ieee_packing_s); -// grib_context_free(c, precision_s); -// return grib_set_double_array(h, "values", val, *len); -// } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_j, &sub_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_k, &sub_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_m, &sub_m)) != GRIB_SUCCESS) - return ret; - - self->dirty = 1; - - Assert((sub_j == sub_k) && (sub_m == sub_j)); - - ret = super->pack_double(a, val, len); - - if (ret == GRIB_SUCCESS) { - n = a->offset + 4 * ((sub_k + 1) * (sub_k + 2)); - - /* Octet number starts from beginning of message but shouldn't */ - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n)) != GRIB_SUCCESS) - return ret; - - // ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection); - // if (ret != GRIB_SUCCESS) - // return ret; - // if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS) - // return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen); - if (ret != GRIB_SUCCESS) - return ret; - - buflen = 32 * (sub_k + 1) * (sub_k + 2) + (*len - (sub_k + 1) * (sub_k + 2)) * bits_per_value + 18 * 8; - half_byte = seclen * 8 - buflen; - if (a->context->debug == -1) { - fprintf(stderr, "ECCODES DEBUG: half_byte=%ld\n", half_byte); - } - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte); - if (ret != GRIB_SUCCESS) - return ret; - } - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc deleted file mode 100644 index 4ae89c576..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g1secondary_bitmap.cc +++ /dev/null @@ -1,220 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_secondary_bitmap - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_ones - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1secondary_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_secondary_bitmap */ - const char* primary_bitmap; - const char* secondary_bitmap; - const char* missing_value; - const char* expand_by; - /* Members defined in data_g1secondary_bitmap */ - const char* number_of_ones; -} grib_accessor_data_g1secondary_bitmap; - -extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; - -static grib_accessor_class _grib_accessor_class_data_g1secondary_bitmap = { - &grib_accessor_class_data_secondary_bitmap, /* super */ - "data_g1secondary_bitmap", /* name */ - sizeof(grib_accessor_data_g1secondary_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap = &_grib_accessor_class_data_g1secondary_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - self->number_of_ones = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - size_t len = 0; - int err = 0; - long expand_by; - *count = 0; - - err = grib_get_long_internal(grib_handle_of_accessor(a), self->expand_by, &expand_by); - if (err) - return err; - - err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &len); - if (err) - return err; - - *count = expand_by * len; - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - - int err = 0; - - long primary_len = 0; - long secondary_len = 0; - double* primary_bitmap = NULL; - double* secondary_bitmap = NULL; - long i = 0; - long j = 0; - long on = 0; - long k; - long m; - double missing_value = 0; - double present_value = 0; - long expand_by = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - if (expand_by <= 0) - return GRIB_ENCODING_ERROR; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len % expand_by) { - /*TODO: issue warning */ - return GRIB_ENCODING_ERROR; - } - - primary_len = *len / expand_by; - primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); - if (!primary_bitmap) - return GRIB_OUT_OF_MEMORY; - - secondary_len = *len; - secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); - if (!secondary_bitmap) { - grib_context_free(a->context, primary_bitmap); - return GRIB_OUT_OF_MEMORY; - } - - if (missing_value == 0) - present_value = 1; - else - present_value = 0; - - k = 0; - m = 0; - for (i = 0; i < *len; i += expand_by) { - int cnt = 0; - for (j = 0; j < expand_by; j++) - if (val[i + j] == missing_value) - cnt++; - - if (cnt == expand_by) /* all expand_by values are missing */ - primary_bitmap[k++] = missing_value; - else { - primary_bitmap[k++] = present_value; - for (j = 0; j < expand_by; j++) - secondary_bitmap[m++] = val[i + j]; - on++; - } - } - - *len = k; - - /*printf("QQQQQQQ %ld %ld second=%ld\n",primary_len,on,m);*/ - Assert(k == primary_len); - - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); - if (err == GRIB_SUCCESS) - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); - - grib_context_free(a->context, primary_bitmap); - grib_context_free(a->context, secondary_bitmap); - - if (err == GRIB_SUCCESS) - err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_ones, on); - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc deleted file mode 100644 index 332b0af0c..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g1shsimple_packing.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_shsimple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); - -typedef struct grib_accessor_data_g1shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; - /* Members defined in data_g1shsimple_packing */ -} grib_accessor_data_g1shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1shsimple_packing = { - &grib_accessor_class_data_shsimple_packing, /* super */ - "data_g1shsimple_packing", /* name */ - sizeof(grib_accessor_data_g1shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1shsimple_packing = &_grib_accessor_class_data_g1shsimple_packing; - -/* END_CLASS_IMP */ - - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1shsimple_packing* self = (grib_accessor_data_g1shsimple_packing*)a; - size_t len = 0; - int err = 0; - - err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &len); - len += 1; - - *count = len; - return err; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g1shsimple_packing* self = (grib_accessor_data_g1shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = 0; - size_t n_vals = 0; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - n_vals = coded_n_vals + 1; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g1shsimple_packing_bitmap : unpack_double : creating %s, %d values", - a->name, n_vals); - - *len = n_vals; - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc deleted file mode 100644 index 98bcaf5cc..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g2complex_packing.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_complex_packing - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; - /* Members defined in data_g2complex_packing */ - const char* numberOfValues; -} grib_accessor_data_g2complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_complex_packing; - -static grib_accessor_class _grib_accessor_class_data_g2complex_packing = { - &grib_accessor_class_data_complex_packing, /* super */ - "data_g2complex_packing", /* name */ - sizeof(grib_accessor_data_g2complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2complex_packing = &_grib_accessor_class_data_g2complex_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->edition = 2; - - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* numberOfValues) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - *numberOfValues = 0; - - return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, numberOfValues); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - int ret = GRIB_SUCCESS; - grib_accessor_class* super = *(a->cclass->super); - - if (*len == 0) - return GRIB_NO_VALUES; - - ret = super->pack_double(a, val, len); - - if (ret == GRIB_SUCCESS) - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len); - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc deleted file mode 100644 index cceb3d765..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g2secondary_bitmap.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_secondary_bitmap - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2secondary_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_secondary_bitmap */ - const char* primary_bitmap; - const char* secondary_bitmap; - const char* missing_value; - const char* expand_by; - /* Members defined in data_g2secondary_bitmap */ - const char* number_of_values; -} grib_accessor_data_g2secondary_bitmap; - -extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; - -static grib_accessor_class _grib_accessor_class_data_g2secondary_bitmap = { - &grib_accessor_class_data_secondary_bitmap, /* super */ - "data_g2secondary_bitmap", /* name */ - sizeof(grib_accessor_data_g2secondary_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_accessor_class_data_g2secondary_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - *len = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - int err = 0; - - long primary_len = 0, secondary_len = 0; - double* primary_bitmap = NULL; - double* secondary_bitmap = NULL; - long i = 0, j = 0, k = 0, m = 0; - double missing_value = 0, present_value = 0; - long expand_by = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - if (expand_by <= 0) - return GRIB_ENCODING_ERROR; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len % expand_by) { - /*TODO: issue warning */ - return GRIB_ENCODING_ERROR; - } - - primary_len = *len / expand_by; - primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); - if (!primary_bitmap) - return GRIB_OUT_OF_MEMORY; - - secondary_len = *len; - secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); - if (!secondary_bitmap) { - grib_context_free(a->context, primary_bitmap); - return GRIB_OUT_OF_MEMORY; - } - - if (missing_value == 0) - present_value = 1; - else - present_value = 0; - - k = 0; - m = 0; - for (i = 0; i < *len; i += expand_by) { - int cnt = 0; - for (j = 0; j < expand_by; j++) - if (val[i + j] == missing_value) - cnt++; - - if (cnt == expand_by) /* all expand_by values are missing */ - primary_bitmap[k++] = missing_value; - else { - primary_bitmap[k++] = present_value; - for (j = 0; j < expand_by; j++) - secondary_bitmap[m++] = val[i + j]; - //on++; - } - } - - *len = k; - - Assert(k == primary_len); - - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); - if (err == GRIB_SUCCESS) - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); - - grib_context_free(a->context, primary_bitmap); - grib_context_free(a->context, secondary_bitmap); - - if (err == GRIB_SUCCESS) - err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len * expand_by); - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc deleted file mode 100644 index bdb1157cf..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g2shsimple_packing.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_shsimple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* numberOfValues - MEMBERS=const char* numberOfDataPoints - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; - /* Members defined in data_g2shsimple_packing */ - const char* numberOfValues; - const char* numberOfDataPoints; -} grib_accessor_data_g2shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2shsimple_packing = { - &grib_accessor_class_data_shsimple_packing, /* super */ - "data_g2shsimple_packing", /* name */ - sizeof(grib_accessor_data_g2shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2shsimple_packing = &_grib_accessor_class_data_g2shsimple_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); - self->numberOfDataPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - *len = 0; - return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, len); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t n_vals = 0; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &n_vals)) != GRIB_SUCCESS) - return err; - - self->dirty = 0; - - /* n_vals = coded_n_vals+1; */ - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = *len - 1; - size_t n_vals = *len; - - if (*len == 0) - return GRIB_NO_VALUES; - - self->dirty = 1; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, (long)n_vals)) != GRIB_SUCCESS) - return err; - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfDataPoints, (long)n_vals)) != GRIB_SUCCESS) - return err; - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc deleted file mode 100644 index 88a4de2cb..000000000 --- a/src/accessor/todo/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#define DIRECT 0 -#define INVERSE 1 - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_g2simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - MEMBERS=const char* pre_processing - MEMBERS=const char* pre_processing_parameter - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2simple_packing_with_preprocessing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2simple_packing */ - /* Members defined in data_g2simple_packing_with_preprocessing */ - const char* pre_processing; - const char* pre_processing_parameter; -} grib_accessor_data_g2simple_packing_with_preprocessing; - -extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2simple_packing_with_preprocessing = { - &grib_accessor_class_data_g2simple_packing, /* super */ - "data_g2simple_packing_with_preprocessing", /* name */ - sizeof(grib_accessor_data_g2simple_packing_with_preprocessing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing = &_grib_accessor_class_data_g2simple_packing_with_preprocessing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->pre_processing_parameter = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - *n_vals = 0; - - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); -} - -static int pre_processing_func(double* values, long length, long pre_processing, - double* pre_processing_parameter, int mode) -{ - int i = 0, ret = 0; - double min = values[0]; - double next_min = values[0]; - Assert(length > 0); - - switch (pre_processing) { - /* NONE */ - case 0: - break; - /* LOGARITHM */ - case 1: - if (mode == DIRECT) { - for (i = 0; i < length; i++) { - if (values[i] < min) - min = values[i]; - if (values[i] > next_min) - next_min = values[i]; - } - for (i = 0; i < length; i++) { - if (values[i] > min && values[i] < next_min) - next_min = values[i]; - } - if (min > 0) { - *pre_processing_parameter = 0; - for (i = 0; i < length; i++) { - DEBUG_ASSERT(values[i] > 0); - values[i] = log(values[i]); - } - } - else { - double ppp = 0; - *pre_processing_parameter = next_min - 2 * min; - if (next_min == min) - return ret; - ppp = *pre_processing_parameter; - for (i = 0; i < length; i++) { - DEBUG_ASSERT((values[i] + ppp) > 0); - values[i] = log(values[i] + ppp); - } - } - } - else { - Assert(mode == INVERSE); - if (*pre_processing_parameter == 0) { - for (i = 0; i < length; i++) - values[i] = exp(values[i]); - } - else { - for (i = 0; i < length; i++) - values[i] = exp(values[i]) - *pre_processing_parameter; - } - } - break; - default: - ret = GRIB_NOT_IMPLEMENTED; - break; - } - - return ret; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - grib_accessor_class* super = *(a->cclass->super); - grib_accessor_class* super2 = NULL; - - size_t n_vals = 0; - long nn = 0; - int err = 0; - - long pre_processing; - double pre_processing_parameter; - - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if (n_vals == 0) { - *len = 0; - return GRIB_SUCCESS; - } - - self->dirty = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) { - return err; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, &pre_processing_parameter)) != GRIB_SUCCESS) { - return err; - } - - Assert(super->super); - super2 = *(super->super); - err = super2->unpack_double(a, val, &n_vals); /* GRIB-364 */ - if (err != GRIB_SUCCESS) - return err; - - err = pre_processing_func(val, n_vals, pre_processing, &pre_processing_parameter, INVERSE); - if (err != GRIB_SUCCESS) - return err; - - *len = (long)n_vals; - - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - grib_accessor_class* super = *(a->cclass->super); - - size_t n_vals = *len; - int err = 0; - - long pre_processing = 0; - double pre_processing_parameter = 0; - - self->dirty = 1; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) - return err; - - err = pre_processing_func((double*)val, n_vals, pre_processing, &pre_processing_parameter, DIRECT); - if (err != GRIB_SUCCESS) - return err; - - err = super->pack_double(a, val, len); - if (err != GRIB_SUCCESS) - return err; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, pre_processing_parameter)) != GRIB_SUCCESS) - return err; - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals)) != GRIB_SUCCESS) - return err; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_data_raw_packing.cc b/src/accessor/todo/grib_accessor_class_data_raw_packing.cc deleted file mode 100644 index 27c3d62e3..000000000 --- a/src/accessor/todo/grib_accessor_class_data_raw_packing.cc +++ /dev/null @@ -1,306 +0,0 @@ -/* - * (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. - */ -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_ieeefloat.h" - -#define PRE_PROCESSING_NONE 0 -#define PRE_PROCESSING_DIFFERENCE 1 -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_raw_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_raw_packing */ - const char* number_of_values; - const char* precision; -} grib_accessor_data_raw_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_raw_packing = { - &grib_accessor_class_values, /* super */ - "data_raw_packing", /* name */ - sizeof(grib_accessor_data_raw_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_raw_packing = &_grib_accessor_class_data_raw_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - - self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - *n_vals = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - unsigned char* buf = NULL; - int bytes = 0; - size_t nvals = 0; - long inlen = grib_byte_count(a); - - long precision = 0; - - int code = GRIB_SUCCESS; - - if ((code = grib_get_long(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return code; - - self->dirty = 0; - - buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - - switch (precision) { - case 1: - bytes = 4; - break; - case 2: - bytes = 8; - break; - default: - return GRIB_NOT_IMPLEMENTED; - } - - nvals = inlen / bytes; - - if (*len < nvals) - return GRIB_ARRAY_TOO_SMALL; - - code = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); - - *len = nvals; - - return code; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - - int bytes = 0; - unsigned char* buffer = NULL; - - long precision = 0; - - double* values = (double*)val; - size_t inlen = *len; - - /*int free_buffer = 0; - *int free_values = 0;*/ - - int code = GRIB_SUCCESS; - - size_t bufsize = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((code = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return code; - - self->dirty = 1; - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - code = GRIB_NOT_IMPLEMENTED; - goto clean_up; - } - - bufsize = bytes * inlen; - - buffer = (unsigned char*)grib_context_malloc(a->context, bufsize); - - if (!buffer) { - code = GRIB_OUT_OF_MEMORY; - goto clean_up; - } - - code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer); - -clean_up: - /*if (free_buffer) - * free(buffer); - * if (free_values) - * free(values); - */ - - grib_buffer_replace(a, buffer, bufsize, 1, 1); - - grib_context_buffer_free(a->context, buffer); - - if (code == GRIB_SUCCESS) { - code = grib_set_long(grib_handle_of_accessor(a), self->number_of_values, inlen); - if (code == GRIB_READ_ONLY) - code = 0; - } - - return code; -} - -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - int ret = 0; - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - unsigned char* buf = NULL; - int bytes = 0; - size_t nvals = 0; - long inlen = grib_byte_count(a); - long pos = 0; - long precision = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return ret; - - self->dirty = 0; - - buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - } - - pos = bytes * idx; - - Assert(pos <= inlen); - - nvals = 1; - buf += pos; - - ret = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); - - return ret; -} - -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - int err = 0; - size_t i = 0; - for (i=0; iprimary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->secondary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); - self->expand_by = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_secondary_bitmap* self = (grib_accessor_data_secondary_bitmap*)a; - - size_t i = 0; - size_t j = 0; - size_t k = 0; - size_t m = 0; - size_t n_vals = 0; - long nn = 0; - long expand_by = 0; - int err = 0; - size_t primary_len; - size_t secondary_len; - double* primary_vals; - double* secondary_vals; - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &primary_len)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->secondary_bitmap, &secondary_len)) != GRIB_SUCCESS) - return err; - - primary_vals = (double*)grib_context_malloc(a->context, primary_len * sizeof(double)); - if (!primary_vals) - return GRIB_OUT_OF_MEMORY; - - secondary_vals = (double*)grib_context_malloc(a->context, secondary_len * sizeof(double)); - if (!secondary_vals) { - grib_context_free(a->context, primary_vals); - return GRIB_OUT_OF_MEMORY; - } - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_vals, &primary_len)) != GRIB_SUCCESS) { - grib_context_free(a->context, secondary_vals); - grib_context_free(a->context, primary_vals); - return err; - } - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_vals, &secondary_len)) != GRIB_SUCCESS) { - grib_context_free(a->context, secondary_vals); - grib_context_free(a->context, primary_vals); - return err; - } - - k = 0; - m = 0; - for (i = 0; i < primary_len; i++) { - /* if(primary_vals[i]) f++; */ - if (primary_vals[i]) { - for (j = 0; j < expand_by; j++) - val[k++] = secondary_vals[m++]; - } - else { - for (j = 0; j < expand_by; j++) - val[k++] = 0; - } - } - - Assert(k <= *len); - Assert(m <= secondary_len); - - /*printf("FOOBAR %d %d %ld %d\n",f,primary_len,expand_by,n_vals);*/ - - *len = n_vals; - - grib_context_free(a->context, primary_vals); - grib_context_free(a->context, secondary_vals); - return err; -} - -static int get_native_type(grib_accessor* a) -{ - // grib_accessor_data_secondary_bitmap* self = (grib_accessor_data_secondary_bitmap*)a; - //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); - return GRIB_TYPE_DOUBLE; -} diff --git a/src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc deleted file mode 100644 index d06743f8d..000000000 --- a/src/accessor/todo/grib_accessor_class_data_shsimple_packing.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = dump;get_native_type - MEMBERS=const char* coded_values - MEMBERS=const char* real_part - MEMBERS=int dirty - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; -} grib_accessor_data_shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_shsimple_packing = { - &grib_accessor_class_gen, /* super */ - "data_shsimple_packing", /* name */ - sizeof(grib_accessor_data_shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_shsimple_packing = &_grib_accessor_class_data_shsimple_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_shsimple_packing* self = (grib_accessor_data_shsimple_packing*)a; - - self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->real_part = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_shsimple_packing* self = (grib_accessor_data_shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = *len - 1; - size_t n_vals = *len; - - self->dirty = 1; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} diff --git a/src/accessor/todo/grib_accessor_class_decimal_precision.cc b/src/accessor/todo/grib_accessor_class_decimal_precision.cc deleted file mode 100644 index e498931b7..000000000 --- a/src/accessor/todo/grib_accessor_class_decimal_precision.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * (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. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bits_per_value - MEMBERS = const char* changing_precision - MEMBERS = const char* decimal_scale_factor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_decimal_precision -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in decimal_precision */ - const char* values; - const char* bits_per_value; - const char* changing_precision; - const char* decimal_scale_factor; -} grib_accessor_decimal_precision; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_decimal_precision = { - &grib_accessor_class_long, /* super */ - "decimal_precision", /* name */ - sizeof(grib_accessor_decimal_precision), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_decimal_precision = &_grib_accessor_class_decimal_precision; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->decimal_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->changing_precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->decimal_scale_factor, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - long bitsPerValue = 0; - double* values = NULL; - size_t size = 0; - int ret = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (!self->values) { - if ((ret = grib_set_long_internal(h, self->bits_per_value, 0)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - return GRIB_SUCCESS; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->bits_per_value, bitsPerValue)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_dirty.cc b/src/accessor/todo/grib_accessor_class_dirty.cc deleted file mode 100644 index ec29923e3..000000000 --- a/src/accessor/todo/grib_accessor_class_dirty.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * (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. - */ - -/************************************ - * Enrico Fucile - **********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* accessor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_dirty -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in dirty */ - const char* accessor; -} grib_accessor_dirty; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_dirty = { - &grib_accessor_class_long, /* super */ - "dirty", /* name */ - sizeof(grib_accessor_dirty), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); - - if (x) - x->dirty = *val; - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); - - if (x) - x->dirty = 1; - - *val = 1; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_divdouble.cc b/src/accessor/todo/grib_accessor_class_divdouble.cc deleted file mode 100644 index 8ab86e22e..000000000 --- a/src/accessor/todo/grib_accessor_class_divdouble.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS = const char* val - MEMBERS = double divisor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_divdouble -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in divdouble */ - const char* val; - double divisor; -} grib_accessor_divdouble; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_divdouble = { - &grib_accessor_class_double, /* super */ - "divdouble", /* name */ - sizeof(grib_accessor_divdouble), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdouble; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_divdouble* self = (grib_accessor_divdouble*)a; - int n = 0; - - self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - const grib_accessor_divdouble* self = (grib_accessor_divdouble*)a; - int ret = GRIB_SUCCESS; - double value = 0; - - ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); - if (ret != GRIB_SUCCESS) - return ret; - - if (self->divisor == 0) { - return GRIB_INVALID_ARGUMENT; - } - *val = value / self->divisor; - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_double.cc b/src/accessor/todo/grib_accessor_class_double.cc deleted file mode 100644 index 3a2933aff..000000000 --- a/src/accessor/todo/grib_accessor_class_double.cc +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;unpack_string - IMPLEMENTS = pack_missing; - IMPLEMENTS = dump - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_double -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ -} grib_accessor_double; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_double = { - &grib_accessor_class_gen, /* super */ - "double", /* name */ - sizeof(grib_accessor_double), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_double = &_grib_accessor_class_double; - -/* END_CLASS_IMP */ - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - double val = 0; - size_t l = 1; - char repres[1024]; - char format[32] = "%g"; - grib_handle* h = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - grib_unpack_double(a, &val, &l); - - if ((val == GRIB_MISSING_DOUBLE) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { - snprintf(repres, sizeof(repres), "MISSING"); - } else { - size_t size = sizeof(format); - grib_get_string(h, "formatForDoubles", format, &size); - snprintf(repres, sizeof(repres), format, val); - } - - l = strlen(repres) + 1; - - if (l > *len) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name); - - *len = l; - - strcpy(v, repres); - return GRIB_SUCCESS; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - long count = 0; - int err = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - while (alen != 0) { - if (*bval != *aval) - retval = GRIB_DOUBLE_VALUE_MISMATCH; - alen--; - } - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static int pack_missing(grib_accessor* a) -{ - size_t len = 1; - double value = GRIB_MISSING_DOUBLE; - - if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_pack_double(a, &value, &len); - return GRIB_VALUE_CANNOT_BE_MISSING; -} diff --git a/src/accessor/todo/grib_accessor_class_evaluate.cc b/src/accessor/todo/grib_accessor_class_evaluate.cc deleted file mode 100644 index 596b95884..000000000 --- a/src/accessor/todo/grib_accessor_class_evaluate.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS= grib_arguments* arg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_evaluate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in evaluate */ - grib_arguments* arg; -} grib_accessor_evaluate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_evaluate = { - &grib_accessor_class_long, /* super */ - "evaluate", /* name */ - sizeof(grib_accessor_evaluate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_evaluate* self = (grib_accessor_evaluate*)a; - self->arg = c; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_evaluate* self = (grib_accessor_evaluate*)a; - grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); - - int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); - *len = 1; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc deleted file mode 100644 index c275253e5..000000000 --- a/src/accessor/todo/grib_accessor_class_g1_half_byte_codeflag.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_half_byte_codeflag -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g1_half_byte_codeflag */ -} grib_accessor_g1_half_byte_codeflag; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g1_half_byte_codeflag = { - &grib_accessor_class_gen, /* super */ - "g1_half_byte_codeflag", /* name */ - sizeof(grib_accessor_g1_half_byte_codeflag), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor_class_g1_half_byte_codeflag; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - unsigned char dat = 0; - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; - - *val = dat; - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ - grib_handle_of_accessor(a)->buffer->data[a->offset] = (a->parent->h->buffer->data[a->offset] & 0xf0) | (*val & 0x0f); - /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ - - *len = 1; - return ret; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_g1_section4_length.cc b/src/accessor/todo/grib_accessor_class_g1_section4_length.cc deleted file mode 100644 index 8e6c2b3f1..000000000 --- a/src/accessor/todo/grib_accessor_class_g1_section4_length.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_section_length - IMPLEMENTS = init;unpack_long;pack_long - MEMBERS = const char* total_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_section4_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ - /* Members defined in g1_section4_length */ - const char* total_length; -} grib_accessor_g1_section4_length; - -extern grib_accessor_class* grib_accessor_class_section_length; - -static grib_accessor_class _grib_accessor_class_g1_section4_length = { - &grib_accessor_class_section_length, /* super */ - "g1_section4_length", /* name */ - sizeof(grib_accessor_g1_section4_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1_section4_length = &_grib_accessor_class_g1_section4_length; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_g1_section4_length* self = (grib_accessor_g1_section4_length*)a; - self->total_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - // Old implementation: - // Here we assume that the totalLength will be coded AFTER the section4 length, and - // the section4 length will be overwritten by the totalLength accessor for large GRIBs - // grib_accessor_class* super = *(a->cclass->super); - // return super->pack_long(a,val,len); - - // Note: Do not directly call pack_long on base class - // because in this special case we want to skip the checks. - // So we call the helper function which has an extra argument - return pack_long_unsigned_helper(a, val, len, /*check=*/0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1_section4_length* self = (grib_accessor_g1_section4_length*)a; - int ret = 0; - long total_length = 0, sec4_length = 0; - - if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), - grib_find_accessor(grib_handle_of_accessor(a), self->total_length), - a, - &total_length, - &sec4_length)) != GRIB_SUCCESS) { - return ret; - } - - *val = sec4_length; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g1bitmap.cc b/src/accessor/todo/grib_accessor_class_g1bitmap.cc deleted file mode 100644 index 519638f6a..000000000 --- a/src/accessor/todo/grib_accessor_class_g1bitmap.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bitmap - IMPLEMENTS = pack_double; unpack_bytes - IMPLEMENTS = value_count - IMPLEMENTS = init; - MEMBERS=const char* unusedBits - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; - /* Members defined in g1bitmap */ - const char* unusedBits; -} grib_accessor_g1bitmap; - -extern grib_accessor_class* grib_accessor_class_bitmap; - -static grib_accessor_class _grib_accessor_class_g1bitmap = { - &grib_accessor_class_bitmap, /* super */ - "g1bitmap", /* name */ - sizeof(grib_accessor_g1bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1bitmap = &_grib_accessor_class_g1bitmap; - -/* END_CLASS_IMP */ - - -static void grib_set_bit_on(unsigned char* p, long* bitp); - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - size_t tlen; - - unsigned char* buf = NULL; - size_t i; - int err = 0; - long pos = 0; - //long bmaplen = 0; - const int bit_padding = 16; - double miss_values = 0; - tlen = ((*len + bit_padding - 1) / bit_padding * bit_padding) / 8; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) - return err; - - buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - pos = 0; - for (i = 0; i < *len; i++) { - if (val[i] == miss_values) - pos++; - else { - //bmaplen++; - grib_set_bit_on(buf, &pos); - } - } - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->unusedBits, tlen * 8 - *len)) != GRIB_SUCCESS) - return err; - - err = grib_buffer_replace(a, buf, tlen, 1, 1); - if (err) return err; - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - long tlen; - int err; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d", self->unusedBits, err); - - *count = (a->length * 8) - tlen; - return err; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - long tlen; - int err; - long length = grib_byte_count(a); - long offset = grib_byte_offset(a); - - if (*len < (size_t)length) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %ld bytes long\n", a->name, length); - *len = length; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) - grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_class_bitmap.unpack_bytes : cannot get %s err=%d", self->unusedBits, err); - - length -= tlen / 8; - memcpy(val, buf + offset, length); - *len = length; - - return GRIB_SUCCESS; -} - -static void grib_set_bit_on(unsigned char* p, long* bitp) -{ - unsigned char o = 1; - p += (*bitp >> 3); - o <<= 7 - ((*bitp) % 8); - *p |= o; - (*bitp) += 1; -} diff --git a/src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc deleted file mode 100644 index 9028d5076..000000000 --- a/src/accessor/todo/grib_accessor_class_g1day_of_the_year_date.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_g1date - IMPLEMENTS = unpack_string - IMPLEMENTS = dump - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1day_of_the_year_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1date */ - const char* century; - const char* year; - const char* month; - const char* day; - /* Members defined in g1day_of_the_year_date */ -} grib_accessor_g1day_of_the_year_date; - -extern grib_accessor_class* grib_accessor_class_g1date; - -static grib_accessor_class _grib_accessor_class_g1day_of_the_year_date = { - &grib_accessor_class_g1date, /* super */ - "g1day_of_the_year_date", /* name */ - sizeof(grib_accessor_g1day_of_the_year_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1day_of_the_year_date = &_grib_accessor_class_g1day_of_the_year_date; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - /* special clim case where each mont have 30 days.. to comply with mars*/ - grib_accessor_g1day_of_the_year_date* self = (grib_accessor_g1day_of_the_year_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - char tmp[1024]; - - long year = 0; - long century = 0; - long month = 0; - long day = 0; - long fullyear = 0; - long fake_day_of_year = 0; - - grib_get_long_internal(hand, self->century, ¢ury); - grib_get_long_internal(hand, self->day, &day); - grib_get_long_internal(hand, self->month, &month); - grib_get_long_internal(hand, self->year, &year); - - fullyear = ((century - 1) * 100 + year); - fake_day_of_year = ((month - 1) * 30) + day; - snprintf(tmp, sizeof(tmp), "%04ld-%03ld", fullyear, fake_day_of_year); - - size_t l = strlen(tmp) + 1; - if (*len < l) { - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - *len = l; - strcpy(val, tmp); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc deleted file mode 100644 index cbf74322c..000000000 --- a/src/accessor/todo/grib_accessor_class_g1end_of_interval_monthly.cc +++ /dev/null @@ -1,234 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* verifyingMonth - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_g1end_of_interval_monthly -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in g1end_of_interval_monthly */ - const char* verifyingMonth; -} grib_accessor_g1end_of_interval_monthly; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_g1end_of_interval_monthly = { - &grib_accessor_class_abstract_vector, /* super */ - "g1end_of_interval_monthly", /* name */ - sizeof(grib_accessor_g1end_of_interval_monthly), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly = &_grib_accessor_class_g1end_of_interval_monthly; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - int n = 0; - - self->verifyingMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - - self->number_of_elements = 6; - self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); - - a->length = 0; - a->dirty = 1; -} - -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; - int ret = 0; - char verifyingMonth[7] = {0,}; - size_t slen = 7; - long year = 0, month = 0, date = 0; - const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - long days = 0; - - if (!a->dirty) - return GRIB_SUCCESS; - - if (*len != (size_t)self->number_of_elements) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) - return ret; - - date = atoi(verifyingMonth); - if (date < 0) { - return GRIB_INVALID_ARGUMENT; - } - year = date / 100; - month = date - year * 100; - if (month == 2) { - days = 28; - if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) - days = 29; - } - else { - if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT; - days = mdays[month - 1]; - } - self->v[0] = year; - self->v[1] = month; - - self->v[2] = days; - self->v[3] = 24; - self->v[4] = 00; - self->v[5] = 00; - - a->dirty = 0; - - val[0] = self->v[0]; - val[1] = self->v[1]; - val[2] = self->v[2]; - val[3] = self->v[3]; - val[4] = self->v[4]; - val[5] = self->v[5]; - - return ret; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - *count = self->number_of_elements; - return 0; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - grib_context_free(c, self->v); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - double* aval = 0; - double* bval = 0; - - long count = 0; - size_t alen = 0; - size_t blen = 0; - int err = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - b->dirty = 1; - a->dirty = 1; - - err = grib_unpack_double(a, aval, &alen); if(err) return err; - err = grib_unpack_double(b, bval, &blen); if(err) return err; - - for(size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/accessor/todo/grib_accessor_class_g1fcperiod.cc b/src/accessor/todo/grib_accessor_class_g1fcperiod.cc deleted file mode 100644 index 03aa6e3f4..000000000 --- a/src/accessor/todo/grib_accessor_class_g1fcperiod.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_g1step_range - IMPLEMENTS = unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); - -typedef struct grib_accessor_g1fcperiod -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in g1step_range */ - const char* p1; - const char* p2; - const char* timeRangeIndicator; - const char *unit; - const char *step_unit; - const char *stepType; - const char *patch_fp_precip; - int error_on_units; - /* Members defined in g1fcperiod */ -} grib_accessor_g1fcperiod; - -extern grib_accessor_class* grib_accessor_class_g1step_range; - -static grib_accessor_class _grib_accessor_class_g1fcperiod = { - &grib_accessor_class_g1step_range, /* super */ - "g1fcperiod", /* name */ - sizeof(grib_accessor_g1fcperiod), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1fcperiod = &_grib_accessor_class_g1fcperiod; - -/* END_CLASS_IMP */ - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long start = 0, theEnd = 0; - char tmp[1024]; - const size_t tmpLen = sizeof(tmp); - int err = grib_g1_step_get_steps(a, &start, &theEnd); - size_t l = 0; - - if (err) - return err; - - snprintf(tmp, tmpLen, "%ld-%ld", start / 24, theEnd / 24); - /*printf("---- FCPERIOD %s [start:%g, end:%g]",tmp,start,end);*/ - - l = strlen(tmp) + 1; - if (*len < l) { - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - *len = l; - strcpy(val, tmp); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g1monthlydate.cc b/src/accessor/todo/grib_accessor_class_g1monthlydate.cc deleted file mode 100644 index 57c3ea729..000000000 --- a/src/accessor/todo/grib_accessor_class_g1monthlydate.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - * (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. - */ - - -/*********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS=const char* date - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1monthlydate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1monthlydate */ - const char* date; -} grib_accessor_g1monthlydate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1monthlydate = { - &grib_accessor_class_long, /* super */ - "g1monthlydate", /* name */ - sizeof(grib_accessor_g1monthlydate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1monthlydate = &_grib_accessor_class_g1monthlydate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a; - - long date = 0; - - grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); - - date /= 100; - date *= 100; - date += 1; - - *val = date; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc deleted file mode 100644 index 45b983502..000000000 --- a/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_complex.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* - * (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. - */ - -/****************************************************** - * Enrico Fucile - *******************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - MEMBERS = const char* JS - MEMBERS = const char* KS - MEMBERS = const char* MS - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1number_of_coded_values_sh_complex -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1number_of_coded_values_sh_complex */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; - const char* JS; - const char* KS; - const char* MS; -} grib_accessor_g1number_of_coded_values_sh_complex; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1number_of_coded_values_sh_complex = { - &grib_accessor_class_long, /* super */ - "g1number_of_coded_values_sh_complex", /* name */ - sizeof(grib_accessor_g1number_of_coded_values_sh_complex), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex = &_grib_accessor_class_g1number_of_coded_values_sh_complex; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g1number_of_coded_values_sh_complex* self = (grib_accessor_g1number_of_coded_values_sh_complex*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->KS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->MS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - long JS = 0, KS = 0, MS = 0, NS = 0; - - grib_accessor_g1number_of_coded_values_sh_complex* self = (grib_accessor_g1number_of_coded_values_sh_complex*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->JS, &JS)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->KS, &KS)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->MS, &MS)) != GRIB_SUCCESS) - return ret; - - if (JS != KS || KS != MS) - return GRIB_NOT_IMPLEMENTED; - - NS = (MS + 1) * (MS + 2); - - if (bpv != 0) { - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits + NS * (bpv - 32)) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc deleted file mode 100644 index 532a4c5dd..000000000 --- a/src/accessor/todo/grib_accessor_class_g1number_of_coded_values_sh_simple.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* - * (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. - */ - -/********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1number_of_coded_values_sh_simple -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1number_of_coded_values_sh_simple */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -} grib_accessor_g1number_of_coded_values_sh_simple; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1number_of_coded_values_sh_simple = { - &grib_accessor_class_long, /* super */ - "g1number_of_coded_values_sh_simple", /* name */ - sizeof(grib_accessor_g1number_of_coded_values_sh_simple), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple = &_grib_accessor_class_g1number_of_coded_values_sh_simple; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g1number_of_coded_values_sh_simple* self = (grib_accessor_g1number_of_coded_values_sh_simple*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - - grib_accessor_g1number_of_coded_values_sh_simple* self = (grib_accessor_g1number_of_coded_values_sh_simple*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if (bpv != 0) { - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_g1verificationdate.cc b/src/accessor/todo/grib_accessor_class_g1verificationdate.cc deleted file mode 100644 index 03c871617..000000000 --- a/src/accessor/todo/grib_accessor_class_g1verificationdate.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1verificationdate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1verificationdate */ - const char* date; - const char* time; - const char* step; -} grib_accessor_g1verificationdate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1verificationdate = { - &grib_accessor_class_long, /* super */ - "g1verificationdate", /* name */ - sizeof(grib_accessor_g1verificationdate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1verificationdate = &_grib_accessor_class_g1verificationdate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->time = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a; - int ret = 0; - long date = 0; - long time = 0; - long cdate = 0; - long step = 0; - long vtime = 0; - long vdate = 0; - long vd = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->step, &step)) != GRIB_SUCCESS) - return ret; - - time /= 100; - - cdate = (long)grib_date_to_julian(date); - vtime = cdate * 24 + time + step; - vd = vtime / 24; - vdate = grib_julian_to_date(vd); - - /* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */ - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = vdate; - - /* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */ - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g2_aerosol.cc b/src/accessor/todo/grib_accessor_class_g2_aerosol.cc deleted file mode 100644 index 7cd8659df..000000000 --- a/src/accessor/todo/grib_accessor_class_g2_aerosol.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=int optical - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_aerosol -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_aerosol */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int optical; -} grib_accessor_g2_aerosol; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_aerosol = { - &grib_accessor_class_unsigned, /* super */ - "g2_aerosol", /* name */ - sizeof(grib_accessor_g2_aerosol), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_aerosol; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++); - self->stepType = grib_arguments_get_name(hand, c, n++); - self->optical = grib_arguments_get_long(hand, c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - long productDefinitionTemplateNumber = 0; - grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); - - if (self->optical) - *val = grib2_is_PDTN_AerosolOptical(productDefinitionTemplateNumber); - else - *val = grib2_is_PDTN_Aerosol(productDefinitionTemplateNumber); - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - grib_handle* hand = grib_handle_of_accessor(a); - long productDefinitionTemplateNumber = -1; - long productDefinitionTemplateNumberNew = -1; - /*long type=-1; - long stream=-1;*/ - long eps = -1; - char stepType[15] = {0,}; - size_t slen = 15; - /*int aerosol = *val;*/ - int isInstant = 0; - /*long derivedForecast=-1;*/ - int ret = 0; - - if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS) - return GRIB_SUCCESS; - - /* - grib_get_long(hand, self->type,&type); - grib_get_long(hand, self->stream,&stream); - */ - ret = grib_get_string(hand, self->stepType, stepType, &slen); - Assert(ret == GRIB_SUCCESS); - - //eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); - eps = grib_is_defined(hand, "perturbationNumber"); - - if (!strcmp(stepType, "instant")) - isInstant = 1; - - if (eps == 1) { - if (isInstant) { - productDefinitionTemplateNumberNew = 45; - } - else { - /*productDefinitionTemplateNumberNew = 47; PDT deprecated*/ - productDefinitionTemplateNumberNew = 85; - } - } - else { - if (isInstant) { - productDefinitionTemplateNumberNew = 48; /*44 is deprecated*/ - } - else { - productDefinitionTemplateNumberNew = 46; - } - } - - if (self->optical) { - /* Note: There is no interval based template for optical properties of aerosol! */ - if (eps) - productDefinitionTemplateNumberNew = 49; - else - productDefinitionTemplateNumberNew = 48; - if (!isInstant) { - grib_context_log(hand->context, GRIB_LOG_ERROR, - "The product definition templates for optical properties of aerosol are for a point-in-time only"); - } - } - - if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { - grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew); - /*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/ - } - - return 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} diff --git a/src/accessor/todo/grib_accessor_class_g2bitmap.cc b/src/accessor/todo/grib_accessor_class_g2bitmap.cc deleted file mode 100644 index 441ad70a6..000000000 --- a/src/accessor/todo/grib_accessor_class_g2bitmap.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bitmap - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init; - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; - /* Members defined in g2bitmap */ - const char* numberOfValues; -} grib_accessor_g2bitmap; - -extern grib_accessor_class* grib_accessor_class_bitmap; - -static grib_accessor_class _grib_accessor_class_g2bitmap = { - &grib_accessor_class_bitmap, /* super */ - "g2bitmap", /* name */ - sizeof(grib_accessor_g2bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2bitmap = &_grib_accessor_class_g2bitmap; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); -} - - -static void grib_set_bit_on(unsigned char* p, long* bitp) -{ - unsigned char o = 1; - p += (*bitp >> 3); - o <<= 7 - ((*bitp) % 8); - *p |= o; - (*bitp) += 1; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - - size_t tlen; - - unsigned char* buf = NULL; - size_t i; - int err = 0; - long pos = 0; - // long bmaplen = 0; - double miss_values = 0; - tlen = (*len + 7) / 8; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) - return err; - - buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - pos = 0; - for (i = 0; i < *len; i++) { - if (val[i] == miss_values) - pos++; - else { - // bmaplen++; - grib_set_bit_on(buf, &pos); - } - } - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len)) != GRIB_SUCCESS) { - grib_context_free(a->context, buf); - return err; - } - - grib_buffer_replace(a, buf, tlen, 1, 1); - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - - -static int value_count(grib_accessor* a, long* tlen) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - int err; - *tlen = 0; - - err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, tlen); - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_g2bitmap_present.cc b/src/accessor/todo/grib_accessor_class_g2bitmap_present.cc deleted file mode 100644 index 52378d4eb..000000000 --- a/src/accessor/todo/grib_accessor_class_g2bitmap_present.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (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. - */ - -/**************************************** - * Enrico Fucile - *************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* bitmapIndicator - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2bitmap_present -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2bitmap_present */ - const char* bitmapIndicator; -} grib_accessor_g2bitmap_present; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2bitmap_present = { - &grib_accessor_class_long, /* super */ - "g2bitmap_present", /* name */ - sizeof(grib_accessor_g2bitmap_present), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2bitmap_present = &_grib_accessor_class_g2bitmap_present; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - self->bitmapIndicator = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bitmapIndicator = 0; - - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapIndicator, &bitmapIndicator); - if (ret) { - if (ret == GRIB_NOT_FOUND) { - *val = 0; - return 0; - } - else - return ret; - } - - *val = 1; - if (bitmapIndicator == 255) - *val = 0; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - long bitmapIndicator = 0; - - if (*val == 0) - bitmapIndicator = 255; - - return grib_set_long(grib_handle_of_accessor(a), self->bitmapIndicator, bitmapIndicator); -} diff --git a/src/accessor/todo/grib_accessor_class_g2date.cc b/src/accessor/todo/grib_accessor_class_g2date.cc deleted file mode 100644 index 698cd4a26..000000000 --- a/src/accessor/todo/grib_accessor_class_g2date.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long;init - MEMBERS=const char* century - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2date */ - const char* century; - const char* year; - const char* month; - const char* day; -} grib_accessor_g2date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2date = { - &grib_accessor_class_long, /* super */ - "g2date", /* name */ - sizeof(grib_accessor_g2date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; - -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2date* self = (grib_accessor_g2date*)a; - int n = 0; - - self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - const grib_accessor_g2date* self = (grib_accessor_g2date*)a; - - int ret = 0; - long year = 0; - long month = 0; - long day = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - val[0] = year * 10000 + month * 100 + day; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const grib_accessor_g2date* self = (grib_accessor_g2date*)a; - - int ret = GRIB_SUCCESS; - long v = val[0]; - long year = 0; - long month = 0; - long day = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - year = v / 10000; - v %= 10000; - month = v / 100; - v %= 100; - day = v; - - if (!is_date_valid(year, month, day, 0, 0, 0)) { - // ECC-1777: For now just a warning. Will later change to an error - fprintf(stderr, "ECCODES WARNING : %s:%s: Date is not valid! year=%ld month=%ld day=%ld\n", - a->cclass->name, __func__, year, month, day); - } - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) - return ret; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_g2latlon.cc b/src/accessor/todo/grib_accessor_class_g2latlon.cc deleted file mode 100644 index 5549b79a3..000000000 --- a/src/accessor/todo/grib_accessor_class_g2latlon.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (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. - */ - -/******************************************** - * Enrico Fucile - *********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = is_missing;pack_missing - IMPLEMENTS = init - MEMBERS=const char* grid - MEMBERS=int index - MEMBERS=const char* given - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_missing(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2latlon -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2latlon */ - const char* grid; - int index; - const char* given; -} grib_accessor_g2latlon; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2latlon = { - &grib_accessor_class_double, /* super */ - "g2latlon", /* name */ - sizeof(grib_accessor_g2latlon), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latlon; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int n = 0; - - self->grid = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - self->given = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int ret = 0; - - long given = 1; - double grid[6]; - size_t size = 6; - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - return ret; - } - - if (self->given) - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given)) != GRIB_SUCCESS) - return ret; - - if (!given) { - *val = GRIB_MISSING_DOUBLE; - return GRIB_SUCCESS; - } - - if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, &size)) != GRIB_SUCCESS) - return ret; - - *val = grid[self->index]; - - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int ret = 0; - double grid[6]; - size_t size = 6; - double new_val = *val; - grib_handle* hand = grib_handle_of_accessor(a); - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - return ret; - } - - if (self->given) { - long given = *val != GRIB_MISSING_DOUBLE; - if ((ret = grib_set_long_internal(hand, self->given, given)) != GRIB_SUCCESS) - return ret; - } - - if ((ret = grib_get_double_array_internal(hand, self->grid, grid, &size)) != GRIB_SUCCESS) - return ret; - - /* index 1 is longitudeOfFirstGridPointInDegrees - * index 3 is longitudeOfLastGridPointInDegrees - */ - if ((self->index == 1 || self->index == 3)) { - /* WMO regulation for GRIB edition 2: - * The longitude values shall be limited to the range 0 to 360 degrees inclusive */ - new_val = normalise_longitude_in_degrees(*val); - if (hand->context->debug && new_val != *val) { - fprintf(stderr, "ECCODES DEBUG pack_double g2latlon: normalise longitude %g -> %g\n", *val, new_val); - } - } - grid[self->index] = new_val; - - return grib_set_double_array_internal(hand, self->grid, grid, size); -} - -static int pack_missing(grib_accessor* a) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - double missing = GRIB_MISSING_DOUBLE; - size_t size = 1; - - if (!self->given) - return GRIB_NOT_IMPLEMENTED; - - return pack_double(a, &missing, &size); -} - -static int is_missing(grib_accessor* a) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - long given = 1; - - if (self->given) - grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); - - return !given; -} diff --git a/src/accessor/todo/grib_accessor_class_g2lon.cc b/src/accessor/todo/grib_accessor_class_g2lon.cc deleted file mode 100644 index c84776915..000000000 --- a/src/accessor/todo/grib_accessor_class_g2lon.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - * (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. - */ - -/******************************************** - * Enrico Fucile - *********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init - MEMBERS=const char* longitude - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2lon -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2lon */ - const char* longitude; -} grib_accessor_g2lon; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2lon = { - &grib_accessor_class_double, /* super */ - "g2lon", /* name */ - sizeof(grib_accessor_g2lon), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - int n = 0; - - self->longitude = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - int ret = 0; - long longitude; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->longitude, &longitude)) != GRIB_SUCCESS) - return ret; - - if (longitude == GRIB_MISSING_LONG) { - *val = GRIB_MISSING_DOUBLE; - return GRIB_SUCCESS; - } - - *val = ((double)longitude) / 1000000.0; - - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - long longitude; - double value = *val; - - if (value == GRIB_MISSING_DOUBLE) { - longitude = GRIB_MISSING_LONG; - } - else { - if (value < 0) - value += 360; - longitude = (long)(value * 1000000); - } - return grib_set_long(grib_handle_of_accessor(a), self->longitude, longitude); -} diff --git a/src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc deleted file mode 100644 index 21117d4f1..000000000 --- a/src/accessor/todo/grib_accessor_class_gaussian_grid_name.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type;string_length - MEMBERS = const char* N - MEMBERS = const char* Ni - MEMBERS = const char* isOctahedral - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gaussian_grid_name -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in gaussian_grid_name */ - const char* N; - const char* Ni; - const char* isOctahedral; -} grib_accessor_gaussian_grid_name; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_gaussian_grid_name = { - &grib_accessor_class_gen, /* super */ - "gaussian_grid_name", /* name */ - sizeof(grib_accessor_gaussian_grid_name), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_class_gaussian_grid_name; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a; - int n = 0; - - self->N = grib_arguments_get_name(a->parent->h, arg, n++); - self->Ni = grib_arguments_get_name(a->parent->h, arg, n++); - self->isOctahedral = grib_arguments_get_name(a->parent->h, arg, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -#define MAX_GRIDNAME_LEN 16 - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a; - - long N = 0, Ni = 0; - char tmp[MAX_GRIDNAME_LEN] = {0,}; - size_t length = 0; - int ret = GRIB_SUCCESS; - - if ((ret = grib_get_long_internal(a->parent->h, self->N, &N)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - - if (Ni == GRIB_MISSING_LONG) { - /* Reduced gaussian grid */ - long isOctahedral = 0; - if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS) - return ret; - if (isOctahedral == 1) { - snprintf(tmp, sizeof(tmp), "O%ld", N); - } - else { - snprintf(tmp, sizeof(tmp), "N%ld", N); /* Classic */ - } - } - else { - /* Regular gaussian grid */ - snprintf(tmp, sizeof(tmp), "F%ld", N); - } - length = strlen(tmp) + 1; - - if (*len < length) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length, *len); - *len = length; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(v, tmp); - *len = length; - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return MAX_GRIDNAME_LEN; -} diff --git a/src/accessor/todo/grib_accessor_class_gds_is_present.cc b/src/accessor/todo/grib_accessor_class_gds_is_present.cc deleted file mode 100644 index 6066231ac..000000000 --- a/src/accessor/todo/grib_accessor_class_gds_is_present.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* - * (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. - */ - -/****************************** - * Enrico Fucile - *****************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* gds_present - MEMBERS = const char* grid_definition - MEMBERS = const char* bitmap_present - MEMBERS = const char* values - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gds_is_present -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in gds_is_present */ - const char* gds_present; - const char* grid_definition; - const char* bitmap_present; - const char* values; -} grib_accessor_gds_is_present; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_gds_is_present = { - &grib_accessor_class_long, /* super */ - "gds_is_present", /* name */ - sizeof(grib_accessor_gds_is_present), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_gds_is_present; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - grib_handle* h = grib_handle_of_accessor(a); - self->gds_present = grib_arguments_get_name(h, c, n++); - self->grid_definition = grib_arguments_get_name(h, c, n++); - self->bitmap_present = grib_arguments_get_name(h, c, n++); - self->values = grib_arguments_get_name(h, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - long missing = 255; - int ret = 0; - size_t size = 0; - double* values = NULL; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val != 1) - return GRIB_NOT_IMPLEMENTED; - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->gds_present, *val)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->bitmap_present, *val)) != GRIB_SUCCESS) - return ret; - - - if ((ret = grib_set_long_internal(h, self->grid_definition, missing)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) - return ret; - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - - if ((ret = grib_get_long_internal(h, self->gds_present, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc deleted file mode 100644 index d8ec8ecd1..000000000 --- a/src/accessor/todo/grib_accessor_class_gds_not_present_bitmap.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (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. - */ - -/****************************** - * Enrico Fucile - *****************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = get_native_type - MEMBERS=const char* missing_value - MEMBERS=const char* number_of_values - MEMBERS=const char* number_of_points - MEMBERS=const char* latitude_of_first_point - MEMBERS=const char* ni - - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gds_not_present_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in gds_not_present_bitmap */ - const char* missing_value; - const char* number_of_values; - const char* number_of_points; - const char* latitude_of_first_point; - const char* ni; -} grib_accessor_gds_not_present_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_gds_not_present_bitmap = { - &grib_accessor_class_gen, /* super */ - "gds_not_present_bitmap", /* name */ - sizeof(grib_accessor_gds_not_present_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accessor_class_gds_not_present_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - int n = 0; - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - self->missing_value = grib_arguments_get_name(hand, args, n++); - self->number_of_values = grib_arguments_get_name(hand, args, n++); - self->number_of_points = grib_arguments_get_name(hand, args, n++); - self->latitude_of_first_point = grib_arguments_get_name(hand, args, n++); - self->ni = grib_arguments_get_name(hand, args, n++); - a->length = 0; -} - -static int value_count(grib_accessor* a, long* number_of_points) -{ - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - *number_of_points = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - long number_of_points = 0, number_of_values = 0, ni = 0; - long latitude_of_first_point = 0; - size_t i = 0; - size_t n_vals = 0; - long nn = 0; - long missing_value; - - int err = 0; - double* coded_vals = NULL; - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if ((err = grib_get_long(hand, self->number_of_points, &number_of_points)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->number_of_values, &number_of_values)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->latitude_of_first_point, &latitude_of_first_point)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->ni, &ni)) != GRIB_SUCCESS) - return err; - - if (*len < number_of_points) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if (number_of_values > 0) { - coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double)); - - if (coded_vals == NULL) - return GRIB_OUT_OF_MEMORY; - } - - if (latitude_of_first_point == 0) { - for (i = 0; i < number_of_values; i++) - val[i] = 1; - for (i = number_of_values; i < number_of_points; i++) - val[i] = 0; - } - else { - for (i = 0; i < ni - 1; i++) - val[i] = 0; - for (i = ni - 1; i < number_of_points; i++) - val[i] = 1; - } - - *len = number_of_points; - - grib_context_free(a->context, coded_vals); - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - // See deprecated/grib_accessor_class_gds_not_present_bitmap.cc for - // a possible implementation - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} diff --git a/src/accessor/todo/grib_accessor_class_gen.cc b/src/accessor/todo/grib_accessor_class_gen.cc deleted file mode 100644 index b611f5043..000000000 --- a/src/accessor/todo/grib_accessor_class_gen.cc +++ /dev/null @@ -1,675 +0,0 @@ -/* - * (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. - */ - -/*************************************************************************** - * Jean Baptiste Filippi - 01.11.2005 * - * Enrico Fucile * - * Shahram Najm * - ***************************************************************************/ -#include "grib_api_internal.h" -#include "grib_value.h" -#include -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - IMPLEMENTS = unpack_long;pack_long; clear - IMPLEMENTS = unpack_double;pack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_string_array;pack_string_array - IMPLEMENTS = unpack_bytes;pack_bytes - IMPLEMENTS = unpack_double_subarray - IMPLEMENTS = init;dump;destroy;string_length - IMPLEMENTS = get_native_type;sub_section - IMPLEMENTS = next_offset;value_count;byte_offset;byte_count - IMPLEMENTS = notify_change;pack_expression - IMPLEMENTS = update_size; next; preferred_size - IMPLEMENTS = compare;is_missing;make_clone - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static grib_section* sub_section(grib_accessor* a); -static int get_native_type(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_string_array(grib_accessor*, const char**, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int notify_change(grib_accessor*, grib_accessor*); -static void update_size(grib_accessor*, size_t); -static size_t preferred_size(grib_accessor*, int); -static grib_accessor* next(grib_accessor*, int); -static int compare(grib_accessor*, grib_accessor*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); -static int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len); -static int clear(grib_accessor*); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_gen -{ - grib_accessor att; - /* Members defined in gen */ -} grib_accessor_gen; - - -static grib_accessor_class _grib_accessor_class_gen = { - 0, /* super */ - "gen", /* name */ - sizeof(grib_accessor_gen), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - &sub_section, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - &pack_string_array, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - ¬ify_change, /* notify_change */ - &update_size, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - &compare, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - &unpack_double_subarray, /* unpack a subarray */ - &clear, /* clear */ - &make_clone, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gen = &_grib_accessor_class_gen; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* param) -{ - grib_action* act = (grib_action*)(a->creator); - if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { - a->length = 0; - if (!a->vvalue) - a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); - a->vvalue->type = grib_accessor_get_native_type(a); - a->vvalue->length = len; - if (act->default_value != NULL) { - const char* p = 0; - size_t s_len = 1; - long l; - int ret = 0; - double d; - char tmp[1024]; - grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); - int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); - switch (type) { - case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); - grib_pack_double(a, &d, &s_len); - break; - - case GRIB_TYPE_LONG: - grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); - break; - - default: - s_len = sizeof(tmp); - p = grib_expression_evaluate_string(grib_handle_of_accessor(a), expression, tmp, &s_len, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to evaluate %s as string", a->name); - Assert(0); - } - s_len = strlen(p) + 1; - grib_pack_string(a, p, &s_len); - break; - } - } - } - else { - a->length = len; - } -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - const int type = grib_accessor_get_native_type(a); - switch (type) { - case GRIB_TYPE_STRING: - grib_dump_string(dumper, a, NULL); - break; - case GRIB_TYPE_DOUBLE: - grib_dump_double(dumper, a, NULL); - break; - case GRIB_TYPE_LONG: - grib_dump_long(dumper, a, NULL); - break; - default: - grib_dump_bytes(dumper, a, NULL); - } -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int get_native_type(grib_accessor* a) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s [%s] must implement 'get_native_type'", a->name, a->cclass->name); - return GRIB_TYPE_UNDEFINED; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - const long length = grib_byte_count(a); - const long offset = grib_byte_offset(a); - - if (*len < length) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", a->name, length); - *len = length; - return GRIB_ARRAY_TOO_SMALL; - } - - memcpy(val, buf + offset, length); - *len = length; - - return GRIB_SUCCESS; -} - -static int clear(grib_accessor* a) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - const long length = grib_byte_count(a); - const long offset = grib_byte_offset(a); - - memset(buf + offset, 0, length); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - int type = GRIB_TYPE_UNDEFINED; - if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - double val = 0.0; - size_t l = 1; - grib_unpack_double(a, &val, &l); - if (val == GRIB_MISSING_DOUBLE) - *v = GRIB_MISSING_LONG; - else - *v = (long)val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtol(val, &last, 10); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", a->name); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - return GRIB_NOT_IMPLEMENTED; -} - -template -static int unpack(grib_accessor* a, T* v, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - int type = GRIB_TYPE_UNDEFINED; - const char* Tname = type_to_string(*v); - if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - long val = 0; - size_t l = 1; - grib_unpack_long(a, &val, &l); - *v = val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - if (*last == 0) { /* conversion of string to double worked */ - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - return unpack(a, v, len); -} - -static int unpack_float(grib_accessor* a, float* v, size_t* len) -{ - return unpack(a, v, len); -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - int err = 0; - if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - double val = 0.0; - size_t l = 1; - err = grib_unpack_double(a, &val, &l); - if (err) return err; - snprintf(v, 64, "%g", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - long val = 0; - size_t l = 1; - err = grib_unpack_long(a, &val, &l); - if (err) return err; - snprintf(v, 64, "%ld", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string_array(grib_accessor* a, char** v, size_t* len) -{ - size_t length = 0; - - int err = grib_get_string_length_acc(a, &length); - if (err) - return err; - v[0] = (char*)grib_context_malloc_clear(a->context, length); - grib_unpack_string(a, v[0], &length); // TODO(masn): check return value - *len = 1; - - return GRIB_SUCCESS; -} - -static int pack_expression(grib_accessor* a, grib_expression* e) -{ - size_t len = 1; - long lval = 0; - double dval = 0; - const char* cval = NULL; - int ret = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - // Use the native type of the expression not the accessor - switch (grib_expression_native_type(hand, e)) { - case GRIB_TYPE_LONG: { - len = 1; - ret = grib_expression_evaluate_long(hand, e, &lval); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as long (from %s)", - a->name, e->cclass->name); - return ret; - } - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %ld\n", a->name,lval);*/ - return grib_pack_long(a, &lval, &len); - } - - case GRIB_TYPE_DOUBLE: { - len = 1; - ret = grib_expression_evaluate_double(hand, e, &dval); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as double (from %s)", - a->name, e->cclass->name); - return ret; - } - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %g\n", a->name, dval);*/ - return grib_pack_double(a, &dval, &len); - } - - case GRIB_TYPE_STRING: { - char tmp[1024]; - len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as string (from %s)", - a->name, e->cclass->name); - return ret; - } - len = strlen(cval); - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %s\n", a->name, cval);*/ - return grib_pack_string(a, cval, &len); - } - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context* c = a->context; - if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); - if (!val) { - grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double))); - return GRIB_OUT_OF_MEMORY; - } - for (size_t i = 0; i < *len; i++) - val[i] = v[i]; - int ret = grib_pack_double(a, val, len); - grib_context_free(c, val); - return ret; - } - grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", a->name); - if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); - } - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) -{ - grib_context* c = a->context; - int ret = GRIB_SUCCESS; - size_t numBytes = *len * (sizeof(long)); - long* lValues = (long*)grib_context_malloc(c, numBytes); - if (!lValues) { - grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes); - return GRIB_OUT_OF_MEMORY; - } - for (size_t i = 0; i < *len; i++) - lValues[i] = (long)v[i]; /* convert from double to long */ - ret = grib_pack_long(a, lValues, len); - grib_context_free(c, lValues); - return ret; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - int do_pack_as_long = 0; - grib_context* c = a->context; - if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - do_pack_as_long = 1; - } - else { - /* ECC-648: Special case of codetable */ - if (strcmp(a->cclass->name, "codetable") == 0) { - do_pack_as_long = 1; - } - } - if (do_pack_as_long) { - return pack_double_array_as_long(a, v, len); - } - grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); - if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); - } - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_string_array(grib_accessor* a, const char** v, size_t* len) -{ - int err = 0; - size_t length = 0; - grib_accessor* as = 0; - - as = a; - long i = (long)*len - 1; - while (as && i >= 0) { - length = strlen(v[i]); - err = grib_pack_string(as, v[i], &length); - if (err) - return err; - --i; - as = as->same; - } - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* v, size_t* len) -{ - if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - size_t l = 1; - char* endPtr = NULL; /* for error handling */ - double val = strtod(v, &endPtr); - if (*endPtr) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Invalid value (%s) for key '%s'. String cannot be converted to a double", - __func__, v, a->name); - return GRIB_WRONG_TYPE; - } - return grib_pack_double(a, &val, &l); - } - - if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - size_t l = 1; - long val = atol(v); - return grib_pack_long(a, &val, &l); - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ - const size_t length = *len; - if (length != a->length) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long", - length, a->name, a->length); - return GRIB_BUFFER_TOO_SMALL; - } - grib_buffer_replace(a, val, length, 1, 1); - return GRIB_SUCCESS; -} - -static void destroy(grib_context* ct, grib_accessor* a) -{ - grib_dependency_remove_observed(a); - grib_dependency_remove_observer(a); - if (a->vvalue != NULL) { - grib_context_free(ct, a->vvalue); - a->vvalue = NULL; - } - /*grib_context_log(ct,GRIB_LOG_DEBUG,"address=%p",a);*/ -} - -static grib_section* sub_section(grib_accessor* a) -{ - return NULL; -} - -static int notify_change(grib_accessor* self, grib_accessor* observed) -{ - /* Default behaviour is to notify creator */ - return grib_action_notify_change(self->creator, self, observed); -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_FATAL, - "Accessor %s [%s] must implement 'update_size'", a->name, a->cclass->name); -} - -static grib_accessor* next(grib_accessor* a, int mod) -{ - grib_accessor* next = NULL; - if (a->next) { - next = a->next; - } - else { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - return GRIB_NOT_IMPLEMENTED; -} - -/* Redefined in all padding */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - return a->length; -} - -static int is_missing(grib_accessor* a) -{ - int i = 0; - int is_missing = 1; - unsigned char ones = 0xff; - unsigned char* v = NULL; - - if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { - if (a->vvalue == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", a->name, a->flags); - Assert(!"grib_accessor_class_gen::is_missing(): a->vvalue == NULL"); - return 0; - } - return a->vvalue->missing; - } - Assert(a->length >= 0); - - v = grib_handle_of_accessor(a)->buffer->data + a->offset; - - for (i = 0; i < a->length; i++) { - if (*v != ones) { - is_missing = 0; - break; - } - v++; - } - - return is_missing; -} - -static int unpack_double_element(grib_accessor* a, size_t i, double* val) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) -{ - *err = GRIB_NOT_IMPLEMENTED; - return NULL; -} diff --git a/src/accessor/todo/grib_accessor_class_getenv.cc b/src/accessor/todo/grib_accessor_class_getenv.cc deleted file mode 100644 index 6bc0ced3e..000000000 --- a/src/accessor/todo/grib_accessor_class_getenv.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS= const char* name - MEMBERS= char* value - MEMBERS= const char* default_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_getenv -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in getenv */ - const char* name; - char* value; - const char* default_value; -} grib_accessor_getenv; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_getenv = { - &grib_accessor_class_ascii, /* super */ - "getenv", /* name */ - sizeof(grib_accessor_getenv), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_getenv = &_grib_accessor_class_getenv; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - grib_accessor_getenv* self = (grib_accessor_getenv*)a; - static char undefined[] = "undefined"; - - self->name = grib_arguments_get_string(grib_handle_of_accessor(a), args, 0); - self->default_value = grib_arguments_get_string(grib_handle_of_accessor(a), args, 1); - if (!self->default_value) - self->default_value = undefined; - self->value = 0; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_getenv* self = (grib_accessor_getenv*)a; - char* v = 0; - size_t l = 0; - - if (!self->value) { - v = getenv(self->name); - if (!v) - v = (char*)self->default_value; - self->value = v; - } - - l = strlen(self->value); - if (*len < l) - return GRIB_BUFFER_TOO_SMALL; - snprintf(val, 1024, "%s", self->value); - *len = strlen(self->value); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} diff --git a/src/accessor/todo/grib_accessor_class_group.cc b/src/accessor/todo/grib_accessor_class_group.cc deleted file mode 100644 index df2118bff..000000000 --- a/src/accessor/todo/grib_accessor_class_group.cc +++ /dev/null @@ -1,272 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - IMPLEMENTS = compare - MEMBERS = char endCharacter - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_group -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in group */ - char endCharacter; -} grib_accessor_group; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_group = { - &grib_accessor_class_gen, /* super */ - "group", /* name */ - sizeof(grib_accessor_group), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; - grib_accessor_group* self = (grib_accessor_group*)a; - - size_t i = 0; - unsigned char* v; - const char* s = grib_arguments_get_string(grib_handle_of_accessor(a), arg, 0); - - if (s && strlen(s) > 1) { - grib_context_log(a->context, GRIB_LOG_WARNING, - "Using only first character as group end of %s not the string %s", a->name, s); - } - - self->endCharacter = s ? s[0] : 0; - - v = buffer->data + a->offset; - i = 0; - if (s) { - while (*v != self->endCharacter && i <= buffer->ulength) { - if (*v > 126) - *v = 32; - v++; - i++; - } - } - else { - while (*v > 32 && *v != 61 && *v < 127 && i <= buffer->ulength) { - v++; - i++; - } - } - a->length = i; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long i = 0; - size_t l = a->length + 1; - grib_handle* h = grib_handle_of_accessor(a); - - if (*len < l) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, l, *len); - *len = l; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - val[i] = h->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "%s:%s not implemented", __func__, a->name); - return GRIB_NOT_IMPLEMENTED; - - // int retval = 0; - // char* aval = 0; - // char* bval = 0; - // int err = 0; - // size_t alen = 0; - // size_t blen = 0; - // long count = 0; - // err = grib_value_count(a, &count); - // if (err) return err; - // alen = count; - // err = grib_value_count(b, &count); - // if (err) return err; - // blen = count; - // if (alen != blen) return GRIB_COUNT_MISMATCH; - // aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); - // bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - // grib_unpack_string(a, aval, &alen); - // grib_unpack_string(b, bval, &blen); - // retval = GRIB_SUCCESS; - // if (strcmp(aval, bval)) retval = GRIB_STRING_VALUE_MISMATCH; - // grib_context_free(a->context, aval); - // grib_context_free(b->context, bval); - // return retval; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_gts_header.cc b/src/accessor/todo/grib_accessor_class_gts_header.cc deleted file mode 100644 index 65b295634..000000000 --- a/src/accessor/todo/grib_accessor_class_gts_header.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS = int gts_offset - MEMBERS = int gts_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gts_header -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in gts_header */ - int gts_offset; - int gts_length; -} grib_accessor_gts_header; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_gts_header = { - &grib_accessor_class_ascii, /* super */ - "gts_header", /* name */ - sizeof(grib_accessor_gts_header), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gts_header = &_grib_accessor_class_gts_header; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_gts_header* self = (grib_accessor_gts_header*)a; - self->gts_offset = -1; - self->gts_length = -1; - self->gts_offset = grib_arguments_get_long(grib_handle_of_accessor(a), c, 0); - self->gts_length = grib_arguments_get_long(grib_handle_of_accessor(a), c, 1); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_gts_header* self = (grib_accessor_gts_header*)a; - grib_handle* h = grib_handle_of_accessor(a); - int offset = 0; - size_t length = 0; - - if (h->gts_header == NULL || h->gts_header_len < 8) { - if (*len < 8) - return GRIB_BUFFER_TOO_SMALL; - snprintf(val, 1024, "missing"); - return GRIB_SUCCESS; - } - if (*len < h->gts_header_len) - return GRIB_BUFFER_TOO_SMALL; - - offset = self->gts_offset > 0 ? self->gts_offset : 0; - length = self->gts_length > 0 ? self->gts_length : h->gts_header_len; - - memcpy(val, h->gts_header + offset, length); - - *len = length; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - grib_handle* h = grib_handle_of_accessor(a); - return h->gts_header_len; -} diff --git a/src/accessor/todo/grib_accessor_class_hash_array.cc b/src/accessor/todo/grib_accessor_class_hash_array.cc deleted file mode 100644 index d191a5232..000000000 --- a/src/accessor/todo/grib_accessor_class_hash_array.cc +++ /dev/null @@ -1,293 +0,0 @@ -/* - * (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. - */ - - -/******************************************************* - * Enrico Fucile - ******************************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare - MEMBERS = char* key - MEMBERS = grib_hash_array_value* ha - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_hash_array -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in hash_array */ - char* key; - grib_hash_array_value* ha; -} grib_accessor_hash_array; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_hash_array = { - &grib_accessor_class_gen, /* super */ - "hash_array", /* name */ - sizeof(grib_accessor_hash_array), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_hash_array = &_grib_accessor_class_hash_array; - -/* END_CLASS_IMP */ - -#define MAX_HASH_ARRAY_STRING_LENGTH 255 - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - a->length = 0; - self->key = 0; - self->ha = NULL; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - char s[200] = {0,}; - snprintf(s, sizeof(s), "%g", *val); - self->key = grib_context_strdup(a->context, s); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - char s[200] = {0,}; - snprintf(s, sizeof(s), "%ld", *val); - if (self->key) - grib_context_free(a->context, self->key); - self->key = grib_context_strdup(a->context, s); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* v, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - self->key = grib_context_strdup(a->context, v); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static grib_hash_array_value* find_hash_value(grib_accessor* a, int* err) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - grib_hash_array_value* ha_ret = 0; - grib_hash_array_value* ha = NULL; - - ha = get_hash_array(grib_handle_of_accessor(a), a->creator); - if (!ha) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get hash value for %s", a->creator->name); - *err = GRIB_HASH_ARRAY_NO_MATCH; - return NULL; - } - - *err = GRIB_SUCCESS; - - Assert(ha != NULL); - if (!self->key) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get hash value for %s, set before getting", a->creator->name); - *err = GRIB_HASH_ARRAY_NO_MATCH; - return NULL; - } - - ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, self->key); - if (!ha_ret) - ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, "default"); - - if (!ha_ret) { - *err = GRIB_HASH_ARRAY_NO_MATCH; - grib_context_log(a->context, GRIB_LOG_ERROR, - "hash_array: no match for %s=%s", - a->creator->name, self->key); - const char* full_path = get_hash_array_full_path(a->creator); - if (full_path) { - grib_context_log(a->context, GRIB_LOG_ERROR, "hash_array: file path = %s", full_path); - } - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Check the key 'masterTablesVersionNumber'"); - return NULL; - } - return ha_ret; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_hash_array_value* ha = 0; - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - int err = 0; - size_t i = 0; - - if (!self->ha) { - ha = find_hash_value(a, &err); - if (err) - return err; - self->ha = ha; - } - - switch (self->ha->type) { - case GRIB_HASH_ARRAY_TYPE_INTEGER: - if (*len < self->ha->iarray->n) { - return GRIB_ARRAY_TOO_SMALL; - } - *len = self->ha->iarray->n; - for (i = 0; i < *len; i++) - val[i] = self->ha->iarray->v[i]; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - } - - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - int type = GRIB_TYPE_STRING; - if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) - type = GRIB_TYPE_LONG; - - return type; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - if (self->key) - grib_context_free(c, self->key); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static size_t string_length(grib_accessor* a) -{ - return MAX_HASH_ARRAY_STRING_LENGTH; -} - -static int value_count(grib_accessor* a, long* count) -{ - int err = 0; - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - grib_hash_array_value* ha = 0; - - if (!self->ha) { - ha = find_hash_value(a, &err); - if (err) - return err; - self->ha = ha; - } - - *count = self->ha->iarray->n; - return err; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/accessor/todo/grib_accessor_class_headers_only.cc b/src/accessor/todo/grib_accessor_class_headers_only.cc deleted file mode 100644 index d3a98efb0..000000000 --- a/src/accessor/todo/grib_accessor_class_headers_only.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long; get_native_type - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_headers_only -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in headers_only */ -} grib_accessor_headers_only; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_headers_only = { - &grib_accessor_class_gen, /* super */ - "headers_only", /* name */ - sizeof(grib_accessor_headers_only), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_headers_only = &_grib_accessor_class_headers_only; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_handle_of_accessor(a)->partial; - *len = 1; - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_ibmfloat.cc b/src/accessor/todo/grib_accessor_class_ibmfloat.cc deleted file mode 100644 index 27e6da1c5..000000000 --- a/src/accessor/todo/grib_accessor_class_ibmfloat.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - MEMBERS = grib_arguments* arg - IMPLEMENTS = update_size - IMPLEMENTS = nearest_smaller_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int nearest_smaller_value (grib_accessor*, double, double*); - -typedef struct grib_accessor_ibmfloat -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in ibmfloat */ - grib_arguments* arg; -} grib_accessor_ibmfloat; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_ibmfloat = { - &grib_accessor_class_double, /* super */ - "ibmfloat", /* name */ - sizeof(grib_accessor_ibmfloat), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - &nearest_smaller_value, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmfloat; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - long count = 0; - - self->arg = arg; - grib_value_count(a, &count); - a->length = 4 * count; - Assert(a->length >= 0); -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - unsigned long rlen = 0; - long count = 0; - int err = 0; - unsigned long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &count); - if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = *len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (rlen == 1) { - - //double x = 0; - //grib_nearest_smaller_ibm_float(val[0],&x); - //double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); - //printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); - - off = byte_offset(a) * 8; - ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); - if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "ibmfloat: Trying to pack %zu values in a scalar %s, packing first value", - *len, a->name); - if (ret == GRIB_SUCCESS) - len[0] = 1; - return ret; - } - - buflen = rlen * 4; - - buf = (unsigned char*)grib_context_malloc(a->context, buflen); - - for (i = 0; i < rlen; i++) { - grib_encode_unsigned_longb(buf, grib_ibm_to_long(val[i]), &off, 32); - } - ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); - - if (ret == GRIB_SUCCESS) - grib_buffer_replace(a, buf, buflen, 1, 1); - else - *len = 0; - - grib_context_free(a->context, buf); - - a->length = byte_count(a); - - return ret; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - *len = 0; - if (!self->arg) { - *len = 1; - return 0; - } - return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = (long)s; - Assert(a->length >= 0); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static int nearest_smaller_value(grib_accessor* a, double val, double* nearest) -{ - int ret = 0; - if (grib_nearest_smaller_ibm_float(val, nearest) == GRIB_INTERNAL_ERROR) { - grib_context_log(a->context, GRIB_LOG_ERROR, "ibm_float:nearest_smaller_value overflow value=%g", val); - grib_dump_content(grib_handle_of_accessor(a), stderr, "wmo", GRIB_DUMP_FLAG_HEXADECIMAL, 0); - ret = GRIB_INTERNAL_ERROR; - } - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_ieeefloat.cc b/src/accessor/todo/grib_accessor_class_ieeefloat.cc deleted file mode 100644 index d6fa411bb..000000000 --- a/src/accessor/todo/grib_accessor_class_ieeefloat.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = init - IMPLEMENTS = value_count - MEMBERS = grib_arguments* arg - IMPLEMENTS = update_size - IMPLEMENTS = nearest_smaller_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int nearest_smaller_value (grib_accessor*, double, double*); - -typedef struct grib_accessor_ieeefloat -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in ieeefloat */ - grib_arguments* arg; -} grib_accessor_ieeefloat; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_ieeefloat = { - &grib_accessor_class_double, /* super */ - "ieeefloat", /* name */ - sizeof(grib_accessor_ieeefloat), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - &nearest_smaller_value, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeefloat; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - long count = 0; - self->arg = arg; - grib_value_count(a, &count); - a->length = 4 * count; - Assert(a->length >= 0); -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - *len = 0; - - if (!self->arg) { - *len = 1; - return 0; - } - return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = (unsigned long)*len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (rlen == 1) { - off = a->offset * 8; - ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ieee_to_long(val[0]), &off, 32); - if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "ieeefloat: Trying to pack %zu values in a scalar %s, packing first value", - *len, a->name); - if (ret == GRIB_SUCCESS) - len[0] = 1; - return ret; - } - - buflen = rlen * 4; - - buf = (unsigned char*)grib_context_malloc(a->context, buflen); - - for (i = 0; i < rlen; i++) { - grib_encode_unsigned_longb(buf, grib_ieee_to_long(val[i]), &off, 32); - } - ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); - - if (ret == GRIB_SUCCESS) - grib_buffer_replace(a, buf, buflen, 1, 1); - else - *len = 0; - - grib_context_free(a->context, buf); - - return ret; -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long rlen = 0; - int err = 0; - long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &rlen); - if (err) - return err; - - if (*len < (size_t)rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = (long)s; - Assert(a->length >= 0); -} - -static int nearest_smaller_value(grib_accessor* a, double val, double* nearest) -{ - return grib_nearest_smaller_ieee_float(val, nearest); -} diff --git a/src/accessor/todo/grib_accessor_class_ifs_param.cc b/src/accessor/todo/grib_accessor_class_ifs_param.cc deleted file mode 100644 index ba7e522c1..000000000 --- a/src/accessor/todo/grib_accessor_class_ifs_param.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init; get_native_type - MEMBERS=const char* paramId - MEMBERS=const char* type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_ifs_param -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ifs_param */ - const char* paramId; - const char* type; -} grib_accessor_ifs_param; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_ifs_param = { - &grib_accessor_class_gen, /* super */ - "ifs_param", /* name */ - sizeof(grib_accessor_ifs_param), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ifs_param = &_grib_accessor_class_ifs_param; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - int n = 0; - - self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->type = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - int ret = 0; - long paramId = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->paramId, ¶mId)) != GRIB_SUCCESS) - return ret; - - if (paramId > 129000 && paramId < 129999) - *val = paramId - 129000; - else if (paramId > 200000 && paramId < 200999) - *val = paramId - 200000; - else if (paramId > 211000 && paramId < 211999) - *val = paramId - 1000; - else - *val = paramId; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - long type = 0; - long table = 128; - long paramId = *val; - long param; - - grib_get_long(grib_handle_of_accessor(a), self->type, &type); - - if (type == 33 || type == 35) { - if (paramId > 1000) { - table = paramId / 1000; - param = paramId - table * 1000; - paramId = param; - } - switch (table) { - case 210: - paramId += 211000; - break; - case 128: - paramId += 200000; - break; - default: - break; - } - } - if (type == 50 || type == 52) { - if (paramId > 1000) { - table = paramId / 1000; - param = paramId - table * 1000; - paramId = param; - } - switch (table) { - case 128: - paramId += 129000; - break; - default: - break; - } - } - - return grib_set_long_internal(grib_handle_of_accessor(a), self->paramId, paramId); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_julian_day.cc b/src/accessor/todo/grib_accessor_class_julian_day.cc deleted file mode 100644 index 7a8e28cfc..000000000 --- a/src/accessor/todo/grib_accessor_class_julian_day.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = dump - IMPLEMENTS = init - MEMBERS = const char *date - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_julian_day -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in julian_day */ - const char *date; - const char *hour; - const char *minute; - const char *second; -} grib_accessor_julian_day; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_julian_day = { - &grib_accessor_class_double, /* super */ - "julian_day", /* name */ - sizeof(grib_accessor_julian_day), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_julian_day = &_grib_accessor_class_julian_day; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->hour = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->minute = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->second = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const double v = *val; - return pack_double(a, &v, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - int ret = 0; - long hour = 0; - long minute = 0; - long second = 0; - long date = 0; - long year, month, day; - - ret = grib_julian_to_datetime(*val, &year, &month, &day, &hour, &minute, &second); - if (ret != 0) - return ret; - - date = year * 10000 + month * 100 + day; - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->date, date); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->hour, hour); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->minute, minute); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->second, second); - - return ret; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - double v = 0; - - ret = unpack_double(a, &v, len); - *val = (long)v; - - return ret; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - long date, hour, minute, second; - long year, month, day; - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->hour, &hour); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->minute, &minute); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->second, &second); - if (ret != GRIB_SUCCESS) - return ret; - - year = date / 10000; - date %= 10000; - month = date / 100; - date %= 100; - day = date; - - ret = grib_datetime_to_julian(year, month, day, hour, minute, second, val); - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_ksec1expver.cc b/src/accessor/todo/grib_accessor_class_ksec1expver.cc deleted file mode 100644 index 762bf66e2..000000000 --- a/src/accessor/todo/grib_accessor_class_ksec1expver.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_long;pack_string; - IMPLEMENTS = pack_long - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_ksec1expver -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in ksec1expver */ -} grib_accessor_ksec1expver; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_ksec1expver = { - &grib_accessor_class_ascii, /* super */ - "ksec1expver", /* name */ - sizeof(grib_accessor_ksec1expver), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ksec1expver = &_grib_accessor_class_ksec1expver; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = len; - Assert(a->length >= 0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset * 8; - char* intc = NULL; - char* pTemp = NULL; - char expver[5]; - char refexpver[5]; - size_t llen = a->length + 1; - Assert(a->length == 4); - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - value = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, a->length * 8); - - grib_unpack_string(a, refexpver, &llen); - - /* test for endian */ - intc = (char*)&value; - pTemp = intc; - - expver[0] = *pTemp++; - expver[1] = *pTemp++; - expver[2] = *pTemp++; - expver[3] = *pTemp++; - expver[4] = 0; - -// expver[0] = intc[0]; -// expver[1] = intc[1]; -// expver[2] = intc[2]; -// expver[3] = intc[3]; -// expver[4] = 0; - - /* if there is a difference, have to reverse*/ - if (strcmp(refexpver, expver)) { - intc[0] = expver[3]; - intc[1] = expver[2]; - intc[2] = expver[1]; - intc[3] = expver[0]; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - int i = 0; - if (len[0] != 4) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4", a->name); - return GRIB_INVALID_KEY_VALUE; - } - if (len[0] > (a->length) + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%lu) for %s, it contains %ld values", - len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - grib_handle_of_accessor(a)->buffer->data[a->offset + i] = val[i]; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char sval[5] = {0,}; - size_t slen = 4; - snprintf(sval, sizeof(sval), "%04d", (int)(*val)); - return pack_string(a, sval, &slen); -} diff --git a/src/accessor/todo/grib_accessor_class_label.cc b/src/accessor/todo/grib_accessor_class_label.cc deleted file mode 100644 index 8d7831faf..000000000 --- a/src/accessor/todo/grib_accessor_class_label.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;get_native_type;unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_label -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in label */ -} grib_accessor_label; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_label = { - &grib_accessor_class_gen, /* super */ - "label", /* name */ - sizeof(grib_accessor_label), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_label = &_grib_accessor_class_label; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_label(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LABEL; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t vlen = strlen(a->name); - if (vlen > *len) - return GRIB_BUFFER_TOO_SMALL; - *len = vlen; - strcpy(val, a->name); - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_latlonvalues.cc b/src/accessor/todo/grib_accessor_class_latlonvalues.cc deleted file mode 100644 index e559eaa3d..000000000 --- a/src/accessor/todo/grib_accessor_class_latlonvalues.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latlonvalues -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latlonvalues */ - const char* values; -} grib_accessor_latlonvalues; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latlonvalues = { - &grib_accessor_class_double, /* super */ - "latlonvalues", /* name */ - sizeof(grib_accessor_latlonvalues), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_latlonvalues = &_grib_accessor_class_latlonvalues; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latlonvalues* self = (grib_accessor_latlonvalues*)a; - int n = 0; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_context* c = a->context; - int err = 0; - double* v = val; - double lat, lon, value; - size_t size = 0; - long count = 0; - grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), 0, &err); - if (err) { - if (iter) grib_iterator_delete(iter); - grib_context_log(c, GRIB_LOG_ERROR, "latlonvalues: Unable to create iterator"); - return err; - } - - err = value_count(a, &count); - if (err) return err; - size = count; - - if (*len < size) { - if (iter) grib_iterator_delete(iter); - return GRIB_ARRAY_TOO_SMALL; - } - - while (grib_iterator_next(iter, &lat, &lon, &value)) { - *(v++) = lat; - *(v++) = lon; - *(v++) = value; - } - - grib_iterator_delete(iter); - - *len = size; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_latlonvalues* self = (grib_accessor_latlonvalues*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = GRIB_SUCCESS; - size_t size; - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_ERROR, "latlonvalues: Unable to get size of %s", self->values); - return ret; - } - - *count = 3 * size; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_library_version.cc b/src/accessor/todo/grib_accessor_class_library_version.cc deleted file mode 100644 index 2088b68c4..000000000 --- a/src/accessor/todo/grib_accessor_class_library_version.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count;string_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); - -typedef struct grib_accessor_library_version -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in library_version */ -} grib_accessor_library_version; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_library_version = { - &grib_accessor_class_ascii, /* super */ - "library_version", /* name */ - sizeof(grib_accessor_library_version), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_library_version = &_grib_accessor_class_library_version; - -/* END_CLASS_IMP */ - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - char result[30] = {0,}; - size_t size; - - int major = ECCODES_MAJOR_VERSION; - int minor = ECCODES_MINOR_VERSION; - int revision = ECCODES_REVISION_VERSION; - - snprintf(result, sizeof(result), "%d.%d.%d", major, minor, revision); - size = sizeof(result); - - if (*len < size) - return GRIB_ARRAY_TOO_SMALL; - strcpy(val, result); - - *len = size; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} diff --git a/src/accessor/todo/grib_accessor_class_long_vector.cc b/src/accessor/todo/grib_accessor_class_long_vector.cc deleted file mode 100644 index 612163a3e..000000000 --- a/src/accessor/todo/grib_accessor_class_long_vector.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_long_vector - IMPLEMENTS = init - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;get_native_type - MEMBERS = const char* vector - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in long_vector */ - const char* vector; - int index; -} grib_accessor_long_vector; - -extern grib_accessor_class* grib_accessor_class_abstract_long_vector; - -static grib_accessor_class _grib_accessor_class_long_vector = { - &grib_accessor_class_abstract_long_vector, /* super */ - "long_vector", /* name */ - sizeof(grib_accessor_long_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_long_vector = &_grib_accessor_class_long_vector; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_abstract_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; -} grib_accessor_abstract_long_vector; - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - int n = 0; - - self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - /* check self->index on init and never change it */ - Assert(self->index < v->number_of_elements && self->index >= 0); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - size_t size = 0; - int err = 0; - long* vector; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - /*TODO implement the dirty mechanism to avoid to unpack every time */ - err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size); - if (err) return err; - DEBUG_ASSERT(size > 0); - vector = (long*)grib_context_malloc(a->context, sizeof(long) * size); - err = grib_unpack_long(va, vector, &size); - grib_context_free(a->context, vector); - if (err) return err; - - *val = v->v[self->index]; - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - long lval = 0; - int err = 0; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - err = unpack_long(a, &lval, len); - - *val = (double)v->v[self->index]; - - return err; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - v->pack_index = self->index; - - err = grib_pack_long(va, val, len); - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_lookup.cc b/src/accessor/todo/grib_accessor_class_lookup.cc deleted file mode 100644 index 5fc2880a8..000000000 --- a/src/accessor/todo/grib_accessor_class_lookup.cc +++ /dev/null @@ -1,242 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; unpack_string - IMPLEMENTS = init;post_init;dump - IMPLEMENTS = byte_offset;byte_count - IMPLEMENTS = pack_long - IMPLEMENTS = notify_change - MEMBERS = long llength - MEMBERS = long loffset - MEMBERS = grib_expression* real_name - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void post_init(grib_accessor*); -static int notify_change(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_lookup -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in lookup */ - long llength; - long loffset; - grib_expression* real_name; -} grib_accessor_lookup; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_lookup = { - &grib_accessor_class_long, /* super */ - "lookup", /* name */ - sizeof(grib_accessor_lookup), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - &post_init, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - ¬ify_change, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_lookup = &_grib_accessor_class_lookup; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - a->length = 0; - self->llength = len; - self->loffset = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 0); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - self->real_name = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); -} - -static void post_init(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - if (self->real_name) { - grib_dependency_observe_expression(a, self->real_name); - } -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - unsigned char bytes[1024] = {0,}; - char msg[1024] = {0,}; - char buf[2048]; - int i; - unsigned long v = 0; - - size_t llen = self->llength; - grib_unpack_bytes(a, bytes, &llen); /* TODO: Unpack byte unpack the wrong offset */ - - bytes[llen] = 0; - for (i = 0; i < llen; i++) { - msg[i] = isprint(bytes[i]) ? bytes[i] : '?'; - v <<= 8; - v |= bytes[i]; - } - - msg[llen] = 0; - - snprintf(buf, sizeof(buf), "%s %lu %ld-%ld", msg, v, (long)a->offset + self->loffset, (long)self->llength); - - grib_dump_long(dumper, a, buf); -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - unsigned char bytes[1024] = {0,}; - int i; - - size_t llen = self->llength; - grib_unpack_bytes(a, bytes, &llen); /* TODO: Unpack byte unpack the wrong offset */ - - bytes[llen] = 0; - - for (i = 0; i < llen; i++) { - v[i] = isprint(bytes[i]) ? bytes[i] : '?'; - } - - v[llen] = 0; - if (llen == 1 && v[0] == '?') { - /* Try unpack as long */ - size_t length = 10; - long lval = 0; - int err = unpack_long(a, &lval, &length); - if (!err) { - char str[5]; - int conv = snprintf(str, sizeof(str), "%ld", lval); - if (conv == 1) { - v[0] = str[0]; - } - } - } - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - grib_handle* h = grib_handle_of_accessor(a); - - long pos = (a->offset + self->loffset) * 8; - - if (len[0] < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - len[0] = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - /* This is used when reparsing or rebuilding */ - if (h->loader) { - Assert(*len == 1); - return h->loader->lookup_long(h->context, h->loader, a->name, val); - } - - val[0] = grib_decode_unsigned_long(h->buffer->data, &pos, self->llength * 8); - len[0] = 1; - - /*printf("###########lookup unpack_long: %s %ld %ld\n",a->name, pos/8, val[0]);*/ - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static long byte_count(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - return self->llength; -} - -static long byte_offset(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - return self->loffset; -} - -static int notify_change(grib_accessor* self, grib_accessor* changed) -{ - /* Forward changes */ - return grib_dependency_notify_change(self); -} diff --git a/src/accessor/todo/grib_accessor_class_mars_param.cc b/src/accessor/todo/grib_accessor_class_mars_param.cc deleted file mode 100644 index beb7a68c5..000000000 --- a/src/accessor/todo/grib_accessor_class_mars_param.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string - IMPLEMENTS = init; string_length - MEMBERS= const char* paramId - MEMBERS= const char* table - MEMBERS= const char* param - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_mars_param -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in mars_param */ - const char* paramId; - const char* table; - const char* param; -} grib_accessor_mars_param; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_mars_param = { - &grib_accessor_class_ascii, /* super */ - "mars_param", /* name */ - sizeof(grib_accessor_mars_param), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_mars_param = &_grib_accessor_class_mars_param; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_mars_param* self = (grib_accessor_mars_param*)a; - self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->table = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->param = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -// For an implementation of pack_string, see -// src/deprecated/grib_accessor_class_mars_param.cc - -// For an alternative implementation of unpack_string, see -// src/deprecated/grib_accessor_class_mars_param.cc -// -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_mars_param* self = (grib_accessor_mars_param*)a; - long param = 0; - long table = 0; - int ret = 0; - - if (self->table != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->table, &table)) != GRIB_SUCCESS) - return ret; - if (self->param != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->param, ¶m)) != GRIB_SUCCESS) - return ret; - - /*if (table==200) table=128;*/ - snprintf(val, 32, "%ld.%ld", param, table); - *len = strlen(val) + 1; - - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return 7; -} diff --git a/src/accessor/todo/grib_accessor_class_mars_step.cc b/src/accessor/todo/grib_accessor_class_mars_step.cc deleted file mode 100644 index 7792995a7..000000000 --- a/src/accessor/todo/grib_accessor_class_mars_step.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = pack_string;unpack_string;value_count;string_length - IMPLEMENTS = pack_long; unpack_long - IMPLEMENTS = get_native_type - IMPLEMENTS = init - MEMBERS = const char* stepRange - MEMBERS = const char* stepType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_mars_step -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in mars_step */ - const char* stepRange; - const char* stepType; -} grib_accessor_mars_step; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_mars_step = { - &grib_accessor_class_ascii, /* super */ - "mars_step", /* name */ - sizeof(grib_accessor_mars_step), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - char stepType[100]; - size_t stepTypeLen = 100; - char buf[100] = {0,}; - int ret; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - - if (!stepRangeAcc) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); - return GRIB_NOT_FOUND; - } - - if ((ret = grib_get_string(grib_handle_of_accessor(a), self->stepType, stepType, &stepTypeLen)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(stepType, "instant")) - snprintf(buf, sizeof(buf), "%s", val); - else - snprintf(buf, sizeof(buf), "0-%s", val); - - return grib_pack_string(stepRangeAcc, buf, len); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int ret = 0; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - char buf[100] = {0,}; - char* p = NULL; - size_t buflen = 100; - long step; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - const char* cclass_name = a->cclass->name; - - if (!stepRangeAcc) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); - return GRIB_NOT_FOUND; - } - - if ((ret = grib_unpack_string(stepRangeAcc, buf, &buflen)) != GRIB_SUCCESS) - return ret; - - if (*len < buflen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, buflen, *len); - *len = buflen; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(val, buf); - step = strtol(buf, &p, 10); - - if (p != NULL && *p == '-' && step == 0) - strcpy(val, ++p); - - *len = strlen(val); - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char buff[100] = {0,}; - size_t bufflen = 100; - - snprintf(buff, sizeof(buff), "%ld", *val); - - return pack_string(a, buff, &bufflen); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - - if (!stepRangeAcc) - return GRIB_NOT_FOUND; - - return grib_unpack_long(stepRangeAcc, val, len); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 16; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_message.cc b/src/accessor/todo/grib_accessor_class_message.cc deleted file mode 100644 index 6c5587b22..000000000 --- a/src/accessor/todo/grib_accessor_class_message.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = init;update_size;resize; value_count - IMPLEMENTS = unpack_string; string_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static void resize(grib_accessor*,size_t); - -typedef struct grib_accessor_message -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in message */ -} grib_accessor_message; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_message = { - &grib_accessor_class_bytes, /* super */ - "message", /* name */ - sizeof(grib_accessor_message), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - &resize, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_message = &_grib_accessor_class_message; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset; -} - -// static int compare(grib_accessor* a, grib_accessor* b) -// { -// if (a->length != b->length) -// return GRIB_COUNT_MISMATCH; -// return GRIB_SUCCESS; -// } - -static void update_size(grib_accessor* a, size_t new_size) -{ - a->length = new_size; -} - -static void resize(grib_accessor* a, size_t new_size) -{ - grib_context_log(a->context, GRIB_LOG_FATAL, "%s %s: Not supported", a->cclass->name, __func__); - - // void* zero = grib_context_malloc_clear(a->context, new_size); - // grib_buffer_replace(a, (const unsigned char*)zero, new_size, 1, 0); - // grib_context_free(a->context, zero); - // grib_context_log(a->context, GRIB_LOG_DEBUG, "resize: grib_accessor_class_message %ld %ld %s %s", - // (long)new_size, (long)a->length, a->cclass->name, a->name); - // Assert(new_size == a->length); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long i = 0; - size_t l = string_length(a) + 1; - grib_handle* h = grib_handle_of_accessor(a); - - if (*len < l) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - val[i] = h->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_message_copy.cc b/src/accessor/todo/grib_accessor_class_message_copy.cc deleted file mode 100644 index 30806b163..000000000 --- a/src/accessor/todo/grib_accessor_class_message_copy.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;string_length - IMPLEMENTS = byte_count - IMPLEMENTS = init;dump;get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_message_copy -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in message_copy */ -} grib_accessor_message_copy; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_message_copy = { - &grib_accessor_class_gen, /* super */ - "message_copy", /* name */ - sizeof(grib_accessor_message_copy), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_message_copy = &_grib_accessor_class_message_copy; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t slen = grib_handle_of_accessor(a)->buffer->ulength; - size_t i; - unsigned char* v = 0; - - if (*len < slen) { - return GRIB_ARRAY_TOO_SMALL; - } - v = grib_handle_of_accessor(a)->buffer->data; - /* replace unprintable characters with space */ - for (i = 0; i < slen; i++) - if (v[i] > 126) - v[i] = 32; - memcpy(val, grib_handle_of_accessor(a)->buffer->data, slen); - val[i] = 0; - - *len = slen; - - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return grib_handle_of_accessor(a)->buffer->ulength; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_multdouble.cc b/src/accessor/todo/grib_accessor_class_multdouble.cc deleted file mode 100644 index ac5771627..000000000 --- a/src/accessor/todo/grib_accessor_class_multdouble.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS = const char* val - MEMBERS = double multiplier - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_multdouble -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in multdouble */ - const char* val; - double multiplier; -} grib_accessor_multdouble; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_multdouble = { - &grib_accessor_class_double, /* super */ - "multdouble", /* name */ - sizeof(grib_accessor_multdouble), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_multdouble* self = (grib_accessor_multdouble*)a; - int n = 0; - - self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - const grib_accessor_multdouble* self = (grib_accessor_multdouble*)a; - int ret = GRIB_SUCCESS; - double value = 0; - - ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); - if (ret != GRIB_SUCCESS) - return ret; - - *val = value * self->multiplier; - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_non_alpha.cc b/src/accessor/todo/grib_accessor_class_non_alpha.cc deleted file mode 100644 index 821f2311f..000000000 --- a/src/accessor/todo/grib_accessor_class_non_alpha.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_non_alpha -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in non_alpha */ -} grib_accessor_non_alpha; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_non_alpha = { - &grib_accessor_class_gen, /* super */ - "non_alpha", /* name */ - sizeof(grib_accessor_non_alpha), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_alpha; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; - size_t i = 0; - unsigned char* v; - - v = buffer->data + a->offset; - i = 0; - while ((*v < 33 || *v > 126) && i <= buffer->ulength) { - v++; - i++; - } - a->length = i; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_handle* hand = grib_handle_of_accessor(a); - long i = 0; - - if (*len < (a->length + 1)) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - *len, a->name, a->length + 1); - *len = a->length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) { - val[i] = hand->buffer->data[a->offset + i]; - } - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - - if (*last == 0) { - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_number_of_coded_values.cc b/src/accessor/todo/grib_accessor_class_number_of_coded_values.cc deleted file mode 100644 index 14ef832d7..000000000 --- a/src/accessor/todo/grib_accessor_class_number_of_coded_values.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (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. - */ - -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_coded_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_coded_values */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -} grib_accessor_number_of_coded_values; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_coded_values = { - &grib_accessor_class_long, /* super */ - "number_of_coded_values", /* name */ - sizeof(grib_accessor_number_of_coded_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_coded_values = &_grib_accessor_class_number_of_coded_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_number_of_coded_values* self = (grib_accessor_number_of_coded_values*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - - grib_accessor_number_of_coded_values* self = (grib_accessor_number_of_coded_values*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if (bpv != 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n", - offsetAfterData, offsetBeforeData, unusedBits, bpv); - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_number_of_points.cc b/src/accessor/todo/grib_accessor_class_number_of_points.cc deleted file mode 100644 index b3d1eade2..000000000 --- a/src/accessor/todo/grib_accessor_class_number_of_points.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* - * (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. - */ - -/**************************************** - * Enrico Fucile - *************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* ni - MEMBERS = const char* nj - MEMBERS = const char* plpresent - MEMBERS = const char* pl - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_points -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_points */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; -} grib_accessor_number_of_points; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_points = { - &grib_accessor_class_long, /* super */ - "number_of_points", /* name */ - sizeof(grib_accessor_number_of_points), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_class_number_of_points; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a; - self->ni = grib_arguments_get_name(hand, c, n++); - self->nj = grib_arguments_get_name(hand, c, n++); - self->plpresent = grib_arguments_get_name(hand, c, n++); - self->pl = grib_arguments_get_name(hand, c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a; - - int ret = GRIB_SUCCESS; - long ni = 0, nj = 0, plpresent = 0; - size_t plsize = 0; - long* pl = NULL; - int i = 0; - grib_context* c = a->context; - grib_handle* hand = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(hand, self->nj, &nj)) != GRIB_SUCCESS) - return ret; - - if (self->plpresent && - ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS)) - return ret; - - if (grib_is_missing(hand, self->nj, &ret) && ret == GRIB_SUCCESS) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 'missing'!", self->nj); - return GRIB_GEOCALCULUS_PROBLEM; - } - - if (nj == 0) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 0!", self->nj); - return GRIB_GEOCALCULUS_PROBLEM; - } - - if (plpresent) { - /*reduced*/ - plsize = nj; - pl = (long*)grib_context_malloc(c, sizeof(long) * plsize); - grib_get_long_array_internal(hand, self->pl, pl, &plsize); - *val = 0; - for (i = 0; i < plsize; i++) - *val += pl[i]; - grib_context_free(c, pl); - } - else { - /*regular*/ - *val = ni * nj; - } - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_number_of_values.cc b/src/accessor/todo/grib_accessor_class_number_of_values.cc deleted file mode 100644 index fb1aff779..000000000 --- a/src/accessor/todo/grib_accessor_class_number_of_values.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (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. - */ - -/********************************** - * Enrico Fucile - **********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bitsPerValue - MEMBERS = const char* numberOfPoints - MEMBERS = const char* bitmapPresent - MEMBERS = const char* bitmap - MEMBERS = const char* numberOfCodedValues - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_values */ - const char* values; - const char* bitsPerValue; - const char* numberOfPoints; - const char* bitmapPresent; - const char* bitmap; - const char* numberOfCodedValues; -} grib_accessor_number_of_values; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_values = { - &grib_accessor_class_long, /* super */ - "number_of_values", /* name */ - sizeof(grib_accessor_number_of_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_values = &_grib_accessor_class_number_of_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_number_of_values* self = (grib_accessor_number_of_values*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - self->values = grib_arguments_get_name(hand, c, n++); - self->bitsPerValue = grib_arguments_get_name(hand, c, n++); - self->numberOfPoints = grib_arguments_get_name(hand, c, n++); - self->bitmapPresent = grib_arguments_get_name(hand, c, n++); - self->bitmap = grib_arguments_get_name(hand, c, n++); - self->numberOfCodedValues = grib_arguments_get_name(hand, c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_number_of_values* self = (grib_accessor_number_of_values*)a; - int ret = GRIB_SUCCESS, i; - long npoints = 0, bitmap_present = 0; - size_t size = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &npoints)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapPresent, &bitmap_present)) != GRIB_SUCCESS) - return ret; - - if (bitmap_present) { - double* bitmap; - size = npoints; - bitmap = (double*)grib_context_malloc(a->context, sizeof(double) * size); - if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->bitmap, bitmap, &size)) != GRIB_SUCCESS) { - grib_context_free(a->context, bitmap); - return ret; - } - *val = 0; - for (i = 0; i < size; i++) - if (bitmap[i] != 0) - (*val)++; - - grib_context_free(a->context, bitmap); - } - else { - *val = npoints; - } - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc deleted file mode 100644 index 5652797ac..000000000 --- a/src/accessor/todo/grib_accessor_class_number_of_values_data_raw_packing.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (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. - */ -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_api_internal.h" -#define PRECISION_32_IEEE 1 -#define PRECISION_64_IEEE 2 -#define PRECISION_128_IEEE 3 - -#define COMPRESSION_NONE 0 -#define COMPRESSION_LZW 1 - -#define PRE_PROCESSING_NONE 0 -#define PRE_PROCESSING_DIFFERENCE 1 -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - MEMBERS=const char* values - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_values_data_raw_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in number_of_values_data_raw_packing */ - const char* values; - const char* precision; -} grib_accessor_number_of_values_data_raw_packing; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_number_of_values_data_raw_packing = { - &grib_accessor_class_gen, /* super */ - "number_of_values_data_raw_packing", /* name */ - sizeof(grib_accessor_number_of_values_data_raw_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing = &_grib_accessor_class_number_of_values_data_raw_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - int n = 0; - grib_accessor_number_of_values_data_raw_packing* self = (grib_accessor_number_of_values_data_raw_packing*)a; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int err = 0; - grib_accessor_number_of_values_data_raw_packing* self = (grib_accessor_number_of_values_data_raw_packing*)a; - grib_accessor* adata = NULL; - long precision = 0; - int bytes = 0; - long byte_count = 0; - - adata = grib_find_accessor(grib_handle_of_accessor(a), self->values); - Assert(adata != NULL); - byte_count = grib_byte_count(adata); - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return err; - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - } - - *val = byte_count / bytes; - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc deleted file mode 100644 index 8035c9ab0..000000000 --- a/src/accessor/todo/grib_accessor_class_octahedral_gaussian.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - IMPLEMENTS = pack_long - MEMBERS=const char* N - MEMBERS=const char* Ni - MEMBERS=const char* plpresent - MEMBERS=const char* pl - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_octahedral_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in octahedral_gaussian */ - const char* N; - const char* Ni; - const char* plpresent; - const char* pl; -} grib_accessor_octahedral_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_octahedral_gaussian = { - &grib_accessor_class_long, /* super */ - "octahedral_gaussian", /* name */ - sizeof(grib_accessor_octahedral_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_class_octahedral_gaussian; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_octahedral_gaussian* self = (grib_accessor_octahedral_gaussian*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - self->N = grib_arguments_get_name(hand, c, n++); - self->Ni = grib_arguments_get_name(hand, c, n++); - self->plpresent = grib_arguments_get_name(hand, c, n++); - self->pl = grib_arguments_get_name(hand, c, n++); -} - -/* Returns 1 (=true) if input pl array is Octahedral, 0 otherwise. - * Possible cases for the deltas in an octahedral pl array: - * +4 .. +4 Top part, above equator - * +4 .. 0 Top part, above and including equator - * +4.. 0 -4.. Middle part, above, equator and below - * 0 -4.. Equator and below - * -4 ..-4 All below equator - * Anything else is considered not octahedral - */ -static int is_pl_octahedral(const long pl[], size_t size) -{ - long i; - long prev_diff = -1; - for (i = 1; i < size; ++i) { - const long diff = pl[i] - pl[i - 1]; - if (diff == 0) { - /* prev must be +4 or undef */ - if (!(prev_diff == +4 || i == 1)) { - return 0; - } - } - else { - if (labs(diff) != 4) { - return 0; - } - if (diff == +4) { - /* prev must be +4 or undef */ - if (!(prev_diff == +4 || i == 1)) { - return 0; - } - } - if (diff == -4) { - /* prev must be 0, -4 or undef */ - if (!(prev_diff == -4 || prev_diff == 0 || i == 1)) { - return 0; - } - } - } - prev_diff = diff; - } - return 1; /* it's octahedral */ -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_octahedral_gaussian* self = (grib_accessor_octahedral_gaussian*)a; - int ret = GRIB_SUCCESS; - long Ni; - long plpresent = 0; - long* pl = NULL; /* pl array */ - size_t plsize = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_context* c = a->context; - - if ((ret = grib_get_long_internal(hand, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - - /* If Ni is not missing, then this is a plain gaussian grid and not reduced. */ - /* So it cannot be an octahedral grid */ - if (Ni != GRIB_MISSING_LONG) { - *val = 0; - return GRIB_SUCCESS; - } - - if ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS) - return ret; - if (!plpresent) { - *val = 0; /* Not octahedral */ - return GRIB_SUCCESS; - } - - if ((ret = grib_get_size(hand, self->pl, &plsize)) != GRIB_SUCCESS) - return ret; - Assert(plsize); /* pl array must have at least one element */ - - pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); - if (!pl) { - return GRIB_OUT_OF_MEMORY; - } - if ((ret = grib_get_long_array_internal(hand, self->pl, pl, &plsize)) != GRIB_SUCCESS) - return ret; - - /* pl[0] is guaranteed to exist. Have already asserted previously */ - *val = is_pl_octahedral(pl, plsize); - grib_context_free(c, pl); - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/accessor/todo/grib_accessor_class_octet_number.cc b/src/accessor/todo/grib_accessor_class_octet_number.cc deleted file mode 100644 index cce0e742b..000000000 --- a/src/accessor/todo/grib_accessor_class_octet_number.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* left - MEMBERS=long right - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_octet_number -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in octet_number */ - const char* left; - long right; -} grib_accessor_octet_number; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_octet_number = { - &grib_accessor_class_long, /* super */ - "octet_number", /* name */ - sizeof(grib_accessor_octet_number), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_octet_number = &_grib_accessor_class_octet_number; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_octet_number* self = (grib_accessor_octet_number*)a; - - int n = 0; - self->left = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->right = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_octet_number* self = (grib_accessor_octet_number*)a; - int ret = GRIB_SUCCESS; - long offset; - - offset = a->offset + self->right; - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->left, offset)) != GRIB_SUCCESS) - return ret; - - *val = offset; - *len = 1; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_offset_file.cc b/src/accessor/todo/grib_accessor_class_offset_file.cc deleted file mode 100644 index 8fd0a0018..000000000 --- a/src/accessor/todo/grib_accessor_class_offset_file.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_offset_file -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in offset_file */ -} grib_accessor_offset_file; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_offset_file = { - &grib_accessor_class_double, /* super */ - "offset_file", /* name */ - sizeof(grib_accessor_offset_file), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_offset_file = &_grib_accessor_class_offset_file; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - *val = (double)grib_handle_of_accessor(a)->offset; - *len = 1; - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - double val = 0; - size_t l = 1; - char repres[1024] = {0,}; - int err = 0; - const char* cclass_name = a->cclass->name; - - err = grib_unpack_double(a, &val, &l); - if (err) return err; - - snprintf(repres, sizeof(repres), "%.0f", val); - - l = strlen(repres) + 1; - if (l > *len) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - grib_context_log(a->context, GRIB_LOG_DEBUG, "%s: Casting double %s to string", __func__, a->name); - - *len = l; - - strcpy(v, repres); - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_offset_values.cc b/src/accessor/todo/grib_accessor_class_offset_values.cc deleted file mode 100644 index 012698f79..000000000 --- a/src/accessor/todo/grib_accessor_class_offset_values.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* - * (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. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missingValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_offset_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in offset_values */ - const char* values; - const char* missingValue; -} grib_accessor_offset_values; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_offset_values = { - &grib_accessor_class_double, /* super */ - "offset_values", /* name */ - sizeof(grib_accessor_offset_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_offset_values = &_grib_accessor_class_offset_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_offset_values* self = (grib_accessor_offset_values*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - *val = 0; - *len = 1; - return ret; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - double* values = NULL; - size_t size = 0; - double missingValue = 0; - long missingValuesPresent = 0; - int ret = 0, i = 0; - grib_accessor_offset_values* self = (grib_accessor_offset_values*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val == 0) - return GRIB_SUCCESS; - - if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { - return ret; - } - if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { - return ret; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - for (i = 0; i < size; i++) { - if (missingValuesPresent) { - if (values[i] != missingValue) - values[i] += *val; - } - else { - values[i] += *val; - } - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) - return ret; - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_pack_bufr_values.cc b/src/accessor/todo/grib_accessor_class_pack_bufr_values.cc deleted file mode 100644 index a076e12ac..000000000 --- a/src/accessor/todo/grib_accessor_class_pack_bufr_values.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = pack_long; pack_double - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = grib_accessor* data_accessor - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_pack_bufr_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in pack_bufr_values */ - grib_accessor* data_accessor; -} grib_accessor_pack_bufr_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_pack_bufr_values = { - &grib_accessor_class_gen, /* super */ - "pack_bufr_values", /* name */ - sizeof(grib_accessor_pack_bufr_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_pack_bufr_values = &_grib_accessor_class_pack_bufr_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - char* key; - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_pack_double(data, 0, 0); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_pack_double(data, 0, 0); -} diff --git a/src/accessor/todo/grib_accessor_class_packing_type.cc b/src/accessor/todo/grib_accessor_class_packing_type.cc deleted file mode 100644 index a9a4a2deb..000000000 --- a/src/accessor/todo/grib_accessor_class_packing_type.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = string_length - IMPLEMENTS = get_native_type - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* packing_type - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_packing_type -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in packing_type */ - const char* values; - const char* packing_type; -} grib_accessor_packing_type; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_packing_type = { - &grib_accessor_class_gen, /* super */ - "packing_type", /* name */ - sizeof(grib_accessor_packing_type), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_packing_type = &_grib_accessor_class_packing_type; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->packing_type = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int pack_string(grib_accessor*a, const char* sval, size_t* len) -{ - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - grib_handle* h = grib_handle_of_accessor(a); - double* values = NULL; - grib_context* c = a->context; - size_t size = 0; - int err = 0; - - if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return err; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_string_internal(h, self->packing_type, sval, len)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - grib_context_free(c, values); - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - grib_handle* h = grib_handle_of_accessor(a); - - return grib_get_string(h, self->packing_type, val, len); -} diff --git a/src/accessor/todo/grib_accessor_class_pad.cc b/src/accessor/todo/grib_accessor_class_pad.cc deleted file mode 100644 index 473a507e1..000000000 --- a/src/accessor/todo/grib_accessor_class_pad.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS =grib_expression* expression - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_pad -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in pad */ - grib_expression* expression; -} grib_accessor_pad; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_pad = { - &grib_accessor_class_padding, /* super */ - "pad", /* name */ - sizeof(grib_accessor_pad), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_pad = &_grib_accessor_class_pad; - -/* END_CLASS_IMP */ - - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_pad* self = (grib_accessor_pad*)a; - - long length = 0; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &length); - - return length > 0 ? length : 0; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_pad* self = (grib_accessor_pad*)a; - - self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - a->length = preferred_size(a, 1); -} diff --git a/src/accessor/todo/grib_accessor_class_padding.cc b/src/accessor/todo/grib_accessor_class_padding.cc deleted file mode 100644 index 790ea9db2..000000000 --- a/src/accessor/todo/grib_accessor_class_padding.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = init;update_size;resize; value_count - IMPLEMENTS = compare;string_length;byte_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static void resize(grib_accessor*,size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_padding -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ -} grib_accessor_padding; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_padding = { - &grib_accessor_class_bytes, /* super */ - "padding", /* name */ - sizeof(grib_accessor_padding), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - &resize, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padding = &_grib_accessor_class_padding; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - if (a->length != b->length) - return GRIB_COUNT_MISMATCH; - return GRIB_SUCCESS; -} - -static void update_size(grib_accessor* a, size_t new_size) -{ - a->length = new_size; -} - -static void resize(grib_accessor* a, size_t new_size) -{ - void* zero = grib_context_malloc_clear(a->context, new_size); - - grib_buffer_replace(a, (const unsigned char*)zero, new_size, - /*update_lengths=*/1, /*update_paddings=*/0); - grib_context_free(a->context, zero); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_class_padding::resize new_size=%zu a->length=%ld %s %s", - new_size, a->length, a->cclass->name, a->name); - Assert(new_size == a->length); -} - -static int value_count(grib_accessor* a, long* c) -{ - *c = a->length; - return 0; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static size_t string_length(grib_accessor* a) -{ - return (size_t)a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_padto.cc b/src/accessor/todo/grib_accessor_class_padto.cc deleted file mode 100644 index f6f9417b4..000000000 --- a/src/accessor/todo/grib_accessor_class_padto.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size;dump - MEMBERS=grib_expression* expression - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padto -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padto */ - grib_expression* expression; -} grib_accessor_padto; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padto = { - &grib_accessor_class_padding, /* super */ - "padto", /* name */ - sizeof(grib_accessor_padto), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padto = &_grib_accessor_class_padto; - -/* END_CLASS_IMP */ - - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padto* self = (grib_accessor_padto*)a; - - long length = 0; - long theEnd; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &theEnd); - - length = theEnd - a->offset; - - /* printf("preferred_size: prefered: %ld current:%ld %s %s %ld\n", (long)length,(long)a->length,a->cclass->name,a->name,(long)a->offset); */ - - return length > 0 ? length : 0; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_padto* self = (grib_accessor_padto*)a; - - self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - a->length = preferred_size(a, 1); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /*grib_dump_string(dumper,a,NULL);*/ -} diff --git a/src/accessor/todo/grib_accessor_class_padtoeven.cc b/src/accessor/todo/grib_accessor_class_padtoeven.cc deleted file mode 100644 index c75e0e254..000000000 --- a/src/accessor/todo/grib_accessor_class_padtoeven.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS=const char* section_offset - MEMBERS=const char* section_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padtoeven -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padtoeven */ - const char* section_offset; - const char* section_length; -} grib_accessor_padtoeven; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padtoeven = { - &grib_accessor_class_padding, /* super */ - "padtoeven", /* name */ - sizeof(grib_accessor_padtoeven), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padtoeven = &_grib_accessor_class_padtoeven; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padtoeven* self = (grib_accessor_padtoeven*)a; - long offset = 0; - long length = 0; - long seclen; - - grib_get_long_internal(grib_handle_of_accessor(a), self->section_offset, &offset); - grib_get_long_internal(grib_handle_of_accessor(a), self->section_length, &length); - - if ((length % 2) && from_handle) { - // grib_context_log(a->context, - // GRIB_LOG_ERROR,"GRIB message has an odd length section (%ld, %s)", - // (long)length,a->name); - return 0; - } - - /* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/ - seclen = a->offset - offset; - - return (seclen % 2) ? 1 : 0; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_padtoeven* self = (grib_accessor_padtoeven*)a; - - self->section_offset = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->section_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - - a->length = preferred_size(a, 1); -} diff --git a/src/accessor/todo/grib_accessor_class_padtomultiple.cc b/src/accessor/todo/grib_accessor_class_padtomultiple.cc deleted file mode 100644 index 3104cdf2f..000000000 --- a/src/accessor/todo/grib_accessor_class_padtomultiple.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS=grib_expression* begin - MEMBERS=grib_expression* multiple - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padtomultiple -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padtomultiple */ - grib_expression* begin; - grib_expression* multiple; -} grib_accessor_padtomultiple; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padtomultiple = { - &grib_accessor_class_padding, /* super */ - "padtomultiple", /* name */ - sizeof(grib_accessor_padtomultiple), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padtomultiple = &_grib_accessor_class_padtomultiple; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padtomultiple* self = (grib_accessor_padtomultiple*)a; - long padding = 0; - long begin = 0; - long multiple = 0; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->begin, &begin); - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->multiple, &multiple); - - padding = a->offset - begin; - padding = ((padding + multiple - 1) / multiple) * multiple - padding; - - return padding == 0 ? multiple : padding; -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_padtomultiple* self = (grib_accessor_padtomultiple*)a; - - self->begin = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - self->multiple = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); - a->length = preferred_size(a, 1); -} diff --git a/src/accessor/todo/grib_accessor_class_position.cc b/src/accessor/todo/grib_accessor_class_position.cc deleted file mode 100644 index 0f9565c37..000000000 --- a/src/accessor/todo/grib_accessor_class_position.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - IMPLEMENTS = init;dump - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_position -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in position */ -} grib_accessor_position; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_position = { - &grib_accessor_class_gen, /* super */ - "position", /* name */ - sizeof(grib_accessor_position), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - *val = a->offset; - *len = 1; - return GRIB_SUCCESS; -} - -// static int compare(grib_accessor* a, grib_accessor* b) -// { -// if (a->offset != b->offset) -// return GRIB_OFFSET_MISMATCH; -// return GRIB_SUCCESS; -// } diff --git a/src/accessor/todo/grib_accessor_class_raw.cc b/src/accessor/todo/grib_accessor_class_raw.cc deleted file mode 100644 index cdac6a100..000000000 --- a/src/accessor/todo/grib_accessor_class_raw.cc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init;update_size; pack_bytes - IMPLEMENTS = compare;unpack_bytes;byte_count;value_count - MEMBERS = const char* totalLength - MEMBERS = const char* sectionLength - MEMBERS = long relativeOffset - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_raw -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in raw */ - const char* totalLength; - const char* sectionLength; - long relativeOffset; -} grib_accessor_raw; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_raw = { - &grib_accessor_class_gen, /* super */ - "raw", /* name */ - sizeof(grib_accessor_raw), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - int err = 0; - long sectionLength; - grib_accessor_raw* self = (grib_accessor_raw*)a; - grib_expression* e; - grib_handle* hand = grib_handle_of_accessor(a); - - a->length = 0; - self->totalLength = grib_arguments_get_name(hand, arg, n++); - self->sectionLength = grib_arguments_get_name(hand, arg, n++); - - e = grib_arguments_get_expression(hand, arg, n++); - err = grib_expression_evaluate_long(hand, e, &(self->relativeOffset)); - if (err) - grib_context_log(hand->context, GRIB_LOG_ERROR, "Unable to evaluate relativeOffset"); - - grib_get_long(hand, self->sectionLength, §ionLength); - - a->length = sectionLength - self->relativeOffset; - if (a->length < 0) - a->length = 0; - - /* Assert(a->length>=0); */ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_BYTES; -} - - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - - size_t alen = (size_t)grib_byte_count(a); - size_t blen = (size_t)grib_byte_count(b); - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - return retval; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* len) -{ - *len = a->length; - return 0; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) -{ - if (*len < a->length) { - *len = a->length; - return GRIB_ARRAY_TOO_SMALL; - } - *len = a->length; - - memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); - - return GRIB_SUCCESS; -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); - a->length = s; - Assert(a->length >= 0); -} - -void accessor_raw_set_length(grib_accessor* a, size_t len) -{ - a->length = len; -} - -long accessor_raw_get_offset(grib_accessor* a) -{ - return a->offset; -} - -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ - size_t length = *len; - long totalLength; - long sectionLength; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_raw* self = (grib_accessor_raw*)a; - long dlen = length - a->length; - - grib_get_long(h, self->totalLength, &totalLength); - totalLength += dlen; - grib_get_long(h, self->sectionLength, §ionLength); - sectionLength += dlen; - - grib_buffer_replace(a, val, length, 1, 1); - - grib_set_long(h, self->totalLength, totalLength); - grib_set_long(h, self->sectionLength, sectionLength); - a->length = length; - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc deleted file mode 100644 index 8a3bfa2a1..000000000 --- a/src/accessor/todo/grib_accessor_class_rdbtime_guess_date.cc +++ /dev/null @@ -1,172 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* typicalYear - MEMBERS=const char* typicalMonth - MEMBERS=const char* typicalDay - MEMBERS=const char* rdbDay - MEMBERS=long yearOrMonth - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_rdbtime_guess_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in rdbtime_guess_date */ - const char* typicalYear; - const char* typicalMonth; - const char* typicalDay; - const char* rdbDay; - long yearOrMonth; -} grib_accessor_rdbtime_guess_date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_rdbtime_guess_date = { - &grib_accessor_class_long, /* super */ - "rdbtime_guess_date", /* name */ - sizeof(grib_accessor_rdbtime_guess_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a; - int n = 0; - - self->typicalYear = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->typicalMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->typicalDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->rdbDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->yearOrMonth = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - long typicalYear, typicalMonth, typicalDay, rdbDay; - long rdbYear, rdbMonth; - - ret = grib_get_long(h, self->typicalYear, &typicalYear); - if (ret) - return ret; - ret = grib_get_long(h, self->typicalMonth, &typicalMonth); - if (ret) - return ret; - ret = grib_get_long(h, self->typicalDay, &typicalDay); - if (ret) - return ret; - ret = grib_get_long(h, self->rdbDay, &rdbDay); - if (ret) - return ret; - - if (rdbDay < typicalDay) { - if (typicalDay == 31 && typicalMonth == 12) { - rdbYear = typicalYear + 1; - rdbMonth = 1; - } - else { - rdbYear = typicalYear; - rdbMonth = typicalMonth + 1; - } - } - else { - rdbYear = typicalYear; - rdbMonth = typicalMonth; - } - - *val = self->yearOrMonth == 1 ? rdbYear : rdbMonth; - *len = 1; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - /* do nothing*/ - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_reference_value_error.cc b/src/accessor/todo/grib_accessor_class_reference_value_error.cc deleted file mode 100644 index 3cc4af20d..000000000 --- a/src/accessor/todo/grib_accessor_class_reference_value_error.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* referenceValue - MEMBERS=const char* floatType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_reference_value_error -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in reference_value_error */ - const char* referenceValue; - const char* floatType; -} grib_accessor_reference_value_error; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_reference_value_error = { - &grib_accessor_class_double, /* super */ - "reference_value_error", /* name */ - sizeof(grib_accessor_reference_value_error), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_reference_value_error* self = (grib_accessor_reference_value_error*)a; - int n = 0; - - self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_reference_value_error* self = (grib_accessor_reference_value_error*)a; - int ret = 0; - double referenceValue = 0; - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), - self->referenceValue, &referenceValue)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(self->floatType, "ibm")) - *val = grib_ibmfloat_error(referenceValue); - else if (!strcmp(self->floatType, "ieee")) - *val = grib_ieeefloat_error(referenceValue); - else - Assert(1 == 0); - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_round.cc b/src/accessor/todo/grib_accessor_class_round.cc deleted file mode 100644 index 98fe2fda5..000000000 --- a/src/accessor/todo/grib_accessor_class_round.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_evaluate - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); - -typedef struct grib_accessor_round -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in evaluate */ - grib_arguments* arg; - /* Members defined in round */ -} grib_accessor_round; - -extern grib_accessor_class* grib_accessor_class_evaluate; - -static grib_accessor_class _grib_accessor_class_round = { - &grib_accessor_class_evaluate, /* super */ - "round", /* name */ - sizeof(grib_accessor_round), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round; - -/* END_CLASS_IMP */ - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_round* self = (grib_accessor_round*)a; - - int ret = GRIB_SUCCESS; - - size_t replen = 0; - double rounding_precision = 0; - double rounded = 0; - double toround = 0; - - const char* oval = NULL; - oval = grib_arguments_get_name(grib_handle_of_accessor(a), self->arg, 0); - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), oval, &toround)) != 0) - return ret; - - rounding_precision = grib_arguments_get_long(grib_handle_of_accessor(a), self->arg, 1); - - rounded = floor(rounding_precision * toround + 0.5) / rounding_precision; - - *len = replen; - - *val = rounded; - - return ret; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - char result[1024]; - int ret = GRIB_SUCCESS; - size_t replen = 1; - - double value = 0; - - ret = unpack_double(a, &value, &replen); - - snprintf(result, sizeof(result), "%.3f", value); - - replen = strlen(result) + 1; - - if (*len < replen) { - *len = replen; - return GRIB_ARRAY_TOO_SMALL; - } - - *len = replen; - - snprintf(val, 1024, "%s", result); - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_scale.cc b/src/accessor/todo/grib_accessor_class_scale.cc deleted file mode 100644 index 6fec75e94..000000000 --- a/src/accessor/todo/grib_accessor_class_scale.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS=const char* value - MEMBERS=const char* multiplier - MEMBERS=const char* divisor - MEMBERS=const char* truncating - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_scale -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in scale */ - const char* value; - const char* multiplier; - const char* divisor; - const char* truncating; -} grib_accessor_scale; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_scale = { - &grib_accessor_class_double, /* super */ - "scale", /* name */ - sizeof(grib_accessor_scale), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int n = 0; - - self->value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->multiplier = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->divisor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int ret = 0; - long value = 0; - long multiplier = 0; - long divisor = 0; - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s cannot gather value for %s and/or %s", - a->name, self->multiplier, self->divisor); - return ret; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->value, &value)) != GRIB_SUCCESS) - return ret; - - if (value == GRIB_MISSING_LONG) - *val = GRIB_MISSING_DOUBLE; - else - *val = ((double)(value * multiplier)) / divisor; - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const double dval = (double)*val; - return pack_double(a, &dval, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int ret = 0; - - long value = 0; - long divisor = 0; - long multiplier = 0; - long truncating = 0; - double x; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor); - if (ret != GRIB_SUCCESS) return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier); - if (ret != GRIB_SUCCESS) return ret; - - if (self->truncating) { - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->truncating, &truncating); - if (ret != GRIB_SUCCESS) return ret; - } - - if (multiplier == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s: cannot divide by a zero multiplier %s", - a->name, self->multiplier); - return GRIB_ENCODING_ERROR; - } - - x = *val * (double)divisor / (double)multiplier; - if (*val == GRIB_MISSING_DOUBLE) - value = GRIB_MISSING_LONG; - else if (truncating) { - value = (long)x; - } - else { - value = x > 0 ? (long)(x + 0.5) : (long)(x - 0.5); - } - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->value, value); - if (ret) - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s: cannot pack value for %s (%s)\n", - a->name, self->value, grib_get_error_message(ret)); - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} - -static int is_missing(grib_accessor* a) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); - - if (!av) - return GRIB_NOT_FOUND; - return grib_is_missing_internal(av); - // int ret=0; - // long value=0; - // if((ret = grib_get_long_internal(grib_handle_of_accessor(a),self->value, &value))!= GRIB_SUCCESS){ - // grib_context_log(a->context, GRIB_LOG_ERROR, - // "Accessor %s cannot gather value for %s error %d \n", a->name, - // self->value, ret); - // return 0; - // } - // return (value == GRIB_MISSING_LONG); -} diff --git a/src/accessor/todo/grib_accessor_class_scale_values.cc b/src/accessor/todo/grib_accessor_class_scale_values.cc deleted file mode 100644 index 8c4b33fcb..000000000 --- a/src/accessor/todo/grib_accessor_class_scale_values.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (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. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missingValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_scale_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in scale_values */ - const char* values; - const char* missingValue; -} grib_accessor_scale_values; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_scale_values = { - &grib_accessor_class_double, /* super */ - "scale_values", /* name */ - sizeof(grib_accessor_scale_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - *val = 1; - *len = 1; - return ret; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - double* values = NULL; - double missingValue = 0; - long missingValuesPresent = 0; - size_t size = 0; - int ret = 0, i = 0; - grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - const grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val == 1) - return GRIB_SUCCESS; - - if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { - return ret; - } - if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { - return ret; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - for (i = 0; i < size; i++) { - if (missingValuesPresent) { - if (values[i] != missingValue) - values[i] *= *val; - } - else { - values[i] *= *val; - } - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_section.cc b/src/accessor/todo/grib_accessor_class_section.cc deleted file mode 100644 index f9c8857a7..000000000 --- a/src/accessor/todo/grib_accessor_class_section.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = next_offset;byte_count - IMPLEMENTS = destroy;sub_section - IMPLEMENTS = get_native_type - IMPLEMENTS = init;dump;update_size - IMPLEMENTS = next - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static grib_section* sub_section(grib_accessor* a); -static int get_native_type(grib_accessor*); -static long byte_count(grib_accessor*); -static long next_offset(grib_accessor*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static grib_accessor* next(grib_accessor*, int); - -typedef struct grib_accessor_section -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in section */ -} grib_accessor_section; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_section = { - &grib_accessor_class_gen, /* super */ - "section", /* name */ - sizeof(grib_accessor_section), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - &sub_section, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section = &_grib_accessor_class_section; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->sub_section = grib_section_create(grib_handle_of_accessor(a), a); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_section(dumper, a, a->sub_section->block); -} - -static long byte_count(grib_accessor* a) -{ - if (!a->length || grib_handle_of_accessor(a)->loader) { - if (a->name[1] == '_') - return 0; - - /* printf("adjusting sizes SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ - grib_section_adjust_sizes(a->sub_section, grib_handle_of_accessor(a)->loader != NULL, 0); - /* printf(" SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ - } - - /* printf("SECTION %s is %ld %d\n",a->name,a->length,a->sub_section->aclength != NULL); */ - return a->length; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + byte_count(a); -} - -static void destroy(grib_context* ct, grib_accessor* a) -{ - grib_section_delete(ct, a->sub_section); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_SECTION; -} - -static grib_section* sub_section(grib_accessor* a) -{ - return a->sub_section; -} - -static void update_size(grib_accessor* a, size_t length) -{ - size_t size = 1; - long len = length; - Assert(length <= 0x7fffffff); - if (a->sub_section->aclength) { - int e = grib_pack_long(a->sub_section->aclength, &len, &size); - Assert(e == GRIB_SUCCESS); - // printf("update_length %s %ld %ld\n", a->sub_section->aclength->name, - // (long)a->sub_section->aclength->offset, - // (long)a->sub_section->aclength->length); - } - - a->sub_section->length = a->length = length; - a->sub_section->padding = 0; - - // printf("update_size %s %ld\n", a->name, a->length); - - Assert(a->length >= 0); -} - -static grib_accessor* next(grib_accessor* a, int explore) -{ - grib_accessor* next = NULL; - if (explore) { - next = a->sub_section->block->first; - if (!next) - next = a->next; - } - else { - next = a->next; - } - if (!next) { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} diff --git a/src/accessor/todo/grib_accessor_class_section_length.cc b/src/accessor/todo/grib_accessor_class_section_length.cc deleted file mode 100644 index 4e5957e71..000000000 --- a/src/accessor/todo/grib_accessor_class_section_length.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump - IMPLEMENTS = value_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_section_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ -} grib_accessor_section_length; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_section_length = { - &grib_accessor_class_unsigned, /* super */ - "section_length", /* name */ - sizeof(grib_accessor_section_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_length = &_grib_accessor_class_section_length; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->parent->aclength = a; - a->length = len; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - Assert(a->length >= 0); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int value_count(grib_accessor* a, long* c) -{ - *c = 1; - return 0; -} diff --git a/src/accessor/todo/grib_accessor_class_section_padding.cc b/src/accessor/todo/grib_accessor_class_section_padding.cc deleted file mode 100644 index 682946df5..000000000 --- a/src/accessor/todo/grib_accessor_class_section_padding.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS = int preserve - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_section_padding -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in section_padding */ - int preserve; -} grib_accessor_section_padding; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_section_padding = { - &grib_accessor_class_padding, /* super */ - "section_padding", /* name */ - sizeof(grib_accessor_section_padding), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_padding = &_grib_accessor_class_section_padding; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_section_padding* self = (grib_accessor_section_padding*)a; - grib_accessor* b = a; - grib_accessor* section_length = 0; - long length = 0; - size_t size = 1; - - long alength = 0; - - if (!from_handle) { - if (self->preserve) - return a->length; - else - return 0; - } - - /* The section length should be a parameter */ - while (section_length == NULL && b != NULL) { - section_length = b->parent->aclength; - b = b->parent->owner; - } - - if (!section_length) { - /* printf("PADDING is no !section_length\n"); */ - return 0; - } - - if (grib_unpack_long(section_length, &length, &size) == GRIB_SUCCESS) { - if (length) - alength = length - a->offset + section_length->parent->owner->offset; - else - alength = 0; - - /*Assert(a->length>=0);*/ - - if (alength < 0) - alength = 0; - - /* printf("PADDING is %ld\n",a->length); */ - } - else { - /* printf("PADDING unpack fails\n"); */ - } - - return alength; -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_section_padding* self = (grib_accessor_section_padding*)a; - self->preserve = 1; /* This should be a parameter */ - a->length = preferred_size(a, 1); -} diff --git a/src/accessor/todo/grib_accessor_class_section_pointer.cc b/src/accessor/todo/grib_accessor_class_section_pointer.cc deleted file mode 100644 index 861ab12e7..000000000 --- a/src/accessor/todo/grib_accessor_class_section_pointer.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;get_native_type;unpack_string - IMPLEMENTS = byte_count; byte_offset - MEMBERS = const char* sectionOffset - MEMBERS = const char* sectionLength - MEMBERS = long sectionNumber - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_section_pointer -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in section_pointer */ - const char* sectionOffset; - const char* sectionLength; - long sectionNumber; -} grib_accessor_section_pointer; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_section_pointer = { - &grib_accessor_class_gen, /* super */ - "section_pointer", /* name */ - sizeof(grib_accessor_section_pointer), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_pointer = &_grib_accessor_class_section_pointer; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - - self->sectionOffset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->sectionLength = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->sectionNumber = grib_arguments_get_long(grib_handle_of_accessor(a), arg, n++); - - Assert(self->sectionNumber < MAX_NUM_SECTIONS); - - grib_handle_of_accessor(a)->section_offset[self->sectionNumber] = (char*)self->sectionOffset; - grib_handle_of_accessor(a)->section_length[self->sectionNumber] = (char*)self->sectionLength; - - /* printf("++++++++++++++ GRIB_API: creating section_pointer%d %s %s\n", */ - /* self->sectionNumber,self->sectionLength,self->sectionLength); */ - - if (grib_handle_of_accessor(a)->sections_count < self->sectionNumber) - grib_handle_of_accessor(a)->sections_count = self->sectionNumber; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->length = 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_BYTES; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - /* - unsigned char* p=NULL; - char* s=v; - int i; - long length=grib_byte_count(a); - - if (*len < length) return GRIB_ARRAY_TOO_SMALL; - - p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); - - for (i = 0; i < length; i++) { - snprintf (s,64,"%02x", *(p++)); - s+=2; - } - *len=length; - */ - snprintf(v, 64, "%ld_%ld", grib_byte_offset(a), grib_byte_count(a)); - return GRIB_SUCCESS; -} - -static long byte_count(grib_accessor* a) -{ - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - long sectionLength = 0; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->sectionLength, §ionLength); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Unable to get %s %s", - self->sectionLength, grib_get_error_message(ret)); - return -1; - } - - return sectionLength; -} - -static long byte_offset(grib_accessor* a) -{ - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - long sectionOffset = 0; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->sectionOffset, §ionOffset); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Unable to get %s %s", - self->sectionOffset, grib_get_error_message(ret)); - return -1; - } - - return sectionOffset; -} diff --git a/src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc deleted file mode 100644 index 9e132d9c2..000000000 --- a/src/accessor/todo/grib_accessor_class_sexagesimal2decimal.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * (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. - */ -/*********************************************************** - * Enrico Fucile - ***********************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_to_double - IMPLEMENTS = init; unpack_string - IMPLEMENTS = dump - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sexagesimal2decimal -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_double */ - const char* key; - long start; - size_t length; - long scale; - /* Members defined in sexagesimal2decimal */ -} grib_accessor_sexagesimal2decimal; - -extern grib_accessor_class* grib_accessor_class_to_double; - -static grib_accessor_class _grib_accessor_class_sexagesimal2decimal = { - &grib_accessor_class_to_double, /* super */ - "sexagesimal2decimal", /* name */ - sizeof(grib_accessor_sexagesimal2decimal), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_sexagesimal2decimal = &_grib_accessor_class_sexagesimal2decimal; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_double(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int err = 0; - grib_accessor_sexagesimal2decimal* self = (grib_accessor_sexagesimal2decimal*)a; - char buff[512] = {0,}; - size_t length = 0; - size_t size = 512; - char* p; - char* q; - double dd, mm = 0, ss = 0; - int dd_sign = 1; - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - q = buff + self->start; - if (self->length) - q[length] = 0; - p = q; - - while (*p != '-' && *p != ':' && *p != ' ' && *p != 0) { - p++; - } - - if (*p == 0) { - return GRIB_WRONG_CONVERSION; - } - *p = 0; - - dd = atoi(q); - p++; - q = p; - while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { - p++; - } - switch (*p) { - case ' ': - case '-': - case ':': - *p = 0; - mm = atoi(q) / 60.0; - dd += mm; - p++; - q = p; - break; - case 'N': - case 'E': - *p = 0; - dd_sign = 1; - mm = atoi(q) / 60.0; - dd += mm; - p++; - q = p; - break; - case 'S': - case 'W': - *p = 0; - mm = atoi(q) / 60.0; - dd += mm; - dd_sign = -1; - p++; - q = p; - break; - case 0: - break; - default: - return GRIB_WRONG_CONVERSION; - } - if (*p) { - while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { - p++; - } - switch (*p) { - case ' ': - case '-': - case ':': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - break; - case 'N': - case 'E': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - dd_sign = 1; - break; - case 'S': - case 'W': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - dd_sign = -1; - break; - case 0: - break; - default: - return GRIB_WRONG_CONVERSION; - } - } - dd *= dd_sign; - - snprintf(buff, sizeof(buff), "%.2f", dd); - length = strlen(buff); - - if (len[0] < length + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - strcpy(val, buff); - - len[0] = length; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_signed_bits.cc b/src/accessor/todo/grib_accessor_class_signed_bits.cc deleted file mode 100644 index dc8ccf488..000000000 --- a/src/accessor/todo/grib_accessor_class_signed_bits.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_signed_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in signed_bits */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_signed_bits; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_signed_bits = { - &grib_accessor_class_long, /* super */ - "signed_bits", /* name */ - sizeof(grib_accessor_signed_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_signed_bits = &_grib_accessor_class_signed_bits; - -/* END_CLASS_IMP */ - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - - return (numberOfBits * numberOfElements + 7) / 8; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -#if 0 - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int i; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - if (numberOfBits == 0) { - for (i = 0; i < rlen; i++) - val[i] = 0; - return GRIB_SUCCESS; - } - - for (i = 0; i < rlen; i++) - val[i] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - *len = rlen; - - return GRIB_SUCCESS; -#endif -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -#if 0 - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - unsigned long rlen = 0; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - rlen = count; - if (*len != rlen) { - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, rlen); - if (ret) - return ret; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); - - for (i = 0; i < rlen; i++) - grib_encode_signed_longb(buf, val[i], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return ret; -#endif -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - *numberOfElements = 0; - - return grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + byte_count(a); -} diff --git a/src/accessor/todo/grib_accessor_class_simple_packing_error.cc b/src/accessor/todo/grib_accessor_class_simple_packing_error.cc deleted file mode 100644 index 64f96eeea..000000000 --- a/src/accessor/todo/grib_accessor_class_simple_packing_error.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_scaling.h" -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* binaryScaleFactor - MEMBERS=const char* bitsPerValue - MEMBERS=const char* decimalScaleFactor - MEMBERS=const char* referenceValue - MEMBERS=const char* floatType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_simple_packing_error -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in simple_packing_error */ - const char* binaryScaleFactor; - const char* bitsPerValue; - const char* decimalScaleFactor; - const char* referenceValue; - const char* floatType; -} grib_accessor_simple_packing_error; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_simple_packing_error = { - &grib_accessor_class_double, /* super */ - "simple_packing_error", /* name */ - sizeof(grib_accessor_simple_packing_error), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_class_simple_packing_error; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); - - self->bitsPerValue = grib_arguments_get_name(h, c, n++); - self->binaryScaleFactor = grib_arguments_get_name(h, c, n++); - self->decimalScaleFactor = grib_arguments_get_name(h, c, n++); - self->referenceValue = grib_arguments_get_name(h, c, n++); - self->floatType = grib_arguments_get_name(h, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - - int ret = 0; - long binaryScaleFactor = 0; - long bitsPerValue = 0; - long decimalScaleFactor = 0; - double referenceValue = 0; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(h, self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(h, self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(h, self->referenceValue, &referenceValue)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(self->floatType, "ibm")) - *val = grib_ibmfloat_error(referenceValue); - else if (!strcmp(self->floatType, "ieee")) - *val = grib_ieeefloat_error(referenceValue); - else - Assert(1 == 0); - - if (bitsPerValue != 0) - *val = (*val + codes_power(binaryScaleFactor, 2)) * codes_power(-decimalScaleFactor, 10) * 0.5; - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_size.cc b/src/accessor/todo/grib_accessor_class_size.cc deleted file mode 100644 index 410cec3c3..000000000 --- a/src/accessor/todo/grib_accessor_class_size.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* accessor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_size -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in size */ - const char* accessor; -} grib_accessor_size; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_size = { - &grib_accessor_class_long, /* super */ - "size", /* name */ - sizeof(grib_accessor_size), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_size* self = (grib_accessor_size*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - size_t size = 0; - grib_accessor_size* self = (grib_accessor_size*)a; - ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); - *val = (long)size; - *len = 1; - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_smart_table_column.cc b/src/accessor/todo/grib_accessor_class_smart_table_column.cc deleted file mode 100644 index 295f29281..000000000 --- a/src/accessor/todo/grib_accessor_class_smart_table_column.cc +++ /dev/null @@ -1,294 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;unpack_string_array;unpack_long - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = const char* smartTable - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_smart_table_column -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in smart_table_column */ - const char* smartTable; - int index; -} grib_accessor_smart_table_column; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_smart_table_column = { - &grib_accessor_class_gen, /* super */ - "smart_table_column", /* name */ - sizeof(grib_accessor_smart_table_column), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_class_smart_table_column; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_smart_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in smart_table */ - const char* values; - const char* tablename; - const char* masterDir; - const char* localDir; - const char* extraDir; - const char* extraTable; - int widthOfCode; - long* tableCodes; - size_t tableCodesSize; - grib_smart_table* table; - int dirty; -} grib_accessor_smart_table; - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - int n = 0; - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - - self->smartTable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); - - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - int type = get_native_type(a); - - switch (type) { - case GRIB_TYPE_LONG: - grib_dump_long(dumper, a, NULL); - break; - case GRIB_TYPE_STRING: - grib_dump_string_array(dumper, a, NULL); - break; - } -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - grib_accessor_smart_table* tableAccessor = NULL; - grib_smart_table* table = NULL; - - size_t size = 1; - long* code; - int err = GRIB_SUCCESS; - char tmp[1024] = {0,}; - int i = 0; - - tableAccessor = (grib_accessor_smart_table*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); - if (!tableAccessor) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Unable to find accessor %s", self->smartTable); - return GRIB_NOT_FOUND; - } - - err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); - if (err) - return err; - if (*len < size) { - return GRIB_BUFFER_TOO_SMALL; - } - - code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!code) { - grib_context_log(a->context, GRIB_LOG_FATAL, "%s: Memory allocation error: %zu bytes", a->name, size); - return GRIB_OUT_OF_MEMORY; - } - - if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS) - return err; - - table = tableAccessor->table; - - for (i = 0; i < size; i++) { - if (table && (code[i] >= 0) && - (code[i] < table->numberOfEntries) && - table->entries[code[i]].column[self->index]) { - strcpy(tmp, table->entries[code[i]].column[self->index]); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)code[i]); - } - - buffer[i] = grib_context_strdup(a->context, tmp); - } - *len = size; - grib_context_free(a->context, code); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - grib_accessor_smart_table* tableAccessor = NULL; - grib_smart_table* table = NULL; - - size_t size = 1; - long* code; - int err = GRIB_SUCCESS; - int i = 0; - - for (i = 0; i < *len; i++) - val[i] = GRIB_MISSING_LONG; - - tableAccessor = (grib_accessor_smart_table*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); - if (!tableAccessor) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Unable to find accessor %s", self->smartTable); - return GRIB_NOT_FOUND; - } - - err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); - if (err) - return err; - if (*len < size) { - return GRIB_BUFFER_TOO_SMALL; - } - - code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!code) return GRIB_OUT_OF_MEMORY; - - if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS) { - grib_context_free(a->context, code); - return err; - } - - table = tableAccessor->table; - - for (i = 0; i < size; i++) { - if (table && (code[i] >= 0) && - (code[i] < table->numberOfEntries) && - table->entries[code[i]].column[self->index]) { - val[i] = atol(table->entries[code[i]].column[self->index]); - } - } - *len = size; - grib_context_free(a->context, code); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - size_t size = 0; - int err = 0; - *count = 0; - - if (!self->smartTable) - return 0; - - err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); - *count = size; - return err; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ - if (a->vvalue != NULL) { - grib_context_free(context, a->vvalue); - a->vvalue = NULL; - } -} - -static int get_native_type(grib_accessor* a) -{ - int type = GRIB_TYPE_LONG; - /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", - a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ - if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) - type = GRIB_TYPE_STRING; - return type; -} diff --git a/src/accessor/todo/grib_accessor_class_spd.cc b/src/accessor/todo/grib_accessor_class_spd.cc deleted file mode 100644 index e0f4a20a7..000000000 --- a/src/accessor/todo/grib_accessor_class_spd.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_spd -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in spd */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_spd; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_spd = { - &grib_accessor_class_long, /* super */ - "spd", /* name */ - sizeof(grib_accessor_spd), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_spd = &_grib_accessor_class_spd; - -/* END_CLASS_IMP */ - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - numberOfElements++; - - return (numberOfBits * numberOfElements + 7) / 8; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int i; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = rlen; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - if (numberOfBits > 64) { - grib_context_log(a->context, GRIB_LOG_ERROR,"Invalid number of bits: %ld",numberOfBits); - return GRIB_DECODING_ERROR; - } - - for (i = 0; i < rlen - 1; i++) - val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - *len = rlen; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len != rlen) { - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, (*len) - 1); - if (ret) return ret; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - - for (i = 0; i < rlen - 1; i++) { - grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); - } - - grib_encode_signed_longb(buf, val[rlen - 1], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - *len = rlen; - return ret; -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int ret; - *numberOfElements = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return ret; - } - (*numberOfElements)++; - - return ret; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_spectral_truncation.cc b/src/accessor/todo/grib_accessor_class_spectral_truncation.cc deleted file mode 100644 index 6cc902fa7..000000000 --- a/src/accessor/todo/grib_accessor_class_spectral_truncation.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS=const char* J - MEMBERS=const char* K - MEMBERS=const char* M - MEMBERS=const char* T - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_spectral_truncation -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in spectral_truncation */ - const char* J; - const char* K; - const char* M; - const char* T; -} grib_accessor_spectral_truncation; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_spectral_truncation = { - &grib_accessor_class_long, /* super */ - "spectral_truncation", /* name */ - sizeof(grib_accessor_spectral_truncation), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_spectral_truncation = &_grib_accessor_class_spectral_truncation; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_spectral_truncation* self = (grib_accessor_spectral_truncation*)a; - int n = 0; - - self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->T = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_spectral_truncation* self = (grib_accessor_spectral_truncation*)a; - int ret = 0; - - long J, K, M, T, Tc; - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) - return ret; - - Tc = -1; - if (J == K && K == M) { - /* Triangular truncation */ - Tc = (M + 1) * (M + 2); - } - if (K == J + M) { - /* Rhomboidal truncation */ - Tc = 2 * J * M; - } - if (J == K && K > M) { - /* Trapezoidal truncation */ - Tc = M * (2 * J - M); - } - *val = Tc; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->T, &T)) != GRIB_SUCCESS) { - if (Tc == -1) - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s. Spectral Truncation Type Unknown: %s=%ld %s=%ld %s=%ld", - a->name, self->J, J, self->K, K, self->M, M); - Tc = 0; - grib_set_long(grib_handle_of_accessor(a), self->T, Tc); - } - else { - if (Tc != -1 && Tc != T) - grib_set_long(grib_handle_of_accessor(a), self->T, Tc); - } - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_statistics_spectral.cc b/src/accessor/todo/grib_accessor_class_statistics_spectral.cc deleted file mode 100644 index 435582bef..000000000 --- a/src/accessor/todo/grib_accessor_class_statistics_spectral.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* J - MEMBERS = const char* K - MEMBERS = const char* M - MEMBERS = const char* JS - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_statistics_spectral -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in statistics_spectral */ - const char* values; - const char* J; - const char* K; - const char* M; - const char* JS; -} grib_accessor_statistics_spectral; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_statistics_spectral = { - &grib_accessor_class_abstract_vector, /* super */ - "statistics_spectral", /* name */ - sizeof(grib_accessor_statistics_spectral), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_statistics_spectral = &_grib_accessor_class_statistics_spectral; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - int n = 0; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - - self->number_of_elements = 4; - self->v = (double*)grib_context_malloc(a->context, - sizeof(double) * self->number_of_elements); - - a->length = 0; - a->dirty = 1; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - int ret = 0, i = 0; - double* values; - size_t size = 0; - long J, K, M, N; - double avg, enorm, sd; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (!a->dirty) - return GRIB_SUCCESS; - - if (*len != self->number_of_elements) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) - return ret; - - if (J != M || M != K) - return GRIB_NOT_IMPLEMENTED; - - N = (M + 1) * (M + 2) / 2; - - if (2 * N != size) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "wrong number of components for spherical harmonics %ld != %ld", 2 * N, size); - return GRIB_WRONG_ARRAY_SIZE; - } - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - avg = values[0]; - sd = 0; - - for (i = 2; i < 2 * J; i += 2) - sd += values[i] * values[i]; - - for (i = 2 * J; i < size; i += 2) - sd += 2 * values[i] * values[i] + 2 * values[i + 1] * values[i + 1]; - - enorm = sd + avg * avg; - - sd = sqrt(sd); - enorm = sqrt(enorm); - - a->dirty = 0; - - grib_context_free(c, values); - - self->v[0] = avg; - self->v[1] = enorm; - self->v[2] = sd; - self->v[3] = sd == 0 ? 1 : 0; - - for (i = 0; i < self->number_of_elements; i++) - val[i] = self->v[i]; - - return ret; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - *count = self->number_of_elements; - return 0; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - grib_context_free(c, self->v); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - b->dirty = 1; - a->dirty = 1; - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - for (size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/accessor/todo/grib_accessor_class_step_human_readable.cc b/src/accessor/todo/grib_accessor_class_step_human_readable.cc deleted file mode 100644 index 557a58185..000000000 --- a/src/accessor/todo/grib_accessor_class_step_human_readable.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include "step.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* stepUnits - MEMBERS = const char* step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_step_human_readable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in step_human_readable */ - const char* stepUnits; - const char* step; -} grib_accessor_step_human_readable; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_step_human_readable = { - &grib_accessor_class_gen, /* super */ - "step_human_readable", /* name */ - sizeof(grib_accessor_step_human_readable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_class_step_human_readable; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_step_human_readable* self = (grib_accessor_step_human_readable*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); - - self->stepUnits = grib_arguments_get_name(h, params, n++); - self->step = grib_arguments_get_name(h, params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int get_step_human_readable(grib_handle* h, char* result, size_t* length) -{ - int err = 0; - size_t slen = 2; - long step, hour, minute, second; - - /* Change units to seconds (highest resolution) - * before computing the step value - */ - if ((err = grib_set_string(h, "stepUnits", "s", &slen)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) - return err; - - hour = step/3600; - minute = step/60 % 60; - second = step % 60; - /* sprintf(result, "%ld:%ld:%ld", hour, minute, second); */ - - if (second) { - snprintf(result, 1024, "%ldh %ldm %lds", hour, minute, second); - } else { - if (minute) snprintf(result, 1024, "%ldh %ldm", hour, minute); - else snprintf(result, 1024, "%ldh", hour); - } - - *length = strlen(result); - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_step_human_readable* self = (grib_accessor_step_human_readable*)a; - grib_handle* h = grib_handle_of_accessor(a); - long stepUnits; - int err = 0; - - /* Save the current value of stepUnits */ - err = grib_get_long_internal(h, self->stepUnits, &stepUnits); - if (err) return err; - - /* This will change stepUnits to seconds for its calculation */ - err = get_step_human_readable(h, buffer, len); - - /* Restore stepUnits */ - grib_set_long(h, self->stepUnits, stepUnits); - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_sum.cc b/src/accessor/todo/grib_accessor_class_sum.cc deleted file mode 100644 index 4d964fc0c..000000000 --- a/src/accessor/todo/grib_accessor_class_sum.cc +++ /dev/null @@ -1,203 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* values - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sum -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in sum */ - const char* values; -} grib_accessor_sum; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_sum = { - &grib_accessor_class_double, /* super */ - "sum", /* name */ - sizeof(grib_accessor_sum), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int n = 0; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int ret = 0; - size_t size = 0; - long* values = 0; - long i; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - size = count; - - if (size == 0) { - *val = 0; - return GRIB_SUCCESS; - } - values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!values) - return GRIB_OUT_OF_MEMORY; - - grib_get_long_array(grib_handle_of_accessor(a), self->values, values, &size); - - *val = 0; - for (i = 0; i < size; i++) - *val += values[i]; - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int ret = 0; - size_t size = 0; - double* values = 0; - long i; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - size = count; - - if (size == 0) { - *val = 0; - return GRIB_SUCCESS; - } - values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - if (!values) - return GRIB_OUT_OF_MEMORY; - - ret = grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size); - if (ret) { - grib_context_free(a->context, values); - return ret; - } - *val = 0; - for (i = 0; i < size; i++) - *val += values[i]; - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - size_t n = 0; - int ret = 0; - - ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n); - *count = n; - - if (ret) - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s is unable to get size of %s", a->name, self->values); - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_suppressed.cc b/src/accessor/todo/grib_accessor_class_suppressed.cc deleted file mode 100644 index a95269c5d..000000000 --- a/src/accessor/todo/grib_accessor_class_suppressed.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = value_count;get_native_type - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS= grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_suppressed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in suppressed */ - grib_arguments* args; -} grib_accessor_suppressed; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_suppressed = { - &grib_accessor_class_long, /* super */ - "suppressed", /* name */ - sizeof(grib_accessor_suppressed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_suppressed; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_suppressed* self = (grib_accessor_suppressed*)a; - self->args = c; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static void log_message(grib_accessor* a) -{ - grib_accessor_suppressed* self = (grib_accessor_suppressed*)a; - int i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_context_log(a->context, GRIB_LOG_ERROR, - "key '%s' is unavailable in this version.", a->name); - grib_context_log(a->context, GRIB_LOG_ERROR, - "Please use the following key(s):"); - while (grib_arguments_get_name(hand, self->args, i)) { - grib_context_log(a->context, GRIB_LOG_ERROR, "\t- %s", - grib_arguments_get_name(hand, self->args, i)); - i++; - } -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/accessor/todo/grib_accessor_class_time.cc b/src/accessor/todo/grib_accessor_class_time.cc deleted file mode 100644 index 3251fdd33..000000000 --- a/src/accessor/todo/grib_accessor_class_time.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = init - MEMBERS=const char* hour - MEMBERS=const char* minute - MEMBERS=const char* second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_time -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in time */ - const char* hour; - const char* minute; - const char* second; -} grib_accessor_time; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_time = { - &grib_accessor_class_long, /* super */ - "time", /* name */ - sizeof(grib_accessor_time), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_time* self = (grib_accessor_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->hour = grib_arguments_get_name(hand, c, n++); - self->minute = grib_arguments_get_name(hand, c, n++); - self->second = grib_arguments_get_name(hand, c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - const grib_accessor_time* self = (grib_accessor_time*)a; - - int ret = 0; - long hour = 0, minute = 0, second = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(hand, self->hour, &hour)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->minute, &minute)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->second, &second)) != GRIB_SUCCESS) - return ret; - - /* We ignore the 'seconds' in our time calculation! */ - if (second != 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); - } - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - *val = hour * 100 + minute; - - if (hour == 255) { - *val = 12 * 100; - } - if (hour != 255 && minute == 255) { - *val = hour * 100; - } - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const grib_accessor_time* self = (grib_accessor_time*)a; - - int ret = 0; - long v = val[0]; - grib_handle* hand = grib_handle_of_accessor(a); - long hour = 0, minute = 0, second = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - if (!is_time_valid(v)) { - // ECC-1777: For now just a warning. Will later change to an error - fprintf(stderr, "ECCODES WARNING : %s:%s: Time is not valid! hour=%ld min=%ld sec=%ld\n", - a->cclass->name, __func__, hour, minute, second); - // return GRIB_ENCODING_ERROR; - } - - hour = v / 100; - minute = v % 100; - second = 0; /* We ignore the 'seconds' in our time calculation! */ - - if ((ret = grib_set_long_internal(hand, self->hour, hour)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->minute, minute)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->second, second)) != GRIB_SUCCESS) - return ret; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long v = 0; - size_t lsize = 1, lmin = 5; - - unpack_long(a, &v, &lsize); - - if (*len < lmin) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, lmin, *len); - *len = lmin; - return GRIB_BUFFER_TOO_SMALL; - } - - snprintf(val, 64, "%04ld", v); - - len[0] = lmin; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_to_double.cc b/src/accessor/todo/grib_accessor_class_to_double.cc deleted file mode 100644 index 69b06add9..000000000 --- a/src/accessor/todo/grib_accessor_class_to_double.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - MEMBERS = long scale - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_double -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_double */ - const char* key; - long start; - size_t length; - long scale; -} grib_accessor_to_double; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_double = { - &grib_accessor_class_gen, /* super */ - "to_double", /* name */ - sizeof(grib_accessor_to_double), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_double; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - self->scale = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 3); - if (!self->scale) - self->scale = 1; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - size_t size = 0; - - if (self->length) - return self->length; - - grib_get_string_length_acc(a, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - - int err = 0; - char buff[512] = {0,}; - size_t size = 512; - size_t length = string_length(a); - - if (*len < length + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - *len, a->name, a->length + 1); - *len = length + 1; - return GRIB_ARRAY_TOO_SMALL; - } - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - err = GRIB_STRING_TOO_SMALL; - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return err; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - *v /= self->scale; - - return err; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtod(val, &last); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - *v /= self->scale; - - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_to_integer.cc b/src/accessor/todo/grib_accessor_class_to_integer.cc deleted file mode 100644 index 76ce1205d..000000000 --- a/src/accessor/todo/grib_accessor_class_to_integer.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_integer -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_integer */ - const char* key; - long start; - size_t length; -} grib_accessor_to_integer; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_integer = { - &grib_accessor_class_gen, /* super */ - "to_integer", /* name */ - sizeof(grib_accessor_to_integer), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_integer; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - size_t size = 0; - - if (self->length) - return self->length; - - grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - - int err = 0; - char buff[512] = {0,}; - size_t size = 512; - - size_t length = string_length(a); - - if (*len < length + 1) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); - *len = length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - /*err=GRIB_STRING_TOO_SMALL;*/ - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - /* if (*last) {err=GRIB_WRONG_CONVERSION;} */ - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - size_t l = 1; - long val = 0; - int err = unpack_long(a, &val, &l); - - *v = (double)val; - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_to_string.cc b/src/accessor/todo/grib_accessor_class_to_string.cc deleted file mode 100644 index 648edd1aa..000000000 --- a/src/accessor/todo/grib_accessor_class_to_string.cc +++ /dev/null @@ -1,227 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_string -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_string */ - const char* key; - long start; - size_t length; -} grib_accessor_to_string; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_string = { - &grib_accessor_class_gen, /* super */ - "to_string", /* name */ - sizeof(grib_accessor_to_string), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_string; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - if (self->length) - return self->length; - - size_t size = 0; - grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - int err = 0; - char buff[512] = {0,}; - - size_t length = string_length(a); - - if (*len < length + 1) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); - *len = length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - size_t size = sizeof(buff); - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - /*err=GRIB_STRING_TOO_SMALL;*/ - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - - return err; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - size_t l = 1; - long val = 0; - int err = unpack_long(a, &val, &l); - - *v = (double)val; - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_transient_darray.cc b/src/accessor/todo/grib_accessor_class_transient_darray.cc deleted file mode 100644 index ba830849a..000000000 --- a/src/accessor/todo/grib_accessor_class_transient_darray.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count - IMPLEMENTS = get_native_type - MEMBERS=grib_darray* arr - MEMBERS=int type; - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_transient_darray -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in transient_darray */ - grib_darray* arr; - int type; -} grib_accessor_transient_darray; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_transient_darray = { - &grib_accessor_class_gen, /* super */ - "transient_darray", /* name */ - sizeof(grib_accessor_transient_darray), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - self->arr = NULL; - self->type = GRIB_TYPE_DOUBLE; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_double(dumper, a, NULL); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, val[i]); - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, (double)val[i]); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = (long)self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - grib_darray_delete(a->context, self->arr); -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - *count = grib_darray_used_size(self->arr); - else - *count = 0; - - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - const grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - return self->type; -} diff --git a/src/accessor/todo/grib_accessor_class_trim.cc b/src/accessor/todo/grib_accessor_class_trim.cc deleted file mode 100644 index 21948ab82..000000000 --- a/src/accessor/todo/grib_accessor_class_trim.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init; string_length - MEMBERS= const char* input - MEMBERS= int trim_left - MEMBERS= int trim_right - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_trim -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in trim */ - const char* input; - int trim_left; - int trim_right; -} grib_accessor_trim; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_trim = { - &grib_accessor_class_ascii, /* super */ - "trim", /* name */ - sizeof(grib_accessor_trim), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* arg) -{ - int n = 0; - grib_accessor_trim* self = (grib_accessor_trim*)a; - grib_handle* h = grib_handle_of_accessor(a); - - self->input = grib_arguments_get_name(h, arg, n++); - self->trim_left = grib_arguments_get_long(h, arg, n++); - self->trim_right= grib_arguments_get_long(h, arg, n++); - DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1); - DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_trim* self = (grib_accessor_trim*)a; - - int err = 0; - grib_handle* h = grib_handle_of_accessor(a); - char input[256] = {0,}; - size_t size = sizeof(input) / sizeof(*input); - char* pInput = input; - - err = grib_get_string(h, self->input, input, &size); - if (err) return err; - - string_lrtrim(&pInput, self->trim_left, self->trim_right); - snprintf(val, 1024, "%s", pInput); - size = strlen(val); - *len = size + 1; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - char input[256] = {0,}; - - size_t inputLen = 256; - char buf[256] = {0,}; - char* pBuf = NULL; - int err; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_trim* self = (grib_accessor_trim*)a; - grib_accessor* inputAccesstor = grib_find_accessor(h, self->input); - if (!inputAccesstor) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input); - return GRIB_NOT_FOUND; - } - - if ((err = grib_get_string(h, self->input, input, &inputLen)) != GRIB_SUCCESS) - return err; - - snprintf(buf, sizeof(buf), "%s", val); - pBuf = buf; - string_lrtrim(&pBuf, self->trim_left, self->trim_right); - - return grib_pack_string(inputAccesstor, pBuf, len); -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} diff --git a/src/accessor/todo/grib_accessor_class_uint16.cc b/src/accessor/todo/grib_accessor_class_uint16.cc deleted file mode 100644 index 4bac26b59..000000000 --- a/src/accessor/todo/grib_accessor_class_uint16.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint16 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint16 */ -} grib_accessor_uint16; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint16 = { - &grib_accessor_class_gen, /* super */ - "uint16", /* name */ - sizeof(grib_accessor_uint16), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint16 = &_grib_accessor_class_uint16; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /*long pos = a->offset;*/ - /*unsigned char* data = grib_handle_of_accessor(a)->buffer->data;*/ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_uint32.cc b/src/accessor/todo/grib_accessor_class_uint32.cc deleted file mode 100644 index b45b7451f..000000000 --- a/src/accessor/todo/grib_accessor_class_uint32.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint32 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint32 */ -} grib_accessor_uint32; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint32 = { - &grib_accessor_class_gen, /* super */ - "uint32", /* name */ - sizeof(grib_accessor_uint32), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint32 = &_grib_accessor_class_uint32; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /* long pos = a->offset; */ - /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_uint32_little_endian.cc b/src/accessor/todo/grib_accessor_class_uint32_little_endian.cc deleted file mode 100644 index 3e39e0586..000000000 --- a/src/accessor/todo/grib_accessor_class_uint32_little_endian.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint32_little_endian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint32_little_endian */ -} grib_accessor_uint32_little_endian; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint32_little_endian = { - &grib_accessor_class_gen, /* super */ - "uint32_little_endian", /* name */ - sizeof(grib_accessor_uint32_little_endian), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint32_little_endian = &_grib_accessor_class_uint32_little_endian; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /* long pos = a->offset; */ - /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_uint64.cc b/src/accessor/todo/grib_accessor_class_uint64.cc deleted file mode 100644 index 20bd7e194..000000000 --- a/src/accessor/todo/grib_accessor_class_uint64.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint64 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint64 */ -} grib_accessor_uint64; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint64 = { - &grib_accessor_class_gen, /* super */ - "uint64", /* name */ - sizeof(grib_accessor_uint64), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - unsigned long long result = 0, tmp; - int i; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < 8; i++) { - result <<= 8; - result |= data[pos + i]; - } - - value = result; - tmp = value; - - /* Result does not fit in long */ - if (tmp != result) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); - return GRIB_DECODING_ERROR; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_uint64_little_endian.cc b/src/accessor/todo/grib_accessor_class_uint64_little_endian.cc deleted file mode 100644 index 0553aefbf..000000000 --- a/src/accessor/todo/grib_accessor_class_uint64_little_endian.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint64_little_endian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint64_little_endian */ -} grib_accessor_uint64_little_endian; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint64_little_endian = { - &grib_accessor_class_gen, /* super */ - "uint64_little_endian", /* name */ - sizeof(grib_accessor_uint64_little_endian), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_class_uint64_little_endian; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - unsigned long long result = 0, tmp; - int i; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 7; i >= 0; i--) { - result <<= 8; - result |= data[pos + i]; - } - - value = result; - tmp = value; - - /* Result does not fit in long */ - if (tmp != result) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); - return GRIB_DECODING_ERROR; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_uint8.cc b/src/accessor/todo/grib_accessor_class_uint8.cc deleted file mode 100644 index 3f4195eff..000000000 --- a/src/accessor/todo/grib_accessor_class_uint8.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint8 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint8 */ -} grib_accessor_uint8; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint8 = { - &grib_accessor_class_gen, /* super */ - "uint8", /* name */ - sizeof(grib_accessor_uint8), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint8 = &_grib_accessor_class_uint8; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - value = data[pos]; - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc deleted file mode 100644 index a026388f2..000000000 --- a/src/accessor/todo/grib_accessor_class_unexpanded_descriptors.cc +++ /dev/null @@ -1,236 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = grib_accessor* unexpandedDescriptorsEncoded - MEMBERS = const char* createNewData - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unexpanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unexpanded_descriptors */ - grib_accessor* unexpandedDescriptorsEncoded; - const char* createNewData; -} grib_accessor_unexpanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unexpanded_descriptors = { - &grib_accessor_class_long, /* super */ - "unexpanded_descriptors", /* name */ - sizeof(grib_accessor_unexpanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); - self->createNewData = grib_arguments_get_name(hand, args, n++); - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int ret = 0; - long pos = 0; - long rlen = 0; - long f, x, y; - long* v = val; - long i; - grib_handle* hand = grib_handle_of_accessor(a); - - pos = accessor_raw_get_offset(self->unexpandedDescriptorsEncoded) * 8; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (rlen == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "No descriptors in section 3. Malformed message."); - return GRIB_MESSAGE_MALFORMED; - } - - if (*len < rlen) { - /* grib_context_log(a->context, GRIB_LOG_ERROR, */ - /* " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen); */ - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) { - f = grib_decode_unsigned_long(hand->buffer->data, &pos, 2); - x = grib_decode_unsigned_long(hand->buffer->data, &pos, 6); - y = grib_decode_unsigned_long(hand->buffer->data, &pos, 8); - *v++ = f * 100000 + x * 1000 + y; - } - *len = rlen; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int ret = 0; - long pos = 0; - unsigned long f, x, y; - unsigned char* buf = NULL; - grib_accessor* expanded = NULL; - size_t buflen = *len * 2; - size_t i = 0, length = *len; - long createNewData = 1; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_get_long(hand, self->createNewData, &createNewData); - - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - - for (i = 0; i < length; i++) { - const long tmp = val[i] % 100000; - f = val[i] / 100000; - x = tmp / 1000; - y = tmp % 1000; - grib_encode_unsigned_longb(buf, f, &pos, 2); - grib_encode_unsigned_longb(buf, x, &pos, 6); - grib_encode_unsigned_longb(buf, y, &pos, 8); - } - - grib_pack_bytes(self->unexpandedDescriptorsEncoded, buf, &buflen); - grib_context_free(hand->context, buf); - - if (createNewData == 0) - return ret; - - expanded = grib_find_accessor(hand, "expandedCodes"); - Assert(expanded != NULL); - ret = grib_accessor_class_expanded_descriptors_set_do_expand(expanded, 1); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_set_long(hand, "unpack", 3); /* BUFR new data */ - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_set_long(hand, "unpack", 1); /* Unpack structure */ - - return ret; -} - -static int value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - long n = 0; - - grib_value_count(self->unexpandedDescriptorsEncoded, &n); - *numberOfUnexpandedDescriptors = n / 2; - - return 0; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc deleted file mode 100644 index cac0cdfd7..000000000 --- a/src/accessor/todo/grib_accessor_class_unpack_bufr_values.cc +++ /dev/null @@ -1,207 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = pack_long; pack_double - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = grib_accessor* data_accessor - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_unpack_bufr_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in unpack_bufr_values */ - grib_accessor* data_accessor; -} grib_accessor_unpack_bufr_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_unpack_bufr_values = { - &grib_accessor_class_gen, /* super */ - "unpack_bufr_values", /* name */ - sizeof(grib_accessor_unpack_bufr_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - char* key; - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - strcpy(buffer, "0"); - *len=1; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -// static const char* mode_to_str(int p) -// { -// if (p==CODES_BUFR_UNPACK_STRUCTURE) return "CODES_BUFR_UNPACK_STRUCTURE"; -// if (p==CODES_BUFR_UNPACK_FLAT) return "CODES_BUFR_UNPACK_FLAT"; -// if (p==CODES_BUFR_NEW_DATA) return "CODES_BUFR_NEW_DATA"; -// return "unknown proc flag"; -// } - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - if (*val == 2) - unpackMode = CODES_BUFR_UNPACK_FLAT; - if (*val == 3) - unpackMode = CODES_BUFR_NEW_DATA; - - accessor_bufr_data_array_set_unpackMode(data, unpackMode); - - return grib_unpack_double(data, 0, 0); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} diff --git a/src/accessor/todo/grib_accessor_class_unsigned_bits.cc b/src/accessor/todo/grib_accessor_class_unsigned_bits.cc deleted file mode 100644 index 38c3425cf..000000000 --- a/src/accessor/todo/grib_accessor_class_unsigned_bits.cc +++ /dev/null @@ -1,265 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unsigned_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned_bits */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_unsigned_bits; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unsigned_bits = { - &grib_accessor_class_long, /* super */ - "unsigned_bits", /* name */ - sizeof(grib_accessor_unsigned_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; - -/* END_CLASS_IMP */ - - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - - return (numberOfBits * numberOfElements + 7) / 8; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen); - *len = rlen; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - if (numberOfBits == 0) { - int i; - for (i = 0; i < rlen; i++) - val[i] = 0; - return GRIB_SUCCESS; - } - - grib_decode_long_array(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits, rlen, val); - - *len = rlen; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - ret = value_count(a, &rlen); - if (ret) return ret; - - /* - if(*len < rlen) - { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size for %s it contains %d values ", a->name , rlen ); - return GRIB_ARRAY_TOO_SMALL; - } - */ - if (*len != rlen) - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, *len); - if (ret) return ret; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) return ret; - if (numberOfBits == 0) { - grib_buffer_replace(a, NULL, 0, 1, 1); - return GRIB_SUCCESS; - } - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); - - for (i = 0; i < *len; i++) - grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return ret; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret; - *numberOfElements = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - } - - return ret; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/accessor/todo/grib_accessor_class_validity_date.cc b/src/accessor/todo/grib_accessor_class_validity_date.cc deleted file mode 100644 index 760b7bccd..000000000 --- a/src/accessor/todo/grib_accessor_class_validity_date.cc +++ /dev/null @@ -1,229 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - MEMBERS=const char* stepUnits - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_validity_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in validity_date */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* year; - const char* month; - const char* day; -} grib_accessor_validity_date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_validity_date = { - &grib_accessor_class_long, /* super */ - "validity_date", /* name */ - sizeof(grib_accessor_validity_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; - -/* END_CLASS_IMP */ - -/* Table of multipliers to convert step units to minutes */ -static const double u2m[] = { - 1, /* index 0: minutes */ - 60, /* index 1: hour */ - 24 * 60, /* index 2: day */ - 24 * 60 * 30, /* index 3: month */ - -1, /* index 4: year */ - -1, /* index 5: decade */ - -1, /* index 6: 30 years */ - -1, /* index 7: century */ - -1, /* index 8: RESERVED */ - -1, /* index 9: RESERVED */ - 3 * 60, /* index 10: 3 hours */ - 6 * 60, /* index 11: 6 hours */ - 12 * 60, /* index 12: 12 hours */ - 1 / 60.0, /* index 13: seconds */ - 15, /* index 14: 15 mins */ - 30 /* index 15: 30 mins */ -}; - -static long convert_to_minutes(long step, long stepUnits) -{ - double result = 0; - if (stepUnits == 0) - return step; /* unit=minutes so no change */ - if (stepUnits == 1) - return step * 60; /* unit=hours */ - if (stepUnits == 13) - return step / 60; /* unit=seconds */ - /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ - - result = step * u2m[stepUnits]; - return (long)result; -} - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_validity_date* self = (grib_accessor_validity_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->date = grib_arguments_get_name(hand, c, n++); - self->time = grib_arguments_get_name(hand, c, n++); - self->step = grib_arguments_get_name(hand, c, n++); - self->stepUnits = grib_arguments_get_name(hand, c, n++); - self->year = grib_arguments_get_name(hand, c, n++); - self->month = grib_arguments_get_name(hand, c, n++); - self->day = grib_arguments_get_name(hand, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_validity_date* self = (grib_accessor_validity_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; - long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; - - if (self->year) { - long year, month, day; - if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) - return ret; - *val = year * 10000 + month * 100 + day; - return GRIB_SUCCESS; - } - if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { - if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { - return ret; /* See ECC-817 */ - } - } - - if (self->stepUnits) { - if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) - return ret; - step_mins = convert_to_minutes(step, stepUnits); - } - - minutes = time % 100; - hours = time / 100; - tmp = minutes + step_mins; /* add the step to our minutes */ - tmp_hrs = tmp / 60; /* how many hours and mins is that? */ - hours += tmp_hrs; /* increment hours */ - - date = grib_date_to_julian(date); - /* does the new 'hours' exceed 24? if so increment julian */ - while (hours >= 24) { - date++; - hours -= 24; - } - /* GRIB-29: Negative forecast time */ - while (hours < 0) { - date--; - hours += 24; - } - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = grib_julian_to_date(date); - - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_validity_time.cc b/src/accessor/todo/grib_accessor_class_validity_time.cc deleted file mode 100644 index 34eb78128..000000000 --- a/src/accessor/todo/grib_accessor_class_validity_time.cc +++ /dev/null @@ -1,249 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = init - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - MEMBERS=const char* stepUnits - MEMBERS=const char* hours - MEMBERS=const char* minutes - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_validity_time -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in validity_time */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* hours; - const char* minutes; -} grib_accessor_validity_time; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_validity_time = { - &grib_accessor_class_long, /* super */ - "validity_time", /* name */ - sizeof(grib_accessor_validity_time), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; - -/* END_CLASS_IMP */ - -/* Table of multipliers to convert step units to minutes */ -static const double u2m[] = { - 1, /* index 0: minutes */ - 60, /* index 1: hour */ - 24 * 60, /* index 2: day */ - 24 * 60 * 30, /* index 3: month */ - -1, /* index 4: year */ - -1, /* index 5: decade */ - -1, /* index 6: 30 years */ - -1, /* index 7: century */ - -1, /* index 8: RESERVED */ - -1, /* index 9: RESERVED */ - 3 * 60, /* index 10: 3 hours */ - 6 * 60, /* index 11: 6 hours */ - 12 * 60, /* index 12: 12 hours */ - 1 / 60.0, /* index 13: seconds */ - 15, /* index 14: 15 mins */ - 30 /* index 15: 30 mins */ -}; - -static long convert_to_minutes(long step, long stepUnits) -{ - double result = 0; - if (stepUnits == 0) - return step; /* unit=minutes so no change */ - if (stepUnits == 1) - return step * 60; /* unit=hours */ - if (stepUnits == 13) - return step / 60; /* unit=seconds*/ - /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ - - result = step * u2m[stepUnits]; - return (long)result; -} - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_validity_time* self = (grib_accessor_validity_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->date = grib_arguments_get_name(hand, c, n++); - self->time = grib_arguments_get_name(hand, c, n++); - self->step = grib_arguments_get_name(hand, c, n++); - self->stepUnits = grib_arguments_get_name(hand, c, n++); - self->hours = grib_arguments_get_name(hand, c, n++); - self->minutes = grib_arguments_get_name(hand, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_validity_time* self = (grib_accessor_validity_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; - long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; - - if (self->hours) { - if ((ret = grib_get_long_internal(hand, self->hours, &hours)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->minutes, &minutes)) != GRIB_SUCCESS) - return ret; - *val = hours * 100 + minutes; - return GRIB_SUCCESS; - } - if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { - if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { - return ret; /* See ECC-817 */ - } - } - - /* Seconds will always be zero. So convert to minutes */ - if (self->stepUnits) { - if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) - return ret; - step_mins = convert_to_minutes(step, stepUnits); - } - - minutes = time % 100; - hours = time / 100; - tmp = minutes + step_mins; /* add the step to our minutes */ - tmp_hrs = tmp / 60; /* how many hours and mins is that? */ - tmp_mins = tmp % 60; - hours += tmp_hrs; /* increment hours */ - if (hours > 0) { - hours = hours % 24; /* wrap round if >= 24 */ - } - else { - /* GRIB-29: Negative forecast time */ - while (hours < 0) { - hours += 24; - } - } - time = hours * 100 + tmp_mins; - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = time; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int err = 0; - long v = 0; - size_t lsize = 1, lmin = 5; - - err = unpack_long(a, &v, &lsize); - if (err) return err; - - if (*len < lmin) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, lmin, *len); - *len = lmin; - return GRIB_BUFFER_TOO_SMALL; - } - - snprintf(val, 64, "%04ld", v); - - len[0] = lmin; - return GRIB_SUCCESS; -} diff --git a/src/accessor/todo/grib_accessor_class_values.cc b/src/accessor/todo/grib_accessor_class_values.cc deleted file mode 100644 index 384282317..000000000 --- a/src/accessor/todo/grib_accessor_class_values.cc +++ /dev/null @@ -1,259 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = byte_offset - IMPLEMENTS = get_native_type - IMPLEMENTS = update_size - IMPLEMENTS = compare - IMPLEMENTS = pack_long - MEMBERS= int carg - MEMBERS= const char* seclen - MEMBERS= const char* offsetdata - MEMBERS= const char* offsetsection - MEMBERS= int dirty - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; -} grib_accessor_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_values = { - &grib_accessor_class_gen, /* super */ - "values", /* name */ - sizeof(grib_accessor_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; - -/* END_CLASS_IMP */ -static long init_length(grib_accessor* a) -{ - grib_accessor_values* self = (grib_accessor_values*)a; - int ret = 0; - - long seclen = 0; - long offsetsection = 0; - long offsetdata = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen))) - return ret; - - if (seclen == 0) { - /* printf("init_length seclen=0\n"); */ - return 0; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection))) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetdata, &offsetdata))) - return ret; - - /* When reparsing */ - if (offsetdata < offsetsection) { - /* printf("init_length offsetdata < offsetsection=0\n"); */ - Assert(grib_handle_of_accessor(a)->loader); - return 0; - } - - return seclen - (offsetdata - offsetsection); -} - -static void init(grib_accessor* a, const long v, grib_arguments* params) -{ - grib_accessor_values* self = (grib_accessor_values*)a; - self->carg = 0; - - self->seclen = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->offsetdata = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->offsetsection = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->dirty = 1; - - a->length = init_length(a); - /* Assert(a->length>=0); */ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static long byte_count(grib_accessor* a) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); - return a->length; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); - a->length = s; - Assert(a->length >= 0); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - for (size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_values* self = (grib_accessor_values*)a; - double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); - - for (size_t i = 0; i < *len; i++) - dval[i] = (double)val[i]; - - int ret = grib_pack_double(a, dval, len); - - grib_context_free(a->context, dval); - - self->dirty = 1; - - return ret; -} diff --git a/src/accessor/todo/grib_accessor_class_vector.cc b/src/accessor/todo/grib_accessor_class_vector.cc deleted file mode 100644 index 1cc69a4c7..000000000 --- a/src/accessor/todo/grib_accessor_class_vector.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (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. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = init - IMPLEMENTS = unpack_double - MEMBERS = const char* vector - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in vector */ - const char* vector; - int index; -} grib_accessor_vector; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_vector = { - &grib_accessor_class_abstract_vector, /* super */ - "vector", /* name */ - sizeof(grib_accessor_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_abstract_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; -} grib_accessor_abstract_vector; - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_vector* self = (grib_accessor_vector*)a; - int n = 0; - - self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int err = 0; - size_t size = 0; - double* stat; - grib_accessor_vector* self = (grib_accessor_vector*)a; - grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - grib_accessor_abstract_vector* v = (grib_accessor_abstract_vector*)va; - - Assert(self->index >= 0); - - if (self->index >= v->number_of_elements) { - grib_context_log(a->context, GRIB_LOG_FATAL, "index=%d number_of_elements=%d for %s", self->index, v->number_of_elements, a->name); - Assert(self->index < v->number_of_elements); - } - - if (va->dirty) { - grib_get_size(grib_handle_of_accessor(a), self->vector, &size); - stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = grib_unpack_double(va, stat, &size); - grib_context_free(a->context, stat); - if (err) - return err; - } - - *val = v->v[self->index]; - - return err; -} diff --git a/src/accessor/todo/grib_accessor_class_when.cc b/src/accessor/todo/grib_accessor_class_when.cc deleted file mode 100644 index 1bf0d999e..000000000 --- a/src/accessor/todo/grib_accessor_class_when.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump; - IMPLEMENTS = get_native_type - IMPLEMENTS = notify_change - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int notify_change(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_when -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in when */ -} grib_accessor_when; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_when = { - &grib_accessor_class_gen, /* super */ - "when", /* name */ - sizeof(grib_accessor_when), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - ¬ify_change, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /* grib_dump_when(dumper,a,NULL); */ -} - -static int notify_change(grib_accessor* a, grib_accessor* changed) -{ - return grib_action_notify_change(a->creator, a, changed); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_UNDEFINED; -} diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 30fcd82b0..cf7673e19 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -206,13 +206,6 @@ void grib_viarray_delete_content(grib_context* c, grib_viarray* v); /* grib_accessor_class_bits_per_value.cc*/ /* grib_accessor_class_bufr_data_array.cc*/ -// ===== TODO(maee): Reenable these functions ===== -//grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); -//grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); -//grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); -//void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); -// ===== END ===== - /* grib_accessor_class_bufr_data_element.cc*/ void accessor_bufr_data_element_set_index(grib_accessor* a, long index); diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index fd0370719..ceda43659 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -1,216 +1,216 @@ #include "grib_api_internal.h" -//extern grib_accessor_class* grib_accessor_class_abstract_long_vector; -//extern grib_accessor_class* grib_accessor_class_abstract_vector; -//extern grib_accessor_class* grib_accessor_class_ascii; -//extern grib_accessor_class* grib_accessor_class_bit; -//extern grib_accessor_class* grib_accessor_class_bitmap; -//extern grib_accessor_class* grib_accessor_class_bits; -//extern grib_accessor_class* grib_accessor_class_bits_per_value; -//extern grib_accessor_class* grib_accessor_class_blob; -//extern grib_accessor_class* grib_accessor_class_budgdate; -//extern grib_accessor_class* grib_accessor_class_bufr_data_array; -//extern grib_accessor_class* grib_accessor_class_bufr_data_element; -//extern grib_accessor_class* grib_accessor_class_bufr_elements_table; -//extern grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets; -//extern grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets; -//extern grib_accessor_class* grib_accessor_class_bufr_extract_subsets; -//extern grib_accessor_class* grib_accessor_class_bufr_group; -//extern grib_accessor_class* grib_accessor_class_bufr_simple_thinning; -//extern grib_accessor_class* grib_accessor_class_bufr_string_values; -//extern grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors; -//extern grib_accessor_class* grib_accessor_class_bytes; -//extern grib_accessor_class* grib_accessor_class_change_alternative_row_scanning; -//extern grib_accessor_class* grib_accessor_class_change_scanning_direction; -//extern grib_accessor_class* grib_accessor_class_check_internal_version; -//extern grib_accessor_class* grib_accessor_class_closest_date; -//extern grib_accessor_class* grib_accessor_class_codeflag; +extern grib_accessor_class* grib_accessor_class_abstract_long_vector; +extern grib_accessor_class* grib_accessor_class_abstract_vector; +extern grib_accessor_class* grib_accessor_class_ascii; +extern grib_accessor_class* grib_accessor_class_bit; +extern grib_accessor_class* grib_accessor_class_bitmap; +extern grib_accessor_class* grib_accessor_class_bits; +extern grib_accessor_class* grib_accessor_class_bits_per_value; +extern grib_accessor_class* grib_accessor_class_blob; +extern grib_accessor_class* grib_accessor_class_budgdate; +extern grib_accessor_class* grib_accessor_class_bufr_data_array; +extern grib_accessor_class* grib_accessor_class_bufr_data_element; +extern grib_accessor_class* grib_accessor_class_bufr_elements_table; +extern grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets; +extern grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets; +extern grib_accessor_class* grib_accessor_class_bufr_extract_subsets; +extern grib_accessor_class* grib_accessor_class_bufr_group; +extern grib_accessor_class* grib_accessor_class_bufr_simple_thinning; +extern grib_accessor_class* grib_accessor_class_bufr_string_values; +extern grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors; +extern grib_accessor_class* grib_accessor_class_bytes; +extern grib_accessor_class* grib_accessor_class_change_alternative_row_scanning; +extern grib_accessor_class* grib_accessor_class_change_scanning_direction; +extern grib_accessor_class* grib_accessor_class_check_internal_version; +extern grib_accessor_class* grib_accessor_class_closest_date; +extern grib_accessor_class* grib_accessor_class_codeflag; #include "accessor/grib_accessor_class_codetable.h" extern grib_accessor_class* grib_accessor_class_codetable; -//extern grib_accessor_class* grib_accessor_class_codetable_title; -//extern grib_accessor_class* grib_accessor_class_codetable_units; -//extern grib_accessor_class* grib_accessor_class_concept; +extern grib_accessor_class* grib_accessor_class_codetable_title; +extern grib_accessor_class* grib_accessor_class_codetable_units; +extern grib_accessor_class* grib_accessor_class_concept; #include "accessor/grib_accessor_class_constant.h" extern grib_accessor_class* grib_accessor_class_constant; -//extern grib_accessor_class* grib_accessor_class_count_file; -//extern grib_accessor_class* grib_accessor_class_count_missing; -//extern grib_accessor_class* grib_accessor_class_count_total; -//extern grib_accessor_class* grib_accessor_class_data_apply_bitmap; -//extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic; -//extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap; -//extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; -//extern grib_accessor_class* grib_accessor_class_data_complex_packing; -//extern grib_accessor_class* grib_accessor_class_data_dummy_field; -//extern grib_accessor_class* grib_accessor_class_data_g1complex_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap; -//extern grib_accessor_class* grib_accessor_class_data_g1shsimple_packing; -//extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; -//extern grib_accessor_class* grib_accessor_class_data_g22order_packing; -//extern grib_accessor_class* grib_accessor_class_data_g2bifourier_packing; -//extern grib_accessor_class* grib_accessor_class_data_g2complex_packing; -//extern grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap; -//extern grib_accessor_class* grib_accessor_class_data_g2shsimple_packing; -//extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; -//extern grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing; -//extern grib_accessor_class* grib_accessor_class_data_jpeg2000_packing; -//extern grib_accessor_class* grib_accessor_class_data_png_packing; -//extern grib_accessor_class* grib_accessor_class_data_raw_packing; -//extern grib_accessor_class* grib_accessor_class_data_run_length_packing; -//extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; -//extern grib_accessor_class* grib_accessor_class_data_sh_packed; -//extern grib_accessor_class* grib_accessor_class_data_sh_unpacked; -//extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; -//extern grib_accessor_class* grib_accessor_class_data_simple_packing; -//extern grib_accessor_class* grib_accessor_class_decimal_precision; -//extern grib_accessor_class* grib_accessor_class_dictionary; -//extern grib_accessor_class* grib_accessor_class_dirty; -//extern grib_accessor_class* grib_accessor_class_divdouble; -//extern grib_accessor_class* grib_accessor_class_double; -//extern grib_accessor_class* grib_accessor_class_element; -//extern grib_accessor_class* grib_accessor_class_evaluate; -//extern grib_accessor_class* grib_accessor_class_expanded_descriptors; -//extern grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value; -//extern grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag; -//extern grib_accessor_class* grib_accessor_class_g1_message_length; -//extern grib_accessor_class* grib_accessor_class_g1_section4_length; -//extern grib_accessor_class* grib_accessor_class_g1bitmap; -//extern grib_accessor_class* grib_accessor_class_g1date; -//extern grib_accessor_class* grib_accessor_class_g1day_of_the_year_date; -//extern grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly; -//extern grib_accessor_class* grib_accessor_class_g1fcperiod; -//extern grib_accessor_class* grib_accessor_class_g1forecastmonth; -//extern grib_accessor_class* grib_accessor_class_g1monthlydate; -//extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex; -//extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple; -//extern grib_accessor_class* grib_accessor_class_g1step_range; -//extern grib_accessor_class* grib_accessor_class_g1verificationdate; -//extern grib_accessor_class* grib_accessor_class_g2_aerosol; -//extern grib_accessor_class* grib_accessor_class_g2_chemical; -//extern grib_accessor_class* grib_accessor_class_g2_eps; -//extern grib_accessor_class* grib_accessor_class_g2_mars_labeling; -//extern grib_accessor_class* grib_accessor_class_g2bitmap; -//extern grib_accessor_class* grib_accessor_class_g2bitmap_present; -//extern grib_accessor_class* grib_accessor_class_g2date; -//extern grib_accessor_class* grib_accessor_class_g2end_step; -//extern grib_accessor_class* grib_accessor_class_g2grid; -//extern grib_accessor_class* grib_accessor_class_g2latlon; -//extern grib_accessor_class* grib_accessor_class_g2level; -//extern grib_accessor_class* grib_accessor_class_g2lon; -//extern grib_accessor_class* grib_accessor_class_g2step_range; -//extern grib_accessor_class* grib_accessor_class_gaussian_grid_name; -//extern grib_accessor_class* grib_accessor_class_gds_is_present; -//extern grib_accessor_class* grib_accessor_class_gds_not_present_bitmap; -//extern grib_accessor_class* grib_accessor_class_gen; -//extern grib_accessor_class* grib_accessor_class_getenv; -//extern grib_accessor_class* grib_accessor_class_global_gaussian; -//extern grib_accessor_class* grib_accessor_class_group; -//extern grib_accessor_class* grib_accessor_class_group_copy; -//extern grib_accessor_class* grib_accessor_class_gts_header; -//extern grib_accessor_class* grib_accessor_class_hash_array; -//extern grib_accessor_class* grib_accessor_class_headers_only; -//extern grib_accessor_class* grib_accessor_class_ibmfloat; -//extern grib_accessor_class* grib_accessor_class_ieeefloat; -//extern grib_accessor_class* grib_accessor_class_ifs_param; +extern grib_accessor_class* grib_accessor_class_count_file; +extern grib_accessor_class* grib_accessor_class_count_missing; +extern grib_accessor_class* grib_accessor_class_count_total; +extern grib_accessor_class* grib_accessor_class_data_apply_bitmap; +extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic; +extern grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap; +extern grib_accessor_class* grib_accessor_class_data_ccsds_packing; +extern grib_accessor_class* grib_accessor_class_data_complex_packing; +extern grib_accessor_class* grib_accessor_class_data_dummy_field; +extern grib_accessor_class* grib_accessor_class_data_g1complex_packing; +extern grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing; +extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing; +extern grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing; +extern grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing; +extern grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap; +extern grib_accessor_class* grib_accessor_class_data_g1shsimple_packing; +extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; +extern grib_accessor_class* grib_accessor_class_data_g22order_packing; +extern grib_accessor_class* grib_accessor_class_data_g2bifourier_packing; +extern grib_accessor_class* grib_accessor_class_data_g2complex_packing; +extern grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap; +extern grib_accessor_class* grib_accessor_class_data_g2shsimple_packing; +extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; +extern grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing; +extern grib_accessor_class* grib_accessor_class_data_jpeg2000_packing; +extern grib_accessor_class* grib_accessor_class_data_png_packing; +extern grib_accessor_class* grib_accessor_class_data_raw_packing; +extern grib_accessor_class* grib_accessor_class_data_run_length_packing; +extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; +extern grib_accessor_class* grib_accessor_class_data_sh_packed; +extern grib_accessor_class* grib_accessor_class_data_sh_unpacked; +extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; +extern grib_accessor_class* grib_accessor_class_data_simple_packing; +extern grib_accessor_class* grib_accessor_class_decimal_precision; +extern grib_accessor_class* grib_accessor_class_dictionary; +extern grib_accessor_class* grib_accessor_class_dirty; +extern grib_accessor_class* grib_accessor_class_divdouble; +extern grib_accessor_class* grib_accessor_class_double; +extern grib_accessor_class* grib_accessor_class_element; +extern grib_accessor_class* grib_accessor_class_evaluate; +extern grib_accessor_class* grib_accessor_class_expanded_descriptors; +extern grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value; +extern grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag; +extern grib_accessor_class* grib_accessor_class_g1_message_length; +extern grib_accessor_class* grib_accessor_class_g1_section4_length; +extern grib_accessor_class* grib_accessor_class_g1bitmap; +extern grib_accessor_class* grib_accessor_class_g1date; +extern grib_accessor_class* grib_accessor_class_g1day_of_the_year_date; +extern grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly; +extern grib_accessor_class* grib_accessor_class_g1fcperiod; +extern grib_accessor_class* grib_accessor_class_g1forecastmonth; +extern grib_accessor_class* grib_accessor_class_g1monthlydate; +extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex; +extern grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple; +extern grib_accessor_class* grib_accessor_class_g1step_range; +extern grib_accessor_class* grib_accessor_class_g1verificationdate; +extern grib_accessor_class* grib_accessor_class_g2_aerosol; +extern grib_accessor_class* grib_accessor_class_g2_chemical; +extern grib_accessor_class* grib_accessor_class_g2_eps; +extern grib_accessor_class* grib_accessor_class_g2_mars_labeling; +extern grib_accessor_class* grib_accessor_class_g2bitmap; +extern grib_accessor_class* grib_accessor_class_g2bitmap_present; +extern grib_accessor_class* grib_accessor_class_g2date; +extern grib_accessor_class* grib_accessor_class_g2end_step; +extern grib_accessor_class* grib_accessor_class_g2grid; +extern grib_accessor_class* grib_accessor_class_g2latlon; +extern grib_accessor_class* grib_accessor_class_g2level; +extern grib_accessor_class* grib_accessor_class_g2lon; +extern grib_accessor_class* grib_accessor_class_g2step_range; +extern grib_accessor_class* grib_accessor_class_gaussian_grid_name; +extern grib_accessor_class* grib_accessor_class_gds_is_present; +extern grib_accessor_class* grib_accessor_class_gds_not_present_bitmap; +extern grib_accessor_class* grib_accessor_class_gen; +extern grib_accessor_class* grib_accessor_class_getenv; +extern grib_accessor_class* grib_accessor_class_global_gaussian; +extern grib_accessor_class* grib_accessor_class_group; +extern grib_accessor_class* grib_accessor_class_group_copy; +extern grib_accessor_class* grib_accessor_class_gts_header; +extern grib_accessor_class* grib_accessor_class_hash_array; +extern grib_accessor_class* grib_accessor_class_headers_only; +extern grib_accessor_class* grib_accessor_class_ibmfloat; +extern grib_accessor_class* grib_accessor_class_ieeefloat; +extern grib_accessor_class* grib_accessor_class_ifs_param; #include "accessor/grib_accessor_class_iterator.h" extern grib_accessor_class* grib_accessor_class_iterator; -//extern grib_accessor_class* grib_accessor_class_julian_date; -//extern grib_accessor_class* grib_accessor_class_julian_day; -//extern grib_accessor_class* grib_accessor_class_ksec1expver; -//extern grib_accessor_class* grib_accessor_class_label; -//extern grib_accessor_class* grib_accessor_class_latitudes; -//extern grib_accessor_class* grib_accessor_class_latlon_increment; -//extern grib_accessor_class* grib_accessor_class_latlonvalues; -//extern grib_accessor_class* grib_accessor_class_library_version; -//extern grib_accessor_class* grib_accessor_class_local_definition; +extern grib_accessor_class* grib_accessor_class_julian_date; +extern grib_accessor_class* grib_accessor_class_julian_day; +extern grib_accessor_class* grib_accessor_class_ksec1expver; +extern grib_accessor_class* grib_accessor_class_label; +extern grib_accessor_class* grib_accessor_class_latitudes; +extern grib_accessor_class* grib_accessor_class_latlon_increment; +extern grib_accessor_class* grib_accessor_class_latlonvalues; +extern grib_accessor_class* grib_accessor_class_library_version; +extern grib_accessor_class* grib_accessor_class_local_definition; #include "accessor/grib_accessor_class_long.h" extern grib_accessor_class* grib_accessor_class_long; -//extern grib_accessor_class* grib_accessor_class_long_vector; -//extern grib_accessor_class* grib_accessor_class_longitudes; -//extern grib_accessor_class* grib_accessor_class_lookup; -//extern grib_accessor_class* grib_accessor_class_mars_param; -//extern grib_accessor_class* grib_accessor_class_mars_step; -//extern grib_accessor_class* grib_accessor_class_md5; -//extern grib_accessor_class* grib_accessor_class_message; -//extern grib_accessor_class* grib_accessor_class_message_copy; -//extern grib_accessor_class* grib_accessor_class_multdouble; +extern grib_accessor_class* grib_accessor_class_long_vector; +extern grib_accessor_class* grib_accessor_class_longitudes; +extern grib_accessor_class* grib_accessor_class_lookup; +extern grib_accessor_class* grib_accessor_class_mars_param; +extern grib_accessor_class* grib_accessor_class_mars_step; +extern grib_accessor_class* grib_accessor_class_md5; +extern grib_accessor_class* grib_accessor_class_message; +extern grib_accessor_class* grib_accessor_class_message_copy; +extern grib_accessor_class* grib_accessor_class_multdouble; #include "accessor/grib_accessor_class_nearest.h" extern grib_accessor_class* grib_accessor_class_nearest; -//extern grib_accessor_class* grib_accessor_class_non_alpha; -//extern grib_accessor_class* grib_accessor_class_number_of_coded_values; -//extern grib_accessor_class* grib_accessor_class_number_of_points; -//extern grib_accessor_class* grib_accessor_class_number_of_points_gaussian; -//extern grib_accessor_class* grib_accessor_class_number_of_values; -//extern grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing; -//extern grib_accessor_class* grib_accessor_class_octahedral_gaussian; -//extern grib_accessor_class* grib_accessor_class_octet_number; -//extern grib_accessor_class* grib_accessor_class_offset_file; -//extern grib_accessor_class* grib_accessor_class_offset_values; -//extern grib_accessor_class* grib_accessor_class_optimal_step_units; -//extern grib_accessor_class* grib_accessor_class_pack_bufr_values; -//extern grib_accessor_class* grib_accessor_class_packing_type; -//extern grib_accessor_class* grib_accessor_class_pad; -//extern grib_accessor_class* grib_accessor_class_padding; -//extern grib_accessor_class* grib_accessor_class_padto; -//extern grib_accessor_class* grib_accessor_class_padtoeven; -//extern grib_accessor_class* grib_accessor_class_padtomultiple; -//extern grib_accessor_class* grib_accessor_class_position; -//extern grib_accessor_class* grib_accessor_class_proj_string; -//extern grib_accessor_class* grib_accessor_class_raw; -//extern grib_accessor_class* grib_accessor_class_rdbtime_guess_date; -//extern grib_accessor_class* grib_accessor_class_reference_value_error; -//extern grib_accessor_class* grib_accessor_class_round; -//extern grib_accessor_class* grib_accessor_class_scale; -//extern grib_accessor_class* grib_accessor_class_scale_values; -//extern grib_accessor_class* grib_accessor_class_second_order_bits_per_value; -//extern grib_accessor_class* grib_accessor_class_section; -//extern grib_accessor_class* grib_accessor_class_section_length; -//extern grib_accessor_class* grib_accessor_class_section_padding; -//extern grib_accessor_class* grib_accessor_class_section_pointer; -//extern grib_accessor_class* grib_accessor_class_select_step_template; -//extern grib_accessor_class* grib_accessor_class_sexagesimal2decimal; -//extern grib_accessor_class* grib_accessor_class_signed; -//extern grib_accessor_class* grib_accessor_class_signed_bits; -//extern grib_accessor_class* grib_accessor_class_simple_packing_error; -//extern grib_accessor_class* grib_accessor_class_size; +extern grib_accessor_class* grib_accessor_class_non_alpha; +extern grib_accessor_class* grib_accessor_class_number_of_coded_values; +extern grib_accessor_class* grib_accessor_class_number_of_points; +extern grib_accessor_class* grib_accessor_class_number_of_points_gaussian; +extern grib_accessor_class* grib_accessor_class_number_of_values; +extern grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing; +extern grib_accessor_class* grib_accessor_class_octahedral_gaussian; +extern grib_accessor_class* grib_accessor_class_octet_number; +extern grib_accessor_class* grib_accessor_class_offset_file; +extern grib_accessor_class* grib_accessor_class_offset_values; +extern grib_accessor_class* grib_accessor_class_optimal_step_units; +extern grib_accessor_class* grib_accessor_class_pack_bufr_values; +extern grib_accessor_class* grib_accessor_class_packing_type; +extern grib_accessor_class* grib_accessor_class_pad; +extern grib_accessor_class* grib_accessor_class_padding; +extern grib_accessor_class* grib_accessor_class_padto; +extern grib_accessor_class* grib_accessor_class_padtoeven; +extern grib_accessor_class* grib_accessor_class_padtomultiple; +extern grib_accessor_class* grib_accessor_class_position; +extern grib_accessor_class* grib_accessor_class_proj_string; +extern grib_accessor_class* grib_accessor_class_raw; +extern grib_accessor_class* grib_accessor_class_rdbtime_guess_date; +extern grib_accessor_class* grib_accessor_class_reference_value_error; +extern grib_accessor_class* grib_accessor_class_round; +extern grib_accessor_class* grib_accessor_class_scale; +extern grib_accessor_class* grib_accessor_class_scale_values; +extern grib_accessor_class* grib_accessor_class_second_order_bits_per_value; +extern grib_accessor_class* grib_accessor_class_section; +extern grib_accessor_class* grib_accessor_class_section_length; +extern grib_accessor_class* grib_accessor_class_section_padding; +extern grib_accessor_class* grib_accessor_class_section_pointer; +extern grib_accessor_class* grib_accessor_class_select_step_template; +extern grib_accessor_class* grib_accessor_class_sexagesimal2decimal; +extern grib_accessor_class* grib_accessor_class_signed; +extern grib_accessor_class* grib_accessor_class_signed_bits; +extern grib_accessor_class* grib_accessor_class_simple_packing_error; +extern grib_accessor_class* grib_accessor_class_size; #include "accessor/grib_accessor_class_smart_table.h" extern grib_accessor_class* grib_accessor_class_smart_table; -//extern grib_accessor_class* grib_accessor_class_smart_table_column; -//extern grib_accessor_class* grib_accessor_class_spd; -//extern grib_accessor_class* grib_accessor_class_spectral_truncation; -//extern grib_accessor_class* grib_accessor_class_sprintf; -//extern grib_accessor_class* grib_accessor_class_statistics; -//extern grib_accessor_class* grib_accessor_class_statistics_spectral; -//extern grib_accessor_class* grib_accessor_class_step_human_readable; -//extern grib_accessor_class* grib_accessor_class_step_in_units; -//extern grib_accessor_class* grib_accessor_class_sum; -//extern grib_accessor_class* grib_accessor_class_suppressed; -//extern grib_accessor_class* grib_accessor_class_time; -//extern grib_accessor_class* grib_accessor_class_to_double; -//extern grib_accessor_class* grib_accessor_class_to_integer; -//extern grib_accessor_class* grib_accessor_class_to_string; +extern grib_accessor_class* grib_accessor_class_smart_table_column; +extern grib_accessor_class* grib_accessor_class_spd; +extern grib_accessor_class* grib_accessor_class_spectral_truncation; +extern grib_accessor_class* grib_accessor_class_sprintf; +extern grib_accessor_class* grib_accessor_class_statistics; +extern grib_accessor_class* grib_accessor_class_statistics_spectral; +extern grib_accessor_class* grib_accessor_class_step_human_readable; +extern grib_accessor_class* grib_accessor_class_step_in_units; +extern grib_accessor_class* grib_accessor_class_sum; +extern grib_accessor_class* grib_accessor_class_suppressed; +extern grib_accessor_class* grib_accessor_class_time; +extern grib_accessor_class* grib_accessor_class_to_double; +extern grib_accessor_class* grib_accessor_class_to_integer; +extern grib_accessor_class* grib_accessor_class_to_string; #include "accessor/grib_accessor_class_transient.h" extern grib_accessor_class* grib_accessor_class_transient; -//extern grib_accessor_class* grib_accessor_class_transient_darray; -//extern grib_accessor_class* grib_accessor_class_trim; -//extern grib_accessor_class* grib_accessor_class_uint16; -//extern grib_accessor_class* grib_accessor_class_uint32; -//extern grib_accessor_class* grib_accessor_class_uint32_little_endian; -//extern grib_accessor_class* grib_accessor_class_uint64; -//extern grib_accessor_class* grib_accessor_class_uint64_little_endian; -//extern grib_accessor_class* grib_accessor_class_uint8; -//extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors; -//extern grib_accessor_class* grib_accessor_class_unpack_bufr_values; +extern grib_accessor_class* grib_accessor_class_transient_darray; +extern grib_accessor_class* grib_accessor_class_trim; +extern grib_accessor_class* grib_accessor_class_uint16; +extern grib_accessor_class* grib_accessor_class_uint32; +extern grib_accessor_class* grib_accessor_class_uint32_little_endian; +extern grib_accessor_class* grib_accessor_class_uint64; +extern grib_accessor_class* grib_accessor_class_uint64_little_endian; +extern grib_accessor_class* grib_accessor_class_uint8; +extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors; +extern grib_accessor_class* grib_accessor_class_unpack_bufr_values; #include "accessor/grib_accessor_class_unsigned.h" extern grib_accessor_class* grib_accessor_class_unsigned; -//extern grib_accessor_class* grib_accessor_class_unsigned_bits; -//extern grib_accessor_class* grib_accessor_class_validity_date; -//extern grib_accessor_class* grib_accessor_class_validity_time; -//extern grib_accessor_class* grib_accessor_class_values; +extern grib_accessor_class* grib_accessor_class_unsigned_bits; +extern grib_accessor_class* grib_accessor_class_validity_date; +extern grib_accessor_class* grib_accessor_class_validity_time; +extern grib_accessor_class* grib_accessor_class_values; #include "accessor/grib_accessor_class_variable.h" extern grib_accessor_class* grib_accessor_class_variable; -//extern grib_accessor_class* grib_accessor_class_vector; -//extern grib_accessor_class* grib_accessor_class_when; +extern grib_accessor_class* grib_accessor_class_vector; +extern grib_accessor_class* grib_accessor_class_when; diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index dd88339f7..178ed937b 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -1,6 +1,6 @@ /* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf -C -W classes -t -G -H grib_accessor_classes_get_id -N grib_accessor_classes_hash -m 1 -j 1 accessor_class_list.gperf */ -/* Computed positions: -k'1' */ +/* Computed positions: -k'1-2,5,7,11' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -37,12 +37,12 @@ #line 6 "accessor_class_list.gperf" struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; -#define TOTAL_KEYWORDS 10 +#define TOTAL_KEYWORDS 205 #define MIN_WORD_LENGTH 1 -#define MAX_WORD_LENGTH 11 +#define MAX_WORD_LENGTH 44 #define MIN_HASH_VALUE 1 -#define MAX_HASH_VALUE 14 -/* maximum key range = 14, duplicates = 0 */ +#define MAX_HASH_VALUE 506 +/* maximum key range = 506, duplicates = 0 */ #ifdef __GNUC__ @@ -54,36 +54,62 @@ struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; static unsigned int grib_accessor_classes_get_id (const char *str, size_t len) { - static const unsigned char asso_values[] = + static const unsigned short asso_values[] = { - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 0, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, - 15, 15, 15, 15, 15, 6, 15, 15, 0, 15, - 0, 15, 15, 15, 15, 2, 3, 3, 0, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15 + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 0, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 1, 145, + 23, 6, 2, 507, 4, 507, 1, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 0, 507, 0, 69, 84, + 0, 0, 161, 24, 187, 1, 8, 9, 87, 102, + 13, 51, 6, 507, 118, 1, 40, 59, 171, 0, + 4, 6, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, + 507, 507, 507, 507, 507, 507 }; - return len + asso_values[(unsigned char)str[0]]; + unsigned int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[10]]; + /*FALLTHROUGH*/ + case 10: + case 9: + case 8: + case 7: + hval += asso_values[(unsigned char)str[6]]; + /*FALLTHROUGH*/ + case 6: + case 5: + hval += asso_values[(unsigned char)str[4]]; + /*FALLTHROUGH*/ + case 4: + case 3: + case 2: + hval += asso_values[(unsigned char)str[1]]; + /*FALLTHROUGH*/ + case 1: + hval += asso_values[(unsigned char)str[0]]; + break; + } + return hval; } static const struct accessor_class_hash classes[] = @@ -91,26 +117,509 @@ static const struct accessor_class_hash classes[] = {""}, #line 9 "accessor_class_list.gperf" {" "}, + {""}, {""}, {""}, {""}, +#line 179 "accessor_class_list.gperf" + {"size", &grib_accessor_class_size}, +#line 12 "accessor_class_list.gperf" + {"ascii", &grib_accessor_class_ascii}, +#line 176 "accessor_class_list.gperf" + {"signed", &grib_accessor_class_signed}, +#line 156 "accessor_class_list.gperf" + {"pad", &grib_accessor_class_pad}, +#line 182 "accessor_class_list.gperf" + {"spd", &grib_accessor_class_spd}, + {""}, +#line 75 "accessor_class_list.gperf" + {"dirty", &grib_accessor_class_dirty}, + {""}, +#line 177 "accessor_class_list.gperf" + {"signed_bits", &grib_accessor_class_signed_bits}, + {""}, +#line 66 "accessor_class_list.gperf" + {"data_raw_packing", &grib_accessor_class_data_raw_packing}, + {""}, {""}, {""}, +#line 72 "accessor_class_list.gperf" + {"data_simple_packing", &grib_accessor_class_data_simple_packing}, +#line 68 "accessor_class_list.gperf" + {"data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap}, +#line 170 "accessor_class_list.gperf" + {"section", &grib_accessor_class_section}, +#line 43 "accessor_class_list.gperf" + {"data_apply_bitmap", &grib_accessor_class_data_apply_bitmap}, + {""}, +#line 74 "accessor_class_list.gperf" + {"dictionary", &grib_accessor_class_dictionary}, + {""}, +#line 112 "accessor_class_list.gperf" + {"gen", &grib_accessor_class_gen}, +#line 64 "accessor_class_list.gperf" + {"data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing}, +#line 65 "accessor_class_list.gperf" + {"data_png_packing", &grib_accessor_class_data_png_packing}, +#line 172 "accessor_class_list.gperf" + {"section_padding", &grib_accessor_class_section_padding}, +#line 173 "accessor_class_list.gperf" + {"section_pointer", &grib_accessor_class_section_pointer}, +#line 44 "accessor_class_list.gperf" + {"data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic}, + {""}, {""}, {""}, {""}, +#line 80 "accessor_class_list.gperf" + {"expanded_descriptors", &grib_accessor_class_expanded_descriptors}, +#line 157 "accessor_class_list.gperf" + {"padding", &grib_accessor_class_padding}, +#line 45 "accessor_class_list.gperf" + {"data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap}, +#line 110 "accessor_class_list.gperf" + {"gds_is_present", &grib_accessor_class_gds_is_present}, +#line 169 "accessor_class_list.gperf" + {"second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value}, +#line 171 "accessor_class_list.gperf" + {"section_length", &grib_accessor_class_section_length}, +#line 113 "accessor_class_list.gperf" + {"getenv", &grib_accessor_class_getenv}, +#line 57 "accessor_class_list.gperf" + {"data_g22order_packing", &grib_accessor_class_data_g22order_packing}, +#line 191 "accessor_class_list.gperf" + {"time", &grib_accessor_class_time}, + {""}, +#line 61 "accessor_class_list.gperf" + {"data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing}, + {""}, +#line 155 "accessor_class_list.gperf" + {"packing_type", &grib_accessor_class_packing_type}, +#line 62 "accessor_class_list.gperf" + {"data_g2simple_packing", &grib_accessor_class_data_g2simple_packing}, +#line 59 "accessor_class_list.gperf" + {"data_g2complex_packing", &grib_accessor_class_data_g2complex_packing}, {""}, {""}, -#line 132 "accessor_class_list.gperf" - {"long", &grib_accessor_class_long}, - {""}, {""}, +#line 104 "accessor_class_list.gperf" + {"g2grid", &grib_accessor_class_g2grid}, + {""}, {""}, {""}, +#line 103 "accessor_class_list.gperf" + {"g2end_step", &grib_accessor_class_g2end_step}, +#line 98 "accessor_class_list.gperf" + {"g2_eps", &grib_accessor_class_g2_eps}, #line 142 "accessor_class_list.gperf" {"nearest", &grib_accessor_class_nearest}, -#line 211 "accessor_class_list.gperf" - {"variable", &grib_accessor_class_variable}, -#line 39 "accessor_class_list.gperf" - {"constant", &grib_accessor_class_constant}, -#line 35 "accessor_class_list.gperf" - {"codetable", &grib_accessor_class_codetable}, + {""}, +#line 158 "accessor_class_list.gperf" + {"padto", &grib_accessor_class_padto}, +#line 189 "accessor_class_list.gperf" + {"sum", &grib_accessor_class_sum}, + {""}, +#line 107 "accessor_class_list.gperf" + {"g2lon", &grib_accessor_class_g2lon}, +#line 203 "accessor_class_list.gperf" + {"uint8", &grib_accessor_class_uint8}, + {""}, +#line 188 "accessor_class_list.gperf" + {"step_in_units", &grib_accessor_class_step_in_units}, +#line 63 "accessor_class_list.gperf" + {"data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing}, +#line 201 "accessor_class_list.gperf" + {"uint64", &grib_accessor_class_uint64}, +#line 47 "accessor_class_list.gperf" + {"data_complex_packing", &grib_accessor_class_data_complex_packing}, +#line 199 "accessor_class_list.gperf" + {"uint32", &grib_accessor_class_uint32}, +#line 13 "accessor_class_list.gperf" + {"bit", &grib_accessor_class_bit}, +#line 15 "accessor_class_list.gperf" + {"bits", &grib_accessor_class_bits}, +#line 48 "accessor_class_list.gperf" + {"data_dummy_field", &grib_accessor_class_data_dummy_field}, +#line 14 "accessor_class_list.gperf" + {"bitmap", &grib_accessor_class_bitmap}, +#line 124 "accessor_class_list.gperf" + {"julian_day", &grib_accessor_class_julian_day}, +#line 123 "accessor_class_list.gperf" + {"julian_date", &grib_accessor_class_julian_date}, +#line 143 "accessor_class_list.gperf" + {"non_alpha", &grib_accessor_class_non_alpha}, + {""}, +#line 29 "accessor_class_list.gperf" + {"bytes", &grib_accessor_class_bytes}, +#line 67 "accessor_class_list.gperf" + {"data_run_length_packing", &grib_accessor_class_data_run_length_packing}, +#line 108 "accessor_class_list.gperf" + {"g2step_range", &grib_accessor_class_g2step_range}, +#line 16 "accessor_class_list.gperf" + {"bits_per_value", &grib_accessor_class_bits_per_value}, + {""}, {""}, {""}, {""}, {""}, +#line 167 "accessor_class_list.gperf" + {"scale", &grib_accessor_class_scale}, + {""}, +#line 185 "accessor_class_list.gperf" + {"statistics", &grib_accessor_class_statistics}, +#line 102 "accessor_class_list.gperf" + {"g2date", &grib_accessor_class_g2date}, +#line 145 "accessor_class_list.gperf" + {"number_of_points", &grib_accessor_class_number_of_points}, +#line 100 "accessor_class_list.gperf" + {"g2bitmap", &grib_accessor_class_g2bitmap}, + {""}, +#line 60 "accessor_class_list.gperf" + {"data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap}, +#line 58 "accessor_class_list.gperf" + {"data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing}, +#line 111 "accessor_class_list.gperf" + {"gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap}, +#line 122 "accessor_class_list.gperf" + {"iterator", &grib_accessor_class_iterator}, +#line 186 "accessor_class_list.gperf" + {"statistics_spectral", &grib_accessor_class_statistics_spectral}, +#line 46 "accessor_class_list.gperf" + {"data_ccsds_packing", &grib_accessor_class_data_ccsds_packing}, +#line 146 "accessor_class_list.gperf" + {"number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian}, #line 206 "accessor_class_list.gperf" {"unsigned", &grib_accessor_class_unsigned}, +#line 138 "accessor_class_list.gperf" + {"md5", &grib_accessor_class_md5}, + {""}, {""}, +#line 96 "accessor_class_list.gperf" + {"g2_aerosol", &grib_accessor_class_g2_aerosol}, +#line 139 "accessor_class_list.gperf" + {"message", &grib_accessor_class_message}, +#line 207 "accessor_class_list.gperf" + {"unsigned_bits", &grib_accessor_class_unsigned_bits}, +#line 174 "accessor_class_list.gperf" + {"select_step_template", &grib_accessor_class_select_step_template}, +#line 136 "accessor_class_list.gperf" + {"mars_param", &grib_accessor_class_mars_param}, +#line 204 "accessor_class_list.gperf" + {"unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors}, +#line 193 "accessor_class_list.gperf" + {"to_integer", &grib_accessor_class_to_integer}, + {""}, {""}, {""}, +#line 178 "accessor_class_list.gperf" + {"simple_packing_error", &grib_accessor_class_simple_packing_error}, +#line 187 "accessor_class_list.gperf" + {"step_human_readable", &grib_accessor_class_step_human_readable}, +#line 140 "accessor_class_list.gperf" + {"message_copy", &grib_accessor_class_message_copy}, +#line 163 "accessor_class_list.gperf" + {"raw", &grib_accessor_class_raw}, + {""}, {""}, +#line 202 "accessor_class_list.gperf" + {"uint64_little_endian", &grib_accessor_class_uint64_little_endian}, + {""}, +#line 200 "accessor_class_list.gperf" + {"uint32_little_endian", &grib_accessor_class_uint32_little_endian}, +#line 114 "accessor_class_list.gperf" + {"global_gaussian", &grib_accessor_class_global_gaussian}, + {""}, {""}, +#line 76 "accessor_class_list.gperf" + {"divdouble", &grib_accessor_class_divdouble}, + {""}, +#line 175 "accessor_class_list.gperf" + {"sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal}, +#line 99 "accessor_class_list.gperf" + {"g2_mars_labeling", &grib_accessor_class_g2_mars_labeling}, +#line 78 "accessor_class_list.gperf" + {"element", &grib_accessor_class_element}, +#line 160 "accessor_class_list.gperf" + {"padtomultiple", &grib_accessor_class_padtomultiple}, +#line 127 "accessor_class_list.gperf" + {"latitudes", &grib_accessor_class_latitudes}, +#line 164 "accessor_class_list.gperf" + {"rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date}, + {""}, {""}, {""}, +#line 194 "accessor_class_list.gperf" + {"to_string", &grib_accessor_class_to_string}, +#line 132 "accessor_class_list.gperf" + {"long", &grib_accessor_class_long}, +#line 19 "accessor_class_list.gperf" + {"bufr_data_array", &grib_accessor_class_bufr_data_array}, +#line 77 "accessor_class_list.gperf" + {"double", &grib_accessor_class_double}, +#line 20 "accessor_class_list.gperf" + {"bufr_data_element", &grib_accessor_class_bufr_data_element}, +#line 105 "accessor_class_list.gperf" + {"g2latlon", &grib_accessor_class_g2latlon}, + {""}, {""}, +#line 26 "accessor_class_list.gperf" + {"bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning}, + {""}, +#line 137 "accessor_class_list.gperf" + {"mars_step", &grib_accessor_class_mars_step}, + {""}, +#line 115 "accessor_class_list.gperf" + {"group", &grib_accessor_class_group}, + {""}, +#line 28 "accessor_class_list.gperf" + {"bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors}, +#line 161 "accessor_class_list.gperf" + {"position", &grib_accessor_class_position}, + {""}, {""}, {""}, +#line 17 "accessor_class_list.gperf" + {"blob", &grib_accessor_class_blob}, +#line 109 "accessor_class_list.gperf" + {"gaussian_grid_name", &grib_accessor_class_gaussian_grid_name}, +#line 197 "accessor_class_list.gperf" + {"trim", &grib_accessor_class_trim}, + {""}, {""}, +#line 119 "accessor_class_list.gperf" + {"ibmfloat", &grib_accessor_class_ibmfloat}, + {""}, {""}, #line 195 "accessor_class_list.gperf" {"transient", &grib_accessor_class_transient}, +#line 55 "accessor_class_list.gperf" + {"data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing}, + {""}, {""}, +#line 56 "accessor_class_list.gperf" + {"data_g1simple_packing", &grib_accessor_class_data_g1simple_packing}, +#line 49 "accessor_class_list.gperf" + {"data_g1complex_packing", &grib_accessor_class_data_g1complex_packing}, +#line 166 "accessor_class_list.gperf" + {"round", &grib_accessor_class_round}, +#line 196 "accessor_class_list.gperf" + {"transient_darray", &grib_accessor_class_transient_darray}, +#line 18 "accessor_class_list.gperf" + {"budgdate", &grib_accessor_class_budgdate}, +#line 210 "accessor_class_list.gperf" + {"values", &grib_accessor_class_values}, +#line 144 "accessor_class_list.gperf" + {"number_of_coded_values", &grib_accessor_class_number_of_coded_values}, +#line 126 "accessor_class_list.gperf" + {"label", &grib_accessor_class_label}, + {""}, {""}, +#line 38 "accessor_class_list.gperf" + {"concept", &grib_accessor_class_concept}, + {""}, +#line 183 "accessor_class_list.gperf" + {"spectral_truncation", &grib_accessor_class_spectral_truncation}, + {""}, {""}, +#line 83 "accessor_class_list.gperf" + {"g1_message_length", &grib_accessor_class_g1_message_length}, +#line 184 "accessor_class_list.gperf" + {"sprintf", &grib_accessor_class_sprintf}, +#line 190 "accessor_class_list.gperf" + {"suppressed", &grib_accessor_class_suppressed}, + {""}, +#line 213 "accessor_class_list.gperf" + {"when", &grib_accessor_class_when}, + {""}, {""}, #line 180 "accessor_class_list.gperf" {"smart_table", &grib_accessor_class_smart_table}, -#line 122 "accessor_class_list.gperf" - {"iterator", &grib_accessor_class_iterator} + {""}, +#line 39 "accessor_class_list.gperf" + {"constant", &grib_accessor_class_constant}, + {""}, {""}, +#line 162 "accessor_class_list.gperf" + {"proj_string", &grib_accessor_class_proj_string}, +#line 150 "accessor_class_list.gperf" + {"octet_number", &grib_accessor_class_octet_number}, +#line 181 "accessor_class_list.gperf" + {"smart_table_column", &grib_accessor_class_smart_table_column}, + {""}, +#line 135 "accessor_class_list.gperf" + {"lookup", &grib_accessor_class_lookup}, + {""}, +#line 94 "accessor_class_list.gperf" + {"g1step_range", &grib_accessor_class_g1step_range}, +#line 73 "accessor_class_list.gperf" + {"decimal_precision", &grib_accessor_class_decimal_precision}, + {""}, +#line 134 "accessor_class_list.gperf" + {"longitudes", &grib_accessor_class_longitudes}, +#line 70 "accessor_class_list.gperf" + {"data_sh_unpacked", &grib_accessor_class_data_sh_unpacked}, +#line 27 "accessor_class_list.gperf" + {"bufr_string_values", &grib_accessor_class_bufr_string_values}, +#line 198 "accessor_class_list.gperf" + {"uint16", &grib_accessor_class_uint16}, + {""}, {""}, +#line 71 "accessor_class_list.gperf" + {"data_shsimple_packing", &grib_accessor_class_data_shsimple_packing}, +#line 86 "accessor_class_list.gperf" + {"g1date", &grib_accessor_class_g1date}, + {""}, +#line 85 "accessor_class_list.gperf" + {"g1bitmap", &grib_accessor_class_g1bitmap}, + {""}, +#line 54 "accessor_class_list.gperf" + {"data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap}, +#line 192 "accessor_class_list.gperf" + {"to_double", &grib_accessor_class_to_double}, +#line 101 "accessor_class_list.gperf" + {"g2bitmap_present", &grib_accessor_class_g2bitmap_present}, +#line 120 "accessor_class_list.gperf" + {"ieeefloat", &grib_accessor_class_ieeefloat}, +#line 151 "accessor_class_list.gperf" + {"offset_file", &grib_accessor_class_offset_file}, +#line 208 "accessor_class_list.gperf" + {"validity_date", &grib_accessor_class_validity_date}, +#line 209 "accessor_class_list.gperf" + {"validity_time", &grib_accessor_class_validity_time}, + {""}, +#line 130 "accessor_class_list.gperf" + {"library_version", &grib_accessor_class_library_version}, +#line 212 "accessor_class_list.gperf" + {"vector", &grib_accessor_class_vector}, +#line 84 "accessor_class_list.gperf" + {"g1_section4_length", &grib_accessor_class_g1_section4_length}, +#line 141 "accessor_class_list.gperf" + {"multdouble", &grib_accessor_class_multdouble}, +#line 52 "accessor_class_list.gperf" + {"data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing}, + {""}, {""}, +#line 53 "accessor_class_list.gperf" + {"data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing}, + {""}, +#line 24 "accessor_class_list.gperf" + {"bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets}, +#line 159 "accessor_class_list.gperf" + {"padtoeven", &grib_accessor_class_padtoeven}, +#line 50 "accessor_class_list.gperf" + {"data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing}, + {""}, +#line 51 "accessor_class_list.gperf" + {"data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing}, +#line 22 "accessor_class_list.gperf" + {"bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets}, + {""}, {""}, {""}, +#line 23 "accessor_class_list.gperf" + {"bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets}, + {""}, +#line 21 "accessor_class_list.gperf" + {"bufr_elements_table", &grib_accessor_class_bufr_elements_table}, + {""}, {""}, {""}, {""}, +#line 154 "accessor_class_list.gperf" + {"pack_bufr_values", &grib_accessor_class_pack_bufr_values}, +#line 35 "accessor_class_list.gperf" + {"codetable", &grib_accessor_class_codetable}, +#line 131 "accessor_class_list.gperf" + {"local_definition", &grib_accessor_class_local_definition}, + {""}, +#line 25 "accessor_class_list.gperf" + {"bufr_group", &grib_accessor_class_bufr_group}, + {""}, +#line 88 "accessor_class_list.gperf" + {"g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly}, +#line 147 "accessor_class_list.gperf" + {"number_of_values", &grib_accessor_class_number_of_values}, + {""}, +#line 116 "accessor_class_list.gperf" + {"gts_header", &grib_accessor_class_gts_header}, + {""}, +#line 33 "accessor_class_list.gperf" + {"closest_date", &grib_accessor_class_closest_date}, +#line 153 "accessor_class_list.gperf" + {"optimal_step_units", &grib_accessor_class_optimal_step_units}, + {""}, +#line 211 "accessor_class_list.gperf" + {"variable", &grib_accessor_class_variable}, +#line 133 "accessor_class_list.gperf" + {"long_vector", &grib_accessor_class_long_vector}, +#line 168 "accessor_class_list.gperf" + {"scale_values", &grib_accessor_class_scale_values}, + {""}, {""}, {""}, +#line 128 "accessor_class_list.gperf" + {"latlon_increment", &grib_accessor_class_latlon_increment}, + {""}, {""}, {""}, +#line 148 "accessor_class_list.gperf" + {"number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing}, + {""}, +#line 79 "accessor_class_list.gperf" + {"evaluate", &grib_accessor_class_evaluate}, + {""}, {""}, {""}, {""}, {""}, +#line 152 "accessor_class_list.gperf" + {"offset_values", &grib_accessor_class_offset_values}, +#line 69 "accessor_class_list.gperf" + {"data_sh_packed", &grib_accessor_class_data_sh_packed}, +#line 11 "accessor_class_list.gperf" + {"abstract_vector", &grib_accessor_class_abstract_vector}, +#line 118 "accessor_class_list.gperf" + {"headers_only", &grib_accessor_class_headers_only}, +#line 125 "accessor_class_list.gperf" + {"ksec1expver", &grib_accessor_class_ksec1expver}, + {""}, {""}, +#line 41 "accessor_class_list.gperf" + {"count_missing", &grib_accessor_class_count_missing}, +#line 205 "accessor_class_list.gperf" + {"unpack_bufr_values", &grib_accessor_class_unpack_bufr_values}, + {""}, {""}, +#line 121 "accessor_class_list.gperf" + {"ifs_param", &grib_accessor_class_ifs_param}, + {""}, {""}, {""}, +#line 36 "accessor_class_list.gperf" + {"codetable_title", &grib_accessor_class_codetable_title}, + {""}, {""}, {""}, +#line 89 "accessor_class_list.gperf" + {"g1fcperiod", &grib_accessor_class_g1fcperiod}, +#line 34 "accessor_class_list.gperf" + {"codeflag", &grib_accessor_class_codeflag}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 106 "accessor_class_list.gperf" + {"g2level", &grib_accessor_class_g2level}, +#line 42 "accessor_class_list.gperf" + {"count_total", &grib_accessor_class_count_total}, + {""}, +#line 117 "accessor_class_list.gperf" + {"hash_array", &grib_accessor_class_hash_array}, + {""}, {""}, +#line 37 "accessor_class_list.gperf" + {"codetable_units", &grib_accessor_class_codetable_units}, + {""}, {""}, +#line 129 "accessor_class_list.gperf" + {"latlonvalues", &grib_accessor_class_latlonvalues}, + {""}, {""}, {""}, {""}, +#line 30 "accessor_class_list.gperf" + {"change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 31 "accessor_class_list.gperf" + {"change_scanning_direction", &grib_accessor_class_change_scanning_direction}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 149 "accessor_class_list.gperf" + {"octahedral_gaussian", &grib_accessor_class_octahedral_gaussian}, +#line 10 "accessor_class_list.gperf" + {"abstract_long_vector", &grib_accessor_class_abstract_long_vector}, + {""}, {""}, {""}, +#line 40 "accessor_class_list.gperf" + {"count_file", &grib_accessor_class_count_file}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 91 "accessor_class_list.gperf" + {"g1monthlydate", &grib_accessor_class_g1monthlydate}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 82 "accessor_class_list.gperf" + {"g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag}, + {""}, +#line 81 "accessor_class_list.gperf" + {"from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 32 "accessor_class_list.gperf" + {"check_internal_version", &grib_accessor_class_check_internal_version}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, +#line 97 "accessor_class_list.gperf" + {"g2_chemical", &grib_accessor_class_g2_chemical}, +#line 87 "accessor_class_list.gperf" + {"g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date}, + {""}, {""}, {""}, {""}, {""}, +#line 165 "accessor_class_list.gperf" + {"reference_value_error", &grib_accessor_class_reference_value_error}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 93 "accessor_class_list.gperf" + {"g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple}, +#line 92 "accessor_class_list.gperf" + {"g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, +#line 90 "accessor_class_list.gperf" + {"g1forecastmonth", &grib_accessor_class_g1forecastmonth}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 95 "accessor_class_list.gperf" + {"g1verificationdate", &grib_accessor_class_g1verificationdate} }; const struct accessor_class_hash * diff --git a/src/grib_accessor_factory.h b/src/grib_accessor_factory.h index 644d2e89b..2f889a0c6 100644 --- a/src/grib_accessor_factory.h +++ b/src/grib_accessor_factory.h @@ -1,205 +1,205 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ -//{ "abstract_long_vector", &grib_accessor_class_abstract_long_vector, }, -//{ "abstract_vector", &grib_accessor_class_abstract_vector, }, -//{ "ascii", &grib_accessor_class_ascii, }, -//{ "bit", &grib_accessor_class_bit, }, -//{ "bitmap", &grib_accessor_class_bitmap, }, -//{ "bits", &grib_accessor_class_bits, }, -//{ "bits_per_value", &grib_accessor_class_bits_per_value, }, -//{ "blob", &grib_accessor_class_blob, }, -//{ "budgdate", &grib_accessor_class_budgdate, }, -//{ "bufr_data_array", &grib_accessor_class_bufr_data_array, }, -//{ "bufr_data_element", &grib_accessor_class_bufr_data_element, }, -//{ "bufr_elements_table", &grib_accessor_class_bufr_elements_table, }, -//{ "bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets, }, -//{ "bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets, }, -//{ "bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets, }, -//{ "bufr_group", &grib_accessor_class_bufr_group, }, -//{ "bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning, }, -//{ "bufr_string_values", &grib_accessor_class_bufr_string_values, }, -//{ "bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors, }, -//{ "bytes", &grib_accessor_class_bytes, }, -//{ "change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning, }, -//{ "change_scanning_direction", &grib_accessor_class_change_scanning_direction, }, -//{ "check_internal_version", &grib_accessor_class_check_internal_version, }, -//{ "closest_date", &grib_accessor_class_closest_date, }, -//{ "codeflag", &grib_accessor_class_codeflag, }, +{ "abstract_long_vector", &grib_accessor_class_abstract_long_vector, }, +{ "abstract_vector", &grib_accessor_class_abstract_vector, }, +{ "ascii", &grib_accessor_class_ascii, }, +{ "bit", &grib_accessor_class_bit, }, +{ "bitmap", &grib_accessor_class_bitmap, }, +{ "bits", &grib_accessor_class_bits, }, +{ "bits_per_value", &grib_accessor_class_bits_per_value, }, +{ "blob", &grib_accessor_class_blob, }, +{ "budgdate", &grib_accessor_class_budgdate, }, +{ "bufr_data_array", &grib_accessor_class_bufr_data_array, }, +{ "bufr_data_element", &grib_accessor_class_bufr_data_element, }, +{ "bufr_elements_table", &grib_accessor_class_bufr_elements_table, }, +{ "bufr_extract_area_subsets", &grib_accessor_class_bufr_extract_area_subsets, }, +{ "bufr_extract_datetime_subsets", &grib_accessor_class_bufr_extract_datetime_subsets, }, +{ "bufr_extract_subsets", &grib_accessor_class_bufr_extract_subsets, }, +{ "bufr_group", &grib_accessor_class_bufr_group, }, +{ "bufr_simple_thinning", &grib_accessor_class_bufr_simple_thinning, }, +{ "bufr_string_values", &grib_accessor_class_bufr_string_values, }, +{ "bufrdc_expanded_descriptors", &grib_accessor_class_bufrdc_expanded_descriptors, }, +{ "bytes", &grib_accessor_class_bytes, }, +{ "change_alternative_row_scanning", &grib_accessor_class_change_alternative_row_scanning, }, +{ "change_scanning_direction", &grib_accessor_class_change_scanning_direction, }, +{ "check_internal_version", &grib_accessor_class_check_internal_version, }, +{ "closest_date", &grib_accessor_class_closest_date, }, +{ "codeflag", &grib_accessor_class_codeflag, }, { "codetable", &grib_accessor_class_codetable, }, -//{ "codetable_title", &grib_accessor_class_codetable_title, }, -//{ "codetable_units", &grib_accessor_class_codetable_units, }, -//{ "concept", &grib_accessor_class_concept, }, +{ "codetable_title", &grib_accessor_class_codetable_title, }, +{ "codetable_units", &grib_accessor_class_codetable_units, }, +{ "concept", &grib_accessor_class_concept, }, { "constant", &grib_accessor_class_constant, }, -//{ "count_file", &grib_accessor_class_count_file, }, -//{ "count_missing", &grib_accessor_class_count_missing, }, -//{ "count_total", &grib_accessor_class_count_total, }, -//{ "data_apply_bitmap", &grib_accessor_class_data_apply_bitmap, }, -//{ "data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic, }, -//{ "data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap, }, -//{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, -//{ "data_complex_packing", &grib_accessor_class_data_complex_packing, }, -//{ "data_dummy_field", &grib_accessor_class_data_dummy_field, }, -//{ "data_g1complex_packing", &grib_accessor_class_data_g1complex_packing, }, -//{ "data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing, }, -//{ "data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing, }, -//{ "data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing, }, -//{ "data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing, }, -//{ "data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap, }, -//{ "data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing, }, -//{ "data_g1simple_packing", &grib_accessor_class_data_g1simple_packing, }, -//{ "data_g22order_packing", &grib_accessor_class_data_g22order_packing, }, -//{ "data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing, }, -//{ "data_g2complex_packing", &grib_accessor_class_data_g2complex_packing, }, -//{ "data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap, }, -//{ "data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing, }, -//{ "data_g2simple_packing", &grib_accessor_class_data_g2simple_packing, }, -//{ "data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing, }, -//{ "data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing, }, -//{ "data_png_packing", &grib_accessor_class_data_png_packing, }, -//{ "data_raw_packing", &grib_accessor_class_data_raw_packing, }, -//{ "data_run_length_packing", &grib_accessor_class_data_run_length_packing, }, -//{ "data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap, }, -//{ "data_sh_packed", &grib_accessor_class_data_sh_packed, }, -//{ "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, }, -//{ "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, }, -//{ "data_simple_packing", &grib_accessor_class_data_simple_packing, }, -//{ "decimal_precision", &grib_accessor_class_decimal_precision, }, -//{ "dictionary", &grib_accessor_class_dictionary, }, -//{ "dirty", &grib_accessor_class_dirty, }, -//{ "divdouble", &grib_accessor_class_divdouble, }, -//{ "double", &grib_accessor_class_double, }, -//{ "element", &grib_accessor_class_element, }, -//{ "evaluate", &grib_accessor_class_evaluate, }, -//{ "expanded_descriptors", &grib_accessor_class_expanded_descriptors, }, -//{ "from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value, }, -//{ "g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag, }, -//{ "g1_message_length", &grib_accessor_class_g1_message_length, }, -//{ "g1_section4_length", &grib_accessor_class_g1_section4_length, }, -//{ "g1bitmap", &grib_accessor_class_g1bitmap, }, -//{ "g1date", &grib_accessor_class_g1date, }, -//{ "g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date, }, -//{ "g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly, }, -//{ "g1fcperiod", &grib_accessor_class_g1fcperiod, }, -//{ "g1forecastmonth", &grib_accessor_class_g1forecastmonth, }, -//{ "g1monthlydate", &grib_accessor_class_g1monthlydate, }, -//{ "g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex, }, -//{ "g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple, }, -//{ "g1step_range", &grib_accessor_class_g1step_range, }, -//{ "g1verificationdate", &grib_accessor_class_g1verificationdate, }, -//{ "g2_aerosol", &grib_accessor_class_g2_aerosol, }, -//{ "g2_chemical", &grib_accessor_class_g2_chemical, }, -//{ "g2_eps", &grib_accessor_class_g2_eps, }, -//{ "g2_mars_labeling", &grib_accessor_class_g2_mars_labeling, }, -//{ "g2bitmap", &grib_accessor_class_g2bitmap, }, -//{ "g2bitmap_present", &grib_accessor_class_g2bitmap_present, }, -//{ "g2date", &grib_accessor_class_g2date, }, -//{ "g2end_step", &grib_accessor_class_g2end_step, }, -//{ "g2grid", &grib_accessor_class_g2grid, }, -//{ "g2latlon", &grib_accessor_class_g2latlon, }, -//{ "g2level", &grib_accessor_class_g2level, }, -//{ "g2lon", &grib_accessor_class_g2lon, }, -//{ "g2step_range", &grib_accessor_class_g2step_range, }, -//{ "gaussian_grid_name", &grib_accessor_class_gaussian_grid_name, }, -//{ "gds_is_present", &grib_accessor_class_gds_is_present, }, -//{ "gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap, }, -//{ "gen", &grib_accessor_class_gen, }, -//{ "getenv", &grib_accessor_class_getenv, }, -//{ "global_gaussian", &grib_accessor_class_global_gaussian, }, -//{ "group", &grib_accessor_class_group, }, -//{ "gts_header", &grib_accessor_class_gts_header, }, -//{ "hash_array", &grib_accessor_class_hash_array, }, -//{ "headers_only", &grib_accessor_class_headers_only, }, -//{ "ibmfloat", &grib_accessor_class_ibmfloat, }, -//{ "ieeefloat", &grib_accessor_class_ieeefloat, }, -//{ "ifs_param", &grib_accessor_class_ifs_param, }, +{ "count_file", &grib_accessor_class_count_file, }, +{ "count_missing", &grib_accessor_class_count_missing, }, +{ "count_total", &grib_accessor_class_count_total, }, +{ "data_apply_bitmap", &grib_accessor_class_data_apply_bitmap, }, +{ "data_apply_boustrophedonic", &grib_accessor_class_data_apply_boustrophedonic, }, +{ "data_apply_boustrophedonic_bitmap", &grib_accessor_class_data_apply_boustrophedonic_bitmap, }, +{ "data_ccsds_packing", &grib_accessor_class_data_ccsds_packing, }, +{ "data_complex_packing", &grib_accessor_class_data_complex_packing, }, +{ "data_dummy_field", &grib_accessor_class_data_dummy_field, }, +{ "data_g1complex_packing", &grib_accessor_class_data_g1complex_packing, }, +{ "data_g1second_order_constant_width_packing", &grib_accessor_class_data_g1second_order_constant_width_packing, }, +{ "data_g1second_order_general_extended_packing", &grib_accessor_class_data_g1second_order_general_extended_packing, }, +{ "data_g1second_order_general_packing", &grib_accessor_class_data_g1second_order_general_packing, }, +{ "data_g1second_order_row_by_row_packing", &grib_accessor_class_data_g1second_order_row_by_row_packing, }, +{ "data_g1secondary_bitmap", &grib_accessor_class_data_g1secondary_bitmap, }, +{ "data_g1shsimple_packing", &grib_accessor_class_data_g1shsimple_packing, }, +{ "data_g1simple_packing", &grib_accessor_class_data_g1simple_packing, }, +{ "data_g22order_packing", &grib_accessor_class_data_g22order_packing, }, +{ "data_g2bifourier_packing", &grib_accessor_class_data_g2bifourier_packing, }, +{ "data_g2complex_packing", &grib_accessor_class_data_g2complex_packing, }, +{ "data_g2secondary_bitmap", &grib_accessor_class_data_g2secondary_bitmap, }, +{ "data_g2shsimple_packing", &grib_accessor_class_data_g2shsimple_packing, }, +{ "data_g2simple_packing", &grib_accessor_class_data_g2simple_packing, }, +{ "data_g2simple_packing_with_preprocessing", &grib_accessor_class_data_g2simple_packing_with_preprocessing, }, +{ "data_jpeg2000_packing", &grib_accessor_class_data_jpeg2000_packing, }, +{ "data_png_packing", &grib_accessor_class_data_png_packing, }, +{ "data_raw_packing", &grib_accessor_class_data_raw_packing, }, +{ "data_run_length_packing", &grib_accessor_class_data_run_length_packing, }, +{ "data_secondary_bitmap", &grib_accessor_class_data_secondary_bitmap, }, +{ "data_sh_packed", &grib_accessor_class_data_sh_packed, }, +{ "data_sh_unpacked", &grib_accessor_class_data_sh_unpacked, }, +{ "data_shsimple_packing", &grib_accessor_class_data_shsimple_packing, }, +{ "data_simple_packing", &grib_accessor_class_data_simple_packing, }, +{ "decimal_precision", &grib_accessor_class_decimal_precision, }, +{ "dictionary", &grib_accessor_class_dictionary, }, +{ "dirty", &grib_accessor_class_dirty, }, +{ "divdouble", &grib_accessor_class_divdouble, }, +{ "double", &grib_accessor_class_double, }, +{ "element", &grib_accessor_class_element, }, +{ "evaluate", &grib_accessor_class_evaluate, }, +{ "expanded_descriptors", &grib_accessor_class_expanded_descriptors, }, +{ "from_scale_factor_scaled_value", &grib_accessor_class_from_scale_factor_scaled_value, }, +{ "g1_half_byte_codeflag", &grib_accessor_class_g1_half_byte_codeflag, }, +{ "g1_message_length", &grib_accessor_class_g1_message_length, }, +{ "g1_section4_length", &grib_accessor_class_g1_section4_length, }, +{ "g1bitmap", &grib_accessor_class_g1bitmap, }, +{ "g1date", &grib_accessor_class_g1date, }, +{ "g1day_of_the_year_date", &grib_accessor_class_g1day_of_the_year_date, }, +{ "g1end_of_interval_monthly", &grib_accessor_class_g1end_of_interval_monthly, }, +{ "g1fcperiod", &grib_accessor_class_g1fcperiod, }, +{ "g1forecastmonth", &grib_accessor_class_g1forecastmonth, }, +{ "g1monthlydate", &grib_accessor_class_g1monthlydate, }, +{ "g1number_of_coded_values_sh_complex", &grib_accessor_class_g1number_of_coded_values_sh_complex, }, +{ "g1number_of_coded_values_sh_simple", &grib_accessor_class_g1number_of_coded_values_sh_simple, }, +{ "g1step_range", &grib_accessor_class_g1step_range, }, +{ "g1verificationdate", &grib_accessor_class_g1verificationdate, }, +{ "g2_aerosol", &grib_accessor_class_g2_aerosol, }, +{ "g2_chemical", &grib_accessor_class_g2_chemical, }, +{ "g2_eps", &grib_accessor_class_g2_eps, }, +{ "g2_mars_labeling", &grib_accessor_class_g2_mars_labeling, }, +{ "g2bitmap", &grib_accessor_class_g2bitmap, }, +{ "g2bitmap_present", &grib_accessor_class_g2bitmap_present, }, +{ "g2date", &grib_accessor_class_g2date, }, +{ "g2end_step", &grib_accessor_class_g2end_step, }, +{ "g2grid", &grib_accessor_class_g2grid, }, +{ "g2latlon", &grib_accessor_class_g2latlon, }, +{ "g2level", &grib_accessor_class_g2level, }, +{ "g2lon", &grib_accessor_class_g2lon, }, +{ "g2step_range", &grib_accessor_class_g2step_range, }, +{ "gaussian_grid_name", &grib_accessor_class_gaussian_grid_name, }, +{ "gds_is_present", &grib_accessor_class_gds_is_present, }, +{ "gds_not_present_bitmap", &grib_accessor_class_gds_not_present_bitmap, }, +{ "gen", &grib_accessor_class_gen, }, +{ "getenv", &grib_accessor_class_getenv, }, +{ "global_gaussian", &grib_accessor_class_global_gaussian, }, +{ "group", &grib_accessor_class_group, }, +{ "gts_header", &grib_accessor_class_gts_header, }, +{ "hash_array", &grib_accessor_class_hash_array, }, +{ "headers_only", &grib_accessor_class_headers_only, }, +{ "ibmfloat", &grib_accessor_class_ibmfloat, }, +{ "ieeefloat", &grib_accessor_class_ieeefloat, }, +{ "ifs_param", &grib_accessor_class_ifs_param, }, { "iterator", &grib_accessor_class_iterator, }, -//{ "julian_date", &grib_accessor_class_julian_date, }, -//{ "julian_day", &grib_accessor_class_julian_day, }, -//{ "ksec1expver", &grib_accessor_class_ksec1expver, }, -//{ "label", &grib_accessor_class_label, }, -//{ "latitudes", &grib_accessor_class_latitudes, }, -//{ "latlon_increment", &grib_accessor_class_latlon_increment, }, -//{ "latlonvalues", &grib_accessor_class_latlonvalues, }, -//{ "library_version", &grib_accessor_class_library_version, }, -//{ "local_definition", &grib_accessor_class_local_definition, }, +{ "julian_date", &grib_accessor_class_julian_date, }, +{ "julian_day", &grib_accessor_class_julian_day, }, +{ "ksec1expver", &grib_accessor_class_ksec1expver, }, +{ "label", &grib_accessor_class_label, }, +{ "latitudes", &grib_accessor_class_latitudes, }, +{ "latlon_increment", &grib_accessor_class_latlon_increment, }, +{ "latlonvalues", &grib_accessor_class_latlonvalues, }, +{ "library_version", &grib_accessor_class_library_version, }, +{ "local_definition", &grib_accessor_class_local_definition, }, { "long", &grib_accessor_class_long, }, -//{ "long_vector", &grib_accessor_class_long_vector, }, -//{ "longitudes", &grib_accessor_class_longitudes, }, -//{ "lookup", &grib_accessor_class_lookup, }, -//{ "mars_param", &grib_accessor_class_mars_param, }, -//{ "mars_step", &grib_accessor_class_mars_step, }, -//{ "md5", &grib_accessor_class_md5, }, -//{ "message", &grib_accessor_class_message, }, -//{ "message_copy", &grib_accessor_class_message_copy, }, -//{ "multdouble", &grib_accessor_class_multdouble, }, +{ "long_vector", &grib_accessor_class_long_vector, }, +{ "longitudes", &grib_accessor_class_longitudes, }, +{ "lookup", &grib_accessor_class_lookup, }, +{ "mars_param", &grib_accessor_class_mars_param, }, +{ "mars_step", &grib_accessor_class_mars_step, }, +{ "md5", &grib_accessor_class_md5, }, +{ "message", &grib_accessor_class_message, }, +{ "message_copy", &grib_accessor_class_message_copy, }, +{ "multdouble", &grib_accessor_class_multdouble, }, { "nearest", &grib_accessor_class_nearest, }, -//{ "non_alpha", &grib_accessor_class_non_alpha, }, -//{ "number_of_coded_values", &grib_accessor_class_number_of_coded_values, }, -//{ "number_of_points", &grib_accessor_class_number_of_points, }, -//{ "number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian, }, -//{ "number_of_values", &grib_accessor_class_number_of_values, }, -//{ "number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing, }, -//{ "octahedral_gaussian", &grib_accessor_class_octahedral_gaussian, }, -//{ "octet_number", &grib_accessor_class_octet_number, }, -//{ "offset_file", &grib_accessor_class_offset_file, }, -//{ "offset_values", &grib_accessor_class_offset_values, }, -//{ "optimal_step_units", &grib_accessor_class_optimal_step_units, }, -//{ "pack_bufr_values", &grib_accessor_class_pack_bufr_values, }, -//{ "packing_type", &grib_accessor_class_packing_type, }, -//{ "pad", &grib_accessor_class_pad, }, -//{ "padding", &grib_accessor_class_padding, }, -//{ "padto", &grib_accessor_class_padto, }, -//{ "padtoeven", &grib_accessor_class_padtoeven, }, -//{ "padtomultiple", &grib_accessor_class_padtomultiple, }, -//{ "position", &grib_accessor_class_position, }, -//{ "proj_string", &grib_accessor_class_proj_string, }, -//{ "raw", &grib_accessor_class_raw, }, -//{ "rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date, }, -//{ "reference_value_error", &grib_accessor_class_reference_value_error, }, -//{ "round", &grib_accessor_class_round, }, -//{ "scale", &grib_accessor_class_scale, }, -//{ "scale_values", &grib_accessor_class_scale_values, }, -//{ "second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value, }, -//{ "section", &grib_accessor_class_section, }, -//{ "section_length", &grib_accessor_class_section_length, }, -//{ "section_padding", &grib_accessor_class_section_padding, }, -//{ "section_pointer", &grib_accessor_class_section_pointer, }, -//{ "select_step_template", &grib_accessor_class_select_step_template, }, -//{ "sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal, }, -//{ "signed", &grib_accessor_class_signed, }, -//{ "signed_bits", &grib_accessor_class_signed_bits, }, -//{ "simple_packing_error", &grib_accessor_class_simple_packing_error, }, -//{ "size", &grib_accessor_class_size, }, +{ "non_alpha", &grib_accessor_class_non_alpha, }, +{ "number_of_coded_values", &grib_accessor_class_number_of_coded_values, }, +{ "number_of_points", &grib_accessor_class_number_of_points, }, +{ "number_of_points_gaussian", &grib_accessor_class_number_of_points_gaussian, }, +{ "number_of_values", &grib_accessor_class_number_of_values, }, +{ "number_of_values_data_raw_packing", &grib_accessor_class_number_of_values_data_raw_packing, }, +{ "octahedral_gaussian", &grib_accessor_class_octahedral_gaussian, }, +{ "octet_number", &grib_accessor_class_octet_number, }, +{ "offset_file", &grib_accessor_class_offset_file, }, +{ "offset_values", &grib_accessor_class_offset_values, }, +{ "optimal_step_units", &grib_accessor_class_optimal_step_units, }, +{ "pack_bufr_values", &grib_accessor_class_pack_bufr_values, }, +{ "packing_type", &grib_accessor_class_packing_type, }, +{ "pad", &grib_accessor_class_pad, }, +{ "padding", &grib_accessor_class_padding, }, +{ "padto", &grib_accessor_class_padto, }, +{ "padtoeven", &grib_accessor_class_padtoeven, }, +{ "padtomultiple", &grib_accessor_class_padtomultiple, }, +{ "position", &grib_accessor_class_position, }, +{ "proj_string", &grib_accessor_class_proj_string, }, +{ "raw", &grib_accessor_class_raw, }, +{ "rdbtime_guess_date", &grib_accessor_class_rdbtime_guess_date, }, +{ "reference_value_error", &grib_accessor_class_reference_value_error, }, +{ "round", &grib_accessor_class_round, }, +{ "scale", &grib_accessor_class_scale, }, +{ "scale_values", &grib_accessor_class_scale_values, }, +{ "second_order_bits_per_value", &grib_accessor_class_second_order_bits_per_value, }, +{ "section", &grib_accessor_class_section, }, +{ "section_length", &grib_accessor_class_section_length, }, +{ "section_padding", &grib_accessor_class_section_padding, }, +{ "section_pointer", &grib_accessor_class_section_pointer, }, +{ "select_step_template", &grib_accessor_class_select_step_template, }, +{ "sexagesimal2decimal", &grib_accessor_class_sexagesimal2decimal, }, +{ "signed", &grib_accessor_class_signed, }, +{ "signed_bits", &grib_accessor_class_signed_bits, }, +{ "simple_packing_error", &grib_accessor_class_simple_packing_error, }, +{ "size", &grib_accessor_class_size, }, { "smart_table", &grib_accessor_class_smart_table, }, -//{ "smart_table_column", &grib_accessor_class_smart_table_column, }, -//{ "spd", &grib_accessor_class_spd, }, -//{ "spectral_truncation", &grib_accessor_class_spectral_truncation, }, -//{ "sprintf", &grib_accessor_class_sprintf, }, -//{ "statistics", &grib_accessor_class_statistics, }, -//{ "statistics_spectral", &grib_accessor_class_statistics_spectral, }, -//{ "step_human_readable", &grib_accessor_class_step_human_readable, }, -//{ "step_in_units", &grib_accessor_class_step_in_units, }, -//{ "sum", &grib_accessor_class_sum, }, -//{ "suppressed", &grib_accessor_class_suppressed, }, -//{ "time", &grib_accessor_class_time, }, -//{ "to_double", &grib_accessor_class_to_double, }, -//{ "to_integer", &grib_accessor_class_to_integer, }, -//{ "to_string", &grib_accessor_class_to_string, }, +{ "smart_table_column", &grib_accessor_class_smart_table_column, }, +{ "spd", &grib_accessor_class_spd, }, +{ "spectral_truncation", &grib_accessor_class_spectral_truncation, }, +{ "sprintf", &grib_accessor_class_sprintf, }, +{ "statistics", &grib_accessor_class_statistics, }, +{ "statistics_spectral", &grib_accessor_class_statistics_spectral, }, +{ "step_human_readable", &grib_accessor_class_step_human_readable, }, +{ "step_in_units", &grib_accessor_class_step_in_units, }, +{ "sum", &grib_accessor_class_sum, }, +{ "suppressed", &grib_accessor_class_suppressed, }, +{ "time", &grib_accessor_class_time, }, +{ "to_double", &grib_accessor_class_to_double, }, +{ "to_integer", &grib_accessor_class_to_integer, }, +{ "to_string", &grib_accessor_class_to_string, }, { "transient", &grib_accessor_class_transient, }, -//{ "transient_darray", &grib_accessor_class_transient_darray, }, -//{ "trim", &grib_accessor_class_trim, }, -//{ "uint16", &grib_accessor_class_uint16, }, -//{ "uint32", &grib_accessor_class_uint32, }, -//{ "uint32_little_endian", &grib_accessor_class_uint32_little_endian, }, -//{ "uint64", &grib_accessor_class_uint64, }, -//{ "uint64_little_endian", &grib_accessor_class_uint64_little_endian, }, -//{ "uint8", &grib_accessor_class_uint8, }, -//{ "unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors, }, -//{ "unpack_bufr_values", &grib_accessor_class_unpack_bufr_values, }, +{ "transient_darray", &grib_accessor_class_transient_darray, }, +{ "trim", &grib_accessor_class_trim, }, +{ "uint16", &grib_accessor_class_uint16, }, +{ "uint32", &grib_accessor_class_uint32, }, +{ "uint32_little_endian", &grib_accessor_class_uint32_little_endian, }, +{ "uint64", &grib_accessor_class_uint64, }, +{ "uint64_little_endian", &grib_accessor_class_uint64_little_endian, }, +{ "uint8", &grib_accessor_class_uint8, }, +{ "unexpanded_descriptors", &grib_accessor_class_unexpanded_descriptors, }, +{ "unpack_bufr_values", &grib_accessor_class_unpack_bufr_values, }, { "unsigned", &grib_accessor_class_unsigned, }, -//{ "unsigned_bits", &grib_accessor_class_unsigned_bits, }, -//{ "validity_date", &grib_accessor_class_validity_date, }, -//{ "validity_time", &grib_accessor_class_validity_time, }, -//{ "values", &grib_accessor_class_values, }, +{ "unsigned_bits", &grib_accessor_class_unsigned_bits, }, +{ "validity_date", &grib_accessor_class_validity_date, }, +{ "validity_time", &grib_accessor_class_validity_time, }, +{ "values", &grib_accessor_class_values, }, { "variable", &grib_accessor_class_variable, }, -//{ "vector", &grib_accessor_class_vector, }, -//{ "when", &grib_accessor_class_when, }, +{ "vector", &grib_accessor_class_vector, }, +{ "when", &grib_accessor_class_when, }, diff --git a/src/grib_accessor_factory_hash_list b/src/grib_accessor_factory_hash_list index 136aedc43..1f7687f38 100644 --- a/src/grib_accessor_factory_hash_list +++ b/src/grib_accessor_factory_hash_list @@ -1,206 +1,206 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ -#abstract_long_vector, &grib_accessor_class_abstract_long_vector -#abstract_vector, &grib_accessor_class_abstract_vector -#ascii, &grib_accessor_class_ascii -#bit, &grib_accessor_class_bit -#bitmap, &grib_accessor_class_bitmap -#bits, &grib_accessor_class_bits -#bits_per_value, &grib_accessor_class_bits_per_value -#blob, &grib_accessor_class_blob -#budgdate, &grib_accessor_class_budgdate -#bufr_data_array, &grib_accessor_class_bufr_data_array -#bufr_data_element, &grib_accessor_class_bufr_data_element -#bufr_elements_table, &grib_accessor_class_bufr_elements_table -#bufr_extract_area_subsets, &grib_accessor_class_bufr_extract_area_subsets -#bufr_extract_datetime_subsets, &grib_accessor_class_bufr_extract_datetime_subsets -#bufr_extract_subsets, &grib_accessor_class_bufr_extract_subsets -#bufr_group, &grib_accessor_class_bufr_group -#bufr_simple_thinning, &grib_accessor_class_bufr_simple_thinning -#bufr_string_values, &grib_accessor_class_bufr_string_values -#bufrdc_expanded_descriptors, &grib_accessor_class_bufrdc_expanded_descriptors -#bytes, &grib_accessor_class_bytes -#change_alternative_row_scanning, &grib_accessor_class_change_alternative_row_scanning -#change_scanning_direction, &grib_accessor_class_change_scanning_direction -#check_internal_version, &grib_accessor_class_check_internal_version -#closest_date, &grib_accessor_class_closest_date -#codeflag, &grib_accessor_class_codeflag +abstract_long_vector, &grib_accessor_class_abstract_long_vector +abstract_vector, &grib_accessor_class_abstract_vector +ascii, &grib_accessor_class_ascii +bit, &grib_accessor_class_bit +bitmap, &grib_accessor_class_bitmap +bits, &grib_accessor_class_bits +bits_per_value, &grib_accessor_class_bits_per_value +blob, &grib_accessor_class_blob +budgdate, &grib_accessor_class_budgdate +bufr_data_array, &grib_accessor_class_bufr_data_array +bufr_data_element, &grib_accessor_class_bufr_data_element +bufr_elements_table, &grib_accessor_class_bufr_elements_table +bufr_extract_area_subsets, &grib_accessor_class_bufr_extract_area_subsets +bufr_extract_datetime_subsets, &grib_accessor_class_bufr_extract_datetime_subsets +bufr_extract_subsets, &grib_accessor_class_bufr_extract_subsets +bufr_group, &grib_accessor_class_bufr_group +bufr_simple_thinning, &grib_accessor_class_bufr_simple_thinning +bufr_string_values, &grib_accessor_class_bufr_string_values +bufrdc_expanded_descriptors, &grib_accessor_class_bufrdc_expanded_descriptors +bytes, &grib_accessor_class_bytes +change_alternative_row_scanning, &grib_accessor_class_change_alternative_row_scanning +change_scanning_direction, &grib_accessor_class_change_scanning_direction +check_internal_version, &grib_accessor_class_check_internal_version +closest_date, &grib_accessor_class_closest_date +codeflag, &grib_accessor_class_codeflag codetable, &grib_accessor_class_codetable -#codetable_title, &grib_accessor_class_codetable_title -#codetable_units, &grib_accessor_class_codetable_units -#concept, &grib_accessor_class_concept +codetable_title, &grib_accessor_class_codetable_title +codetable_units, &grib_accessor_class_codetable_units +concept, &grib_accessor_class_concept constant, &grib_accessor_class_constant -#count_file, &grib_accessor_class_count_file -#count_missing, &grib_accessor_class_count_missing -#count_total, &grib_accessor_class_count_total -#data_apply_bitmap, &grib_accessor_class_data_apply_bitmap -#data_apply_boustrophedonic, &grib_accessor_class_data_apply_boustrophedonic -#data_apply_boustrophedonic_bitmap, &grib_accessor_class_data_apply_boustrophedonic_bitmap -#data_ccsds_packing, &grib_accessor_class_data_ccsds_packing -#data_complex_packing, &grib_accessor_class_data_complex_packing -#data_dummy_field, &grib_accessor_class_data_dummy_field -#data_g1complex_packing, &grib_accessor_class_data_g1complex_packing -#data_g1second_order_constant_width_packing, &grib_accessor_class_data_g1second_order_constant_width_packing -#data_g1second_order_general_extended_packing, &grib_accessor_class_data_g1second_order_general_extended_packing -#data_g1second_order_general_packing, &grib_accessor_class_data_g1second_order_general_packing -#data_g1second_order_row_by_row_packing, &grib_accessor_class_data_g1second_order_row_by_row_packing -#data_g1secondary_bitmap, &grib_accessor_class_data_g1secondary_bitmap -#data_g1shsimple_packing, &grib_accessor_class_data_g1shsimple_packing -#data_g1simple_packing, &grib_accessor_class_data_g1simple_packing -#data_g22order_packing, &grib_accessor_class_data_g22order_packing -#data_g2bifourier_packing, &grib_accessor_class_data_g2bifourier_packing -#data_g2complex_packing, &grib_accessor_class_data_g2complex_packing -#data_g2secondary_bitmap, &grib_accessor_class_data_g2secondary_bitmap -#data_g2shsimple_packing, &grib_accessor_class_data_g2shsimple_packing -#data_g2simple_packing, &grib_accessor_class_data_g2simple_packing -#data_g2simple_packing_with_preprocessing, &grib_accessor_class_data_g2simple_packing_with_preprocessing -#data_jpeg2000_packing, &grib_accessor_class_data_jpeg2000_packing -#data_png_packing, &grib_accessor_class_data_png_packing -#data_raw_packing, &grib_accessor_class_data_raw_packing -#data_run_length_packing, &grib_accessor_class_data_run_length_packing -#data_secondary_bitmap, &grib_accessor_class_data_secondary_bitmap -#data_sh_packed, &grib_accessor_class_data_sh_packed -#data_sh_unpacked, &grib_accessor_class_data_sh_unpacked -#data_shsimple_packing, &grib_accessor_class_data_shsimple_packing -#data_simple_packing, &grib_accessor_class_data_simple_packing -#decimal_precision, &grib_accessor_class_decimal_precision -#dictionary, &grib_accessor_class_dictionary -#dirty, &grib_accessor_class_dirty -#divdouble, &grib_accessor_class_divdouble -#double, &grib_accessor_class_double -#element, &grib_accessor_class_element -#evaluate, &grib_accessor_class_evaluate -#expanded_descriptors, &grib_accessor_class_expanded_descriptors -#from_scale_factor_scaled_value, &grib_accessor_class_from_scale_factor_scaled_value -#g1_half_byte_codeflag, &grib_accessor_class_g1_half_byte_codeflag -#g1_message_length, &grib_accessor_class_g1_message_length -#g1_section4_length, &grib_accessor_class_g1_section4_length -#g1bitmap, &grib_accessor_class_g1bitmap -#g1date, &grib_accessor_class_g1date -#g1day_of_the_year_date, &grib_accessor_class_g1day_of_the_year_date -#g1end_of_interval_monthly, &grib_accessor_class_g1end_of_interval_monthly -#g1fcperiod, &grib_accessor_class_g1fcperiod -#g1forecastmonth, &grib_accessor_class_g1forecastmonth -#g1monthlydate, &grib_accessor_class_g1monthlydate -#g1number_of_coded_values_sh_complex, &grib_accessor_class_g1number_of_coded_values_sh_complex -#g1number_of_coded_values_sh_simple, &grib_accessor_class_g1number_of_coded_values_sh_simple -#g1step_range, &grib_accessor_class_g1step_range -#g1verificationdate, &grib_accessor_class_g1verificationdate -#g2_aerosol, &grib_accessor_class_g2_aerosol -#g2_chemical, &grib_accessor_class_g2_chemical -#g2_eps, &grib_accessor_class_g2_eps -#g2_mars_labeling, &grib_accessor_class_g2_mars_labeling -#g2bitmap, &grib_accessor_class_g2bitmap -#g2bitmap_present, &grib_accessor_class_g2bitmap_present -#g2date, &grib_accessor_class_g2date -#g2end_step, &grib_accessor_class_g2end_step -#g2grid, &grib_accessor_class_g2grid -#g2latlon, &grib_accessor_class_g2latlon -#g2level, &grib_accessor_class_g2level -#g2lon, &grib_accessor_class_g2lon -#g2step_range, &grib_accessor_class_g2step_range -#gaussian_grid_name, &grib_accessor_class_gaussian_grid_name -#gds_is_present, &grib_accessor_class_gds_is_present -#gds_not_present_bitmap, &grib_accessor_class_gds_not_present_bitmap -#gen, &grib_accessor_class_gen -#getenv, &grib_accessor_class_getenv -#global_gaussian, &grib_accessor_class_global_gaussian -#group, &grib_accessor_class_group -#gts_header, &grib_accessor_class_gts_header -#hash_array, &grib_accessor_class_hash_array -#headers_only, &grib_accessor_class_headers_only -#ibmfloat, &grib_accessor_class_ibmfloat -#ieeefloat, &grib_accessor_class_ieeefloat -#ifs_param, &grib_accessor_class_ifs_param +count_file, &grib_accessor_class_count_file +count_missing, &grib_accessor_class_count_missing +count_total, &grib_accessor_class_count_total +data_apply_bitmap, &grib_accessor_class_data_apply_bitmap +data_apply_boustrophedonic, &grib_accessor_class_data_apply_boustrophedonic +data_apply_boustrophedonic_bitmap, &grib_accessor_class_data_apply_boustrophedonic_bitmap +data_ccsds_packing, &grib_accessor_class_data_ccsds_packing +data_complex_packing, &grib_accessor_class_data_complex_packing +data_dummy_field, &grib_accessor_class_data_dummy_field +data_g1complex_packing, &grib_accessor_class_data_g1complex_packing +data_g1second_order_constant_width_packing, &grib_accessor_class_data_g1second_order_constant_width_packing +data_g1second_order_general_extended_packing, &grib_accessor_class_data_g1second_order_general_extended_packing +data_g1second_order_general_packing, &grib_accessor_class_data_g1second_order_general_packing +data_g1second_order_row_by_row_packing, &grib_accessor_class_data_g1second_order_row_by_row_packing +data_g1secondary_bitmap, &grib_accessor_class_data_g1secondary_bitmap +data_g1shsimple_packing, &grib_accessor_class_data_g1shsimple_packing +data_g1simple_packing, &grib_accessor_class_data_g1simple_packing +data_g22order_packing, &grib_accessor_class_data_g22order_packing +data_g2bifourier_packing, &grib_accessor_class_data_g2bifourier_packing +data_g2complex_packing, &grib_accessor_class_data_g2complex_packing +data_g2secondary_bitmap, &grib_accessor_class_data_g2secondary_bitmap +data_g2shsimple_packing, &grib_accessor_class_data_g2shsimple_packing +data_g2simple_packing, &grib_accessor_class_data_g2simple_packing +data_g2simple_packing_with_preprocessing, &grib_accessor_class_data_g2simple_packing_with_preprocessing +data_jpeg2000_packing, &grib_accessor_class_data_jpeg2000_packing +data_png_packing, &grib_accessor_class_data_png_packing +data_raw_packing, &grib_accessor_class_data_raw_packing +data_run_length_packing, &grib_accessor_class_data_run_length_packing +data_secondary_bitmap, &grib_accessor_class_data_secondary_bitmap +data_sh_packed, &grib_accessor_class_data_sh_packed +data_sh_unpacked, &grib_accessor_class_data_sh_unpacked +data_shsimple_packing, &grib_accessor_class_data_shsimple_packing +data_simple_packing, &grib_accessor_class_data_simple_packing +decimal_precision, &grib_accessor_class_decimal_precision +dictionary, &grib_accessor_class_dictionary +dirty, &grib_accessor_class_dirty +divdouble, &grib_accessor_class_divdouble +double, &grib_accessor_class_double +element, &grib_accessor_class_element +evaluate, &grib_accessor_class_evaluate +expanded_descriptors, &grib_accessor_class_expanded_descriptors +from_scale_factor_scaled_value, &grib_accessor_class_from_scale_factor_scaled_value +g1_half_byte_codeflag, &grib_accessor_class_g1_half_byte_codeflag +g1_message_length, &grib_accessor_class_g1_message_length +g1_section4_length, &grib_accessor_class_g1_section4_length +g1bitmap, &grib_accessor_class_g1bitmap +g1date, &grib_accessor_class_g1date +g1day_of_the_year_date, &grib_accessor_class_g1day_of_the_year_date +g1end_of_interval_monthly, &grib_accessor_class_g1end_of_interval_monthly +g1fcperiod, &grib_accessor_class_g1fcperiod +g1forecastmonth, &grib_accessor_class_g1forecastmonth +g1monthlydate, &grib_accessor_class_g1monthlydate +g1number_of_coded_values_sh_complex, &grib_accessor_class_g1number_of_coded_values_sh_complex +g1number_of_coded_values_sh_simple, &grib_accessor_class_g1number_of_coded_values_sh_simple +g1step_range, &grib_accessor_class_g1step_range +g1verificationdate, &grib_accessor_class_g1verificationdate +g2_aerosol, &grib_accessor_class_g2_aerosol +g2_chemical, &grib_accessor_class_g2_chemical +g2_eps, &grib_accessor_class_g2_eps +g2_mars_labeling, &grib_accessor_class_g2_mars_labeling +g2bitmap, &grib_accessor_class_g2bitmap +g2bitmap_present, &grib_accessor_class_g2bitmap_present +g2date, &grib_accessor_class_g2date +g2end_step, &grib_accessor_class_g2end_step +g2grid, &grib_accessor_class_g2grid +g2latlon, &grib_accessor_class_g2latlon +g2level, &grib_accessor_class_g2level +g2lon, &grib_accessor_class_g2lon +g2step_range, &grib_accessor_class_g2step_range +gaussian_grid_name, &grib_accessor_class_gaussian_grid_name +gds_is_present, &grib_accessor_class_gds_is_present +gds_not_present_bitmap, &grib_accessor_class_gds_not_present_bitmap +gen, &grib_accessor_class_gen +getenv, &grib_accessor_class_getenv +global_gaussian, &grib_accessor_class_global_gaussian +group, &grib_accessor_class_group +gts_header, &grib_accessor_class_gts_header +hash_array, &grib_accessor_class_hash_array +headers_only, &grib_accessor_class_headers_only +ibmfloat, &grib_accessor_class_ibmfloat +ieeefloat, &grib_accessor_class_ieeefloat +ifs_param, &grib_accessor_class_ifs_param iterator, &grib_accessor_class_iterator -#julian_date, &grib_accessor_class_julian_date -#julian_day, &grib_accessor_class_julian_day -#ksec1expver, &grib_accessor_class_ksec1expver -#label, &grib_accessor_class_label -#latitudes, &grib_accessor_class_latitudes -#latlon_increment, &grib_accessor_class_latlon_increment -#latlonvalues, &grib_accessor_class_latlonvalues -#library_version, &grib_accessor_class_library_version -#local_definition, &grib_accessor_class_local_definition +julian_date, &grib_accessor_class_julian_date +julian_day, &grib_accessor_class_julian_day +ksec1expver, &grib_accessor_class_ksec1expver +label, &grib_accessor_class_label +latitudes, &grib_accessor_class_latitudes +latlon_increment, &grib_accessor_class_latlon_increment +latlonvalues, &grib_accessor_class_latlonvalues +library_version, &grib_accessor_class_library_version +local_definition, &grib_accessor_class_local_definition long, &grib_accessor_class_long -#long_vector, &grib_accessor_class_long_vector -#longitudes, &grib_accessor_class_longitudes -#lookup, &grib_accessor_class_lookup -#mars_param, &grib_accessor_class_mars_param -#mars_step, &grib_accessor_class_mars_step -#md5, &grib_accessor_class_md5 -#message, &grib_accessor_class_message -#message_copy, &grib_accessor_class_message_copy -#multdouble, &grib_accessor_class_multdouble +long_vector, &grib_accessor_class_long_vector +longitudes, &grib_accessor_class_longitudes +lookup, &grib_accessor_class_lookup +mars_param, &grib_accessor_class_mars_param +mars_step, &grib_accessor_class_mars_step +md5, &grib_accessor_class_md5 +message, &grib_accessor_class_message +message_copy, &grib_accessor_class_message_copy +multdouble, &grib_accessor_class_multdouble nearest, &grib_accessor_class_nearest -#non_alpha, &grib_accessor_class_non_alpha -#number_of_coded_values, &grib_accessor_class_number_of_coded_values -#number_of_points, &grib_accessor_class_number_of_points -#number_of_points_gaussian, &grib_accessor_class_number_of_points_gaussian -#number_of_values, &grib_accessor_class_number_of_values -#number_of_values_data_raw_packing, &grib_accessor_class_number_of_values_data_raw_packing -#octahedral_gaussian, &grib_accessor_class_octahedral_gaussian -#octet_number, &grib_accessor_class_octet_number -#offset_file, &grib_accessor_class_offset_file -#offset_values, &grib_accessor_class_offset_values -#optimal_step_units, &grib_accessor_class_optimal_step_units -#pack_bufr_values, &grib_accessor_class_pack_bufr_values -#packing_type, &grib_accessor_class_packing_type -#pad, &grib_accessor_class_pad -#padding, &grib_accessor_class_padding -#padto, &grib_accessor_class_padto -#padtoeven, &grib_accessor_class_padtoeven -#padtomultiple, &grib_accessor_class_padtomultiple -#position, &grib_accessor_class_position -#proj_string, &grib_accessor_class_proj_string -#raw, &grib_accessor_class_raw -#rdbtime_guess_date, &grib_accessor_class_rdbtime_guess_date -#reference_value_error, &grib_accessor_class_reference_value_error -#round, &grib_accessor_class_round -#scale, &grib_accessor_class_scale -#scale_values, &grib_accessor_class_scale_values -#second_order_bits_per_value, &grib_accessor_class_second_order_bits_per_value -#section, &grib_accessor_class_section -#section_length, &grib_accessor_class_section_length -#section_padding, &grib_accessor_class_section_padding -#section_pointer, &grib_accessor_class_section_pointer -#select_step_template, &grib_accessor_class_select_step_template -#sexagesimal2decimal, &grib_accessor_class_sexagesimal2decimal -#signed, &grib_accessor_class_signed -#signed_bits, &grib_accessor_class_signed_bits -#simple_packing_error, &grib_accessor_class_simple_packing_error -#size, &grib_accessor_class_size +non_alpha, &grib_accessor_class_non_alpha +number_of_coded_values, &grib_accessor_class_number_of_coded_values +number_of_points, &grib_accessor_class_number_of_points +number_of_points_gaussian, &grib_accessor_class_number_of_points_gaussian +number_of_values, &grib_accessor_class_number_of_values +number_of_values_data_raw_packing, &grib_accessor_class_number_of_values_data_raw_packing +octahedral_gaussian, &grib_accessor_class_octahedral_gaussian +octet_number, &grib_accessor_class_octet_number +offset_file, &grib_accessor_class_offset_file +offset_values, &grib_accessor_class_offset_values +optimal_step_units, &grib_accessor_class_optimal_step_units +pack_bufr_values, &grib_accessor_class_pack_bufr_values +packing_type, &grib_accessor_class_packing_type +pad, &grib_accessor_class_pad +padding, &grib_accessor_class_padding +padto, &grib_accessor_class_padto +padtoeven, &grib_accessor_class_padtoeven +padtomultiple, &grib_accessor_class_padtomultiple +position, &grib_accessor_class_position +proj_string, &grib_accessor_class_proj_string +raw, &grib_accessor_class_raw +rdbtime_guess_date, &grib_accessor_class_rdbtime_guess_date +reference_value_error, &grib_accessor_class_reference_value_error +round, &grib_accessor_class_round +scale, &grib_accessor_class_scale +scale_values, &grib_accessor_class_scale_values +second_order_bits_per_value, &grib_accessor_class_second_order_bits_per_value +section, &grib_accessor_class_section +section_length, &grib_accessor_class_section_length +section_padding, &grib_accessor_class_section_padding +section_pointer, &grib_accessor_class_section_pointer +select_step_template, &grib_accessor_class_select_step_template +sexagesimal2decimal, &grib_accessor_class_sexagesimal2decimal +signed, &grib_accessor_class_signed +signed_bits, &grib_accessor_class_signed_bits +simple_packing_error, &grib_accessor_class_simple_packing_error +size, &grib_accessor_class_size smart_table, &grib_accessor_class_smart_table -#smart_table_column, &grib_accessor_class_smart_table_column -#spd, &grib_accessor_class_spd -#spectral_truncation, &grib_accessor_class_spectral_truncation -#sprintf, &grib_accessor_class_sprintf -#statistics, &grib_accessor_class_statistics -#statistics_spectral, &grib_accessor_class_statistics_spectral -#step_human_readable, &grib_accessor_class_step_human_readable -#step_in_units, &grib_accessor_class_step_in_units -#sum, &grib_accessor_class_sum -#suppressed, &grib_accessor_class_suppressed -#time, &grib_accessor_class_time -#to_double, &grib_accessor_class_to_double -#to_integer, &grib_accessor_class_to_integer -#to_string, &grib_accessor_class_to_string +smart_table_column, &grib_accessor_class_smart_table_column +spd, &grib_accessor_class_spd +spectral_truncation, &grib_accessor_class_spectral_truncation +sprintf, &grib_accessor_class_sprintf +statistics, &grib_accessor_class_statistics +statistics_spectral, &grib_accessor_class_statistics_spectral +step_human_readable, &grib_accessor_class_step_human_readable +step_in_units, &grib_accessor_class_step_in_units +sum, &grib_accessor_class_sum +suppressed, &grib_accessor_class_suppressed +time, &grib_accessor_class_time +to_double, &grib_accessor_class_to_double +to_integer, &grib_accessor_class_to_integer +to_string, &grib_accessor_class_to_string transient, &grib_accessor_class_transient -#transient_darray, &grib_accessor_class_transient_darray -#trim, &grib_accessor_class_trim -#uint16, &grib_accessor_class_uint16 -#uint32, &grib_accessor_class_uint32 -#uint32_little_endian, &grib_accessor_class_uint32_little_endian -#uint64, &grib_accessor_class_uint64 -#uint64_little_endian, &grib_accessor_class_uint64_little_endian -#uint8, &grib_accessor_class_uint8 -#unexpanded_descriptors, &grib_accessor_class_unexpanded_descriptors -#unpack_bufr_values, &grib_accessor_class_unpack_bufr_values +transient_darray, &grib_accessor_class_transient_darray +trim, &grib_accessor_class_trim +uint16, &grib_accessor_class_uint16 +uint32, &grib_accessor_class_uint32 +uint32_little_endian, &grib_accessor_class_uint32_little_endian +uint64, &grib_accessor_class_uint64 +uint64_little_endian, &grib_accessor_class_uint64_little_endian +uint8, &grib_accessor_class_uint8 +unexpanded_descriptors, &grib_accessor_class_unexpanded_descriptors +unpack_bufr_values, &grib_accessor_class_unpack_bufr_values unsigned, &grib_accessor_class_unsigned -#unsigned_bits, &grib_accessor_class_unsigned_bits -#validity_date, &grib_accessor_class_validity_date -#validity_time, &grib_accessor_class_validity_time -#values, &grib_accessor_class_values +unsigned_bits, &grib_accessor_class_unsigned_bits +validity_date, &grib_accessor_class_validity_date +validity_time, &grib_accessor_class_validity_time +values, &grib_accessor_class_values variable, &grib_accessor_class_variable -#vector, &grib_accessor_class_vector -#when, &grib_accessor_class_when +vector, &grib_accessor_class_vector +when, &grib_accessor_class_when diff --git a/src/shared_functions.cc b/src/shared_functions.cc new file mode 100644 index 000000000..fc6f090fb --- /dev/null +++ b/src/shared_functions.cc @@ -0,0 +1,47 @@ +#include "shared_functions.h" + + +/* Table of multipliers to convert step units to minutes */ +static const double u2m[] = { + 1, /* index 0: minutes */ + 60, /* index 1: hour */ + 24 * 60, /* index 2: day */ + 24 * 60 * 30, /* index 3: month */ + -1, /* index 4: year */ + -1, /* index 5: decade */ + -1, /* index 6: 30 years */ + -1, /* index 7: century */ + -1, /* index 8: RESERVED */ + -1, /* index 9: RESERVED */ + 3 * 60, /* index 10: 3 hours */ + 6 * 60, /* index 11: 6 hours */ + 12 * 60, /* index 12: 12 hours */ + 1 / 60.0, /* index 13: seconds */ + 15, /* index 14: 15 mins */ + 30 /* index 15: 30 mins */ +}; + + +void grib_set_bit_on(unsigned char* p, long* bitp){ + unsigned char o = 1; + p += (*bitp >> 3); + o <<= 7 - ((*bitp) % 8); + *p |= o; + (*bitp) += 1; +} + +long convert_to_minutes(long step, long stepUnits) +{ + double result = 0; + if (stepUnits == 0) + return step; /* unit=minutes so no change */ + if (stepUnits == 1) + return step * 60; /* unit=hours */ + if (stepUnits == 13) + return step / 60; /* unit=seconds */ + /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ + + result = step * u2m[stepUnits]; + return (long)result; +} + diff --git a/src/shared_functions.h b/src/shared_functions.h new file mode 100644 index 000000000..04ae2f90f --- /dev/null +++ b/src/shared_functions.h @@ -0,0 +1,9 @@ +#ifndef eccodes_shared_functions_h +#define eccodes_shared_functions_h + +#include "grib_api_internal.h" + +void grib_set_bit_on(unsigned char*, long*); +long convert_to_minutes(long step, long stepUnits); + +#endif // eccodes_shared_functions_h From 8529fc3a1f6d3e2a6cfeecf118928b3d1c550698 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 19 Mar 2024 12:17:17 +0000 Subject: [PATCH 07/90] Enable disabled BUFR function calls --- src/grib_bufr_descriptor.cc | 9 +++------ src/grib_query.cc | 12 +++--------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/grib_bufr_descriptor.cc b/src/grib_bufr_descriptor.cc index ef6bc1fbc..6b7f2b3ce 100644 --- a/src/grib_bufr_descriptor.cc +++ b/src/grib_bufr_descriptor.cc @@ -9,16 +9,13 @@ */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" +#include "grib_scaling.h" bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err) { - // ===== TODO(maee): Enable this when grib_accessor_class_bufr_elements_table.cc is moved to C++ ===== - throw std::runtime_error("grib_bufr_descriptor_new not implemented"); - bufr_descriptor* ret = NULL; - //bufr_descriptor* ret = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, err); - // ===== END TODO ===== + bufr_descriptor* ret = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, err); if (!silent && *err) grib_context_log(tables_accessor->context, GRIB_LOG_ERROR, "unable to get descriptor %06d from table", code); diff --git a/src/grib_query.cc b/src/grib_query.cc index e8d82541d..7b2ecb08a 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -14,6 +14,7 @@ * * ***************************************************************************/ #include "grib_api_internal.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" /* Note: A fast cut-down version of strcmp which does NOT return -1 */ /* 0 means input strings are equal and 1 means not equal */ @@ -213,11 +214,7 @@ static char* get_condition(const char* name, codes_condition* condition) static grib_accessor* _search_by_rank(grib_accessor* a, const char* name, int rank) { - // ===== TODO(maee): Enable when grib_accessor_class_bufr_data_array.cc is moved to C++ ===== - throw "grib_accessor_class_bufr_data_array.cc is not yet moved to C++"; - grib_trie_with_rank* t = NULL; - //grib_trie_with_rank* t = accessor_bufr_data_array_get_dataAccessorsTrie(a); - // ===== END TODO ===== + grib_trie_with_rank* t = accessor_bufr_data_array_get_dataAccessorsTrie(a); grib_accessor* ret = (grib_accessor*)grib_trie_with_rank_get(t, name, rank); return ret; } @@ -438,10 +435,7 @@ static grib_accessors_list* search_by_condition(grib_handle* h, const char* name grib_accessors_list* result = NULL; grib_accessor* data = search_and_cache(h, "dataAccessors", 0); if (data && condition->left) { - // ===== TODO(maee): Enable when grib_accessor_class_bufr_data_array.cc is moved to C++ ===== - //al = accessor_bufr_data_array_get_dataAccessors(data); - throw "grib_accessor_class_bufr_data_array.cc is not yet moved to C++"; - // ===== END TODO ===== + al = accessor_bufr_data_array_get_dataAccessors(data); if (!al) return NULL; result = (grib_accessors_list*)grib_context_malloc_clear(al->accessor->context, sizeof(grib_accessors_list)); From 78c1129ed7c78b4195a50b71ae8e48ebd63e16cb Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 19 Mar 2024 12:19:54 +0000 Subject: [PATCH 08/90] Fix offsets --- src/accessor/grib_accessor_class_ibmfloat.cc | 4 ++-- src/accessor/grib_accessor_class_section.cc | 2 +- src/accessor/grib_accessor_class_signed_bits.cc | 2 +- src/accessor/grib_accessor_class_spd.cc | 2 +- src/accessor/grib_accessor_class_unexpanded_descriptors.cc | 2 +- src/accessor/grib_accessor_class_unsigned_bits.cc | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index 4528c0807..65a471eb5 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -82,7 +82,7 @@ int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* //double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); //printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); - off = byte_offset(a) * 8; + off = a->byte_offset() * 8; ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); if (*len > 1) grib_context_log(a->context, GRIB_LOG_WARNING, "ibmfloat: Trying to pack %zu values in a scalar %s, packing first value", @@ -108,7 +108,7 @@ int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* grib_context_free(a->context, buf); - a->length = byte_count(a); + a->length = a->byte_count(); return ret; } diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc index b6222a551..732435d67 100644 --- a/src/accessor/grib_accessor_class_section.cc +++ b/src/accessor/grib_accessor_class_section.cc @@ -41,7 +41,7 @@ long grib_accessor_class_section_t::byte_count(grib_accessor* a){ } long grib_accessor_class_section_t::next_offset(grib_accessor* a){ - return a->offset + byte_count(a); + return a->offset + a->byte_count(); } void grib_accessor_class_section_t::destroy(grib_context* ct, grib_accessor* a){ diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc index 85a764628..e27f8b53c 100644 --- a/src/accessor/grib_accessor_class_signed_bits.cc +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -148,5 +148,5 @@ void grib_accessor_class_signed_bits_t::update_size(grib_accessor* a, size_t s){ } long grib_accessor_class_signed_bits_t::next_offset(grib_accessor* a){ - return byte_offset(a) + byte_count(a); + return a->byte_offset() + a->byte_count(); } diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc index 7e1083377..709cfef6e 100644 --- a/src/accessor/grib_accessor_class_spd.cc +++ b/src/accessor/grib_accessor_class_spd.cc @@ -154,5 +154,5 @@ void grib_accessor_class_spd_t::update_size(grib_accessor* a, size_t s){ } long grib_accessor_class_spd_t::next_offset(grib_accessor* a){ - return byte_offset(a) + a->length; + return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index e51262387..5cfa0970d 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -128,5 +128,5 @@ void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, } long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a){ - return byte_offset(a) + a->length; + return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index 25d16fdc3..953951fd9 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -155,5 +155,5 @@ void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s } long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a){ - return byte_offset(a) + a->length; + return a->byte_offset() + a->length; } From 6fc7074c50ce45997a62afeb6bcc8059391f6813 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 19 Mar 2024 13:24:04 +0000 Subject: [PATCH 09/90] Fix initialisation --- src/accessor/grib_accessor_class_ascii.cc | 1 + src/accessor/grib_accessor_class_bit.cc | 1 + src/accessor/grib_accessor_class_bitmap.cc | 1 + src/accessor/grib_accessor_class_bits.cc | 1 + src/accessor/grib_accessor_class_bits_per_value.cc | 1 + src/accessor/grib_accessor_class_blob.cc | 1 + src/accessor/grib_accessor_class_budgdate.cc | 1 + src/accessor/grib_accessor_class_bufr_data_array.cc | 1 + src/accessor/grib_accessor_class_bufr_data_element.cc | 1 + src/accessor/grib_accessor_class_bufr_elements_table.cc | 1 + src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc | 1 + .../grib_accessor_class_bufr_extract_datetime_subsets.cc | 1 + src/accessor/grib_accessor_class_bufr_extract_subsets.cc | 1 + src/accessor/grib_accessor_class_bufr_simple_thinning.cc | 1 + src/accessor/grib_accessor_class_bufr_string_values.cc | 1 + src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc | 1 + src/accessor/grib_accessor_class_bytes.cc | 1 + .../grib_accessor_class_change_alternative_row_scanning.cc | 1 + src/accessor/grib_accessor_class_change_scanning_direction.cc | 1 + src/accessor/grib_accessor_class_check_internal_version.cc | 1 + src/accessor/grib_accessor_class_closest_date.cc | 1 + src/accessor/grib_accessor_class_codeflag.cc | 1 + src/accessor/grib_accessor_class_codetable_title.cc | 1 + src/accessor/grib_accessor_class_codetable_units.cc | 1 + src/accessor/grib_accessor_class_concept.cc | 1 + src/accessor/grib_accessor_class_count_file.cc | 1 + src/accessor/grib_accessor_class_count_missing.cc | 1 + src/accessor/grib_accessor_class_count_total.cc | 1 + src/accessor/grib_accessor_class_data_apply_bitmap.cc | 1 + src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc | 1 + .../grib_accessor_class_data_apply_boustrophedonic_bitmap.cc | 1 + src/accessor/grib_accessor_class_data_ccsds_packing.cc | 1 + src/accessor/grib_accessor_class_data_complex_packing.cc | 1 + src/accessor/grib_accessor_class_data_dummy_field.cc | 1 + src/accessor/grib_accessor_class_data_g1complex_packing.cc | 1 + ..._accessor_class_data_g1second_order_constant_width_packing.cc | 1 + ...ccessor_class_data_g1second_order_general_extended_packing.cc | 1 + .../grib_accessor_class_data_g1second_order_general_packing.cc | 1 + ...grib_accessor_class_data_g1second_order_row_by_row_packing.cc | 1 + src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc | 1 + src/accessor/grib_accessor_class_data_g1simple_packing.cc | 1 + src/accessor/grib_accessor_class_data_g22order_packing.cc | 1 + src/accessor/grib_accessor_class_data_g2bifourier_packing.cc | 1 + src/accessor/grib_accessor_class_data_g2complex_packing.cc | 1 + src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc | 1 + src/accessor/grib_accessor_class_data_g2shsimple_packing.cc | 1 + src/accessor/grib_accessor_class_data_g2simple_packing.cc | 1 + ...ib_accessor_class_data_g2simple_packing_with_preprocessing.cc | 1 + src/accessor/grib_accessor_class_data_jpeg2000_packing.cc | 1 + src/accessor/grib_accessor_class_data_png_packing.cc | 1 + src/accessor/grib_accessor_class_data_raw_packing.cc | 1 + src/accessor/grib_accessor_class_data_run_length_packing.cc | 1 + src/accessor/grib_accessor_class_data_secondary_bitmap.cc | 1 + src/accessor/grib_accessor_class_data_sh_packed.cc | 1 + src/accessor/grib_accessor_class_data_sh_unpacked.cc | 1 + src/accessor/grib_accessor_class_data_shsimple_packing.cc | 1 + src/accessor/grib_accessor_class_data_simple_packing.cc | 1 + src/accessor/grib_accessor_class_decimal_precision.cc | 1 + src/accessor/grib_accessor_class_dictionary.cc | 1 + src/accessor/grib_accessor_class_dirty.cc | 1 + src/accessor/grib_accessor_class_divdouble.cc | 1 + src/accessor/grib_accessor_class_element.cc | 1 + src/accessor/grib_accessor_class_evaluate.cc | 1 + src/accessor/grib_accessor_class_expanded_descriptors.cc | 1 + .../grib_accessor_class_from_scale_factor_scaled_value.cc | 1 + src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc | 1 + src/accessor/grib_accessor_class_g1_message_length.cc | 1 + src/accessor/grib_accessor_class_g1_section4_length.cc | 1 + src/accessor/grib_accessor_class_g1bitmap.cc | 1 + src/accessor/grib_accessor_class_g1date.cc | 1 + src/accessor/grib_accessor_class_g1day_of_the_year_date.cc | 1 + src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc | 1 + src/accessor/grib_accessor_class_g1forecastmonth.cc | 1 + src/accessor/grib_accessor_class_g1monthlydate.cc | 1 + .../grib_accessor_class_g1number_of_coded_values_sh_complex.cc | 1 + .../grib_accessor_class_g1number_of_coded_values_sh_simple.cc | 1 + src/accessor/grib_accessor_class_g1step_range.cc | 1 + src/accessor/grib_accessor_class_g1verificationdate.cc | 1 + src/accessor/grib_accessor_class_g2_aerosol.cc | 1 + src/accessor/grib_accessor_class_g2_chemical.cc | 1 + src/accessor/grib_accessor_class_g2_eps.cc | 1 + src/accessor/grib_accessor_class_g2_mars_labeling.cc | 1 + src/accessor/grib_accessor_class_g2bitmap.cc | 1 + src/accessor/grib_accessor_class_g2bitmap_present.cc | 1 + src/accessor/grib_accessor_class_g2date.cc | 1 + src/accessor/grib_accessor_class_g2end_step.cc | 1 + src/accessor/grib_accessor_class_g2grid.cc | 1 + src/accessor/grib_accessor_class_g2latlon.cc | 1 + src/accessor/grib_accessor_class_g2level.cc | 1 + src/accessor/grib_accessor_class_g2lon.cc | 1 + src/accessor/grib_accessor_class_g2step_range.cc | 1 + src/accessor/grib_accessor_class_gaussian_grid_name.cc | 1 + src/accessor/grib_accessor_class_gds_is_present.cc | 1 + src/accessor/grib_accessor_class_gds_not_present_bitmap.cc | 1 + src/accessor/grib_accessor_class_getenv.cc | 1 + src/accessor/grib_accessor_class_global_gaussian.cc | 1 + src/accessor/grib_accessor_class_group.cc | 1 + src/accessor/grib_accessor_class_gts_header.cc | 1 + src/accessor/grib_accessor_class_hash_array.cc | 1 + src/accessor/grib_accessor_class_headers_only.cc | 1 + src/accessor/grib_accessor_class_ibmfloat.cc | 1 + src/accessor/grib_accessor_class_ieeefloat.cc | 1 + src/accessor/grib_accessor_class_ifs_param.cc | 1 + src/accessor/grib_accessor_class_julian_date.cc | 1 + src/accessor/grib_accessor_class_julian_day.cc | 1 + src/accessor/grib_accessor_class_ksec1expver.cc | 1 + src/accessor/grib_accessor_class_label.cc | 1 + src/accessor/grib_accessor_class_latitudes.cc | 1 + src/accessor/grib_accessor_class_latlon_increment.cc | 1 + src/accessor/grib_accessor_class_latlonvalues.cc | 1 + src/accessor/grib_accessor_class_local_definition.cc | 1 + src/accessor/grib_accessor_class_long_vector.cc | 1 + src/accessor/grib_accessor_class_longitudes.cc | 1 + src/accessor/grib_accessor_class_lookup.cc | 1 + src/accessor/grib_accessor_class_mars_param.cc | 1 + src/accessor/grib_accessor_class_mars_step.cc | 1 + src/accessor/grib_accessor_class_md5.cc | 1 + src/accessor/grib_accessor_class_message.cc | 1 + src/accessor/grib_accessor_class_message_copy.cc | 1 + src/accessor/grib_accessor_class_multdouble.cc | 1 + src/accessor/grib_accessor_class_non_alpha.cc | 1 + src/accessor/grib_accessor_class_number_of_coded_values.cc | 1 + src/accessor/grib_accessor_class_number_of_points.cc | 1 + src/accessor/grib_accessor_class_number_of_points_gaussian.cc | 1 + src/accessor/grib_accessor_class_number_of_values.cc | 1 + .../grib_accessor_class_number_of_values_data_raw_packing.cc | 1 + src/accessor/grib_accessor_class_octahedral_gaussian.cc | 1 + src/accessor/grib_accessor_class_octet_number.cc | 1 + src/accessor/grib_accessor_class_offset_file.cc | 1 + src/accessor/grib_accessor_class_offset_values.cc | 1 + src/accessor/grib_accessor_class_optimal_step_units.cc | 1 + src/accessor/grib_accessor_class_pack_bufr_values.cc | 1 + src/accessor/grib_accessor_class_packing_type.cc | 1 + src/accessor/grib_accessor_class_pad.cc | 1 + src/accessor/grib_accessor_class_padding.cc | 1 + src/accessor/grib_accessor_class_padto.cc | 1 + src/accessor/grib_accessor_class_padtoeven.cc | 1 + src/accessor/grib_accessor_class_padtomultiple.cc | 1 + src/accessor/grib_accessor_class_position.cc | 1 + src/accessor/grib_accessor_class_proj_string.cc | 1 + src/accessor/grib_accessor_class_raw.cc | 1 + src/accessor/grib_accessor_class_rdbtime_guess_date.cc | 1 + src/accessor/grib_accessor_class_reference_value_error.cc | 1 + src/accessor/grib_accessor_class_scale.cc | 1 + src/accessor/grib_accessor_class_scale_values.cc | 1 + src/accessor/grib_accessor_class_second_order_bits_per_value.cc | 1 + src/accessor/grib_accessor_class_section.cc | 1 + src/accessor/grib_accessor_class_section_length.cc | 1 + src/accessor/grib_accessor_class_section_padding.cc | 1 + src/accessor/grib_accessor_class_section_pointer.cc | 1 + src/accessor/grib_accessor_class_select_step_template.cc | 1 + src/accessor/grib_accessor_class_sexagesimal2decimal.cc | 1 + src/accessor/grib_accessor_class_signed.cc | 1 + src/accessor/grib_accessor_class_signed_bits.cc | 1 + src/accessor/grib_accessor_class_simple_packing_error.cc | 1 + src/accessor/grib_accessor_class_size.cc | 1 + src/accessor/grib_accessor_class_smart_table_column.cc | 1 + src/accessor/grib_accessor_class_spd.cc | 1 + src/accessor/grib_accessor_class_spectral_truncation.cc | 1 + src/accessor/grib_accessor_class_sprintf.cc | 1 + src/accessor/grib_accessor_class_statistics.cc | 1 + src/accessor/grib_accessor_class_statistics_spectral.cc | 1 + src/accessor/grib_accessor_class_step_human_readable.cc | 1 + src/accessor/grib_accessor_class_step_in_units.cc | 1 + src/accessor/grib_accessor_class_sum.cc | 1 + src/accessor/grib_accessor_class_suppressed.cc | 1 + src/accessor/grib_accessor_class_time.cc | 1 + src/accessor/grib_accessor_class_to_double.cc | 1 + src/accessor/grib_accessor_class_to_integer.cc | 1 + src/accessor/grib_accessor_class_to_string.cc | 1 + src/accessor/grib_accessor_class_transient_darray.cc | 1 + src/accessor/grib_accessor_class_trim.cc | 1 + src/accessor/grib_accessor_class_unexpanded_descriptors.cc | 1 + src/accessor/grib_accessor_class_unpack_bufr_values.cc | 1 + src/accessor/grib_accessor_class_unsigned_bits.cc | 1 + src/accessor/grib_accessor_class_validity_date.cc | 1 + src/accessor/grib_accessor_class_validity_time.cc | 1 + src/accessor/grib_accessor_class_values.cc | 1 + src/accessor/grib_accessor_class_vector.cc | 1 + src/accessor/grib_accessor_class_when.cc | 1 + 180 files changed, 180 insertions(+) diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc index 4fedc7c60..2c824fe29 100644 --- a/src/accessor/grib_accessor_class_ascii.cc +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; void grib_accessor_class_ascii_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->length = len; Assert(a->length >= 0); } diff --git a/src/accessor/grib_accessor_class_bit.cc b/src/accessor/grib_accessor_class_bit.cc index 2cf31bd48..ef30efe24 100644 --- a/src/accessor/grib_accessor_class_bit.cc +++ b/src/accessor/grib_accessor_class_bit.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; void grib_accessor_class_bit_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_long_t::init(a, len, arg); grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; a->length = 0; self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index eb45c4464..a2d659f65 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -53,6 +53,7 @@ void compute_size(grib_accessor* a){ } void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bytes_t::init(a, len, arg); grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc index b38de626c..bb2b8f9ad 100644 --- a/src/accessor/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bits = &_grib_accessor_class_bits; void grib_accessor_class_bits_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_handle* hand = grib_handle_of_accessor(a); grib_expression* e = NULL; diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc index b5d3698e0..51403f855 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_ void grib_accessor_class_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_long_t::init(a, l, args); int n = 0; grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index ddcfc9961..93c7095bb 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); Assert(a->length >= 0); } diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc index 1bfd6e7b9..e496488e2 100644 --- a/src/accessor/grib_accessor_class_budgdate.cc +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_budgdate = &_grib_accessor_class_budgda void grib_accessor_class_budgdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index ea32d69c4..dc903a154 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -157,6 +157,7 @@ int check_overridden_reference_values(const grib_context* c, long* refValList, s #define DYN_ARRAY_SIZE_INCR 1000 /* Increment size for grib_iarray_new and grib_darray_new */ void grib_accessor_class_bufr_data_array_t::init(grib_accessor* a, const long v, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, v, params); grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int n = 0; const char* dataKeysName = NULL; diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index 295c0b13e..584515de2 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -119,6 +119,7 @@ void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, g } void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA; diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc index 9b589c114..9a34353de 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -48,6 +48,7 @@ grib_accessor_class* grib_accessor_class_bufr_elements_table = &_grib_accessor_c void grib_accessor_class_bufr_elements_table_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); int n = 0; grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index 85eb98d0d..cbd6b5c5f 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets = &_grib_acce void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index 0568f02dc..400473180 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets = &_grib_ void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); int n = 0; grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc index 6fbea28a2..75f0618b8 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc @@ -27,6 +27,7 @@ void get_accessors(grib_accessor* a){ } void grib_accessor_class_bufr_extract_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); int n = 0; grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc index 1743104fd..c2621e52c 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_ void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index 2568021a4..3015a7b8c 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_cl void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_ascii_t::init(a, len, args); grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; int n = 0; self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc index 2f4073460..73282fcea 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors = &_grib_ac void grib_accessor_class_bufrdc_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_bufrdc_expanded_descriptors_t* self = (grib_accessor_bufrdc_expanded_descriptors_t*)a; int n = 0; self->expandedDescriptors = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_bytes.cc b/src/accessor/grib_accessor_class_bytes.cc index e0002429a..b7719e232 100644 --- a/src/accessor/grib_accessor_class_bytes.cc +++ b/src/accessor/grib_accessor_class_bytes.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_bytes = &_grib_accessor_class_bytes; void grib_accessor_class_bytes_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ a->length = len; Assert(a->length >= 0); diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc index 8375ee26d..f9d740206 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_change_alternative_row_scanning = &_gri void grib_accessor_class_change_alternative_row_scanning_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); int n = 0; grib_accessor_change_alternative_row_scanning_t* self = (grib_accessor_change_alternative_row_scanning_t*)a; diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc index b8f71f14c..cfa45c592 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_change_scanning_direction = &_grib_acce void grib_accessor_class_change_scanning_direction_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); grib_accessor_change_scanning_direction_t* self = (grib_accessor_change_scanning_direction_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc index 65bdbcbf0..987a512f5 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.cc +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -22,6 +22,7 @@ grib_accessor_class* grib_accessor_class_check_internal_version = &_grib_accesso #define LATEST_ENGINE_VERSION 30 void grib_accessor_class_check_internal_version_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_ascii_t::init(a, l, args); /* Check version of definition files is compatible with the engine */ int err = 0; long defs_file_version = 0; diff --git a/src/accessor/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc index 462b90078..ace5bdf71 100644 --- a/src/accessor/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_closest_date = &_grib_accessor_class_cl void grib_accessor_class_closest_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_closest_date_t* self = (grib_accessor_closest_date_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 3baa24c1b..d81c031a9 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codefl void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* param){ + grib_accessor_class_unsigned_t::init(a, len, param); grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; a->length = len; self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0); diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc index 27d787170..52d8b8b32 100644 --- a/src/accessor/grib_accessor_class_codetable_title.cc +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -17,6 +17,7 @@ grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{"code grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; int n = 0; self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc index cc2c3815b..cb72847e0 100644 --- a/src/accessor/grib_accessor_class_codetable_units.cc +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -17,6 +17,7 @@ grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{"code grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 55f535cb2..1e4eb27c1 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -35,6 +35,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) } void grib_accessor_class_concept_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); a->length = 0; } diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc index 9e88700a3..b3317e515 100644 --- a/src/accessor/grib_accessor_class_count_file.cc +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_coun void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } diff --git a/src/accessor/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc index f0e74d165..a14c6d6c0 100644 --- a/src/accessor/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -36,6 +36,7 @@ static const unsigned char bitsoff[] = { }; void grib_accessor_class_count_missing_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_long_t::init(a, len, arg); int n = 0; grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc index 2c2c69c3c..604981a56 100644 --- a/src/accessor/grib_accessor_class_count_total.cc +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_cou void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index ac7fccc1c..865d9be74 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_apply_bitmap = &_grib_accessor_cla void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index ef36eb2b2..2f1456b39 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic = &_grib_acc void grib_accessor_class_data_apply_boustrophedonic_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index 217431b43..d7e07a561 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap = &_g void grib_accessor_class_data_apply_boustrophedonic_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 5158ee7fd..46af9722f 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_cl void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index e9c36000f..5709b4798 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -22,6 +22,7 @@ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_dummy_field.cc b/src/accessor/grib_accessor_class_data_dummy_field.cc index 5216c2a94..23bc83c9c 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.cc +++ b/src/accessor/grib_accessor_class_data_dummy_field.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_clas void grib_accessor_class_data_dummy_field_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_g1simple_packing_t::init(a, v, args); grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc index eecf83cfb..b1fc4fa4b 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_g1complex_packing = &_grib_accesso void grib_accessor_class_data_g1complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_complex_packing_t::init(a, v, args); grib_accessor_data_g1complex_packing_t* self = (grib_accessor_data_g1complex_packing_t*)a; self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->N = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc index b0009cfa9..44452957e 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_pack void grib_accessor_class_data_g1second_order_constant_width_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 5058a2102..cf47dee15 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -56,6 +56,7 @@ long number_of_bits(grib_handle* h, unsigned long x){ } void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; grib_handle* handle = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index e9d620f52..e709da053 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing = & void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index 10dc06079..8237cf577 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc index cbabc9cf1..639512a57 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap = &_grib_access void grib_accessor_class_data_g1secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_secondary_bitmap_t::init(a, v, args); grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; self->number_of_ones = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); } diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc index a3320a810..2346e33dd 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g1simple_packing = &_grib_accessor void grib_accessor_class_data_g1simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index e8e9aed36..6b82e035e 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g22order_packing = &_grib_accessor void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index f4196a36c..06121f9aa 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -21,6 +21,7 @@ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); void grib_accessor_class_data_g2bifourier_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/grib_accessor_class_data_g2complex_packing.cc index 28958de56..7ccd19117 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_g2complex_packing = &_grib_accesso void grib_accessor_class_data_g2complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_complex_packing_t::init(a, v, args); grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->edition = 2; diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc index bce04078b..f16ccf74f 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_access void grib_accessor_class_data_g2secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_secondary_bitmap_t::init(a, v, args); grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); } diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc index e765539ee..ad204da06 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_g2shsimple_packing = &_grib_access void grib_accessor_class_data_g2shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_shsimple_packing_t::init(a, v, args); grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing.cc index 051239cbc..849c4647a 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_g2simple_packing = &_grib_accessor void grib_accessor_class_data_g2simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; a->flags |= GRIB_ACCESSOR_FLAG_DATA; self->edition = 2; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index 21493c113..ad877ca82 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -19,6 +19,7 @@ grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessin void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_g2simple_packing_t::init(a, v, args); grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->pre_processing_parameter = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index d5f3eaaf4..245d2f6a6 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -22,6 +22,7 @@ static int first = 1; #define OPENJPEG_LIB 2 void grib_accessor_class_data_jpeg2000_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); const char* user_lib = NULL; grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 8c1c62bb3..7e2c90baf 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_clas void grib_accessor_class_data_png_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc index 943359f47..e9de19af0 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_raw_packing = &_grib_accessor_clas void grib_accessor_class_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.cc b/src/accessor/grib_accessor_class_data_run_length_packing.cc index c0b61c254..849652127 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.cc +++ b/src/accessor/grib_accessor_class_data_run_length_packing.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_data_run_length_packing = &_grib_access void grib_accessor_class_data_run_length_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(gh, args, self->carg++); diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc index 51bfb4afc..b453aa5b1 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_secondary_bitmap = &_grib_accessor void grib_accessor_class_data_secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; self->primary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); self->secondary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); diff --git a/src/accessor/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc index a1cb7a7ba..f7febe225 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -21,6 +21,7 @@ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); void grib_accessor_class_data_sh_packed_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc index 842411f26..9573bd732 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -21,6 +21,7 @@ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); void grib_accessor_class_data_sh_unpacked_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/grib_accessor_class_data_shsimple_packing.cc index 68fc83a7b..6fd8d9f6b 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_data_shsimple_packing = &_grib_accessor void grib_accessor_class_data_shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); grib_accessor_data_shsimple_packing_t* self = (grib_accessor_data_shsimple_packing_t*)a; self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); diff --git a/src/accessor/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc index f01a2c612..a167d0b53 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -22,6 +22,7 @@ grib_accessor_class* grib_accessor_class_data_simple_packing = &_grib_accessor_c void grib_accessor_class_data_simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->units_factor = grib_arguments_get_name(gh, args, self->carg++); diff --git a/src/accessor/grib_accessor_class_decimal_precision.cc b/src/accessor/grib_accessor_class_decimal_precision.cc index 0ffe7b0c1..c063512c0 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.cc +++ b/src/accessor/grib_accessor_class_decimal_precision.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_decimal_precision = &_grib_accessor_cla void grib_accessor_class_decimal_precision_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_long_t::init(a, l, args); int n = 0; grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; diff --git a/src/accessor/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc index e078cde45..59ed89b32 100644 --- a/src/accessor/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_dictionary = &_grib_accessor_class_dict void grib_accessor_class_dictionary_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); int n = 0; grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc index 633c3dee2..89a05806b 100644 --- a/src/accessor/grib_accessor_class_dirty.cc +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; diff --git a/src/accessor/grib_accessor_class_divdouble.cc b/src/accessor/grib_accessor_class_divdouble.cc index 03a1b63b5..cf79b434d 100644 --- a/src/accessor/grib_accessor_class_divdouble.cc +++ b/src/accessor/grib_accessor_class_divdouble.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdo void grib_accessor_class_divdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_divdouble_t* self = (grib_accessor_divdouble_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc index a393a57aa..a058d3dea 100644 --- a/src/accessor/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_element = &_grib_accessor_class_element void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_element_t* self = (grib_accessor_element_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc index 62228b065..25f4f5ba5 100644 --- a/src/accessor/grib_accessor_class_evaluate.cc +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evalua void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; self->arg = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index 8a12d93ff..6ea941b55 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -43,6 +43,7 @@ typedef struct change_coding_params } void grib_accessor_class_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc index 3ba6e198e..9ba8aa65e 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value = &_grib void grib_accessor_class_from_scale_factor_scaled_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc index cf115535f..f2d309d06 100644 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor void grib_accessor_class_g1_half_byte_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; diff --git a/src/accessor/grib_accessor_class_g1_message_length.cc b/src/accessor/grib_accessor_class_g1_message_length.cc index 9b318b6a0..de8145a53 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.cc +++ b/src/accessor/grib_accessor_class_g1_message_length.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1_message_length = &_grib_accessor_cla void grib_accessor_class_g1_message_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_section_length_t::init(a, len, args); grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; self->sec4_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); } diff --git a/src/accessor/grib_accessor_class_g1_section4_length.cc b/src/accessor/grib_accessor_class_g1_section4_length.cc index 858ef0d69..1c4f9ccf1 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.cc +++ b/src/accessor/grib_accessor_class_g1_section4_length.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1_section4_length = &_grib_accessor_cl void grib_accessor_class_g1_section4_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_section_length_t::init(a, len, args); grib_accessor_g1_section4_length_t* self = (grib_accessor_g1_section4_length_t*)a; self->total_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); } diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc index ad186dff0..1a7a7bb9e 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.cc +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_g1bitmap = &_grib_accessor_class_g1bitm void grib_accessor_class_g1bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bitmap_t::init(a, len, arg); grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); } diff --git a/src/accessor/grib_accessor_class_g1date.cc b/src/accessor/grib_accessor_class_g1date.cc index de787abba..938628031 100644 --- a/src/accessor/grib_accessor_class_g1date.cc +++ b/src/accessor/grib_accessor_class_g1date.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1date = &_grib_accessor_class_g1date; void grib_accessor_class_g1date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc index 9bf107e94..a75e043c9 100644 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_g1day_of_the_year_date = &_grib_accesso void grib_accessor_class_g1day_of_the_year_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_g1date_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc index c362016b1..fddd7f48e 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly = &_grib_acce void grib_accessor_class_g1end_of_interval_monthly_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc index f0a0e86db..a849125f9 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1forecastmonth = &_grib_accessor_class void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g1monthlydate.cc b/src/accessor/grib_accessor_class_g1monthlydate.cc index 3a184669b..79aba52ed 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.cc +++ b/src/accessor/grib_accessor_class_g1monthlydate.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1monthlydate = &_grib_accessor_class_g void grib_accessor_class_g1monthlydate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g1monthlydate_t* self = (grib_accessor_g1monthlydate_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc index 17d36f908..0623a32d7 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex = & void grib_accessor_class_g1number_of_coded_values_sh_complex_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_g1number_of_coded_values_sh_complex_t* self = (grib_accessor_g1number_of_coded_values_sh_complex_t*)a; self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc index c2d9801f8..50fe992c9 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple = &_ void grib_accessor_class_g1number_of_coded_values_sh_simple_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_g1number_of_coded_values_sh_simple_t* self = (grib_accessor_g1number_of_coded_values_sh_simple_t*)a; self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc index f2444486a..5cf69c863 100644 --- a/src/accessor/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1step_range = &_grib_accessor_class_g1 void grib_accessor_class_g1step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_long_vector_t::init(a, l, c); grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g1verificationdate.cc b/src/accessor/grib_accessor_class_g1verificationdate.cc index 7f91c5b99..b77267427 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.cc +++ b/src/accessor/grib_accessor_class_g1verificationdate.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g1verificationdate = &_grib_accessor_cl void grib_accessor_class_g1verificationdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g1verificationdate_t* self = (grib_accessor_g1verificationdate_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc index 654c0e97a..4d20e0d9a 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.cc +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_a void grib_accessor_class_g2_aerosol_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc index 72d7581e1..d00e90feb 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2_chemical = &_grib_accessor_class_g2_ void grib_accessor_class_g2_chemical_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g2_eps.cc b/src/accessor/grib_accessor_class_g2_eps.cc index 336245721..afdea42bf 100644 --- a/src/accessor/grib_accessor_class_g2_eps.cc +++ b/src/accessor/grib_accessor_class_g2_eps.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2_eps = &_grib_accessor_class_g2_eps; void grib_accessor_class_g2_eps_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index 4de889cfa..8fcc03141 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2_mars_labeling = &_grib_accessor_clas void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_g2bitmap.cc b/src/accessor/grib_accessor_class_g2bitmap.cc index f6ed3f1c8..3996e0c7f 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.cc +++ b/src/accessor/grib_accessor_class_g2bitmap.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_g2bitmap = &_grib_accessor_class_g2bitm void grib_accessor_class_g2bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bitmap_t::init(a, len, arg); grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.cc b/src/accessor/grib_accessor_class_g2bitmap_present.cc index b4dfb5cf5..4e31cb3ba 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.cc +++ b/src/accessor/grib_accessor_class_g2bitmap_present.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2bitmap_present = &_grib_accessor_clas void grib_accessor_class_g2bitmap_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; self->bitmapIndicator = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc index 5b54ccc83..b4ea04eda 100644 --- a/src/accessor/grib_accessor_class_g2date.cc +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -16,6 +16,7 @@ grib_accessor_class_g2date_t _grib_accessor_class_g2date{"g2date"}; grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index 947b867fd..1e0f77c03 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -20,6 +20,7 @@ grib_accessor_class* grib_accessor_class_g2end_step = &_grib_accessor_class_g2en void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc index 74f276c62..c28351a29 100644 --- a/src/accessor/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2grid = &_grib_accessor_class_g2grid; void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g2latlon.cc b/src/accessor/grib_accessor_class_g2latlon.cc index f3d64f1e6..35bb09e7e 100644 --- a/src/accessor/grib_accessor_class_g2latlon.cc +++ b/src/accessor/grib_accessor_class_g2latlon.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latl void grib_accessor_class_g2latlon_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g2level.cc b/src/accessor/grib_accessor_class_g2level.cc index 084b6eba9..37e3c01d6 100644 --- a/src/accessor/grib_accessor_class_g2level.cc +++ b/src/accessor/grib_accessor_class_g2level.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2level = &_grib_accessor_class_g2level void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_g2lon.cc b/src/accessor/grib_accessor_class_g2lon.cc index 1ef641a89..e5b25640f 100644 --- a/src/accessor/grib_accessor_class_g2lon.cc +++ b/src/accessor/grib_accessor_class_g2lon.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; void grib_accessor_class_g2lon_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc index ca7595ace..b53d8c92f 100644 --- a/src/accessor/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -23,6 +23,7 @@ grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2 void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/grib_accessor_class_gaussian_grid_name.cc index 7b27f2c05..b77970ae9 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.cc +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_cl void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_gds_is_present.cc b/src/accessor/grib_accessor_class_gds_is_present.cc index 4939d0949..b2685ee3a 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.cc +++ b/src/accessor/grib_accessor_class_gds_is_present.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_ void grib_accessor_class_gds_is_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc index 368f112d4..0fd8c9e01 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accesso void grib_accessor_class_gds_not_present_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc index 2c714767d..e95c3d39a 100644 --- a/src/accessor/grib_accessor_class_getenv.cc +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_getenv = &_grib_accessor_class_getenv; void grib_accessor_class_getenv_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_ascii_t::init(a, l, args); grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; static char undefined[] = "undefined"; diff --git a/src/accessor/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc index a26b77252..1a86afd55 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_global_gaussian = &_grib_accessor_class void grib_accessor_class_global_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc index 20ca66ae2..d540c927c 100644 --- a/src/accessor/grib_accessor_class_group.cc +++ b/src/accessor/grib_accessor_class_group.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; void grib_accessor_class_group_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; grib_accessor_group_t* self = (grib_accessor_group_t*)a; diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc index 4d24c8835..493cbf0f8 100644 --- a/src/accessor/grib_accessor_class_gts_header.cc +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_gts_header = &_grib_accessor_class_gts_ void grib_accessor_class_gts_header_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); grib_accessor_gts_header_t* self = (grib_accessor_gts_header_t*)a; self->gts_offset = -1; self->gts_length = -1; diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc index d2fd1a8ef..757b1887e 100644 --- a/src/accessor/grib_accessor_class_hash_array.cc +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -19,6 +19,7 @@ grib_accessor_class* grib_accessor_class_hash_array = &_grib_accessor_class_hash #define MAX_HASH_ARRAY_STRING_LENGTH 255 void grib_accessor_class_hash_array_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; a->length = 0; self->key = 0; diff --git a/src/accessor/grib_accessor_class_headers_only.cc b/src/accessor/grib_accessor_class_headers_only.cc index b1c00a529..802fd3f67 100644 --- a/src/accessor/grib_accessor_class_headers_only.cc +++ b/src/accessor/grib_accessor_class_headers_only.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_headers_only = &_grib_accessor_class_he void grib_accessor_class_headers_only_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->length = 0; diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index 65a471eb5..54bdb05c6 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmflo void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_double_t::init(a, len, arg); grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; long count = 0; diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index 1433bd8d5..4d220d18e 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeef void grib_accessor_class_ieeefloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_double_t::init(a, len, arg); grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; long count = 0; self->arg = arg; diff --git a/src/accessor/grib_accessor_class_ifs_param.cc b/src/accessor/grib_accessor_class_ifs_param.cc index 291849046..419eeff91 100644 --- a/src/accessor/grib_accessor_class_ifs_param.cc +++ b/src/accessor/grib_accessor_class_ifs_param.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_ifs_param = &_grib_accessor_class_ifs_p void grib_accessor_class_ifs_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc index 966dc2d66..8e3f1e1c4 100644 --- a/src/accessor/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_julian_date = &_grib_accessor_class_jul void grib_accessor_class_julian_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_julian_day.cc b/src/accessor/grib_accessor_class_julian_day.cc index 4e978c20e..f96213a0e 100644 --- a/src/accessor/grib_accessor_class_julian_day.cc +++ b/src/accessor/grib_accessor_class_julian_day.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_julian_day = &_grib_accessor_class_juli void grib_accessor_class_julian_day_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_ksec1expver.cc b/src/accessor/grib_accessor_class_ksec1expver.cc index dcd3c336e..0b6d94754 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.cc +++ b/src/accessor/grib_accessor_class_ksec1expver.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_ksec1expver = &_grib_accessor_class_kse void grib_accessor_class_ksec1expver_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_ascii_t::init(a, len, arg); a->length = len; Assert(a->length >= 0); } diff --git a/src/accessor/grib_accessor_class_label.cc b/src/accessor/grib_accessor_class_label.cc index 547bdb11a..dfcecd887 100644 --- a/src/accessor/grib_accessor_class_label.cc +++ b/src/accessor/grib_accessor_class_label.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_label = &_grib_accessor_class_label; void grib_accessor_class_label_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; a->length = 0; diff --git a/src/accessor/grib_accessor_class_latitudes.cc b/src/accessor/grib_accessor_class_latitudes.cc index 65fcf65a8..c290c9f8e 100644 --- a/src/accessor/grib_accessor_class_latitudes.cc +++ b/src/accessor/grib_accessor_class_latitudes.cc @@ -43,6 +43,7 @@ int compare_doubles_descending(const void* a, const void* b){ } void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc index 3ecff170a..66e0944ac 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_latlon_increment = &_grib_accessor_clas void grib_accessor_class_latlon_increment_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_latlonvalues.cc b/src/accessor/grib_accessor_class_latlonvalues.cc index ca52ffb6d..42a2b8c31 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.cc +++ b/src/accessor/grib_accessor_class_latlonvalues.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_latlonvalues = &_grib_accessor_class_la void grib_accessor_class_latlonvalues_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_latlonvalues_t* self = (grib_accessor_latlonvalues_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index c216ddb2a..b0633c698 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_local_definition = &_grib_accessor_clas void grib_accessor_class_local_definition_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc index d99b6e860..2ca32aa48 100644 --- a/src/accessor/grib_accessor_class_long_vector.cc +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_long_vector = &_grib_accessor_class_lon void grib_accessor_class_long_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_long_vector_t::init(a, l, c); grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; grib_accessor* va = NULL; grib_accessor_abstract_long_vector_t* v = NULL; diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index 09fd4a4e6..5b2f363b7 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -20,6 +20,7 @@ grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_long static int get_distinct(grib_accessor* a, double** val, long* len); int compare_doubles(const void* a, const void* b); void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc index d480866c5..3275b9d4e 100644 --- a/src/accessor/grib_accessor_class_lookup.cc +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_lookup = &_grib_accessor_class_lookup; void grib_accessor_class_lookup_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_long_t::init(a, len, arg); grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; a->length = 0; self->llength = len; diff --git a/src/accessor/grib_accessor_class_mars_param.cc b/src/accessor/grib_accessor_class_mars_param.cc index 76b55a1fe..99012ca4f 100644 --- a/src/accessor/grib_accessor_class_mars_param.cc +++ b/src/accessor/grib_accessor_class_mars_param.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_mars_param = &_grib_accessor_class_mars void grib_accessor_class_mars_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); int n = 0; grib_accessor_mars_param_t* self = (grib_accessor_mars_param_t*)a; self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc index 05a5120c2..40e198ba3 100644 --- a/src/accessor/grib_accessor_class_mars_step.cc +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_ void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); int n = 0; grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index f19836aea..7d5fd330f 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_md5 = &_grib_accessor_class_md5; void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; char* b = 0; int n = 0; diff --git a/src/accessor/grib_accessor_class_message.cc b/src/accessor/grib_accessor_class_message.cc index 76fcb7be7..c855e067e 100644 --- a/src/accessor/grib_accessor_class_message.cc +++ b/src/accessor/grib_accessor_class_message.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_message = &_grib_accessor_class_message void grib_accessor_class_message_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bytes_t::init(a, len, arg); a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset; diff --git a/src/accessor/grib_accessor_class_message_copy.cc b/src/accessor/grib_accessor_class_message_copy.cc index e32d39355..36490fb89 100644 --- a/src/accessor/grib_accessor_class_message_copy.cc +++ b/src/accessor/grib_accessor_class_message_copy.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_message_copy = &_grib_accessor_class_me void grib_accessor_class_message_copy_t::init(grib_accessor* a, const long length, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, length, args); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } diff --git a/src/accessor/grib_accessor_class_multdouble.cc b/src/accessor/grib_accessor_class_multdouble.cc index 3b8b42bd5..ea5068291 100644 --- a/src/accessor/grib_accessor_class_multdouble.cc +++ b/src/accessor/grib_accessor_class_multdouble.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_mult void grib_accessor_class_multdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_multdouble_t* self = (grib_accessor_multdouble_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_non_alpha.cc b/src/accessor/grib_accessor_class_non_alpha.cc index 05f8ca01c..26401d764 100644 --- a/src/accessor/grib_accessor_class_non_alpha.cc +++ b/src/accessor/grib_accessor_class_non_alpha.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_a void grib_accessor_class_non_alpha_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; size_t i = 0; unsigned char* v; diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.cc b/src/accessor/grib_accessor_class_number_of_coded_values.cc index b77769898..3cbcf7324 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.cc +++ b/src/accessor/grib_accessor_class_number_of_coded_values.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_number_of_coded_values = &_grib_accesso void grib_accessor_class_number_of_coded_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_number_of_coded_values_t* self = (grib_accessor_number_of_coded_values_t*)a; self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc index abd4af786..d1c164fac 100644 --- a/src/accessor/grib_accessor_class_number_of_points.cc +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_clas void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc index c7fd4e4b8..909aa1b3d 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -19,6 +19,7 @@ grib_accessor_class* grib_accessor_class_number_of_points_gaussian = &_grib_acce #define EFDEBUG 0 void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_handle* h = grib_handle_of_accessor(a); grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; diff --git a/src/accessor/grib_accessor_class_number_of_values.cc b/src/accessor/grib_accessor_class_number_of_values.cc index 3472eb68d..1b8e9fd65 100644 --- a/src/accessor/grib_accessor_class_number_of_values.cc +++ b/src/accessor/grib_accessor_class_number_of_values.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_number_of_values = &_grib_accessor_clas void grib_accessor_class_number_of_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_number_of_values_t* self = (grib_accessor_number_of_values_t*)a; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc index ecfe11b22..1605faa21 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing = &_g void grib_accessor_class_number_of_values_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; grib_accessor_number_of_values_data_raw_packing_t* self = (grib_accessor_number_of_values_data_raw_packing_t*)a; diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index 259f97375..a5e4c7a76 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_c void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_octet_number.cc b/src/accessor/grib_accessor_class_octet_number.cc index 4a4c28ad7..bb30500a4 100644 --- a/src/accessor/grib_accessor_class_octet_number.cc +++ b/src/accessor/grib_accessor_class_octet_number.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_octet_number = &_grib_accessor_class_oc void grib_accessor_class_octet_number_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_octet_number_t* self = (grib_accessor_octet_number_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_offset_file.cc b/src/accessor/grib_accessor_class_offset_file.cc index ab9c79a11..9bcb55f99 100644 --- a/src/accessor/grib_accessor_class_offset_file.cc +++ b/src/accessor/grib_accessor_class_offset_file.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_offset_file = &_grib_accessor_class_off void grib_accessor_class_offset_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } diff --git a/src/accessor/grib_accessor_class_offset_values.cc b/src/accessor/grib_accessor_class_offset_values.cc index bbd0139c9..700bdb0f4 100644 --- a/src/accessor/grib_accessor_class_offset_values.cc +++ b/src/accessor/grib_accessor_class_offset_values.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_offset_values = &_grib_accessor_class_o void grib_accessor_class_offset_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_double_t::init(a, l, args); int n = 0; grib_accessor_offset_values_t* self = (grib_accessor_offset_values_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc index 7a4802045..c6d5006c5 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -19,6 +19,7 @@ grib_accessor_class* grib_accessor_class_optimal_step_units = &_grib_accessor_cl void grib_accessor_class_optimal_step_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc index 803491932..17d17746b 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_pack_bufr_values = &_grib_accessor_clas void grib_accessor_class_pack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); char* key; grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); diff --git a/src/accessor/grib_accessor_class_packing_type.cc b/src/accessor/grib_accessor_class_packing_type.cc index 845400a00..8be8c02aa 100644 --- a/src/accessor/grib_accessor_class_packing_type.cc +++ b/src/accessor/grib_accessor_class_packing_type.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_packing_type = &_grib_accessor_class_pa void grib_accessor_class_packing_type_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, l, args); int n = 0; grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_pad.cc b/src/accessor/grib_accessor_class_pad.cc index 10ceda53c..aa6ff538f 100644 --- a/src/accessor/grib_accessor_class_pad.cc +++ b/src/accessor/grib_accessor_class_pad.cc @@ -29,6 +29,7 @@ size_t grib_accessor_class_pad_t::preferred_size(grib_accessor* a, int from_hand void grib_accessor_class_pad_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); grib_accessor_pad_t* self = (grib_accessor_pad_t*)a; self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_padding.cc b/src/accessor/grib_accessor_class_padding.cc index 5a1699124..2dd0c6265 100644 --- a/src/accessor/grib_accessor_class_padding.cc +++ b/src/accessor/grib_accessor_class_padding.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_padding = &_grib_accessor_class_padding void grib_accessor_class_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bytes_t::init(a, len, arg); a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_padto.cc b/src/accessor/grib_accessor_class_padto.cc index 79207c8a9..d162403ed 100644 --- a/src/accessor/grib_accessor_class_padto.cc +++ b/src/accessor/grib_accessor_class_padto.cc @@ -34,6 +34,7 @@ size_t grib_accessor_class_padto_t::preferred_size(grib_accessor* a, int from_ha void grib_accessor_class_padto_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); grib_accessor_padto_t* self = (grib_accessor_padto_t*)a; self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_padtoeven.cc b/src/accessor/grib_accessor_class_padtoeven.cc index 5d3dfba45..ff6aef055 100644 --- a/src/accessor/grib_accessor_class_padtoeven.cc +++ b/src/accessor/grib_accessor_class_padtoeven.cc @@ -39,6 +39,7 @@ size_t grib_accessor_class_padtoeven_t::preferred_size(grib_accessor* a, int fro } void grib_accessor_class_padtoeven_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_padding_t::init(a, len, args); grib_accessor_padtoeven_t* self = (grib_accessor_padtoeven_t*)a; self->section_offset = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); diff --git a/src/accessor/grib_accessor_class_padtomultiple.cc b/src/accessor/grib_accessor_class_padtomultiple.cc index 3f92f8409..88e4c6591 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.cc +++ b/src/accessor/grib_accessor_class_padtomultiple.cc @@ -32,6 +32,7 @@ size_t grib_accessor_class_padtomultiple_t::preferred_size(grib_accessor* a, int } void grib_accessor_class_padtomultiple_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); grib_accessor_padtomultiple_t* self = (grib_accessor_padtomultiple_t*)a; self->begin = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_position.cc b/src/accessor/grib_accessor_class_position.cc index fb00740f3..a8d6201d4 100644 --- a/src/accessor/grib_accessor_class_position.cc +++ b/src/accessor/grib_accessor_class_position.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_positi void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index ab03465fb..da7f7ac35 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_proj_string = &_grib_accessor_class_pro void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc index 310d887e3..1473325a3 100644 --- a/src/accessor/grib_accessor_class_raw.cc +++ b/src/accessor/grib_accessor_class_raw.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); int n = 0; int err = 0; long sectionLength; diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc index 346288ad2..77d917757 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_cl void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc index 8d4f3a1cc..7329acaee 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.cc +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc index a90f31862..76deb2dc5 100644 --- a/src/accessor/grib_accessor_class_scale.cc +++ b/src/accessor/grib_accessor_class_scale.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc index 0496bd1e4..dcb3e8a1a 100644 --- a/src/accessor/grib_accessor_class_scale_values.cc +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_sc void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_double_t::init(a, l, args); int n = 0; grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc index a42496716..5d0075ad3 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -51,6 +51,7 @@ int number_of_bits(size_t x, long* result){ } void grib_accessor_class_second_order_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc index 732435d67..da5380280 100644 --- a/src/accessor/grib_accessor_class_section.cc +++ b/src/accessor/grib_accessor_class_section.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_section = &_grib_accessor_class_section void grib_accessor_class_section_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->sub_section = grib_section_create(grib_handle_of_accessor(a), a); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_section_length.cc b/src/accessor/grib_accessor_class_section_length.cc index 4d78f5f19..3378d60c8 100644 --- a/src/accessor/grib_accessor_class_section_length.cc +++ b/src/accessor/grib_accessor_class_section_length.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_section_length = &_grib_accessor_class_ void grib_accessor_class_section_length_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_unsigned_t::init(a, len, arg); a->parent->aclength = a; a->length = len; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_section_padding.cc b/src/accessor/grib_accessor_class_section_padding.cc index 53cd22c06..d05abcd25 100644 --- a/src/accessor/grib_accessor_class_section_padding.cc +++ b/src/accessor/grib_accessor_class_section_padding.cc @@ -64,6 +64,7 @@ size_t grib_accessor_class_section_padding_t::preferred_size(grib_accessor* a, i } void grib_accessor_class_section_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); grib_accessor_section_padding_t* self = (grib_accessor_section_padding_t*)a; self->preserve = 1; /* This should be a parameter */ a->length = preferred_size(a, 1); diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc index 553deb30f..93344acfc 100644 --- a/src/accessor/grib_accessor_class_section_pointer.cc +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_section_pointer = &_grib_accessor_class void grib_accessor_class_section_pointer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); int n = 0; grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; diff --git a/src/accessor/grib_accessor_class_select_step_template.cc b/src/accessor/grib_accessor_class_select_step_template.cc index fd4578d41..8de2bc24f 100644 --- a/src/accessor/grib_accessor_class_select_step_template.cc +++ b/src/accessor/grib_accessor_class_select_step_template.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_select_step_template = &_grib_accessor_ void grib_accessor_class_select_step_template_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); grib_accessor_select_step_template_t* self = (grib_accessor_select_step_template_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc index 7b3a7dbfb..275ce2ff0 100644 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_sexagesimal2decimal = &_grib_accessor_c void grib_accessor_class_sexagesimal2decimal_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_to_double_t::init(a, len, arg); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index ac2f7757c..84822b421 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed; void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_long_t::init(a, len, arg); grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; long count = 0; diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc index e27f8b53c..c43f2c064 100644 --- a/src/accessor/grib_accessor_class_signed_bits.cc +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -44,6 +44,7 @@ static long compute_byte_count(grib_accessor* a){ } void grib_accessor_class_signed_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; int n = 0; self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc index 41cfddacb..3675b7d15 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.cc +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_ void grib_accessor_class_simple_packing_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_simple_packing_error_t* self = (grib_accessor_simple_packing_error_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc index 7fbeac212..363cafd28 100644 --- a/src/accessor/grib_accessor_class_size.cc +++ b/src/accessor/grib_accessor_class_size.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_size_t* self = (grib_accessor_size_t*)a; self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc index d8a5e267f..d63587cd1 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.cc +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -19,6 +19,7 @@ grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_cl void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); int n = 0; grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc index 709cfef6e..546007ef0 100644 --- a/src/accessor/grib_accessor_class_spd.cc +++ b/src/accessor/grib_accessor_class_spd.cc @@ -45,6 +45,7 @@ static long compute_byte_count(grib_accessor* a){ } void grib_accessor_class_spd_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; int n = 0; self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_spectral_truncation.cc b/src/accessor/grib_accessor_class_spectral_truncation.cc index c10a32d6e..5a51a416c 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.cc +++ b/src/accessor/grib_accessor_class_spectral_truncation.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_spectral_truncation = &_grib_accessor_c void grib_accessor_class_spectral_truncation_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_spectral_truncation_t* self = (grib_accessor_spectral_truncation_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc index 8df2bb732..6c361604e 100644 --- a/src/accessor/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_sprintf = &_grib_accessor_class_sprintf void grib_accessor_class_sprintf_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); grib_accessor_sprintf_t* self = (grib_accessor_sprintf_t*)a; self->args = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc index 9a4eeee20..ea73e69c3 100644 --- a/src/accessor/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_statistics = &_grib_accessor_class_stat void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_statistics_spectral.cc b/src/accessor/grib_accessor_class_statistics_spectral.cc index f8596b84b..57fd16549 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.cc +++ b/src/accessor/grib_accessor_class_statistics_spectral.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_statistics_spectral = &_grib_accessor_c void grib_accessor_class_statistics_spectral_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index 153468565..ea6930f90 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_c void grib_accessor_class_step_human_readable_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc index 4d7cb6cf9..1d6c0afb9 100644 --- a/src/accessor/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -20,6 +20,7 @@ grib_accessor_class* grib_accessor_class_step_in_units = &_grib_accessor_class_s void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_sum.cc b/src/accessor/grib_accessor_class_sum.cc index 5129ade27..5001e6b52 100644 --- a/src/accessor/grib_accessor_class_sum.cc +++ b/src/accessor/grib_accessor_class_sum.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum; void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc index a209e8326..e205b782e 100644 --- a/src/accessor/grib_accessor_class_suppressed.cc +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_supp void grib_accessor_class_suppressed_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; self->args = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc index e31de829f..ead200ca3 100644 --- a/src/accessor/grib_accessor_class_time.cc +++ b/src/accessor/grib_accessor_class_time.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_time_t* self = (grib_accessor_time_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc index 8e9e8a0dc..51e6de3e1 100644 --- a/src/accessor/grib_accessor_class_to_double.cc +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_do void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc index 06f268974..9109ab603 100644 --- a/src/accessor/grib_accessor_class_to_integer.cc +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_i void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc index fd70a7feb..65f7a3647 100644 --- a/src/accessor/grib_accessor_class_to_string.cc +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_st void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc index d5372e3ca..5f1ec2b2b 100644 --- a/src/accessor/grib_accessor_class_transient_darray.cc +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_clas void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long length, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, length, args); grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; self->arr = NULL; self->type = GRIB_TYPE_DOUBLE; diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc index 8f45138fe..8e0e45a6b 100644 --- a/src/accessor/grib_accessor_class_trim.cc +++ b/src/accessor/grib_accessor_class_trim.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_arguments* arg){ + grib_accessor_class_ascii_t::init(a, l, arg); int n = 0; grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; grib_handle* h = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index 5cfa0970d..4339691a9 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accesso void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index f7af4f6fa..984378dc2 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -20,6 +20,7 @@ grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_cl void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); char* key; grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index 953951fd9..14c22d309 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -42,6 +42,7 @@ static long compute_byte_count(grib_accessor* a){ void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; int n = 0; self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc index 5c250964d..8a62f296b 100644 --- a/src/accessor/grib_accessor_class_validity_date.cc +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -17,6 +17,7 @@ grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{"validity grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc index 074bac88e..c74b44035 100644 --- a/src/accessor/grib_accessor_class_validity_time.cc +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_v void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index e7009129c..7def5b09e 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -48,6 +48,7 @@ long init_length(grib_accessor* a){ } void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, v, params); grib_accessor_values_t* self = (grib_accessor_values_t*)a; self->carg = 0; diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index e48ab1aaf..36b252f95 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -18,6 +18,7 @@ grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; int n = 0; diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc index 0834d0f86..68b7196c3 100644 --- a/src/accessor/grib_accessor_class_when.cc +++ b/src/accessor/grib_accessor_class_when.cc @@ -17,6 +17,7 @@ grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; From 05e8b45d424ed6559a7d18482c249147ecdcaa14 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Thu, 4 Apr 2024 12:47:20 +0000 Subject: [PATCH 10/90] 99% tests passed, 4 tests failed out of 337 --- src/accessor/grib_accessor.cc | 12 - src/accessor/grib_accessor.h | 54 +--- src/accessor/grib_accessor_class_bits.cc | 1 - .../grib_accessor_class_bufr_data_array.h | 3 +- .../grib_accessor_class_bufr_data_element.cc | 5 +- .../grib_accessor_class_bufr_data_element.h | 1 + .../grib_accessor_class_bufr_group.cc | 6 +- src/accessor/grib_accessor_class_bufr_group.h | 1 + .../grib_accessor_class_data_apply_bitmap.cc | 80 ------ .../grib_accessor_class_data_apply_bitmap.h | 86 ++++++ ...cessor_class_data_apply_boustrophedonic.cc | 95 ------- ...ccessor_class_data_apply_boustrophedonic.h | 101 +++++++ .../grib_accessor_class_data_ccsds_packing.cc | 152 +---------- .../grib_accessor_class_data_ccsds_packing.h | 158 ++++++++++- ...rib_accessor_class_data_complex_packing.cc | 225 ---------------- ...grib_accessor_class_data_complex_packing.h | 229 +++++++++++++++- ...g1second_order_general_extended_packing.cc | 2 +- ..._g1second_order_general_extended_packing.h | 3 + ...ass_data_g1second_order_general_packing.cc | 105 -------- ...lass_data_g1second_order_general_packing.h | 110 +++++++- ..._data_g1second_order_row_by_row_packing.cc | 167 ------------ ...s_data_g1second_order_row_by_row_packing.h | 173 +++++++++++- ...ib_accessor_class_data_g22order_packing.cc | 250 +---------------- ...rib_accessor_class_data_g22order_packing.h | 254 +++++++++++++++++- ...rib_accessor_class_data_g2simple_packing.h | 8 +- ...ib_accessor_class_data_jpeg2000_packing.cc | 4 +- ...grib_accessor_class_data_simple_packing.cc | 142 ---------- .../grib_accessor_class_data_simple_packing.h | 149 +++++++++- src/accessor/grib_accessor_class_double.cc | 3 +- src/accessor/grib_accessor_class_double.h | 7 +- src/accessor/grib_accessor_class_gen.cc | 151 ++++++----- src/accessor/grib_accessor_class_gen.h | 65 +++++ src/accessor/grib_accessor_class_ibmfloat.cc | 26 -- src/accessor/grib_accessor_class_ibmfloat.h | 31 +++ src/accessor/grib_accessor_class_ieeefloat.cc | 25 -- src/accessor/grib_accessor_class_ieeefloat.h | 31 ++- src/accessor/grib_accessor_class_lookup.h | 2 - src/accessor/grib_accessor_class_section.cc | 9 +- src/accessor/grib_accessor_class_section.h | 9 +- .../grib_accessor_class_smart_table_column.h | 2 - src/accessor/grib_accessor_class_transient.h | 1 - src/accessor/grib_accessor_class_values.h | 3 - src/accessor/grib_accessor_class_variable.h | 1 - src/accessor/grib_accessors_list.cc | 3 - src/accessor/grib_accessors_list.h | 7 +- src/action_class_remove.cc | 8 +- src/action_class_section.cc | 6 +- src/eccodes_prototypes.h | 4 - src/grib_accessor_class.cc | 17 +- src/grib_api_internal.h | 2 +- src/grib_buffer.cc | 4 +- src/grib_dumper_class.cc | 2 +- src/grib_handle.cc | 6 +- src/grib_query.cc | 6 +- src/grib_value.cc | 11 +- tools/bufr_dump.cc | 6 +- tools/gts_compare.cc | 2 +- tools/metar_compare.cc | 2 +- 58 files changed, 1529 insertions(+), 1499 deletions(-) diff --git a/src/accessor/grib_accessor.cc b/src/accessor/grib_accessor.cc index da14833bd..08e50cb78 100644 --- a/src/accessor/grib_accessor.cc +++ b/src/accessor/grib_accessor.cc @@ -28,18 +28,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } -template <> -int grib_accessor::unpack(double* v, size_t* len) -{ - return unpack_double(v, len); -} - -template <> -int grib_accessor::unpack(float* v, size_t* len) -{ - return unpack_float(v, len); -} - int grib_accessor::compare_accessors(grib_accessor* a2, int compare_flags) { int ret = 0; diff --git a/src/accessor/grib_accessor.h b/src/accessor/grib_accessor.h index d79e30111..7220e90e7 100644 --- a/src/accessor/grib_accessor.h +++ b/src/accessor/grib_accessor.h @@ -12,16 +12,13 @@ #include "../grib_api_internal.h" #include "../grib_value.h" -#include class grib_accessor { public: - grib_accessor() : name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), length(0), offset(0), parent(nullptr), next(nullptr), previous(nullptr), cclass(nullptr), flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), set(nullptr), parent_as_attribute(nullptr) {} + grib_accessor() : name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), length(0), offset(0), parent(nullptr), next_(nullptr), previous_(nullptr), cclass(nullptr), flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), set(nullptr), parent_as_attribute(nullptr) {} virtual ~grib_accessor() {} - template int unpack(T* v, size_t* len); - virtual void init_accessor(const long, grib_arguments*) = 0; virtual void dump(grib_dumper* f) = 0; virtual int pack_missing() = 0; @@ -75,8 +72,8 @@ public: long length; /** < byte length of the accessor */ long offset; /** < offset of the data in the buffer */ grib_section* parent; /** < section to which the accessor is attached */ - grib_accessor* next; /** < next accessor in list */ - grib_accessor* previous; /** < next accessor in list */ + grib_accessor* next_; /** < next accessor in list */ + grib_accessor* previous_; /** < next accessor in list */ grib_accessor_class* cclass; /** < behaviour of the accessor */ unsigned long flags; /** < Various flags */ grib_section* sub_section; @@ -93,6 +90,7 @@ public: grib_accessor* parent_as_attribute; }; + class grib_accessor_class { public: @@ -145,47 +143,3 @@ public: }; -template -int unpack_helper(grib_accessor* a, T* v, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - int type = GRIB_TYPE_UNDEFINED; - const char* Tname = type_to_string(*v); - //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - try { - long val = 0; - size_t l = 1; - a->unpack_long(&val, &l); - *v = val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - catch (std::runtime_error& e) { - // TODO(maee): log error - } - - //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - try { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - a->unpack_string(val, &l); - - *v = strtod(val, &last); - if (*last == 0) { /* conversion of string to double worked */ - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - catch (std::runtime_error& e) { - // TODO(maee): log error - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - - return GRIB_NOT_IMPLEMENTED; -} - diff --git a/src/accessor/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc index bb2b8f9ad..d5d1f248c 100644 --- a/src/accessor/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -192,7 +192,6 @@ int grib_accessor_class_bits_t::unpack_string(grib_accessor* a, char* v, size_t* double dval = 0; long lval = 0; size_t llen = 1; - grib_accessor_class* super = NULL; switch (get_native_type(a)) { case GRIB_TYPE_LONG: diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h b/src/accessor/grib_accessor_class_bufr_data_array.h index 386d4ce9c..c6089fa63 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.h +++ b/src/accessor/grib_accessor_class_bufr_data_array.h @@ -12,13 +12,11 @@ #ifndef eccodes_accessor_bufr_data_array_h #define eccodes_accessor_bufr_data_array_h -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_data_array_t : public grib_accessor_gen_t { public: - /* Members defined in bufr_data_array */ const char* bufrDataEncodedName; const char* numberOfSubsetsName; const char* expandedDescriptorsName; @@ -90,4 +88,5 @@ grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); + #endif /* eccodes_accessor_bufr_data_array_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index 584515de2..f479fd236 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,14 +8,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_data_element.h" grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{"bufr_data_element"}; grib_accessor_class* grib_accessor_class_bufr_data_element = &_grib_accessor_class_bufr_data_element; - -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) +grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor* a, grib_section* s, int* err) { grib_accessor* the_clone = NULL; grib_accessor* attribute = NULL; diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h index d75afbe03..6cba5b91c 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.h +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -52,5 +52,6 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; }; #endif /* eccodes_accessor_bufr_data_element_h */ diff --git a/src/accessor/grib_accessor_class_bufr_group.cc b/src/accessor/grib_accessor_class_bufr_group.cc index 73075fcf1..2aae5e583 100644 --- a/src/accessor/grib_accessor_class_bufr_group.cc +++ b/src/accessor/grib_accessor_class_bufr_group.cc @@ -20,16 +20,16 @@ void grib_accessor_class_bufr_group_t::dump(grib_accessor* a, grib_dumper* dumpe grib_dump_section(dumper, a, a->sub_section->block); } -static grib_accessor* next(grib_accessor* a, int explore) +grib_accessor* grib_accessor_class_bufr_group_t::next(grib_accessor* a, int explore) { grib_accessor* next = NULL; if (explore) { next = a->sub_section->block->first; if (!next) - next = a->next; + next = a->next_; } else { - next = a->next; + next = a->next_; } if (!next) { if (a->parent->owner) diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h index 84a202583..3bd71690f 100644 --- a/src/accessor/grib_accessor_class_bufr_group.h +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -27,5 +27,6 @@ public: grib_accessor_class_bufr_group_t(const char* name) : grib_accessor_class_variable_t(name) {} grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; } void dump(grib_accessor*, grib_dumper*) override; + grib_accessor* next(grib_accessor* a, int explore) override; }; #endif /* eccodes_accessor_bufr_group_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index 865d9be74..5529ab36f 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -231,86 +231,6 @@ int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const return err; } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - - size_t i = 0; - size_t j = 0; - size_t n_vals = 0; - long nn = 0; - int err = 0; - size_t coded_n_vals = 0; - T* coded_vals = NULL; - double missing_value = 0; - - err = a->value_count(&nn); n_vals = nn; - if (err) - return err; - - if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) - return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if (coded_n_vals == 0) { - for (i = 0; i < n_vals; i++) - val[i] = missing_value; - - *len = n_vals; - return GRIB_SUCCESS; - } - - if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) - return err; - - coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); - if (coded_vals == NULL) - return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { - grib_context_free(a->context, coded_vals); - return err; - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", - __func__, - a->name, n_vals); - - for (i = 0; i < n_vals; i++) { - if (val[i] == 0) { - val[i] = missing_value; - } - else { - val[i] = coded_vals[j++]; - if (j > coded_n_vals) { - grib_context_free(a->context, coded_vals); - grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_class_data_apply_bitmap [%s]:" - " %s : number of coded values does not match bitmap %ld %ld", - a->name, __func__, coded_n_vals, n_vals); - - return GRIB_ARRAY_TOO_SMALL; - } - } - } - - *len = n_vals; - - grib_context_free(a->context, coded_vals); - return err; -} int grib_accessor_class_data_apply_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h b/src/accessor/grib_accessor_class_data_apply_bitmap.h index 42091e75d..b2516ec4e 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.h @@ -42,5 +42,91 @@ public: int compare(grib_accessor*, grib_accessor*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_data_apply_bitmap_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + + size_t i = 0; + size_t j = 0; + size_t n_vals = 0; + long nn = 0; + int err = 0; + size_t coded_n_vals = 0; + T* coded_vals = NULL; + double missing_value = 0; + + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) + return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if (coded_n_vals == 0) { + for (i = 0; i < n_vals; i++) + val[i] = missing_value; + + *len = n_vals; + return GRIB_SUCCESS; + } + + if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) + return err; + + coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); + if (coded_vals == NULL) + return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { + grib_context_free(a->context, coded_vals); + return err; + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", + __func__, + a->name, n_vals); + + for (i = 0; i < n_vals; i++) { + if (val[i] == 0) { + val[i] = missing_value; + } + else { + val[i] = coded_vals[j++]; + if (j > coded_n_vals) { + grib_context_free(a->context, coded_vals); + grib_context_log(a->context, GRIB_LOG_ERROR, + "grib_accessor_class_data_apply_bitmap [%s]:" + " %s : number of coded values does not match bitmap %ld %ld", + a->name, __func__, coded_n_vals, n_vals); + + return GRIB_ARRAY_TOO_SMALL; + } + } + } + + *len = n_vals; + + grib_context_free(a->context, coded_vals); + return err; +} + #endif /* eccodes_accessor_data_apply_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index 2f1456b39..4222078fe 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -43,101 +43,6 @@ int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* return ret; } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; - - size_t plSize = 0; - long* pl = 0; - double* values = 0; - double* pvalues = 0; - T* pval = 0; - size_t valuesSize = 0; - long i, j; - int ret; - long numberOfPoints, numberOfRows, numberOfColumns; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); - if (ret) - return ret; - - if (*len < numberOfPoints) { - *len = numberOfPoints; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_size(grib_handle_of_accessor(a), self->values, &valuesSize); - if (ret) - return ret; - - /* constant field */ - if (valuesSize == 0) - return 0; - - if (valuesSize != numberOfPoints) { - grib_context_log(a->context, GRIB_LOG_ERROR, "boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)", - self->numberOfPoints, numberOfPoints, self->values, (long)valuesSize); - return GRIB_DECODING_ERROR; - } - - values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * numberOfPoints); - ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->values, values, &valuesSize); - if (ret) - return ret; - - pvalues = values; - pval = val; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfRows, &numberOfRows); - if (ret) - return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfColumns, &numberOfColumns); - if (ret) - return ret; - - if (grib_get_size(grib_handle_of_accessor(a), self->pl, &plSize) == GRIB_SUCCESS) { - Assert(plSize == numberOfRows); - pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); - ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->pl, pl, &plSize); - if (ret) - return ret; - - for (j = 0; j < numberOfRows; j++) { - if (j % 2) { - pval += pl[j]; - for (i = 0; i < pl[j]; i++) - *(pval--) = *(pvalues++); - pval += pl[j]; - } - else { - for (i = 0; i < pl[j]; i++) - *(pval++) = *(pvalues++); - } - } - - grib_context_free(a->context, pl); - } - else { - for (j = 0; j < numberOfRows; j++) { - if (j % 2) { - pval += numberOfColumns - 1; - for (i = 0; i < numberOfColumns; i++) - *(pval--) = *(pvalues++); - pval += numberOfColumns + 1; - } - else { - for (i = 0; i < numberOfColumns; i++) - *(pval++) = *(pvalues++); - } - } - } - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h index a0358195f..9810efe25 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h @@ -40,5 +40,106 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_data_apply_boustrophedonic_t::unpack(grib_accessor* a, T* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; + + size_t plSize = 0; + long* pl = 0; + double* values = 0; + double* pvalues = 0; + T* pval = 0; + size_t valuesSize = 0; + long i, j; + int ret; + long numberOfPoints, numberOfRows, numberOfColumns; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); + if (ret) + return ret; + + if (*len < numberOfPoints) { + *len = numberOfPoints; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_size(grib_handle_of_accessor(a), self->values, &valuesSize); + if (ret) + return ret; + + /* constant field */ + if (valuesSize == 0) + return 0; + + if (valuesSize != numberOfPoints) { + grib_context_log(a->context, GRIB_LOG_ERROR, "boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)", + self->numberOfPoints, numberOfPoints, self->values, (long)valuesSize); + return GRIB_DECODING_ERROR; + } + + values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * numberOfPoints); + ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->values, values, &valuesSize); + if (ret) + return ret; + + pvalues = values; + pval = val; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfRows, &numberOfRows); + if (ret) + return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfColumns, &numberOfColumns); + if (ret) + return ret; + + if (grib_get_size(grib_handle_of_accessor(a), self->pl, &plSize) == GRIB_SUCCESS) { + Assert(plSize == numberOfRows); + pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); + ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->pl, pl, &plSize); + if (ret) + return ret; + + for (j = 0; j < numberOfRows; j++) { + if (j % 2) { + pval += pl[j]; + for (i = 0; i < pl[j]; i++) + *(pval--) = *(pvalues++); + pval += pl[j]; + } + else { + for (i = 0; i < pl[j]; i++) + *(pval++) = *(pvalues++); + } + } + + grib_context_free(a->context, pl); + } + else { + for (j = 0; j < numberOfRows; j++) { + if (j % 2) { + pval += numberOfColumns - 1; + for (i = 0; i < numberOfColumns; i++) + *(pval--) = *(pvalues++); + pval += numberOfColumns + 1; + } + else { + for (i = 0; i < numberOfColumns; i++) + *(pval++) = *(pvalues++); + } + } + } + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + + #endif /* eccodes_accessor_data_apply_boustrophedonic_h */ diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 46af9722f..1feed1323 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_ccsds_packing.h" -#include "grib_scaling.h" grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{"data_ccsds_packing"}; grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing; @@ -44,20 +42,14 @@ int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long #if defined(HAVE_LIBAEC) || defined(HAVE_AEC) -#include - -#ifndef LIBAEC_DLL_EXPORTED - #error Version of libaec appears to be too old. Please upgrade. -#endif - -static bool is_big_endian() +bool grib_accessor_class_data_ccsds_packing_t::is_big_endian() { unsigned char is_big_endian = 0; unsigned short endianess_test = 1; return reinterpret_cast(&endianess_test)[0] == is_big_endian; } -void modify_aec_flags(long* flags){ +void grib_accessor_class_data_ccsds_packing_t::modify_aec_flags(long* flags){ // ECC-1602: Performance improvement: enabled the use of native data types *flags &= ~AEC_DATA_3BYTE; // disable support for 3-bytes per value if (is_big_endian()) @@ -66,7 +58,7 @@ void modify_aec_flags(long* flags){ *flags &= ~AEC_DATA_MSB; // enable little-endian } -static const char* aec_get_error_message(int code) +const char* grib_accessor_class_data_ccsds_packing_t::aec_get_error_message(int code) { if (code == AEC_MEM_ERROR) return "AEC_MEM_ERROR"; if (code == AEC_DATA_ERROR) return "AEC_DATA_ERROR"; @@ -76,7 +68,7 @@ static const char* aec_get_error_message(int code) return "Unknown error code"; } -void print_aec_stream_info(struct aec_stream* strm, const char* func){ +void grib_accessor_class_data_ccsds_packing_t::print_aec_stream_info(struct aec_stream* strm, const char* func){ fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.bits_per_sample=%u\n", func, strm->bits_per_sample); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); @@ -375,142 +367,6 @@ cleanup: return err; } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - int err = GRIB_SUCCESS, i = 0; - size_t buflen = 0; - struct aec_stream strm; - double bscale = 0; - double dscale = 0; - unsigned char* buf = NULL; - size_t n_vals = 0; - size_t size = 0; - unsigned char* decoded = NULL; - // unsigned char* p = NULL; - long nn = 0; - - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - double reference_value = 0; - long bits_per_value = 0; - - long ccsds_flags; - long ccsds_block_size; - long ccsds_rsi; - size_t nbytes; - - self->dirty = 0; - - if ((err = a->value_count(&nn)) != GRIB_SUCCESS) - return err; - n_vals = nn; - - if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - // ECC-477: Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) - return err; - - modify_aec_flags(&ccsds_flags); - - // TODO(masn): This should be called upstream - if (*len < n_vals) - return GRIB_ARRAY_TOO_SMALL; - - // Special case - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - bscale = codes_power(binary_scale_factor, 2); - dscale = codes_power(-decimal_scale_factor, 10); - - buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; - buf += a->byte_offset(); - strm.flags = ccsds_flags; - strm.bits_per_sample = bits_per_value; - strm.block_size = ccsds_block_size; - strm.rsi = ccsds_rsi; - - strm.next_in = buf; - strm.avail_in = buflen; - - nbytes = (bits_per_value + 7) / 8; - if (nbytes == 3) - nbytes = 4; - - size = n_vals * nbytes; - decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); - if (!decoded) { - err = GRIB_OUT_OF_MEMORY; - goto cleanup; - } - strm.next_out = decoded; - strm.avail_out = size; - - if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); - - if ((err = aec_buffer_decode(&strm)) != AEC_OK) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); - err = GRIB_DECODING_ERROR; - goto cleanup; - } - - // ECC-1427: Performance improvement (replaced by ECC-1602) - //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); - - // ECC-1602: Performance improvement - switch (nbytes) { - case 1: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 2: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 4: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - default: - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", - cclass_name, __func__, a->name, bits_per_value); - err = GRIB_INVALID_BPV; - goto cleanup; - } - - *len = n_vals; - -cleanup: - grib_context_buffer_free(a->context, decoded); - return err; -} - int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h index 2d06c6f09..19889e937 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.h +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -12,8 +12,16 @@ #ifndef eccodes_accessor_data_ccsds_packing_h #define eccodes_accessor_data_ccsds_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) +#include +#endif + +#ifndef LIBAEC_DLL_EXPORTED + #error Version of libaec appears to be too old. Please upgrade. +#endif class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t { @@ -31,6 +39,9 @@ public: const char* ccsds_rsi; }; + + +// TODO(maee): if libaec is not available, this class should not be defined class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t { public: @@ -43,5 +54,150 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + template int unpack(grib_accessor*, T*, size_t* ); + void print_aec_stream_info(struct aec_stream*, const char*); + void modify_aec_flags(long*); + const char* aec_get_error_message(int); + bool is_big_endian(); }; + + +template +int grib_accessor_class_data_ccsds_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + int err = GRIB_SUCCESS, i = 0; + size_t buflen = 0; + struct aec_stream strm; + double bscale = 0; + double dscale = 0; + unsigned char* buf = NULL; + size_t n_vals = 0; + size_t size = 0; + unsigned char* decoded = NULL; + // unsigned char* p = NULL; + long nn = 0; + + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + double reference_value = 0; + long bits_per_value = 0; + + long ccsds_flags; + long ccsds_block_size; + long ccsds_rsi; + size_t nbytes; + + self->dirty = 0; + + if ((err = a->value_count(&nn)) != GRIB_SUCCESS) + return err; + n_vals = nn; + + if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + // ECC-477: Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) + return err; + + modify_aec_flags(&ccsds_flags); + + // TODO(masn): This should be called upstream + if (*len < n_vals) + return GRIB_ARRAY_TOO_SMALL; + + // Special case + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + bscale = codes_power(binary_scale_factor, 2); + dscale = codes_power(-decimal_scale_factor, 10); + + buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; + buf += a->byte_offset(); + strm.flags = ccsds_flags; + strm.bits_per_sample = bits_per_value; + strm.block_size = ccsds_block_size; + strm.rsi = ccsds_rsi; + + strm.next_in = buf; + strm.avail_in = buflen; + + nbytes = (bits_per_value + 7) / 8; + if (nbytes == 3) + nbytes = 4; + + size = n_vals * nbytes; + decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); + if (!decoded) { + err = GRIB_OUT_OF_MEMORY; + goto cleanup; + } + strm.next_out = decoded; + strm.avail_out = size; + + if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); + + if ((err = aec_buffer_decode(&strm)) != AEC_OK) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", + cclass_name, __func__, err, aec_get_error_message(err)); + err = GRIB_DECODING_ERROR; + goto cleanup; + } + + // ECC-1427: Performance improvement (replaced by ECC-1602) + //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); + + // ECC-1602: Performance improvement + switch (nbytes) { + case 1: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 2: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 4: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + default: + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", + cclass_name, __func__, a->name, bits_per_value); + err = GRIB_INVALID_BPV; + goto cleanup; + } + + *len = n_vals; + +cleanup: + grib_context_buffer_free(a->context, decoded); + return err; +} + #endif /* eccodes_accessor_data_ccsds_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index 5709b4798..77a3ab822 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -9,18 +9,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_complex_packing.h" -#include "grib_scaling.h" -#include "grib_ieeefloat.h" grib_accessor_class_data_complex_packing_t _grib_accessor_class_data_complex_packing{"data_complex_packing"}; grib_accessor_class* grib_accessor_class_data_complex_packing = &_grib_accessor_class_data_complex_packing; - -typedef unsigned long (*encode_float_proc)(double); -typedef double (*decode_float_proc)(unsigned long); - void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; @@ -544,224 +537,6 @@ int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, co } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - size_t i = 0; - int ret = GRIB_SUCCESS; - long hcount = 0; - long lcount = 0; - long hpos = 0; - long lup = 0; - long mmax = 0; - long n_vals = 0; - T* scals = NULL; - T* pscals = NULL, *pval = NULL; - - T s = 0; - T d = 0; - T laplacianOperator = 0; - unsigned char* buf = NULL; - unsigned char* hres = NULL; - unsigned char* lres = NULL; - unsigned long packed_offset; - long lpos = 0; - - long maxv = 0; - long GRIBEX_sh_bug_present = 0; - long ieee_floats = 0; - - long offsetdata = 0; - long bits_per_value = 0; - T reference_value = 0; - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - - long sub_j = 0; - long sub_k = 0; - long sub_m = 0; - long pen_j = 0; - long pen_k = 0; - long pen_m = 0; - - T operat = 0; - int bytes; - int err = 0; - double tmp; - - decode_float_proc decode_float = NULL; - - err = a->value_count(&n_vals); if (err) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) - return ret; - reference_value = tmp; - if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) - return ret; - - /* ECC-774: don't use grib_get_long_internal */ - if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) - return ret; - laplacianOperator = tmp; - - if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) - return ret; - - self->dirty = 0; - - switch (ieee_floats) { - case 0: - decode_float = grib_long_to_ibm; - bytes = 4; - break; - case 1: - decode_float = grib_long_to_ieee; - bytes = 4; - break; - case 2: - decode_float = grib_long_to_ieee64; - bytes = 8; - break; - default: - return GRIB_NOT_IMPLEMENTED; - } - - if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); - return GRIB_DECODING_ERROR; - } - - buf = (unsigned char*)gh->buffer->data; - - maxv = pen_j + 1; - - buf += a->byte_offset(); hres = buf; - lres = buf; - - if (pen_j == sub_j) { - n_vals = (pen_j + 1) * (pen_j + 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); - if (d) { - for (i = 0; i < n_vals; i++) - val[i] *= d; - } - return 0; - } - - packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); - lpos = 8 * (packed_offset - offsetdata); - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); - if (!scals) return GRIB_OUT_OF_MEMORY; - - scals[0] = 0; - for (i = 1; i < maxv; i++) { - operat = pow(i * (i + 1), laplacianOperator); - if (operat != 0) - scals[i] = (1.0 / operat); - else { - grib_context_log(a->context, GRIB_LOG_WARNING, - "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); - scals[i] = 0; - } - } - - /* - printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); - printf("packed offset=%ld\n",packed_offset); - for(i=0;i 0) { - lup = mmax; - if (sub_k >= 0) { - for (hcount = 0; hcount < sub_k + 1; hcount++) { - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - - if (GRIBEX_sh_bug_present && hcount == sub_k) { - /* bug in ecmwf data, last row (K+1)is scaled but should not */ - val[i - 2] *= scals[lup]; - val[i - 1] *= scals[lup]; - } - lup++; - } - sub_k--; - } - - pscals = scals + lup; - pval = val + i; -#if FAST_BIG_ENDIAN - grib_decode_double_array_complex(lres, - &lpos, bits_per_value, - reference_value, s, pscals, (maxv - hcount) * 2, pval); - i += (maxv - hcount) * 2; -#else - (void)pscals; /* suppress gcc warning */ - (void)pval; /* suppress gcc warning */ - for (lcount = hcount; lcount < maxv; lcount++) { - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - /* These values should always be zero, but as they are packed, - it is necessary to force them back to zero */ - if (mmax == 0) - val[i - 1] = 0; - lup++; - } -#endif - - maxv--; - hcount = 0; - mmax++; - } - - Assert(*len >= i); - *len = i; - - grib_context_free(a->context, scals); - - return ret; -} int grib_accessor_class_data_complex_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h b/src/accessor/grib_accessor_class_data_complex_packing.h index 2c4618865..d588eef38 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.h +++ b/src/accessor/grib_accessor_class_data_complex_packing.h @@ -12,8 +12,12 @@ #ifndef eccodes_accessor_data_complex_packing_h #define eccodes_accessor_data_complex_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" +#include "grib_ieeefloat.h" + +typedef unsigned long (*encode_float_proc)(double); +typedef double (*decode_float_proc)(unsigned long); class grib_accessor_data_complex_packing_t : public grib_accessor_data_simple_packing_t { @@ -41,5 +45,228 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + +template +int grib_accessor_class_data_complex_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + size_t i = 0; + int ret = GRIB_SUCCESS; + long hcount = 0; + long lcount = 0; + long hpos = 0; + long lup = 0; + long mmax = 0; + long n_vals = 0; + T* scals = NULL; + T* pscals = NULL, *pval = NULL; + + T s = 0; + T d = 0; + T laplacianOperator = 0; + unsigned char* buf = NULL; + unsigned char* hres = NULL; + unsigned char* lres = NULL; + unsigned long packed_offset; + long lpos = 0; + + long maxv = 0; + long GRIBEX_sh_bug_present = 0; + long ieee_floats = 0; + + long offsetdata = 0; + long bits_per_value = 0; + T reference_value = 0; + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + + long sub_j = 0; + long sub_k = 0; + long sub_m = 0; + long pen_j = 0; + long pen_k = 0; + long pen_m = 0; + + T operat = 0; + int bytes; + int err = 0; + double tmp; + + decode_float_proc decode_float = NULL; + + err = a->value_count(&n_vals); if (err) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) + return ret; + reference_value = tmp; + if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) + return ret; + + /* ECC-774: don't use grib_get_long_internal */ + if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) + return ret; + laplacianOperator = tmp; + + if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) + return ret; + + self->dirty = 0; + + switch (ieee_floats) { + case 0: + decode_float = grib_long_to_ibm; + bytes = 4; + break; + case 1: + decode_float = grib_long_to_ieee; + bytes = 4; + break; + case 2: + decode_float = grib_long_to_ieee64; + bytes = 8; + break; + default: + return GRIB_NOT_IMPLEMENTED; + } + + if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); + return GRIB_DECODING_ERROR; + } + + buf = (unsigned char*)gh->buffer->data; + + maxv = pen_j + 1; + + buf += a->byte_offset(); hres = buf; + lres = buf; + + if (pen_j == sub_j) { + n_vals = (pen_j + 1) * (pen_j + 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); + if (d) { + for (i = 0; i < n_vals; i++) + val[i] *= d; + } + return 0; + } + + packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); + lpos = 8 * (packed_offset - offsetdata); + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); + if (!scals) return GRIB_OUT_OF_MEMORY; + + scals[0] = 0; + for (i = 1; i < maxv; i++) { + operat = pow(i * (i + 1), laplacianOperator); + if (operat != 0) + scals[i] = (1.0 / operat); + else { + grib_context_log(a->context, GRIB_LOG_WARNING, + "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); + scals[i] = 0; + } + } + + /* + printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); + printf("packed offset=%ld\n",packed_offset); + for(i=0;i 0) { + lup = mmax; + if (sub_k >= 0) { + for (hcount = 0; hcount < sub_k + 1; hcount++) { + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + + if (GRIBEX_sh_bug_present && hcount == sub_k) { + /* bug in ecmwf data, last row (K+1)is scaled but should not */ + val[i - 2] *= scals[lup]; + val[i - 1] *= scals[lup]; + } + lup++; + } + sub_k--; + } + + pscals = scals + lup; + pval = val + i; +#if FAST_BIG_ENDIAN + grib_decode_double_array_complex(lres, + &lpos, bits_per_value, + reference_value, s, pscals, (maxv - hcount) * 2, pval); + i += (maxv - hcount) * 2; +#else + (void)pscals; /* suppress gcc warning */ + (void)pval; /* suppress gcc warning */ + for (lcount = hcount; lcount < maxv; lcount++) { + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + /* These values should always be zero, but as they are packed, + it is necessary to force them back to zero */ + if (mmax == 0) + val[i - 1] = 0; + lup++; + } +#endif + + maxv--; + hcount = 0; + mmax++; + } + + Assert(*len >= i); + *len = i; + + grib_context_free(a->context, scals); + + return ret; +} + #endif /* eccodes_accessor_data_complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index cf47dee15..f95103d73 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -177,7 +177,7 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_d return GRIB_SUCCESS; } -int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len){ grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h index a870edcf6..245217f7f 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -61,5 +61,8 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + int unpack(grib_accessor* a, double*, float*, size_t*); }; #endif /* eccodes_accessor_data_g1second_order_general_extended_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index e709da053..07ecb170a 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1second_order_general_packing.h" -#include "grib_scaling.h" grib_accessor_class_data_g1second_order_general_packing_t _grib_accessor_class_data_g1second_order_general_packing{"data_g1second_order_general_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing = &_grib_accessor_class_data_g1second_order_general_packing; @@ -52,109 +50,6 @@ int grib_accessor_class_data_g1second_order_general_packing_t::value_count(grib_ return err; } -template -int unpack(grib_accessor* a, T* values, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; - int ret = 0; - long numberOfGroups, numberOfSecondOrderPackedValues; - long* groupWidths = 0; - long* firstOrderValues = 0; - long* X = 0; - long pos = 0; - long widthOfFirstOrderValues = 0; - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - long i, n; - double reference_value; - long binary_scale_factor; - long decimal_scale_factor; - double s, d; - long* secondaryBitmap; - long groupLength, j; - size_t groupWidthsSize; - - buf += a->byte_offset(); - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, - &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) - return ret; - - if (*len < (size_t)numberOfSecondOrderPackedValues) - return GRIB_ARRAY_TOO_SMALL; - - groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - groupWidthsSize = numberOfGroups; - if ((ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) - return ret; - - secondaryBitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * (numberOfSecondOrderPackedValues + 1)); - secondaryBitmap[numberOfSecondOrderPackedValues] = 1; - grib_decode_long_array(buf, &pos, 1, numberOfSecondOrderPackedValues, secondaryBitmap); - pos = 8 * ((pos + 7) / 8); - - firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); - pos = 8 * ((pos + 7) / 8); - - X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfSecondOrderPackedValues); - - n = 0; - i = -1; - groupLength = 0; - while (n < numberOfSecondOrderPackedValues) { - if (secondaryBitmap[n]) { - long* p = secondaryBitmap + n + 1; - groupLength = 1; - while (*p != 1) { - groupLength++; - p++; - } - i++; - } - if (groupWidths[i] > 0) { - for (j = 0; j < groupLength; j++) { - X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); - X[n] = firstOrderValues[i] + X[n]; - n++; - } - } - else { - for (j = 0; j < groupLength; j++) { - X[n] = firstOrderValues[i]; - n++; - } - } - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - for (i = 0; i < numberOfSecondOrderPackedValues; i++) { - values[i] = (T)(((X[i] * s) + reference_value) * d); - } - - *len = numberOfSecondOrderPackedValues; - grib_context_free(a->context, secondaryBitmap); - grib_context_free(a->context, firstOrderValues); - grib_context_free(a->context, X); - grib_context_free(a->context, groupWidths); - - return ret; -} - int grib_accessor_class_data_g1second_order_general_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ return unpack(a, values, len); } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h index 5161324f0..837e10097 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h @@ -12,8 +12,8 @@ #ifndef eccodes_accessor_data_g1second_order_general_packing_h #define eccodes_accessor_data_g1second_order_general_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" class grib_accessor_data_g1second_order_general_packing_t : public grib_accessor_data_simple_packing_t { @@ -47,5 +47,113 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_data_g1second_order_general_packing_t::unpack(grib_accessor* a, T* values, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; + int ret = 0; + long numberOfGroups, numberOfSecondOrderPackedValues; + long* groupWidths = 0; + long* firstOrderValues = 0; + long* X = 0; + long pos = 0; + long widthOfFirstOrderValues = 0; + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + long i, n; + double reference_value; + long binary_scale_factor; + long decimal_scale_factor; + double s, d; + long* secondaryBitmap; + long groupLength, j; + size_t groupWidthsSize; + + buf += a->byte_offset(); + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, + &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) + return ret; + + if (*len < (size_t)numberOfSecondOrderPackedValues) + return GRIB_ARRAY_TOO_SMALL; + + groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + groupWidthsSize = numberOfGroups; + if ((ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) + return ret; + + secondaryBitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * (numberOfSecondOrderPackedValues + 1)); + secondaryBitmap[numberOfSecondOrderPackedValues] = 1; + grib_decode_long_array(buf, &pos, 1, numberOfSecondOrderPackedValues, secondaryBitmap); + pos = 8 * ((pos + 7) / 8); + + firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); + pos = 8 * ((pos + 7) / 8); + + X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfSecondOrderPackedValues); + + n = 0; + i = -1; + groupLength = 0; + while (n < numberOfSecondOrderPackedValues) { + if (secondaryBitmap[n]) { + long* p = secondaryBitmap + n + 1; + groupLength = 1; + while (*p != 1) { + groupLength++; + p++; + } + i++; + } + if (groupWidths[i] > 0) { + for (j = 0; j < groupLength; j++) { + X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); + X[n] = firstOrderValues[i] + X[n]; + n++; + } + } + else { + for (j = 0; j < groupLength; j++) { + X[n] = firstOrderValues[i]; + n++; + } + } + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + for (i = 0; i < numberOfSecondOrderPackedValues; i++) { + values[i] = (T)(((X[i] * s) + reference_value) * d); + } + + *len = numberOfSecondOrderPackedValues; + grib_context_free(a->context, secondaryBitmap); + grib_context_free(a->context, firstOrderValues); + grib_context_free(a->context, X); + grib_context_free(a->context, groupWidths); + + return ret; +} + #endif /* eccodes_accessor_data_g1second_order_general_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index 8237cf577..f49a52586 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1second_order_row_by_row_packing.h" -#include "grib_scaling.h" grib_accessor_class_data_g1second_order_row_by_row_packing_t _grib_accessor_class_data_g1second_order_row_by_row_packing{"data_g1second_order_row_by_row_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing = &_grib_accessor_class_data_g1second_order_row_by_row_packing; @@ -116,171 +114,6 @@ int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(gr return ret; } -template -int unpack(grib_accessor* a, T* values, size_t* len){ - grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - int ret = 0; - long numberOfGroups, numberOfSecondOrderPackedValues; - long* groupWidths = 0; - long* firstOrderValues = 0; - long* X = 0; - long numberOfRows, numberOfColumns; - long* numbersPerRow; - long pos = 0; - long widthOfFirstOrderValues = 0; - long jPointsAreConsecutive; - unsigned char* buf = (unsigned char*)gh->buffer->data; - long k, i, j, n, Ni, Nj; - double reference_value; - long binary_scale_factor; - long decimal_scale_factor; - double s, d; - size_t groupWidthsSize = 0; - int bitmapPresent = 0; - size_t plSize = 0; - long* pl = 0; - - buf += a->byte_offset(); - if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->jPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS) - return ret; - - if (self->bitmap) - bitmapPresent = 1; - ret = grib_get_size(gh, self->pl, &plSize); - if (ret == GRIB_SUCCESS) { - pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); - if ((ret = grib_get_long_array(gh, self->pl, pl, &plSize)) != GRIB_SUCCESS) - return ret; - } - - if ((ret = grib_get_long_internal(gh, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->Nj, &Nj)) != GRIB_SUCCESS) - return ret; - if (jPointsAreConsecutive) { - numberOfRows = Ni; - numberOfColumns = Nj; - } - else { - numberOfRows = Nj; - numberOfColumns = Ni; - } - - numbersPerRow = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfRows); - if (!numbersPerRow) - return GRIB_OUT_OF_MEMORY; - if (bitmapPresent) { - long *bitmap, *pbitmap; - size_t numberOfPoints = Ni * Nj; - - if (plSize && pl) { - numberOfPoints = 0; - for (i = 0; i < numberOfRows; i++) - numberOfPoints += pl[i]; - } - bitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfPoints); - pbitmap = bitmap; - grib_get_long_array(gh, self->bitmap, bitmap, &numberOfPoints); - if (plSize && pl) { - for (i = 0; i < numberOfRows; i++) { - for (j = 0; j < pl[i]; j++) { - numbersPerRow[i] += *(bitmap++); - } - } - } - else { - for (i = 0; i < numberOfRows; i++) { - numbersPerRow[i] = 0; - for (j = 0; j < Ni; j++) { - numbersPerRow[i] += *(bitmap++); - } - } - } - - grib_context_free(a->context, pbitmap); - } - else { - if (plSize && pl) { - for (i = 0; i < numberOfRows; i++) - numbersPerRow[i] = pl[i]; - } - else { - for (i = 0; i < numberOfRows; i++) - numbersPerRow[i] = numberOfColumns; - } - } - - if ((ret = grib_get_long_internal(gh, self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->numberOfSecondOrderPackedValues, - &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) - return ret; - - groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - groupWidthsSize = numberOfGroups; - if ((ret = grib_get_long_array_internal(gh, self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) - return ret; - - firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); - pos = 8 * ((pos + 7) / 8); - - n = 0; - for (i = 0; i < numberOfGroups; i++) - n += numbersPerRow[i]; - - if (*len < (size_t)n) - return GRIB_ARRAY_TOO_SMALL; - - X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * n); - n = 0; - k = 0; - for (i = 0; i < numberOfGroups; i++) { - if (groupWidths[i] > 0) { - for (j = 0; j < numbersPerRow[k]; j++) { - X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); - X[n] += firstOrderValues[i]; - n++; - } - } - else { - for (j = 0; j < numbersPerRow[k]; j++) { - X[n] = firstOrderValues[i]; - n++; - } - } - k++; - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - for (i = 0; i < n; i++) { - values[i] = (T)(((X[i] * s) + reference_value) * d); - } - grib_context_free(a->context, firstOrderValues); - grib_context_free(a->context, X); - grib_context_free(a->context, groupWidths); - if (plSize) - grib_context_free(a->context, pl); - if (numbersPerRow) - grib_context_free(a->context, numbersPerRow); - - return ret; -} int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ return unpack(a, values, len); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h index 1e9c27f39..d2db87fe9 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h @@ -12,8 +12,8 @@ #ifndef eccodes_accessor_data_g1second_order_row_by_row_packing_h #define eccodes_accessor_data_g1second_order_row_by_row_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" class grib_accessor_data_g1second_order_row_by_row_packing_t : public grib_accessor_data_simple_packing_t { @@ -47,5 +47,176 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack(grib_accessor* a, T* values, size_t* len){ + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + int ret = 0; + long numberOfGroups, numberOfSecondOrderPackedValues; + long* groupWidths = 0; + long* firstOrderValues = 0; + long* X = 0; + long numberOfRows, numberOfColumns; + long* numbersPerRow; + long pos = 0; + long widthOfFirstOrderValues = 0; + long jPointsAreConsecutive; + unsigned char* buf = (unsigned char*)gh->buffer->data; + long k, i, j, n, Ni, Nj; + double reference_value; + long binary_scale_factor; + long decimal_scale_factor; + double s, d; + size_t groupWidthsSize = 0; + int bitmapPresent = 0; + size_t plSize = 0; + long* pl = 0; + + buf += a->byte_offset(); + if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->jPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS) + return ret; + + if (self->bitmap) + bitmapPresent = 1; + ret = grib_get_size(gh, self->pl, &plSize); + if (ret == GRIB_SUCCESS) { + pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); + if ((ret = grib_get_long_array(gh, self->pl, pl, &plSize)) != GRIB_SUCCESS) + return ret; + } + + if ((ret = grib_get_long_internal(gh, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->Nj, &Nj)) != GRIB_SUCCESS) + return ret; + if (jPointsAreConsecutive) { + numberOfRows = Ni; + numberOfColumns = Nj; + } + else { + numberOfRows = Nj; + numberOfColumns = Ni; + } + + numbersPerRow = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfRows); + if (!numbersPerRow) + return GRIB_OUT_OF_MEMORY; + if (bitmapPresent) { + long *bitmap, *pbitmap; + size_t numberOfPoints = Ni * Nj; + + if (plSize && pl) { + numberOfPoints = 0; + for (i = 0; i < numberOfRows; i++) + numberOfPoints += pl[i]; + } + bitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfPoints); + pbitmap = bitmap; + grib_get_long_array(gh, self->bitmap, bitmap, &numberOfPoints); + if (plSize && pl) { + for (i = 0; i < numberOfRows; i++) { + for (j = 0; j < pl[i]; j++) { + numbersPerRow[i] += *(bitmap++); + } + } + } + else { + for (i = 0; i < numberOfRows; i++) { + numbersPerRow[i] = 0; + for (j = 0; j < Ni; j++) { + numbersPerRow[i] += *(bitmap++); + } + } + } + + grib_context_free(a->context, pbitmap); + } + else { + if (plSize && pl) { + for (i = 0; i < numberOfRows; i++) + numbersPerRow[i] = pl[i]; + } + else { + for (i = 0; i < numberOfRows; i++) + numbersPerRow[i] = numberOfColumns; + } + } + + if ((ret = grib_get_long_internal(gh, self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->numberOfSecondOrderPackedValues, + &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) + return ret; + + groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + groupWidthsSize = numberOfGroups; + if ((ret = grib_get_long_array_internal(gh, self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) + return ret; + + firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); + pos = 8 * ((pos + 7) / 8); + + n = 0; + for (i = 0; i < numberOfGroups; i++) + n += numbersPerRow[i]; + + if (*len < (size_t)n) + return GRIB_ARRAY_TOO_SMALL; + + X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * n); + n = 0; + k = 0; + for (i = 0; i < numberOfGroups; i++) { + if (groupWidths[i] > 0) { + for (j = 0; j < numbersPerRow[k]; j++) { + X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); + X[n] += firstOrderValues[i]; + n++; + } + } + else { + for (j = 0; j < numbersPerRow[k]; j++) { + X[n] = firstOrderValues[i]; + n++; + } + } + k++; + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + for (i = 0; i < n; i++) { + values[i] = (T)(((X[i] * s) + reference_value) * d); + } + grib_context_free(a->context, firstOrderValues); + grib_context_free(a->context, X); + grib_context_free(a->context, groupWidths); + if (plSize) + grib_context_free(a->context, pl); + if (numbersPerRow) + grib_context_free(a->context, numbersPerRow); + + return ret; +} + #endif /* eccodes_accessor_data_g1second_order_row_by_row_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index 6b82e035e..8fe861965 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g22order_packing.h" -#include "../grib_scaling.h" grib_accessor_class_data_g22order_packing_t _grib_accessor_class_data_g22order_packing{"data_g22order_packing"}; grib_accessor_class* grib_accessor_class_data_g22order_packing = &_grib_accessor_class_data_g22order_packing; @@ -299,7 +297,7 @@ int min_max_array(double* data, unsigned int n, double* min, double* max){ // return bms; // } -int post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]){ +int grib_accessor_class_data_g22order_packing_t::post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]){ unsigned long last, penultimate = 0, j = 0; Assert(order > 0); Assert(order <= 3); @@ -359,252 +357,6 @@ int post_process(grib_context* c, long* vals, long len, long order, long bias, c return GRIB_SUCCESS; } -template -int unpack(grib_accessor* a, T* val, const size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating points numbers"); - grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - - size_t i = 0; - size_t j = 0; - long n_vals = 0; - long vcount = 0; - int err = GRIB_SUCCESS; - long* sec_val = NULL; - unsigned char* buf = reinterpret_cast(gh->buffer->data); - unsigned char* buf_ref = NULL; - unsigned char* buf_width = NULL; - unsigned char* buf_length = NULL; - unsigned char* buf_vals = NULL; - - long length_p = 0; - long ref_p = 0; - long width_p = 0; - long vals_p = 0; - long nvals_per_group = 0; - long nbits_per_group_val = 0; - long group_ref_val = 0; - - long bits_per_value = 0; - T binary_s = 0; - T decimal_s = 0; - double reference_value = 0; - - long binary_scale_factor; - long decimal_scale_factor; - long typeOfOriginalFieldValues; - long groupSplittingMethodUsed; - long missingValueManagementUsed; - long primaryMissingValueSubstitute; - long secondaryMissingValueSubstitute; - long numberOfGroupsOfDataValues; - long referenceForGroupWidths; - long numberOfBitsUsedForTheGroupWidths; - long referenceForGroupLengths; - long lengthIncrementForTheGroupLengths; - long trueLengthOfLastGroup; - long numberOfBitsUsedForTheScaledGroupLengths; - long orderOfSpatialDifferencing = 0; - long numberOfOctetsExtraDescriptors = 0; - double missingValue = 0; - - err = a->value_count(&n_vals); if (err) - return err; - - if (*len < static_cast(n_vals)) - return GRIB_ARRAY_TOO_SMALL; - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) - return err; - - // Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) - return err; - - self->dirty = 0; - - sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); - if (!sec_val) return GRIB_OUT_OF_MEMORY; - memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 - - buf_ref = buf + a->offset; - - ref_p = (numberOfGroupsOfDataValues * bits_per_value); - - if (orderOfSpatialDifferencing) - ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); - - buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); - - width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); - buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); - - length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); - buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); - - length_p = 0; - ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; - width_p = 0; - vals_p = 0; - vcount = 0; - - for (i = 0; i < numberOfGroupsOfDataValues; i++) { - group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); - nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); - nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); - - nvals_per_group *= lengthIncrementForTheGroupLengths; - nvals_per_group += referenceForGroupLengths; - nbits_per_group_val += referenceForGroupWidths; - - if (i == numberOfGroupsOfDataValues - 1) - nvals_per_group = trueLengthOfLastGroup; - if (n_vals < vcount + nvals_per_group) { - return GRIB_DECODING_ERROR; - } - - // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); - if (missingValueManagementUsed == 0) { - // No explicit missing values included within data values - for (j = 0; j < nvals_per_group; j++) { - DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); - sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); - } - } - else if (missingValueManagementUsed == 1) { - // Primary missing values included within data values - long maxn = 0; // (1 << bits_per_value) - 1; - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn = (1 << bits_per_value) - 1; - if (group_ref_val == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - if (temp == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - else if (missingValueManagementUsed == 2) { - // Primary and secondary missing values included within data values - long maxn = (1 << bits_per_value) - 1; - long maxn2 = 0; // maxn - 1 - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn2 = maxn - 1; - if (group_ref_val == maxn || group_ref_val == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - maxn2 = maxn - 1; - if (temp == maxn || temp == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - - vcount += nvals_per_group; - } - - if (orderOfSpatialDifferencing) { - long bias = 0; - unsigned long extras[2] = {0, }; - ref_p = 0; - - // For Complex packing, order == 0 - // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) - if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); - return GRIB_INTERNAL_ERROR; - } - - for (i = 0; i < orderOfSpatialDifferencing; i++) { - extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - } - - bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - - post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); - // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); - } - - binary_s = (T)codes_power(binary_scale_factor, 2); - decimal_s = (T)codes_power(-decimal_scale_factor, 10); - - for (i = 0; i < n_vals; i++) { - if (sec_val[i] == LONG_MAX) { - val[i] = (T)missingValue; - } - else { - val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; - } - } - - grib_context_free(a->context, sec_val); - return err; -} int find_nbits(unsigned int i){ #if !defined __GNUC__ || __GNUC__ < 4 diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h b/src/accessor/grib_accessor_class_data_g22order_packing.h index 87d7e3a8d..0b87602a9 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.h +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h @@ -12,8 +12,8 @@ #ifndef eccodes_accessor_data_g22order_packing_h #define eccodes_accessor_data_g22order_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_values.h" +#include "../grib_scaling.h" class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t { @@ -53,5 +53,257 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +private: + int post_process(grib_context*, long*, long, long, long, const unsigned long[2]); + template int unpack(grib_accessor*, T*, const size_t*); }; + + +template +int grib_accessor_class_data_g22order_packing_t::unpack(grib_accessor* a, T* val, const size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating points numbers"); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + + size_t i = 0; + size_t j = 0; + long n_vals = 0; + long vcount = 0; + int err = GRIB_SUCCESS; + long* sec_val = NULL; + unsigned char* buf = reinterpret_cast(gh->buffer->data); + unsigned char* buf_ref = NULL; + unsigned char* buf_width = NULL; + unsigned char* buf_length = NULL; + unsigned char* buf_vals = NULL; + + long length_p = 0; + long ref_p = 0; + long width_p = 0; + long vals_p = 0; + long nvals_per_group = 0; + long nbits_per_group_val = 0; + long group_ref_val = 0; + + long bits_per_value = 0; + T binary_s = 0; + T decimal_s = 0; + double reference_value = 0; + + long binary_scale_factor; + long decimal_scale_factor; + long typeOfOriginalFieldValues; + long groupSplittingMethodUsed; + long missingValueManagementUsed; + long primaryMissingValueSubstitute; + long secondaryMissingValueSubstitute; + long numberOfGroupsOfDataValues; + long referenceForGroupWidths; + long numberOfBitsUsedForTheGroupWidths; + long referenceForGroupLengths; + long lengthIncrementForTheGroupLengths; + long trueLengthOfLastGroup; + long numberOfBitsUsedForTheScaledGroupLengths; + long orderOfSpatialDifferencing = 0; + long numberOfOctetsExtraDescriptors = 0; + double missingValue = 0; + + err = a->value_count(&n_vals); if (err) + return err; + + if (*len < static_cast(n_vals)) + return GRIB_ARRAY_TOO_SMALL; + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) + return err; + + // Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) + return err; + + self->dirty = 0; + + sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); + if (!sec_val) return GRIB_OUT_OF_MEMORY; + memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 + + buf_ref = buf + a->offset; + + ref_p = (numberOfGroupsOfDataValues * bits_per_value); + + if (orderOfSpatialDifferencing) + ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); + + buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); + + width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); + buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); + + length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); + buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); + + length_p = 0; + ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; + width_p = 0; + vals_p = 0; + vcount = 0; + + for (i = 0; i < numberOfGroupsOfDataValues; i++) { + group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); + nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); + nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); + + nvals_per_group *= lengthIncrementForTheGroupLengths; + nvals_per_group += referenceForGroupLengths; + nbits_per_group_val += referenceForGroupWidths; + + if (i == numberOfGroupsOfDataValues - 1) + nvals_per_group = trueLengthOfLastGroup; + if (n_vals < vcount + nvals_per_group) { + return GRIB_DECODING_ERROR; + } + + // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); + if (missingValueManagementUsed == 0) { + // No explicit missing values included within data values + for (j = 0; j < nvals_per_group; j++) { + DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); + sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); + } + } + else if (missingValueManagementUsed == 1) { + // Primary missing values included within data values + long maxn = 0; // (1 << bits_per_value) - 1; + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn = (1 << bits_per_value) - 1; + if (group_ref_val == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + if (temp == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + else if (missingValueManagementUsed == 2) { + // Primary and secondary missing values included within data values + long maxn = (1 << bits_per_value) - 1; + long maxn2 = 0; // maxn - 1 + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn2 = maxn - 1; + if (group_ref_val == maxn || group_ref_val == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + maxn2 = maxn - 1; + if (temp == maxn || temp == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + + vcount += nvals_per_group; + } + + if (orderOfSpatialDifferencing) { + long bias = 0; + unsigned long extras[2] = {0, }; + ref_p = 0; + + // For Complex packing, order == 0 + // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) + if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); + return GRIB_INTERNAL_ERROR; + } + + for (i = 0; i < orderOfSpatialDifferencing; i++) { + extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + } + + bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + + post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); + // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); + } + + binary_s = (T)codes_power(binary_scale_factor, 2); + decimal_s = (T)codes_power(-decimal_scale_factor, 10); + + for (i = 0; i < n_vals; i++) { + if (sec_val[i] == LONG_MAX) { + val[i] = (T)missingValue; + } + else { + val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; + } + } + + grib_context_free(a->context, sec_val); + return err; +} + #endif /* eccodes_accessor_data_g22order_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h b/src/accessor/grib_accessor_class_data_g2simple_packing.h index b3982c40d..4f27ab87c 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.h +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -12,14 +11,9 @@ #ifndef eccodes_accessor_data_g2simple_packing_h #define eccodes_accessor_data_g2simple_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" -class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g2simple_packing */ -}; +class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t {}; class grib_accessor_class_data_g2simple_packing_t : public grib_accessor_class_data_simple_packing_t { diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index 245d2f6a6..73ad0ea64 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -194,7 +194,6 @@ int grib_accessor_class_data_jpeg2000_packing_t::unpack_double(grib_accessor* a, int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; - grib_accessor_class* super = *(a->cclass->super); size_t n_vals = *len; int err = 0; int i; @@ -251,7 +250,8 @@ int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, c for (i = 0; i < n_vals; i++) val[i] += units_bias; - ret = super->pack_double(a, val, len); + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, val, len); + switch (ret) { case GRIB_CONSTANT_FIELD: grib_buffer_replace(a, NULL, 0, 1, 1); diff --git a/src/accessor/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc index a167d0b53..d1032808e 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -9,10 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" -#include "grib_scaling.h" -#include "grib_bits_any_endian_simple.h" #include "grib_optimize_decimal_factor.h" #include #include @@ -159,145 +156,6 @@ int grib_accessor_class_data_simple_packing_t::unpack_double_element_set(grib_ac return GRIB_SUCCESS; } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - - grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - - size_t i = 0; - int err = 0; - size_t n_vals = 0; - long pos = 0; - long count = 0; - - double reference_value; - long binary_scale_factor; - long bits_per_value; - long decimal_scale_factor; - long offsetBeforeData; - double s = 0; - double d = 0; - double units_factor = 1.0; - double units_bias = 0.0; - - err = a->value_count(&count); if (err) - return err; - n_vals = count; - - if (*len < n_vals) { - *len = (long)n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - - /* - * check we don't decode bpv > max(ulong) as it is - * not currently supported by the algorithm - */ - if (bits_per_value > (sizeof(long) * 8)) { - return GRIB_INVALID_BPV; - } - - if (self->units_factor && - (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_factor, 1.0); - } - - if (self->units_bias && - (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_bias, 0.0); - } - - if (n_vals == 0) { - *len = 0; - return GRIB_SUCCESS; - } - - self->dirty = 0; - - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - /* Special case */ - - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - - offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; - - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ - - /* ECC-941 */ - if (!a->context->ieee_packing) { - /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ - long offsetAfterData = 0; - err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); - if (!err && offsetAfterData > offsetBeforeData) { - const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ - if (offsetBeforeData + valuesSize > offsetAfterData) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Data section size mismatch: " - "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", - cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); - return GRIB_DECODING_ERROR; - } - } - // if (offsetBeforeData == offsetAfterData) { - // /* Crazy case: Constant field with bitsPerValue > 0 */ - // for (i = 0; i < n_vals; i++) - // val[i] = reference_value; - // *len = n_vals; - // return GRIB_SUCCESS; - // } - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", - cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); - grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); - - *len = (long)n_vals; - - if (units_factor != 1.0) { - if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] = val[i] * units_factor + units_bias; - } - } else { - for (i = 0; i < n_vals; i++) { - val[i] *= units_factor; - } - } - } - else if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] += units_bias; - } - } - return err; -} int grib_accessor_class_data_simple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h b/src/accessor/grib_accessor_class_data_simple_packing.h index 9187f37eb..92f355b3f 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.h +++ b/src/accessor/grib_accessor_class_data_simple_packing.h @@ -12,8 +12,9 @@ #ifndef eccodes_accessor_data_simple_packing_h #define eccodes_accessor_data_simple_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_values.h" +#include "grib_bits_any_endian_simple.h" +#include "grib_scaling.h" class grib_accessor_data_simple_packing_t : public grib_accessor_values_t { @@ -44,5 +45,151 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_data_simple_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + + size_t i = 0; + int err = 0; + size_t n_vals = 0; + long pos = 0; + long count = 0; + + double reference_value; + long binary_scale_factor; + long bits_per_value; + long decimal_scale_factor; + long offsetBeforeData; + double s = 0; + double d = 0; + double units_factor = 1.0; + double units_bias = 0.0; + + err = a->value_count(&count); if (err) + return err; + n_vals = count; + + if (*len < n_vals) { + *len = (long)n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + + /* + * check we don't decode bpv > max(ulong) as it is + * not currently supported by the algorithm + */ + if (bits_per_value > (sizeof(long) * 8)) { + return GRIB_INVALID_BPV; + } + + if (self->units_factor && + (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_factor, 1.0); + } + + if (self->units_bias && + (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_bias, 0.0); + } + + if (n_vals == 0) { + *len = 0; + return GRIB_SUCCESS; + } + + self->dirty = 0; + + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + /* Special case */ + + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); + + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; + + /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + + /* ECC-941 */ + if (!a->context->ieee_packing) { + /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ + long offsetAfterData = 0; + err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); + if (!err && offsetAfterData > offsetBeforeData) { + const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ + if (offsetBeforeData + valuesSize > offsetAfterData) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Data section size mismatch: " + "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", + cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); + return GRIB_DECODING_ERROR; + } + } + // if (offsetBeforeData == offsetAfterData) { + // /* Crazy case: Constant field with bitsPerValue > 0 */ + // for (i = 0; i < n_vals; i++) + // val[i] = reference_value; + // *len = n_vals; + // return GRIB_SUCCESS; + // } + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", + cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); + grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); + + *len = (long)n_vals; + + if (units_factor != 1.0) { + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] = val[i] * units_factor + units_bias; + } + } else { + for (i = 0; i < n_vals; i++) { + val[i] *= units_factor; + } + } + } + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] += units_bias; + } + } + return err; +} + + #endif /* eccodes_accessor_data_simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_double.cc b/src/accessor/grib_accessor_class_double.cc index 2d8e019a7..0e3b0ea00 100644 --- a/src/accessor/grib_accessor_class_double.cc +++ b/src/accessor/grib_accessor_class_double.cc @@ -101,5 +101,6 @@ int grib_accessor_class_double_t::pack_missing(grib_accessor* a){ double value = GRIB_MISSING_DOUBLE; if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return a->pack_double(&value, &len); return GRIB_VALUE_CANNOT_BE_MISSING; + return a->pack_double(&value, &len); + return GRIB_VALUE_CANNOT_BE_MISSING; } diff --git a/src/accessor/grib_accessor_class_double.h b/src/accessor/grib_accessor_class_double.h index 865bab9bc..1c1e2fb4f 100644 --- a/src/accessor/grib_accessor_class_double.h +++ b/src/accessor/grib_accessor_class_double.h @@ -12,14 +12,9 @@ #ifndef eccodes_accessor_double_h #define eccodes_accessor_double_h -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" -class grib_accessor_double_t : public grib_accessor_gen_t -{ -public: - /* Members defined in double */ -}; +class grib_accessor_double_t : public grib_accessor_gen_t {}; class grib_accessor_class_double_t : public grib_accessor_class_gen_t { diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 08f2f1bba..89debb2ac 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -77,8 +77,7 @@ int grib_accessor_gen_t::unpack_double(double* v, size_t* len) int grib_accessor_gen_t::unpack_float(float* v, size_t* len) { - // return cclass->unpack_float(this, v, len); - return GRIB_NOT_IMPLEMENTED; + return cclass->unpack_float(this, v, len); } int grib_accessor_gen_t::unpack_double_element(size_t i, double* v) @@ -180,7 +179,7 @@ size_t grib_accessor_gen_t::preferred_size(int from_handle) grib_accessor* grib_accessor_gen_t::next_accessor() { - return cclass->next(this, 0); + return cclass->next(this, 1); } void grib_accessor_gen_t::resize(size_t new_size) @@ -192,7 +191,7 @@ void grib_accessor_gen_t::resize(size_t new_size) void grib_accessor_gen_t::destroy(grib_context* ct) { cclass->destroy(ct, this); - delete this; + //delete this; } @@ -223,6 +222,7 @@ void grib_accessor_class_gen_t::init(grib_accessor* a, const long len, grib_argu grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); switch (type) { + // TODO(maee): single-precision case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); a->pack_double(&d, &s_len); @@ -333,40 +333,39 @@ int grib_accessor_class_gen_t::clear(grib_accessor* a) int grib_accessor_class_gen_t::unpack_long(grib_accessor* a, long* v, size_t* len) { + is_overridden_[UNPACK_LONG] = 0; int type = GRIB_TYPE_UNDEFINED; //if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - try { + if (is_overridden_[UNPACK_DOUBLE] == 1) { double val = 0.0; size_t l = 1; a->unpack_double(&val, &l); - if (val == GRIB_MISSING_DOUBLE) - *v = GRIB_MISSING_LONG; - else - *v = (long)val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); - return GRIB_SUCCESS; - } - catch (std::runtime_error& e) { - // TODO(maee): log error + if (is_overridden_[UNPACK_DOUBLE] == 1) { + if (val == GRIB_MISSING_DOUBLE) + *v = GRIB_MISSING_LONG; + else + *v = (long)val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); + return GRIB_SUCCESS; + } } //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - try { + if (is_overridden_[UNPACK_STRING] == 1) { char val[1024]; size_t l = sizeof(val); char* last = NULL; a->unpack_string(val, &l); - *v = strtol(val, &last, 10); + if (is_overridden_[UNPACK_STRING] == 1) { + *v = strtol(val, &last, 10); - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); - return GRIB_SUCCESS; + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); + return GRIB_SUCCESS; + } } } - catch (std::runtime_error& e) { - // TODO(maee): log error - } grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", a->name); if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { @@ -387,35 +386,33 @@ int grib_accessor_class_gen_t::unpack_float(grib_accessor* a, float* v, size_t* int grib_accessor_class_gen_t::unpack_string(grib_accessor* a, char* v, size_t* len) { + is_overridden_[UNPACK_STRING] = 0; + int err = 0; - //if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - try { + if (is_overridden_[UNPACK_DOUBLE] == 1) { double val = 0.0; size_t l = 1; err = a->unpack_double(&val, &l); - if (err) return err; - snprintf(v, 64, "%g", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); - return GRIB_SUCCESS; - } - catch (std::runtime_error& e) { - // TODO(maee): log error + if (is_overridden_[UNPACK_DOUBLE] == 1) { + if (err) return err; + snprintf(v, 64, "%g", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); + return GRIB_SUCCESS; + } } - //if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - try { + if (is_overridden_[UNPACK_LONG] == 1) { long val = 0; size_t l = 1; err = a->unpack_long(&val, &l); - if (err) return err; - snprintf(v, 64, "%ld", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); - return GRIB_SUCCESS; - } - catch (std::runtime_error& e) { - // TODO(maee): log error + if (is_overridden_[UNPACK_LONG] == 1) { + if (err) return err; + snprintf(v, 64, "%ld", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); + return GRIB_SUCCESS; + } } return GRIB_NOT_IMPLEMENTED; @@ -493,9 +490,9 @@ int grib_accessor_class_gen_t::pack_expression(grib_accessor* a, grib_expression int grib_accessor_class_gen_t::pack_long(grib_accessor* a, const long* v, size_t* len) { + is_overridden_[PACK_LONG] = 0; grib_context* c = a->context; - //if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - try { + if (is_overridden_[PACK_DOUBLE]) { double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); if (!val) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double))); @@ -505,19 +502,16 @@ int grib_accessor_class_gen_t::pack_long(grib_accessor* a, const long* v, size_t val[i] = v[i]; int ret = a->pack_double(val, len); grib_context_free(c, val); - return ret; - } - catch (std::runtime_error& e) { - // TODO(maee): log error + if (is_overridden_[PACK_DOUBLE]) { + return ret; + } } + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", a->name); - //if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - try { + if (is_overridden_[PACK_STRING]) { grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); } - catch (std::runtime_error& e) { - // TODO(maee): log error - } + return GRIB_NOT_IMPLEMENTED; } @@ -540,31 +534,37 @@ int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, size_t* len) { + static int check_pack_long = 1; + if (check_pack_long) { + const long v_tmp = 0; + size_t l_tmp = 0; + pack_long(a, &v_tmp, &l_tmp); + check_pack_long = 0; + } + + is_overridden_[PACK_DOUBLE] = 0; + int do_pack_as_long = 0; grib_context* c = a->context; //if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - try { + if (is_overridden_[PACK_LONG]) { do_pack_as_long = 1; } - //else { - catch (std::runtime_error& e) { + else { /* ECC-648: Special case of codetable */ if (strcmp(a->cclass->name, "codetable") == 0) { do_pack_as_long = 1; } - // TODO(maee): replace try-catch logic } + if (do_pack_as_long) { return pack_double_array_as_long(a, v, len); } grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); - //if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - try { + + if (is_overridden_[PACK_STRING]) { grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); } - catch (std::runtime_error& e) { - // TODO(maee): replace try-catch logic - } return GRIB_NOT_IMPLEMENTED; } @@ -589,8 +589,8 @@ int grib_accessor_class_gen_t::pack_string_array(grib_accessor* a, const char** int grib_accessor_class_gen_t::pack_string(grib_accessor* a, const char* v, size_t* len) { - //if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - try { + is_overridden_[PACK_STRING] = 0; + if (is_overridden_[PACK_DOUBLE]) { size_t l = 1; char* endPtr = NULL; /* for error handling */ double val = strtod(v, &endPtr); @@ -600,20 +600,19 @@ int grib_accessor_class_gen_t::pack_string(grib_accessor* a, const char* v, size __func__, v, a->name); return GRIB_WRONG_TYPE; } - return a->pack_double(&val, &l); - } - catch (std::runtime_error& e) { - // TODO(maee): replace try-catch logic + int err = a->pack_double(&val, &l); + if (is_overridden_[PACK_DOUBLE]) { + return err; + } } - //if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - try { + if (is_overridden_[PACK_LONG]) { size_t l = 1; long val = atol(v); - return a->pack_long(&val, &l); - } - catch (std::runtime_error& e) { - // TODO(maee): replace try-catch logic + int err = a->pack_long(&val, &l); + if (is_overridden_[PACK_LONG]) { + return err; + } } grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name); @@ -664,8 +663,8 @@ void grib_accessor_class_gen_t::update_size(grib_accessor* a, size_t s) grib_accessor* grib_accessor_class_gen_t::next(grib_accessor* a, int mod) { grib_accessor* next = NULL; - if (a->next) { - next = a->next; + if (a->next_) { + next = a->next_; } else { if (a->parent->owner) diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h index d68ad4320..2d76361ae 100644 --- a/src/accessor/grib_accessor_class_gen.h +++ b/src/accessor/grib_accessor_class_gen.h @@ -2,6 +2,7 @@ #include "../grib_api_internal.h" #include "grib_accessor.h" +#include class grib_accessor_gen_t : public grib_accessor { void init_accessor(const long, grib_arguments*) override; @@ -90,4 +91,68 @@ public: int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; int clear(grib_accessor*) override; grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; + + template + int unpack_helper(grib_accessor* a, T* v, size_t* len); + +private: + enum { + PACK_DOUBLE, + PACK_FLOAT, + PACK_LONG, + PACK_STRING, + UNPACK_DOUBLE, + UNPACK_FLOAT, + UNPACK_LONG, + UNPACK_STRING, + }; + std::bitset<8> is_overridden_ = 0b11111111; }; + + +template +int grib_accessor_class_gen_t::unpack_helper(grib_accessor* a, T* v, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + int type = GRIB_TYPE_UNDEFINED; + const char* Tname = type_to_string(*v); + + if constexpr (std::is_same_v) { + is_overridden_[UNPACK_FLOAT] = 0; + } + else if constexpr (std::is_same_v) { + is_overridden_[UNPACK_DOUBLE] = 0; + } + + if (is_overridden_[UNPACK_LONG]) { + long val = 0; + size_t l = 1; + a->unpack_long(&val, &l); + if (is_overridden_[UNPACK_LONG]) { + *v = val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + + if (is_overridden_[UNPACK_STRING]) { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + if (is_overridden_[UNPACK_STRING]) { + *v = strtod(val, &last); + if (*last == 0) { /* conversion of string to double worked */ + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index 54bdb05c6..65c59ba0f 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -26,32 +26,6 @@ void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib Assert(a->length >= 0); } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - unsigned long rlen = 0; - long count = 0; - int err = 0; - unsigned long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&count); if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} int grib_accessor_class_ibmfloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); diff --git a/src/accessor/grib_accessor_class_ibmfloat.h b/src/accessor/grib_accessor_class_ibmfloat.h index 4a82dda63..d98864516 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.h +++ b/src/accessor/grib_accessor_class_ibmfloat.h @@ -36,5 +36,36 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; int nearest_smaller_value(grib_accessor*, double, double*) override; +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_ibmfloat_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + unsigned long rlen = 0; + long count = 0; + int err = 0; + unsigned long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&count); if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + #endif /* eccodes_accessor_ibmfloat_h */ diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index 4d220d18e..e15091925 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -81,31 +81,6 @@ int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* return ret; } -template -int unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long rlen = 0; - int err = 0; - long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&rlen); if (err) - return err; - - if (*len < (size_t)rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - int grib_accessor_class_ieeefloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ return unpack(a, val, len); } diff --git a/src/accessor/grib_accessor_class_ieeefloat.h b/src/accessor/grib_accessor_class_ieeefloat.h index b59357d72..100b2ad6a 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.h +++ b/src/accessor/grib_accessor_class_ieeefloat.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_ieeefloat_h #define eccodes_accessor_ieeefloat_h -#include "../grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_ieeefloat_t : public grib_accessor_double_t @@ -33,5 +32,35 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); }; + + +template +int grib_accessor_class_ieeefloat_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + long rlen = 0; + int err = 0; + long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&rlen); if (err) + return err; + + if (*len < (size_t)rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + #endif /* eccodes_accessor_ieeefloat_h */ diff --git a/src/accessor/grib_accessor_class_lookup.h b/src/accessor/grib_accessor_class_lookup.h index 4237d4517..1fba42fe5 100644 --- a/src/accessor/grib_accessor_class_lookup.h +++ b/src/accessor/grib_accessor_class_lookup.h @@ -12,13 +12,11 @@ #ifndef eccodes_accessor_lookup_h #define eccodes_accessor_lookup_h -#include "../grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_lookup_t : public grib_accessor_long_t { public: - /* Members defined in lookup */ long llength; long loffset; grib_expression* real_name; diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc index da5380280..b859639b0 100644 --- a/src/accessor/grib_accessor_class_section.cc +++ b/src/accessor/grib_accessor_class_section.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_section.h" grib_accessor_class_section_t _grib_accessor_class_section{"section"}; @@ -53,7 +52,7 @@ int grib_accessor_class_section_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_SECTION; } -static grib_section* sub_section(grib_accessor* a) +grib_section* grib_accessor_class_section_t::sub_section(grib_accessor* a) { return a->sub_section; } @@ -77,16 +76,16 @@ void grib_accessor_class_section_t::update_size(grib_accessor* a, size_t length) Assert(a->length >= 0); } -static grib_accessor* next(grib_accessor* a, int explore) +grib_accessor* grib_accessor_class_section_t::next(grib_accessor* a, int explore) { grib_accessor* next = NULL; if (explore) { next = a->sub_section->block->first; if (!next) - next = a->next; + next = a->next_; } else { - next = a->next; + next = a->next_; } if (!next) { if (a->parent->owner) diff --git a/src/accessor/grib_accessor_class_section.h b/src/accessor/grib_accessor_class_section.h index b755b8b27..b1905b182 100644 --- a/src/accessor/grib_accessor_class_section.h +++ b/src/accessor/grib_accessor_class_section.h @@ -12,14 +12,9 @@ #ifndef eccodes_accessor_section_h #define eccodes_accessor_section_h -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" -class grib_accessor_section_t : public grib_accessor_gen_t -{ -public: - /* Members defined in section */ -}; +class grib_accessor_section_t : public grib_accessor_gen_t {}; class grib_accessor_class_section_t : public grib_accessor_class_gen_t { @@ -33,5 +28,7 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; + grib_section* sub_section(grib_accessor*) override; + grib_accessor* next(grib_accessor*, int) override; }; #endif /* eccodes_accessor_section_h */ diff --git a/src/accessor/grib_accessor_class_smart_table_column.h b/src/accessor/grib_accessor_class_smart_table_column.h index 0c24454bc..f5787f780 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.h +++ b/src/accessor/grib_accessor_class_smart_table_column.h @@ -12,13 +12,11 @@ #ifndef eccodes_accessor_smart_table_column_h #define eccodes_accessor_smart_table_column_h -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_smart_table_column_t : public grib_accessor_gen_t { public: - /* Members defined in smart_table_column */ const char* smartTable; int index; }; diff --git a/src/accessor/grib_accessor_class_transient.h b/src/accessor/grib_accessor_class_transient.h index fa6771ecd..e330ad686 100644 --- a/src/accessor/grib_accessor_class_transient.h +++ b/src/accessor/grib_accessor_class_transient.h @@ -10,7 +10,6 @@ #pragma once -#include "../grib_api_internal.h" #include "grib_accessor_class_variable.h" class grib_accessor_transient_t : public grib_accessor_variable_t { diff --git a/src/accessor/grib_accessor_class_values.h b/src/accessor/grib_accessor_class_values.h index a77a5e89c..c7cbf54e7 100644 --- a/src/accessor/grib_accessor_class_values.h +++ b/src/accessor/grib_accessor_class_values.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -12,13 +11,11 @@ #ifndef eccodes_accessor_values_h #define eccodes_accessor_values_h -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_values_t : public grib_accessor_gen_t { public: - /* Members defined in values */ int carg; const char* seclen; const char* offsetdata; diff --git a/src/accessor/grib_accessor_class_variable.h b/src/accessor/grib_accessor_class_variable.h index 91c7f815d..90ff71238 100644 --- a/src/accessor/grib_accessor_class_variable.h +++ b/src/accessor/grib_accessor_class_variable.h @@ -10,7 +10,6 @@ #pragma once -#include "../grib_api_internal.h" #include "grib_accessor.h" #include "grib_accessor_class_gen.h" diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc index 29d8b1f0d..935516964 100644 --- a/src/accessor/grib_accessors_list.cc +++ b/src/accessor/grib_accessors_list.cc @@ -15,9 +15,6 @@ void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) { } } - - - int grib_accessors_list::value_count(size_t* count) { long lcount = 0; diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h index f088414f5..0ec5798a4 100644 --- a/src/accessor/grib_accessors_list.h +++ b/src/accessor/grib_accessors_list.h @@ -2,7 +2,7 @@ #include "grib_accessor.h" -struct grib_accessors_list +class grib_accessors_list { public: grib_accessors_list(); @@ -23,6 +23,5 @@ public: grib_accessors_list* last_; }; -//grib_accessors_list* grib_accessors_list_create(grib_context* c); -//void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); - +grib_accessors_list* grib_accessors_list_create(grib_context* c); +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index a334a79f1..eff91cdce 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -94,7 +94,7 @@ static void remove_accessor(grib_accessor* a) grib_section* s = NULL; int id; - if (!a || !a->previous) + if (!a || !a->previous_) return; s = a->parent; @@ -103,12 +103,12 @@ static void remove_accessor(grib_accessor* a) grib_handle_of_accessor(a)->accessors[id] = NULL; } - if (a->next) - a->previous->next = a->next; + if (a->next_) + a->previous_->next_ = a->next_; else return; - a->next->previous = a->previous; + a->next_->previous_ = a->previous_; a->destroy(s->h->context); } diff --git a/src/action_class_section.cc b/src/action_class_section.cc index 9dda3dc30..e8f8b0a39 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -171,7 +171,8 @@ static int notify_change(grib_action* act, grib_accessor* notified, /*err = GRIB_SUCCESS;*/ } else { - grib_handle_delete(tmp_handle); + // TODO(maee): segmentation fault + //grib_handle_delete(tmp_handle); h->kid = NULL; /* ECC-1314: must set to NULL for grib_handle_delete(h) to work */ return err; } @@ -203,7 +204,8 @@ static int notify_change(grib_action* act, grib_accessor* notified, Assert(tmp_handle->dependencies == NULL); /* printf("grib_handle_delete %p\n",(void*)tmp_handle); */ - grib_handle_delete(tmp_handle); + //TODO(maee): causes segmentation fault + //grib_handle_delete(tmp_handle); h->use_trie = 1; h->trie_invalid = 1; diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index cf7673e19..5e0c68cd0 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -106,10 +106,6 @@ grib_action* grib_action_create_modify(grib_context* context, const char* name, grib_action* grib_action_create_transient_darray(grib_context* context, const char* name, grib_darray* darray, int flags); /* grib_accessor.cc*/ -grib_accessors_list* grib_accessors_list_create(grib_context* c); -void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank); -grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al); -void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); /* grib_concept.cc*/ grib_concept_value* grib_concept_value_new(grib_context* c, const char* name, grib_concept_condition* conditions); diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc index 63c2fede6..4120fb5bd 100644 --- a/src/grib_accessor_class.cc +++ b/src/grib_accessor_class.cc @@ -11,6 +11,7 @@ #include "grib_api_internal.h" #include "grib_accessor_classes_hash.cc" +#include /* grib level */ @@ -150,8 +151,8 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->creator = creator; a->context = p->h->context; a->h = NULL; - a->next = NULL; - a->previous = NULL; + a->next_ = NULL; + a->previous_ = NULL; a->parent = p; a->length = 0; a->offset = 0; @@ -240,8 +241,8 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l) if (!l->first) l->first = l->last = a; else { - l->last->next = a; - a->previous = l->last; + l->last->next_ = a; + a->previous_ = l->last; } l->last = a; @@ -270,13 +271,11 @@ void grib_section_post_init(grib_section* s) while (a) { grib_accessor_class* c = a->cclass; - //if (c->post_init) - // c->post_init(a); c->post_init(a); if (a->sub_section) grib_section_post_init(a->sub_section); - a = a->next; + a = a->next_; } } @@ -308,7 +307,7 @@ int grib_section_adjust_sizes(grib_section* s, int update, int depth) } length += l; offset += l; - a = a->next; + a = a->next_; } if (s) { @@ -402,7 +401,7 @@ grib_accessor* find_paddings(grib_section* s) if (a->preferred_size(0) != a->length) return a; - a = a->next; + a = a->next_; } return NULL; diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 0cff18a9b..2b28ad91c 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -739,7 +739,7 @@ struct grib_handle grib_context* context; /** < context attached to this handle */ grib_buffer* buffer; /** < buffer attached to the handle */ grib_section* root; /** the root section*/ - grib_section* rules; /** the rules section*/ + //grib_section* rules; [>* the rules section<] grib_dependency* dependencies; /** List of dependencies */ grib_handle* main; /** Used during reparsing */ grib_handle* kid; /** Used during reparsing */ diff --git a/src/grib_buffer.cc b/src/grib_buffer.cc index 89313429d..cb313141c 100644 --- a/src/grib_buffer.cc +++ b/src/grib_buffer.cc @@ -123,14 +123,14 @@ static void update_offsets(grib_accessor* a, long len) grib_context_log(a->context, GRIB_LOG_DEBUG, "::::: grib_buffer : accessor %s is moving by %d bytes to %ld", a->name, len, a->offset); if (s) update_offsets(s->block->first, len); - a = a->next; + a = a->next_; } } static void update_offsets_after(grib_accessor* a, long len) { while (a) { - update_offsets(a->next, len); + update_offsets(a->next_, len); a = a->parent->owner; } } diff --git a/src/grib_dumper_class.cc b/src/grib_dumper_class.cc index eca1610b0..4af527151 100644 --- a/src/grib_dumper_class.cc +++ b/src/grib_dumper_class.cc @@ -53,7 +53,7 @@ void grib_dump_accessors_block(grib_dumper* dumper, grib_block_of_accessors* blo grib_accessor* a = block->first; while (a) { a->dump(dumper); - a = a->next; + a = a->next_; } } diff --git a/src/grib_handle.cc b/src/grib_handle.cc index 08b6f7eaa..faaefbebe 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -54,7 +54,7 @@ static void update_sections(grib_section* s, grib_handle* h, long offset) a->offset += offset; /* update_sections ( grib_get_sub_section ( a ),h,offset ); */ update_sections(a->sub_section, h, offset); - a = a->next; + a = a->next_; } } @@ -74,7 +74,7 @@ void grib_swap_sections(grib_section* the_old, grib_section* the_new) a = the_old->block->first; while (a) { a->parent = the_old; - a = a->next; + a = a->next_; } update_sections(the_old, the_old->h, the_old->owner->offset); @@ -94,7 +94,7 @@ void grib_empty_section(grib_context* c, grib_section* b) current = b->block->first; while (current) { - grib_accessor* next = current->next; + grib_accessor* next = current->next_; if (current->sub_section) { grib_section_delete(c, current->sub_section); current->sub_section = 0; diff --git a/src/grib_query.cc b/src/grib_query.cc index 7b2ecb08a..29e3e1322 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -64,7 +64,7 @@ static grib_accessor* search(grib_section* s, const char* name, const char* name if ((b = search(sub, name, name_space)) != NULL) match = b; - a = a->next; + a = a->next_; } return match; @@ -95,7 +95,7 @@ static void rebuild_hash_keys(grib_handle* h, grib_section* s) i++; } rebuild_hash_keys(h, sub); - a = a->next; + a = a->next_; } } @@ -229,7 +229,7 @@ static grib_accessor* _search_by_rank(grib_accessor* a,const char* name,long ran if (r==rank) return al->accessor; r++; } - al=al->next; + al=al->next_; } return NULL; diff --git a/src/grib_value.cc b/src/grib_value.cc index 2913d5849..13efc00e4 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -1274,13 +1274,18 @@ int grib_get_native_type(const grib_handle* h, const char* name, int* type) template static int _grib_get_array_internal(const grib_handle* h, grib_accessor* a, T* val, size_t buffer_len, size_t* decoded_length) { - //static_assert(std::is_floating_point::value, "Requires floating point numbers"); + static_assert(std::is_floating_point::value, "Requires floating point numbers"); if (a) { int err = _grib_get_array_internal(h, a->same, val, buffer_len, decoded_length); if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = a->unpack(val + *decoded_length, &len); + if constexpr (std::is_same::value) { + err = a->unpack_double(val + *decoded_length, &len); + } + else if constexpr (std::is_same::value) { + err = a->unpack_float(val + *decoded_length, &len); + } *decoded_length += len; } @@ -1321,7 +1326,7 @@ int grib_get_double_array(const grib_handle* h, const char* name, double* val, s if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return a->unpack(val, length); + return a->unpack_double(val, length); } else { *length = 0; diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index 679ec79a3..6c31ce76e 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -9,6 +9,7 @@ */ #include "grib_tools.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" grib_option grib_options[] = { /* {id, args, help}, on, command_line, value*/ @@ -475,10 +476,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } } a = grib_find_accessor(h, "numericValues"); - // ===== TODO(maee): Reanable this ==== - //al = accessor_bufr_data_array_get_dataAccessors(a); - throw std::runtime_error("Functionality disabled"); - // ===== TODO(maee): Reanable this ==== + al = accessor_bufr_data_array_get_dataAccessors(a); options->dump_flags = GRIB_DUMP_FLAG_ALL_ATTRIBUTES; codes_dump_bufr_flat(al, h, stdout, options->dump_mode, options->dump_flags, 0); break; diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index 2f570c61c..0bdd6751b 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -609,7 +609,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*err)++; write_messages(h1, h2); ret = 1; } diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index 258a09024..b201c8f6e 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -772,7 +772,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*err)++; write_messages(h1, h2); ret = 1; } From 8a7f8c8ef44118d867bd9ad907fe8b5d928fd175 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 4 Apr 2024 16:10:06 +0100 Subject: [PATCH 11/90] Fix compilation --- src/accessor/grib_accessor_class_data_png_packing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_data_png_packing.h b/src/accessor/grib_accessor_class_data_png_packing.h index d8c9211a3..1bd29fda4 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.h +++ b/src/accessor/grib_accessor_class_data_png_packing.h @@ -12,8 +12,8 @@ #ifndef eccodes_accessor_data_png_packing_h #define eccodes_accessor_data_png_packing_h -#include "../grib_api_internal.h" #include "grib_accessor_class_values.h" +#include "grib_scaling.h" class grib_accessor_data_png_packing_t : public grib_accessor_values_t { From 1184bcca24a580baec277d92d5933e0c74c99d5a Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 4 Apr 2024 16:21:11 +0100 Subject: [PATCH 12/90] Make local functions static --- .../grib_accessor_class_proj_string.cc | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index da7f7ac35..d55b277e0 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -42,7 +42,7 @@ struct proj_mapping typedef struct proj_mapping proj_mapping; // This should only be called for GRID POINT data (not spherical harmonics etc) -int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ +static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ int err = 0; if (grib_is_earth_oblate(h)) { if ((err = grib_get_double_internal(h, "earthMinorAxisInMetres", pMinor)) != GRIB_SUCCESS) return err; @@ -57,7 +57,7 @@ int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ } // Caller must have allocated enough space in the 'result' argument -int get_earth_shape(grib_handle* h, char* result){ +static int get_earth_shape(grib_handle* h, char* result){ int err = 0; double major = 0, minor = 0; if ((err = get_major_minor_axes(h, &major, &minor)) != GRIB_SUCCESS) @@ -69,7 +69,7 @@ int get_earth_shape(grib_handle* h, char* result){ return err; } -int proj_space_view(grib_handle* h, char* result){ +static int proj_space_view(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; // int err = 0; // char shape[128] = {0,}; @@ -85,17 +85,17 @@ int proj_space_view(grib_handle* h, char* result){ // return err; } -int proj_albers(grib_handle* h, char* result){ +static int proj_albers(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -int proj_transverse_mercator(grib_handle* h, char* result){ +static int proj_transverse_mercator(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result){ +static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result){ return GRIB_NOT_IMPLEMENTED; } -int proj_lambert_conformal(grib_handle* h, char* result){ +static int proj_lambert_conformal(grib_handle* h, char* result){ int err = 0; char shape[128] = {0,}; double LoVInDegrees = 0, LaDInDegrees = 0, Latin1InDegrees = 0, Latin2InDegrees = 0; @@ -115,7 +115,7 @@ int proj_lambert_conformal(grib_handle* h, char* result){ return err; } -int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ +static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ int err = 0; char shape[128] = {0,}; double standardParallel = 0, centralLongitude = 0; @@ -131,7 +131,7 @@ int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ return err; } -int proj_polar_stereographic(grib_handle* h, char* result){ +static int proj_polar_stereographic(grib_handle* h, char* result){ int err = 0; double centralLongitude = 0, centralLatitude = 0; int has_northPole = 0; @@ -154,7 +154,7 @@ int proj_polar_stereographic(grib_handle* h, char* result){ // ECC-1552: This is for regular_ll, regular_gg, reduced_ll, reduced_gg // These are not 'projected' grids! -int proj_unprojected(grib_handle* h, char* result){ +static int proj_unprojected(grib_handle* h, char* result){ int err = 0; //char shape[128] = {0,}; //if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; @@ -164,7 +164,7 @@ int proj_unprojected(grib_handle* h, char* result){ return err; } -int proj_mercator(grib_handle* h, char* result){ +static int proj_mercator(grib_handle* h, char* result){ int err = 0; double LaDInDegrees = 0; char shape[128] = {0,}; From 77d358a4d04742d28abf50f2403a2d794bf3e6c8 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 9 Apr 2024 11:46:43 +0000 Subject: [PATCH 13/90] Fix memory issue --- .../grib_accessor_class_bufrdc_expanded_descriptors.cc | 1 + .../grib_accessor_class_g1end_of_interval_monthly.cc | 1 + src/accessor/grib_accessor_class_g1step_range.cc | 1 + src/accessor/grib_accessor_class_gen.cc | 5 +---- src/accessor/grib_accessor_class_hash_array.cc | 1 + src/accessor/grib_accessor_class_md5.cc | 1 + src/accessor/grib_accessor_class_pack_bufr_values.cc | 1 + src/accessor/grib_accessor_class_section.cc | 1 + src/accessor/grib_accessor_class_smart_table.cc | 2 ++ src/accessor/grib_accessor_class_smart_table_column.cc | 2 ++ src/accessor/grib_accessor_class_statistics.cc | 1 + src/accessor/grib_accessor_class_statistics_spectral.cc | 1 + src/accessor/grib_accessor_class_transient_darray.cc | 1 + src/accessor/grib_accessor_class_unpack_bufr_values.cc | 1 + src/accessor/grib_accessor_class_unsigned.cc | 2 ++ src/accessor/grib_accessor_class_variable.cc | 2 ++ src/action_class_section.cc | 4 ++-- 17 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc index 73282fcea..9aa38faa4 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -96,4 +96,5 @@ int grib_accessor_class_bufrdc_expanded_descriptors_t::value_count(grib_accessor return descriptors->value_count(rlen);} void grib_accessor_class_bufrdc_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_class_long_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc index fddd7f48e..c280f26b3 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -95,6 +95,7 @@ int grib_accessor_class_g1end_of_interval_monthly_t::value_count(grib_accessor* void grib_accessor_class_g1end_of_interval_monthly_t::destroy(grib_context* c, grib_accessor* a){ grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); } int grib_accessor_class_g1end_of_interval_monthly_t::compare(grib_accessor* a, grib_accessor* b){ diff --git a/src/accessor/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc index 5cf69c863..8ad1b3e12 100644 --- a/src/accessor/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -635,4 +635,5 @@ int grib_accessor_class_g1step_range_t::get_native_type(grib_accessor* a){ void grib_accessor_class_g1step_range_t::destroy(grib_context* c, grib_accessor* a){ grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_long_vector_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 89debb2ac..a27e1e9ca 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -335,7 +335,6 @@ int grib_accessor_class_gen_t::unpack_long(grib_accessor* a, long* v, size_t* le { is_overridden_[UNPACK_LONG] = 0; int type = GRIB_TYPE_UNDEFINED; - //if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { if (is_overridden_[UNPACK_DOUBLE] == 1) { double val = 0.0; size_t l = 1; @@ -350,7 +349,6 @@ int grib_accessor_class_gen_t::unpack_long(grib_accessor* a, long* v, size_t* le } } - //if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { if (is_overridden_[UNPACK_STRING] == 1) { char val[1024]; size_t l = sizeof(val); @@ -536,7 +534,7 @@ int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, si { static int check_pack_long = 1; if (check_pack_long) { - const long v_tmp = 0; + const long v_tmp = (long) (*v); size_t l_tmp = 0; pack_long(a, &v_tmp, &l_tmp); check_pack_long = 0; @@ -546,7 +544,6 @@ int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, si int do_pack_as_long = 0; grib_context* c = a->context; - //if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { if (is_overridden_[PACK_LONG]) { do_pack_as_long = 1; } diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc index 757b1887e..d4f005710 100644 --- a/src/accessor/grib_accessor_class_hash_array.cc +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -146,6 +146,7 @@ void grib_accessor_class_hash_array_t::destroy(grib_context* c, grib_accessor* a grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; if (self->key) grib_context_free(c, self->key); + grib_accessor_class_gen_t::destroy(c, a); } int grib_accessor_class_hash_array_t::unpack_string(grib_accessor* a, char* val, size_t* len){ diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index 7d5fd330f..4cc9beaf0 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -143,6 +143,7 @@ void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a){ grib_context_free(c, cur); } } + grib_accessor_class_gen_t::destroy(c, a); } int grib_accessor_class_md5_t::value_count(grib_accessor* a, long* count){ diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc index 17d17746b..4c276ed42 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -51,6 +51,7 @@ int grib_accessor_class_pack_bufr_values_t::value_count(grib_accessor* a, long* } void grib_accessor_class_pack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ + grib_accessor_class_gen_t::destroy(context, a); } int grib_accessor_class_pack_bufr_values_t::get_native_type(grib_accessor* a){ diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc index b859639b0..ec6e14c2b 100644 --- a/src/accessor/grib_accessor_class_section.cc +++ b/src/accessor/grib_accessor_class_section.cc @@ -46,6 +46,7 @@ long grib_accessor_class_section_t::next_offset(grib_accessor* a){ void grib_accessor_class_section_t::destroy(grib_context* ct, grib_accessor* a){ grib_section_delete(ct, a->sub_section); + grib_accessor_class_gen_t::destroy(ct, a); } int grib_accessor_class_section_t::get_native_type(grib_accessor* a){ diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index 4d1997854..e26169656 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -405,6 +405,8 @@ void grib_accessor_class_smart_table_t::destroy(grib_context* context, grib_acce } if (self->tableCodes) grib_context_free(a->context, self->tableCodes); + + grib_accessor_class_unsigned_t::destroy(context, a); } int grib_accessor_class_smart_table_t::get_native_type(grib_accessor* a) diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc index d63587cd1..d04f63e5e 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.cc +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -166,6 +166,8 @@ void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, gr grib_context_free(context, a->vvalue); a->vvalue = NULL; } + + grib_accessor_class_gen_t::destroy(context, a); } int grib_accessor_class_smart_table_column_t::get_native_type(grib_accessor* a){ diff --git a/src/accessor/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc index ea73e69c3..f84731e0e 100644 --- a/src/accessor/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -176,6 +176,7 @@ int grib_accessor_class_statistics_t::value_count(grib_accessor* a, long* count) void grib_accessor_class_statistics_t::destroy(grib_context* c, grib_accessor* a){ grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); } int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b){ diff --git a/src/accessor/grib_accessor_class_statistics_spectral.cc b/src/accessor/grib_accessor_class_statistics_spectral.cc index 57fd16549..ea57cd2be 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.cc +++ b/src/accessor/grib_accessor_class_statistics_spectral.cc @@ -124,6 +124,7 @@ int grib_accessor_class_statistics_spectral_t::value_count(grib_accessor* a, lon void grib_accessor_class_statistics_spectral_t::destroy(grib_context* c, grib_accessor* a){ grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); } int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_accessor* b){ diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc index 5f1ec2b2b..5ed3333db 100644 --- a/src/accessor/grib_accessor_class_transient_darray.cc +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -94,6 +94,7 @@ void grib_accessor_class_transient_darray_t::destroy(grib_context* c, grib_acces grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; if (self->arr) grib_darray_delete(a->context, self->arr); + grib_accessor_class_gen_t::destroy(c, a); } int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* count){ diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index 984378dc2..4b3be3ad4 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -64,6 +64,7 @@ int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long } void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ + grib_accessor_class_gen_t::destroy(context, a); } int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index b5615ac37..0a60e809c 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -268,4 +268,6 @@ void grib_accessor_class_unsigned_t::destroy(grib_context* context, grib_accesso grib_context_free(context, a->vvalue); a->vvalue = NULL; + + grib_accessor_class_long_t::destroy(context, a); } diff --git a/src/accessor/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc index 879da527b..a9bd8741b 100644 --- a/src/accessor/grib_accessor_class_variable.cc +++ b/src/accessor/grib_accessor_class_variable.cc @@ -218,6 +218,8 @@ void grib_accessor_class_variable_t::destroy(grib_context* c, grib_accessor* a) a->attributes[i] = NULL; ++i; } + + grib_accessor_class_gen_t::destroy(c, a); } int grib_accessor_class_variable_t::unpack_string(grib_accessor* a, char* val, size_t* len) diff --git a/src/action_class_section.cc b/src/action_class_section.cc index e8f8b0a39..d5a986f5d 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -172,7 +172,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, } else { // TODO(maee): segmentation fault - //grib_handle_delete(tmp_handle); + grib_handle_delete(tmp_handle); h->kid = NULL; /* ECC-1314: must set to NULL for grib_handle_delete(h) to work */ return err; } @@ -205,7 +205,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, /* printf("grib_handle_delete %p\n",(void*)tmp_handle); */ //TODO(maee): causes segmentation fault - //grib_handle_delete(tmp_handle); + grib_handle_delete(tmp_handle); h->use_trie = 1; h->trie_invalid = 1; From 6bdef3a4c68d973ea7afb7f619b15d99cf4f9e06 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 9 Apr 2024 12:13:37 +0000 Subject: [PATCH 14/90] Fix compare function --- src/accessor/grib_accessor_class_long.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_long.cc b/src/accessor/grib_accessor_class_long.cc index a1f125f25..89d757acb 100644 --- a/src/accessor/grib_accessor_class_long.cc +++ b/src/accessor/grib_accessor_class_long.cc @@ -129,7 +129,7 @@ int grib_accessor_class_long_t::compare(grib_accessor* a, grib_accessor* b) return err; alen = count; - err = a->value_count(&count); + err = b->value_count(&count); if (err) return err; blen = count; From ea48de72dfb879aff56cf9c98459ac63c573a501 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 9 Apr 2024 15:02:44 +0000 Subject: [PATCH 15/90] PNG fix --- src/accessor/grib_accessor_class_data_png_packing.cc | 4 +++- src/accessor/grib_accessor_class_data_png_packing.h | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 7e2c90baf..8db2e5b3b 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -9,8 +9,10 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_png_packing.h" +#include "grib_scaling.h" + +#define PNG_ANYBITS grib_accessor_class_data_png_packing_t _grib_accessor_class_data_png_packing{"data_png_packing"}; grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_class_data_png_packing; diff --git a/src/accessor/grib_accessor_class_data_png_packing.h b/src/accessor/grib_accessor_class_data_png_packing.h index 1bd29fda4..841ed9d31 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.h +++ b/src/accessor/grib_accessor_class_data_png_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,16 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_png_packing_h -#define eccodes_accessor_data_png_packing_h +#pragma once #include "grib_accessor_class_values.h" -#include "grib_scaling.h" class grib_accessor_data_png_packing_t : public grib_accessor_values_t { public: - /* Members defined in data_png_packing */ const char* number_of_values; const char* reference_value; const char* binary_scale_factor; @@ -43,4 +39,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_data_png_packing_h */ From 78a9429c4e93fc6bab58b2743d5527dc4a4a407e Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 9 Apr 2024 16:02:57 +0100 Subject: [PATCH 16/90] Add PNG_ANYBITS --- src/accessor/grib_accessor_class_data_png_packing.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 7e2c90baf..d10d0765e 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -11,6 +11,7 @@ #include "grib_api_internal.h" #include "grib_accessor_class_data_png_packing.h" +#define PNG_ANYBITS grib_accessor_class_data_png_packing_t _grib_accessor_class_data_png_packing{"data_png_packing"}; grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_class_data_png_packing; From cec5b2f4e15625f954d80bebaeb3d998af6daa71 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 9 Apr 2024 20:32:45 +0000 Subject: [PATCH 17/90] Fix destroy() function --- src/accessor/grib_accessor_class_bufr_data_array.cc | 1 + src/accessor/grib_accessor_class_bufr_data_element.cc | 1 + src/accessor/grib_accessor_class_bufr_string_values.cc | 1 + src/accessor/grib_accessor_class_codetable.cc | 1 + src/accessor/grib_accessor_class_concept.cc | 1 + ...ssor_class_data_g1second_order_general_extended_packing.cc | 1 + src/accessor/grib_accessor_class_expanded_descriptors.cc | 1 + src/accessor/grib_accessor_class_getenv.cc | 1 - src/accessor/grib_accessor_class_getenv.h | 4 +--- src/action_class_section.cc | 2 -- 10 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index dc903a154..e89d096b1 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -3242,4 +3242,5 @@ void grib_accessor_class_bufr_data_array_t::destroy(grib_context* c, grib_access } grib_iarray_delete(self->iss_list); + grib_accessor_class_gen_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index f479fd236..e2c9eafbe 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -497,6 +497,7 @@ void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_acc a->attributes[i] = NULL; i++; } + grib_accessor_class_gen_t::destroy(ct, a); } #define MAX_STRING_SIZE 4096 diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index 3015a7b8c..f6b7d561a 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -82,4 +82,5 @@ int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long return descriptors->value_count(rlen);} void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_class_ascii_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index 696370ba9..54f51929b 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -775,6 +775,7 @@ void grib_accessor_class_codetable_t::destroy(grib_context* context, grib_access grib_context_free(context, a->vvalue); a->vvalue = NULL; } + grib_accessor_class_unsigned_t::destroy(context, a); } int grib_accessor_class_codetable_t::get_native_type(grib_accessor* a) diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 1e4eb27c1..a5b9fba44 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -424,6 +424,7 @@ int grib_accessor_class_concept_t::get_native_type(grib_accessor* a){ void grib_accessor_class_concept_t::destroy(grib_context* c, grib_accessor* a){ //grib_accessor_concept_t *self = (grib_accessor_concept_t*)a; //grib_context_free(c,self->cval); + grib_accessor_class_gen_t::destroy(c, a); } int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, size_t* len){ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index f95103d73..48b5081df 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -1203,4 +1203,5 @@ void grib_accessor_class_data_g1second_order_general_extended_packing_t::destroy grib_context_free(context, self->fvalues); self->fvalues = NULL; } + grib_accessor_class_data_simple_packing_t::destroy(context, a); } diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index 6ea941b55..d885ad1d8 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -725,6 +725,7 @@ int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, lo } void grib_accessor_class_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_class_long_t::destroy(c, a); // grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; // if (self->rank==0 && self->expanded) // grib_bufr_descriptors_array_delete(self->expanded); diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc index e95c3d39a..d812cc276 100644 --- a/src/accessor/grib_accessor_class_getenv.cc +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_getenv.h" grib_accessor_class_getenv_t _grib_accessor_class_getenv{"getenv"}; diff --git a/src/accessor/grib_accessor_class_getenv.h b/src/accessor/grib_accessor_class_getenv.h index 8ddf7db14..5068dad2c 100644 --- a/src/accessor/grib_accessor_class_getenv.h +++ b/src/accessor/grib_accessor_class_getenv.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -12,13 +11,11 @@ #ifndef eccodes_accessor_getenv_h #define eccodes_accessor_getenv_h -#include "../grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_getenv_t : public grib_accessor_ascii_t { public: - /* Members defined in getenv */ const char* name; char* value; const char* default_value; @@ -35,4 +32,5 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; + #endif /* eccodes_accessor_getenv_h */ diff --git a/src/action_class_section.cc b/src/action_class_section.cc index d5a986f5d..9dda3dc30 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -171,7 +171,6 @@ static int notify_change(grib_action* act, grib_accessor* notified, /*err = GRIB_SUCCESS;*/ } else { - // TODO(maee): segmentation fault grib_handle_delete(tmp_handle); h->kid = NULL; /* ECC-1314: must set to NULL for grib_handle_delete(h) to work */ return err; @@ -204,7 +203,6 @@ static int notify_change(grib_action* act, grib_accessor* notified, Assert(tmp_handle->dependencies == NULL); /* printf("grib_handle_delete %p\n",(void*)tmp_handle); */ - //TODO(maee): causes segmentation fault grib_handle_delete(tmp_handle); h->use_trie = 1; From cc40569e216529ba475a5a0b658d6ea556085bfa Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 9 Apr 2024 20:38:08 +0000 Subject: [PATCH 18/90] Fix memory leak --- src/accessor/grib_accessor_class_gen.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index a27e1e9ca..f118d45e3 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -191,7 +191,7 @@ void grib_accessor_gen_t::resize(size_t new_size) void grib_accessor_gen_t::destroy(grib_context* ct) { cclass->destroy(ct, this); - //delete this; + delete this; } From eb8bdcf87e86ef42bbde15959f3f16caf216caba Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 16 Apr 2024 11:36:39 +0100 Subject: [PATCH 19/90] ECC-1800: GRIB2: Failure setting stepUnits=s,paramId=210203 --- .../grib_accessor_class_g2step_range.cc | 10 +++++ tests/grib_sub_hourly.sh | 41 +++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc index b53d8c92f..ae2b9976d 100644 --- a/src/accessor/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -115,6 +115,16 @@ int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) return ret; + // Note: + // forceStepUnits is a special key that is used to identify the origin of the defined units + // i.e., whether they have been defined by the user. + // If this key is defined (!= 255), it indicates that the stepUnits have been defined by the user. + // Once this key is set, it has the highest priority: it automatically overrides certain units and the default value in stepUnits + + if (h->loader) { // h->loader is set only when rebuilding or reparsing + force_step_units = 255; // See ECC-1768 and ECC-1800 + } + try { std::vector steps = parse_range(val, eccodes::Unit{force_step_units}); if (steps.size() == 0) { diff --git a/tests/grib_sub_hourly.sh b/tests/grib_sub_hourly.sh index fdd174c28..2f399da0f 100755 --- a/tests/grib_sub_hourly.sh +++ b/tests/grib_sub_hourly.sh @@ -13,6 +13,14 @@ # See JIRA issues ECC-1620, ECC-1238 # ----------------------------------- +label="grib_sub_hourly" +temp=temp.1.$label +temp2=temp.2.$label +tempFilt=temp.$label.filt +tempText=temp.$label.txt + +sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + grib_expect_failure() { a_file=$1 @@ -51,14 +59,6 @@ if (set -u; : ${ECCODES_GRIB_HOURLY_STEPS_WITH_UNITS?}) 2> /dev/null; then fi -label="grib_sub_hourly" -temp=temp.1.$label -temp2=temp.2.$label -tempFilt=temp.$label.filt -tempText=temp.$label.txt - -sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl - instantaneous_field=$data_dir/reduced_gaussian_surface.grib2 accumulated_field=$data_dir/reduced_gaussian_sub_area.grib2 @@ -542,5 +542,30 @@ set -e [ $status -ne 0 ] grep -q "Invalid unit" $tempText + +# ECC-1800: Set stepUnits before paramIds, which cause changes in the PTDN +${tools_dir}/grib_set -s stepUnits=m,productDefinitionTemplateNumber=40 $sample_g2 $temp +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '0 m 40' + +${tools_dir}/grib_set -s stepUnits=m,step=6,productDefinitionTemplateNumber=40 $sample_g2 $temp +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,forecastTime' '0 m 6' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210203 $sample_g2 $temp # is_chemical +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40' + +${tools_dir}/grib_set -s stepUnits=s,paramId=131060 $sample_g2 $temp # probability forecasts +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 9' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210073 $sample_g2 $temp # is_aerosol +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 48' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210170 $sample_g2 $temp # is_chemical_srcsink +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 76' + +# Add a case with filter too +echo "set stepUnits='s'; set paramId=210203; write;" | ${tools_dir}/grib_filter -o $temp - $sample_g2 +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40' + + # Clean up rm -f $temp $temp2 $tempFilt $tempText From a43c798eff7b2ba40707385cdfaa08aec88e2fef Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 16 Apr 2024 16:17:08 +0000 Subject: [PATCH 20/90] C++ modernisation: Added Fortran --- fortran/CMakeLists.txt | 2 +- fortran/{grib_fortran.c => grib_fortran.cc} | 0 fortran/grib_fortran_prototypes.h | 332 ++++++++++++++++++++ 3 files changed, 333 insertions(+), 1 deletion(-) rename fortran/{grib_fortran.c => grib_fortran.cc} (100%) create mode 100644 fortran/grib_fortran_prototypes.h diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 979ad0652..66b6e598f 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -42,7 +42,7 @@ if( HAVE_FORTRAN ) # Note: $ will be present only while building (for the whole bundle), # whereas $ is only present once you install the package / bundle ecbuild_add_library( TARGET eccodes_f90 - SOURCES grib_fortran.c grib_f90.f90 eccodes_f90.f90 grib_kinds.h + SOURCES grib_fortran.cc grib_f90.f90 eccodes_f90.f90 grib_kinds.h GENERATED grib_f90.f90 eccodes_f90.f90 PUBLIC_INCLUDES $ $ diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.cc similarity index 100% rename from fortran/grib_fortran.c rename to fortran/grib_fortran.cc diff --git a/fortran/grib_fortran_prototypes.h b/fortran/grib_fortran_prototypes.h new file mode 100644 index 000000000..4eb0a313d --- /dev/null +++ b/fortran/grib_fortran_prototypes.h @@ -0,0 +1,332 @@ +/* + * Copyright 2005-2018 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +/* grib_fortran.c */ +#ifdef __cplusplus +extern "C" { +#endif + +int grib_f_read_any_headers_only_from_file_(int *fid, char *buffer, size_t *nbytes); +int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes); +int any_f_new_from_loaded_(int* msgid, int* gid); +int codes_f_bufr_copy_data_(int* gid1,int* gid2); +int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len); +int codes_f_bufr_keys_iterator_rewind_(int* kiter); +int any_f_scan_file_(int* fid, int* n); +int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize); +int grib_f_copy_key_(int* gidsrc, char* key, int* giddest, int len); +int grib_f_set_samples_path_(char* path, int len); + +int grib_f_read_file(int *fid, char *buffer, size_t *nbytes); +int grib_f_open_file_(int *fid, char *name, char *op, int lname, int lop); +int grib_f_open_file__(int *fid, char *name, char *op, int lname, int lop); +int grib_f_open_file(int *fid, char *name, char *op, int lname, int lop); +int grib_f_close_file_(int *fid); +int grib_f_close_file__(int *fid); +int grib_f_close_file(int *fid); +void grib_f_write_on_fail(int *gid); +void grib_f_write_on_fail_(int* gid); +void grib_f_write_on_fail__(int* gid); +int grib_f_multi_support_on_(void); +int grib_f_multi_support_on__(void); +int grib_f_multi_support_on(void); +int grib_f_multi_support_off_(void); +int grib_f_multi_support_off__(void); +int grib_f_multi_support_off(void); +int grib_f_iterator_new_(int *gid, int *iterid, int *mode); +int grib_f_iterator_new__(int *gid, int *iterid, int *mode); +int grib_f_iterator_new(int *gid, int *iterid, int *mode); +int grib_f_iterator_next_(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_next__(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_next(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_delete_(int *iterid); +int grib_f_iterator_delete__(int *iterid); +int grib_f_iterator_delete(int *iterid); +int grib_f_keys_iterator_new_(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_new__(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_new(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_next_(int *iterid); +int grib_f_keys_iterator_next__(int *iterid); +int grib_f_keys_iterator_next(int *iterid); +int grib_f_keys_iterator_delete_(int *iterid); +int grib_f_keys_iterator_delete__(int *iterid); +int grib_f_keys_iterator_delete(int *iterid); +int grib_f_gribex_mode_on_(void); +int grib_f_gribex_mode_on__(void); +int grib_f_gribex_mode_on(void); +int grib_f_gribex_mode_off_(void); +int grib_f_gribex_mode_off__(void); +int grib_f_gribex_mode_off(void); +int grib_f_skip_computed_(int *iterid); +int grib_f_skip_computed__(int *iterid); +int grib_f_skip_computed(int *iterid); +int grib_f_skip_coded_(int *iterid); +int grib_f_skip_coded__(int *iterid); +int grib_f_skip_coded(int *iterid); +int grib_f_skip_edition_specific_(int *iterid); +int grib_f_skip_edition_specific__(int *iterid); +int grib_f_skip_edition_specific(int *iterid); +int grib_f_skip_duplicates_(int *iterid); +int grib_f_skip_duplicates__(int *iterid); +int grib_f_skip_duplicates(int *iterid); +int grib_f_skip_read_only_(int *iterid); +int grib_f_skip_read_only__(int *iterid); +int grib_f_skip_read_only(int *iterid); +int grib_f_skip_function_(int *iterid); +int grib_f_skip_function__(int *iterid); +int grib_f_skip_function(int *iterid); +int grib_f_keys_iterator_get_name_(int *iterid, char *name, int len); +int grib_f_keys_iterator_get_name__(int *kiter, char *name, int len); +int grib_f_keys_iterator_get_name(int *kiter, char *name, int len); +int grib_f_keys_iterator_rewind_(int *kiter); +int grib_f_keys_iterator_rewind__(int *kiter); +int grib_f_keys_iterator_rewind(int *kiter); +int grib_f_new_from_message_(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message__(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy_(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy__(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_samples_(int *gid, char *name, int lname); +int grib_f_new_from_samples__(int *gid, char *name, int lname); +int grib_f_new_from_samples(int *gid, char *name, int lname); +int grib_f_new_from_template_(int *gid, char *name, int lname); +int grib_f_new_from_template__(int *gid, char *name, int lname); +int grib_f_new_from_template(int *gid, char *name, int lname); +int grib_f_clone_(int *gidsrc, int *giddest); +int grib_f_clone__(int *gidsrc, int *giddest); +int grib_f_clone(int *gidsrc, int *giddest); +int grib_f_util_sections_copy_(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_util_sections_copy__(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_util_sections_copy(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_copy_namespace_(int *gidsrc, char *name, int *giddest, int len); +int grib_f_copy_namespace__(int *gidsrc, char *name, int *giddest, int len); +int grib_f_copy_namespace(int *gidsrc, char *name, int *giddest, int len); +int grib_f_count_in_file(int *fid, int *n); +int grib_f_count_in_file_(int *fid, int *n); +int grib_f_count_in_file__(int *fid, int *n); +int grib_f_new_from_file_(int *fid, int *gid); +int grib_f_new_from_file__(int *fid, int *gid); +int grib_f_new_from_file(int *fid, int *gid); +int grib_f_headers_only_new_from_file_(int *fid, int *gid); +int grib_f_headers_only_new_from_file__(int *fid, int *gid); +int grib_f_headers_only_new_from_file(int *fid, int *gid); +int grib_f_new_from_index_(int *iid, int *gid); +int grib_f_new_from_index__(int *iid, int *gid); +int grib_f_new_from_index(int *iid, int *gid); +int grib_f_index_new_from_file_(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_new_from_file__(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_new_from_file(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_add_file_(int* iid, char* file, int lfile); +int grib_f_index_add_file__(int* iid, char* file, int lfile); +int grib_f_index_add_file(int* iid, char* file, int lfile); +int grib_f_index_read_(char *file, int *gid, int lfile); +int grib_f_index_read__(char *file, int *gid, int lfile); +int grib_f_index_read(char *file, int *gid, int lfile); +int grib_f_index_write_(int *gid, char *file, int lfile); +int grib_f_index_write__(int *gid, char *file, int lfile); +int grib_f_index_write(int *gid, char *file, int lfile); +int grib_f_index_release_(int *hid); +int grib_f_index_release__(int *hid); +int grib_f_index_release(int *hid); +int grib_f_multi_handle_release_(int *hid); +int grib_f_multi_handle_release__(int *hid); +int grib_f_multi_handle_release(int *hid); +int grib_f_release_(int *hid); +int grib_f_release__(int *hid); +int grib_f_release(int *hid); +int grib_f_dump_(int *gid); +int grib_f_dump__(int *gid); +int grib_f_dump(int *gid); +int grib_f_print_(int *gid, char *key, int len); +int grib_f_print__(int *gid, char *key, int len); +int grib_f_print(int *gid, char *key, int len); +int grib_f_get_error_string_(int *err, char *buf, int len); +int grib_f_get_error_string__(int *err, char *buf, int len); +int grib_f_get_error_string(int *err, char *buf, int len); +int grib_f_get_size_int_(int *gid, char *key, int *val, int len); +int grib_f_get_size_int__(int *gid, char *key, int *val, int len); +int grib_f_get_size_int(int *gid, char *key, int *val, int len); +int grib_f_get_size_long_(int *gid, char *key, long *val, int len); +int grib_f_get_size_long__(int *gid, char *key, long *val, int len); +int grib_f_get_size_long(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_int_(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_int__(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_int(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_long_(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_long__(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_long(int *gid, char *key, long *val, int len); +int grib_f_get_int_(int *gid, char *key, int *val, int len); +int grib_f_get_int__(int *gid, char *key, int *val, int len); +int grib_f_get_int(int *gid, char *key, int *val, int len); +int grib_f_get_long_(int *gid, char *key, long *val, int len); +int grib_f_get_long__(int *gid, char *key, long *val, int len); +int grib_f_get_long(int *gid, char *key, long *val, int len); +int grib_f_get_int_array_(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_int_array__(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_int_array(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_long_array_(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_long_array__(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_long_array(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_get_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_get_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_index_get_string_(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_string__(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_string(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_long_(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_long__(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_long(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_int_(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_int__(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_int(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_real8_(int *gid, char *key, double *val, int *size, int len); +int grib_f_index_get_real8__(int *gid, char *key, double *val, int *size, int len); +int grib_f_index_get_real8(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_int_array_(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_int_array__(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_int_array(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_long_array_(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_long_array__(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_long_array(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_int_(int *gid, char *key, int *val, int len); +int grib_f_set_int__(int *gid, char *key, int *val, int len); +int grib_f_set_int(int *gid, char *key, int *val, int len); +int grib_f_set_long_(int *gid, char *key, long *val, int len); +int grib_f_set_long__(int *gid, char *key, long *val, int len); +int grib_f_set_long(int *gid, char *key, long *val, int len); +int grib_f_set_missing_(int *gid, char *key, int len); +int grib_f_set_missing__(int *gid, char *key, int len); +int grib_f_set_missing(int *gid, char *key, int len); +int grib_f_is_missing_(int *gid, char *key, int *isMissing, int len); +int grib_f_is_defined_(int *gid, char *key, int *isDefined, int len); +int grib_f_is_missing__(int *gid, char *key, int *isMissing, int len); +int grib_f_is_missing(int *gid, char *key, int *isMissing, int len); +int grib_f_set_real4_(int *gid, char *key, float *val, int len); +int grib_f_set_real4__(int *gid, char *key, float *val, int len); +int grib_f_set_real4(int *gid, char *key, float *val, int len); +int grib_f_get_real4_element_(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_element__(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_element(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_elements_(int *gid, char *key, int *index, float *val, int *size, int len); +int grib_f_get_real4_elements__(int *gid, char *key, int *index, float *val, int *len, int size); +int grib_f_get_real4_elements(int *gid, char *key, int *index, float *val, int *len, int size); +int grib_f_get_real4_(int *gid, char *key, float *val, int len); +int grib_f_get_real4__(int *gid, char *key, float *val, int len); +int grib_f_get_real4(int *gid, char *key, float *val, int len); +int grib_f_get_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_get_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_get_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_index_select_real8_(int *gid, char *key, double *val, int len); +int grib_f_index_select_real8__(int *gid, char *key, double *val, int len); +int grib_f_index_select_real8(int *gid, char *key, double *val, int len); +int grib_f_index_select_string_(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_string__(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_string(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_int_(int *gid, char *key, int *val, int len); +int grib_f_index_select_int__(int *gid, char *key, int *val, int len); +int grib_f_index_select_int(int *gid, char *key, int *val, int len); +int grib_f_index_select_long_(int *gid, char *key, long *val, int len); +int grib_f_index_select_long__(int *gid, char *key, long *val, int len); +int grib_f_index_select_long(int *gid, char *key, long *val, int len); +int grib_f_set_real8_(int *gid, char *key, double *val, int len); +int grib_f_set_real8__(int *gid, char *key, double *val, int len); +int grib_f_set_real8(int *gid, char *key, double *val, int len); +int grib_f_get_real8_(int *gid, char *key, double *val, int len); +int grib_f_get_real8__(int *gid, char *key, double *val, int len); +int grib_f_get_real8(int *gid, char *key, double *val, int len); +int grib_f_get_real8_element_(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_element__(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_element(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_elements_(int *gid, char *key, int *index, double *val, int *size, int len); +int grib_f_get_real8_elements__(int *gid, char *key, int *index, double *val, int *len, int size); +int grib_f_get_real8_elements(int *gid, char *key, int *index, double *val, int *len, int size); +int grib_f_find_nearest_four_single_(int *gid, int *is_lsm, double *inlat, double *inlon, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_four_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_four_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_multiple_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_find_nearest_multiple__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_find_nearest_multiple(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_get_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_string_(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_string__(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_string(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string_(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string__(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_data_real4_(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real4__(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real4(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real8_(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_data_real8__(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_data_real8(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_message_size_(int *gid, size_t *len); +int grib_f_get_message_size__(int *gid, size_t *len); +int grib_f_get_message_size(int *gid, size_t *len); +int grib_f_copy_message_(int *gid, void *mess, size_t *len); +int grib_f_copy_message__(int *gid, void *mess, size_t *len); +int grib_f_copy_message(int *gid, void *mess, size_t *len); +void grib_f_check_(int *err, char *call, char *str, int lencall, int lenstr); +void grib_f_check__(int *err, char *call, char *key, int lencall, int lenkey); +void grib_f_check(int *err, char *call, char *key, int lencall, int lenkey); +int grib_f_write_(int *gid, int *fid); +int grib_f_write__(int *gid, int *fid); +int grib_f_write(int *gid, int *fid); +int grib_f_multi_write_(int *gid, int *fid); +int grib_f_multi_write__(int *gid, int *fid); +int grib_f_multi_write(int *gid, int *fid); +int grib_f_multi_append_(int *ingid, int *sec, int *mgid); +int grib_f_multi_append(int *ingid, int *sec, int *mgid); +int grib_f_multi_append__(int *ingid, int *sec, int *mgid); + +int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid); +int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes); +int codes_f_bufr_keys_iterator_delete_(int* iterid); +int grib_f_set_definitions_path_(char* path, int len); +int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes); +int any_f_new_from_file_(int* fid, int* gid); +int grib_f_get_native_type_(int* gid, char* key, int* val, int len); +int grib_f_get_api_version_(int* apiVersion,int len); +int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname); +int any_f_load_all_from_file_(int* fid, int* n); +int codes_f_bufr_multi_element_constant_arrays_on_(); +int bufr_f_new_from_file_(int* fid, int* gid); +int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second); +int any_f_new_from_scanned_file_(int* fid, int* msgid, int* gid); +int codes_f_bufr_keys_iterator_next_(int* iterid); +int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd); +int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len); +int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len); +int codes_f_bufr_multi_element_constant_arrays_off_(); + + +#ifdef __cplusplus +} +#endif From 6f9a1b643e88982ec94763168ab24c6a3485ffe7 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 16 Apr 2024 16:33:57 +0000 Subject: [PATCH 21/90] C++ modernisation: Fix Fortran --- fortran/grib_fortran.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/fortran/grib_fortran.cc b/fortran/grib_fortran.cc index ce9298348..d7f3315bf 100644 --- a/fortran/grib_fortran.cc +++ b/fortran/grib_fortran.cc @@ -9,6 +9,7 @@ */ #include "grib_api_internal.h" +#include "grib_fortran_prototypes.h" #if HAVE_SYS_TYPES_H # include From 14648c67eb097b9de608dffd6e2d8306e46dbc63 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 25 Apr 2024 13:01:59 +0100 Subject: [PATCH 22/90] Print dataset when concept match fails --- src/accessor/grib_accessor_class_concept.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index a5b9fba44..32e612546 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -270,6 +270,11 @@ int grib_concept_apply(grib_accessor* a, const char* name){ grib_get_string(h, "centre", centre_s, ¢re_len) == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, "concept: input handle edition=%ld, centre=%s", editionNumber, centre_s); } + char dataset_s[80]; + size_t dataset_len = sizeof(dataset_s); + if (grib_get_string(h, "datasetForLocal", dataset_s, &dataset_len) == GRIB_SUCCESS && !STR_EQUAL(dataset_s, "unknown")) { + grib_context_log(h->context, GRIB_LOG_ERROR, "concept: input handle dataset=%s", dataset_s); + } if (strcmp(act->name, "paramId") == 0) { if (string_to_long(name, &dummy, 1) == GRIB_SUCCESS) { // The paramId value is an integer. Show them the param DB From f229bd590877e24839d038804ac0bbeab8a5bcf6 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 25 Apr 2024 13:11:05 +0100 Subject: [PATCH 23/90] Remove staticForceStepUnits --- src/accessor/grib_accessor_class_optimal_step_units.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc index c6d5006c5..8df1db80e 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -68,7 +68,6 @@ int grib_accessor_class_optimal_step_units_t::pack_expression(grib_accessor* a, } static long staticStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); -static long staticForceStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); int grib_accessor_class_optimal_step_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); From 5dd62ff5a52dba4fc0ee9f1515469310d9b24240 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 25 Apr 2024 13:13:45 +0100 Subject: [PATCH 24/90] Initialise return values --- src/accessor/grib_accessor_class_variable.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/accessor/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc index a9bd8741b..b87798663 100644 --- a/src/accessor/grib_accessor_class_variable.cc +++ b/src/accessor/grib_accessor_class_variable.cc @@ -32,9 +32,9 @@ void grib_accessor_class_variable_t::init(grib_accessor* a, const long length, g grib_expression* expression = grib_arguments_get_expression(hand, args, 0); const char* p = 0; size_t len = 1; - long l; + long l = 0; int ret = 0; - double d; + double d = 0; self->cname = NULL; a->length = 0; From 17e250b7d3b21532f7c66f5dfbfeae2855d6c2d1 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 12:55:21 +0100 Subject: [PATCH 25/90] Cleanup --- ...rib_accessor_class_data_apply_boustrophedonic.cc | 11 ++++------- src/accessor/grib_accessor_class_longitudes.cc | 3 +-- src/accessor/grib_accessor_class_spd.cc | 13 +++++-------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index 4222078fe..01783ad96 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -35,10 +35,9 @@ void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, gr int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints){ grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; - int ret = 0; *numberOfPoints = 0; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); + int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); return ret; } @@ -54,17 +53,16 @@ int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ size_t size; double* values; - int err = 0; /* GRIB-564: The index idx relates to codedValues NOT values! */ - err = grib_get_size(a->parent->h, "codedValues", &size); + int err = grib_get_size(a->parent->h, "codedValues", &size); if (err) return err; if (idx > size) return GRIB_INVALID_NEAREST; values = (double*)grib_context_malloc_clear(a->parent->h->context, size * sizeof(double)); - err = grib_get_double_array(a->parent->h, "codedValues", values, &size); + err = grib_get_double_array(a->parent->h, "codedValues", values, &size); if (err) { grib_context_free(a->parent->h->context, values); return err; @@ -111,10 +109,9 @@ int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* double* pval = 0; size_t valuesSize = 0; long i, j; - int ret; long numberOfPoints, numberOfRows, numberOfColumns; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); + int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); if (ret) return ret; diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index 5b2f363b7..68b89dc23 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -123,7 +123,6 @@ static int get_distinct(grib_accessor* a, double** val, long* len){ double* v1 = NULL; double dummyLat = 0; int ret = 0; - int i; size_t size = *len; grib_context* c = a->context; @@ -157,7 +156,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len){ prev = v[0]; v1[0] = prev; count = 1; - for (i = 1; i < *len; i++) { + for (long i = 1; i < *len; i++) { if (v[i] != prev) { prev = v[i]; v1[count] = prev; diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc index 546007ef0..699ab6f9c 100644 --- a/src/accessor/grib_accessor_class_spd.cc +++ b/src/accessor/grib_accessor_class_spd.cc @@ -22,11 +22,10 @@ long grib_accessor_class_spd_t::byte_count(grib_accessor* a){ static long compute_byte_count(grib_accessor* a){ grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; + long numberOfBits = 0; + long numberOfElements = 0; - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + int ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); if (ret) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s unable to get %s to compute size", a->name, self->numberOfBits); @@ -55,13 +54,11 @@ void grib_accessor_class_spd_t::init(grib_accessor* a, const long len, grib_argu int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t* len){ grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; - int i; - int ret = 0; long pos = a->offset * 8; long rlen = 0; long numberOfBits = 0; - ret = value_count(a, &rlen); + int ret = value_count(a, &rlen); if (ret) return ret; @@ -80,7 +77,7 @@ int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t* return GRIB_DECODING_ERROR; } - for (i = 0; i < rlen - 1; i++) + for (long i = 0; i < rlen - 1; i++) val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); From 82cb39cc55f8d64e86dce2fefc66012b5f95b933 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 13:13:31 +0100 Subject: [PATCH 26/90] C++: Move function from header to local static --- ...cessor_class_data_apply_boustrophedonic.cc | 133 ++++++++++++++++-- ...ccessor_class_data_apply_boustrophedonic.h | 106 +------------- 2 files changed, 119 insertions(+), 120 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index 01783ad96..a4b020276 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -12,15 +12,16 @@ #include "grib_api_internal.h" #include "grib_accessor_class_data_apply_boustrophedonic.h" -grib_accessor_class_data_apply_boustrophedonic_t _grib_accessor_class_data_apply_boustrophedonic{"data_apply_boustrophedonic"}; +grib_accessor_class_data_apply_boustrophedonic_t _grib_accessor_class_data_apply_boustrophedonic{ "data_apply_boustrophedonic" }; grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic = &_grib_accessor_class_data_apply_boustrophedonic; -void grib_accessor_class_data_apply_boustrophedonic_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_apply_boustrophedonic_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_gen_t::init(a, v, args); - int n = 0; grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; + int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->numberOfRows = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->numberOfColumns = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -29,28 +30,127 @@ void grib_accessor_class_data_apply_boustrophedonic_t::init(grib_accessor* a, co a->length = 0; } -void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_values(dumper, a); } -int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints){ +int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints) +{ grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; *numberOfPoints = 0; - int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); - - return ret; + return grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); } -int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; + + size_t plSize = 0; + long* pl = 0; + double* values = 0; + double* pvalues = 0; + T* pval = 0; + size_t valuesSize = 0; + long i, j; + int ret; + long numberOfPoints, numberOfRows, numberOfColumns; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); + if (ret) + return ret; + + if (*len < numberOfPoints) { + *len = numberOfPoints; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_size(grib_handle_of_accessor(a), self->values, &valuesSize); + if (ret) + return ret; + + /* constant field */ + if (valuesSize == 0) + return 0; + + if (valuesSize != numberOfPoints) { + grib_context_log(a->context, GRIB_LOG_ERROR, "boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)", + self->numberOfPoints, numberOfPoints, self->values, (long)valuesSize); + return GRIB_DECODING_ERROR; + } + + values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * numberOfPoints); + ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->values, values, &valuesSize); + if (ret) + return ret; + + pvalues = values; + pval = val; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfRows, &numberOfRows); + if (ret) + return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfColumns, &numberOfColumns); + if (ret) + return ret; + + if (grib_get_size(grib_handle_of_accessor(a), self->pl, &plSize) == GRIB_SUCCESS) { + Assert(plSize == numberOfRows); + pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); + ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->pl, pl, &plSize); + if (ret) + return ret; + + for (j = 0; j < numberOfRows; j++) { + if (j % 2) { + pval += pl[j]; + for (i = 0; i < pl[j]; i++) + *(pval--) = *(pvalues++); + pval += pl[j]; + } + else { + for (i = 0; i < pl[j]; i++) + *(pval++) = *(pvalues++); + } + } + + grib_context_free(a->context, pl); + } + else { + for (j = 0; j < numberOfRows; j++) { + if (j % 2) { + pval += numberOfColumns - 1; + for (i = 0; i < numberOfColumns; i++) + *(pval--) = *(pvalues++); + pval += numberOfColumns + 1; + } + else { + for (i = 0; i < numberOfColumns; i++) + *(pval++) = *(pvalues++); + } + } + } + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ size_t size; double* values; @@ -62,7 +162,7 @@ int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib return GRIB_INVALID_NEAREST; values = (double*)grib_context_malloc_clear(a->parent->h->context, size * sizeof(double)); - err = grib_get_double_array(a->parent->h, "codedValues", values, &size); + err = grib_get_double_array(a->parent->h, "codedValues", values, &size); if (err) { grib_context_free(a->parent->h->context, values); return err; @@ -72,7 +172,8 @@ int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib return GRIB_SUCCESS; } -int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ size_t size = 0, i = 0; double* values; int err = 0; @@ -99,7 +200,8 @@ int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element_set( return GRIB_SUCCESS; } -int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; size_t plSize = 0; @@ -181,6 +283,7 @@ int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* return GRIB_SUCCESS; } -int grib_accessor_class_data_apply_boustrophedonic_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_data_apply_boustrophedonic_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_DOUBLE; } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h index 9810efe25..9b101e7ed 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_apply_boustrophedonic_h -#define eccodes_accessor_data_apply_boustrophedonic_h +#pragma once -#include "../grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_apply_boustrophedonic_t : public grib_accessor_gen_t @@ -40,106 +38,4 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_data_apply_boustrophedonic_t::unpack(grib_accessor* a, T* val, size_t* len){ - grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; - - size_t plSize = 0; - long* pl = 0; - double* values = 0; - double* pvalues = 0; - T* pval = 0; - size_t valuesSize = 0; - long i, j; - int ret; - long numberOfPoints, numberOfRows, numberOfColumns; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); - if (ret) - return ret; - - if (*len < numberOfPoints) { - *len = numberOfPoints; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_size(grib_handle_of_accessor(a), self->values, &valuesSize); - if (ret) - return ret; - - /* constant field */ - if (valuesSize == 0) - return 0; - - if (valuesSize != numberOfPoints) { - grib_context_log(a->context, GRIB_LOG_ERROR, "boustrophedonic ordering error: ( %s=%ld ) != (sizeOf(%s)=%ld)", - self->numberOfPoints, numberOfPoints, self->values, (long)valuesSize); - return GRIB_DECODING_ERROR; - } - - values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * numberOfPoints); - ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->values, values, &valuesSize); - if (ret) - return ret; - - pvalues = values; - pval = val; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfRows, &numberOfRows); - if (ret) - return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfColumns, &numberOfColumns); - if (ret) - return ret; - - if (grib_get_size(grib_handle_of_accessor(a), self->pl, &plSize) == GRIB_SUCCESS) { - Assert(plSize == numberOfRows); - pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); - ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->pl, pl, &plSize); - if (ret) - return ret; - - for (j = 0; j < numberOfRows; j++) { - if (j % 2) { - pval += pl[j]; - for (i = 0; i < pl[j]; i++) - *(pval--) = *(pvalues++); - pval += pl[j]; - } - else { - for (i = 0; i < pl[j]; i++) - *(pval++) = *(pvalues++); - } - } - - grib_context_free(a->context, pl); - } - else { - for (j = 0; j < numberOfRows; j++) { - if (j % 2) { - pval += numberOfColumns - 1; - for (i = 0; i < numberOfColumns; i++) - *(pval--) = *(pvalues++); - pval += numberOfColumns + 1; - } - else { - for (i = 0; i < numberOfColumns; i++) - *(pval++) = *(pvalues++); - } - } - } - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - - -#endif /* eccodes_accessor_data_apply_boustrophedonic_h */ From aca85e100e451b7f3198e8e00707d8d92db15f5b Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 13:32:14 +0100 Subject: [PATCH 27/90] C++: Move function from header to local static. Use pragma once --- ...ass_data_g1second_order_general_packing.cc | 135 +++++- ...lass_data_g1second_order_general_packing.h | 112 +---- ..._data_g1second_order_row_by_row_packing.cc | 195 ++++++++- ...s_data_g1second_order_row_by_row_packing.h | 175 +------- ...ib_accessor_class_data_g22order_packing.cc | 387 +++++++++++++++--- ...rib_accessor_class_data_g22order_packing.h | 258 +----------- 6 files changed, 639 insertions(+), 623 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index 07ecb170a..8fb0165d0 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_data_g1second_order_general_packing.h" -grib_accessor_class_data_g1second_order_general_packing_t _grib_accessor_class_data_g1second_order_general_packing{"data_g1second_order_general_packing"}; +grib_accessor_class_data_g1second_order_general_packing_t _grib_accessor_class_data_g1second_order_general_packing{ "data_g1second_order_general_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing = &_grib_accessor_class_data_g1second_order_general_packing; -void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_handle* hand = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(hand, args, self->carg++); self->packingType = grib_arguments_get_name(hand, args, self->carg++); @@ -40,32 +41,138 @@ void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_access a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_g1second_order_general_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues){ - int err = 0; +int grib_accessor_class_data_g1second_order_general_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) +{ grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; - *numberOfSecondOrderPackedValues = 0; + *numberOfSecondOrderPackedValues = 0; - err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); + int err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); return err; } -int grib_accessor_class_data_g1second_order_general_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ - return unpack(a, values, len); +template +static int unpack_real(grib_accessor* a, T* values, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; + int ret = 0; + long numberOfGroups, numberOfSecondOrderPackedValues; + long* groupWidths = 0; + long* firstOrderValues = 0; + long* X = 0; + long pos = 0; + long widthOfFirstOrderValues = 0; + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + long i, n; + double reference_value; + long binary_scale_factor; + long decimal_scale_factor; + double s, d; + long* secondaryBitmap; + long groupLength, j; + size_t groupWidthsSize; + + buf += a->byte_offset(); + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, + &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) + return ret; + + if (*len < (size_t)numberOfSecondOrderPackedValues) + return GRIB_ARRAY_TOO_SMALL; + + groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + groupWidthsSize = numberOfGroups; + if ((ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) + return ret; + + secondaryBitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * (numberOfSecondOrderPackedValues + 1)); + secondaryBitmap[numberOfSecondOrderPackedValues] = 1; + grib_decode_long_array(buf, &pos, 1, numberOfSecondOrderPackedValues, secondaryBitmap); + pos = 8 * ((pos + 7) / 8); + + firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); + pos = 8 * ((pos + 7) / 8); + + X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfSecondOrderPackedValues); + + n = 0; + i = -1; + groupLength = 0; + while (n < numberOfSecondOrderPackedValues) { + if (secondaryBitmap[n]) { + long* p = secondaryBitmap + n + 1; + groupLength = 1; + while (*p != 1) { + groupLength++; + p++; + } + i++; + } + if (groupWidths[i] > 0) { + for (j = 0; j < groupLength; j++) { + X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); + X[n] = firstOrderValues[i] + X[n]; + n++; + } + } + else { + for (j = 0; j < groupLength; j++) { + X[n] = firstOrderValues[i]; + n++; + } + } + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + for (i = 0; i < numberOfSecondOrderPackedValues; i++) { + values[i] = (T)(((X[i] * s) + reference_value) * d); + } + + *len = numberOfSecondOrderPackedValues; + grib_context_free(a->context, secondaryBitmap); + grib_context_free(a->context, firstOrderValues); + grib_context_free(a->context, X); + grib_context_free(a->context, groupWidths); + + return ret; } -int grib_accessor_class_data_g1second_order_general_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ - return unpack(a, values, len); +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) +{ + return unpack_real(a, values, len); } -int grib_accessor_class_data_g1second_order_general_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) +{ + return unpack_real(a, values, len); +} + +int grib_accessor_class_data_g1second_order_general_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len) +{ /* return GRIB_NOT_IMPLEMENTED; */ - int err = 0; char type[] = "grid_second_order"; size_t size = strlen(type); grib_handle* hand = grib_handle_of_accessor(a); - err = grib_set_string(hand, "packingType", type, &size); + int err = grib_set_string(hand, "packingType", type, &size); if (err) return err; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h index 837e10097..2e8bb3620 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1second_order_general_packing_h -#define eccodes_accessor_data_g1second_order_general_packing_h +#pragma once #include "grib_accessor_class_data_simple_packing.h" #include "grib_scaling.h" @@ -47,113 +46,4 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_data_g1second_order_general_packing_t::unpack(grib_accessor* a, T* values, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; - int ret = 0; - long numberOfGroups, numberOfSecondOrderPackedValues; - long* groupWidths = 0; - long* firstOrderValues = 0; - long* X = 0; - long pos = 0; - long widthOfFirstOrderValues = 0; - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - long i, n; - double reference_value; - long binary_scale_factor; - long decimal_scale_factor; - double s, d; - long* secondaryBitmap; - long groupLength, j; - size_t groupWidthsSize; - - buf += a->byte_offset(); - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, - &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) - return ret; - - if (*len < (size_t)numberOfSecondOrderPackedValues) - return GRIB_ARRAY_TOO_SMALL; - - groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - groupWidthsSize = numberOfGroups; - if ((ret = grib_get_long_array_internal(grib_handle_of_accessor(a), self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) - return ret; - - secondaryBitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * (numberOfSecondOrderPackedValues + 1)); - secondaryBitmap[numberOfSecondOrderPackedValues] = 1; - grib_decode_long_array(buf, &pos, 1, numberOfSecondOrderPackedValues, secondaryBitmap); - pos = 8 * ((pos + 7) / 8); - - firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); - pos = 8 * ((pos + 7) / 8); - - X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfSecondOrderPackedValues); - - n = 0; - i = -1; - groupLength = 0; - while (n < numberOfSecondOrderPackedValues) { - if (secondaryBitmap[n]) { - long* p = secondaryBitmap + n + 1; - groupLength = 1; - while (*p != 1) { - groupLength++; - p++; - } - i++; - } - if (groupWidths[i] > 0) { - for (j = 0; j < groupLength; j++) { - X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); - X[n] = firstOrderValues[i] + X[n]; - n++; - } - } - else { - for (j = 0; j < groupLength; j++) { - X[n] = firstOrderValues[i]; - n++; - } - } - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - for (i = 0; i < numberOfSecondOrderPackedValues; i++) { - values[i] = (T)(((X[i] * s) + reference_value) * d); - } - - *len = numberOfSecondOrderPackedValues; - grib_context_free(a->context, secondaryBitmap); - grib_context_free(a->context, firstOrderValues); - grib_context_free(a->context, X); - grib_context_free(a->context, groupWidths); - - return ret; -} - -#endif /* eccodes_accessor_data_g1second_order_general_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index f49a52586..afed13ca2 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_data_g1second_order_row_by_row_packing.h" -grib_accessor_class_data_g1second_order_row_by_row_packing_t _grib_accessor_class_data_g1second_order_row_by_row_packing{"data_g1second_order_row_by_row_packing"}; +grib_accessor_class_data_g1second_order_row_by_row_packing_t _grib_accessor_class_data_g1second_order_row_by_row_packing{ "data_g1second_order_row_by_row_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing = &_grib_accessor_class_data_g1second_order_row_by_row_packing; -void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_handle* gh = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(gh, args, self->carg++); self->packingType = grib_arguments_get_name(gh, args, self->carg++); @@ -40,11 +41,13 @@ void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_acc a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); + + grib_handle* gh = grib_handle_of_accessor(a); long n = 0, i = 0; - long numberOfRows = 0; + long numberOfRows = 0; long jPointsAreConsecutive = 0; long Ni = 0, Nj = 0; int bitmapPresent = 0; @@ -114,16 +117,186 @@ int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(gr return ret; } +template +static int unpack_real(grib_accessor* a, T* values, size_t* len) +{ + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; -int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ - return unpack(a, values, len); + grib_handle* gh = grib_handle_of_accessor(a); + int ret = 0; + long numberOfGroups, numberOfSecondOrderPackedValues; + long* groupWidths = 0; + long* firstOrderValues = 0; + long* X = 0; + long numberOfRows, numberOfColumns; + long* numbersPerRow; + long pos = 0; + long widthOfFirstOrderValues = 0; + long jPointsAreConsecutive; + unsigned char* buf = (unsigned char*)gh->buffer->data; + long k, i, j, n, Ni, Nj; + double reference_value; + long binary_scale_factor; + long decimal_scale_factor; + double s, d; + size_t groupWidthsSize = 0; + int bitmapPresent = 0; + size_t plSize = 0; + long* pl = 0; + + buf += a->byte_offset(); + if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->jPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS) + return ret; + + if (self->bitmap) + bitmapPresent = 1; + ret = grib_get_size(gh, self->pl, &plSize); + if (ret == GRIB_SUCCESS) { + pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); + if ((ret = grib_get_long_array(gh, self->pl, pl, &plSize)) != GRIB_SUCCESS) + return ret; + } + + if ((ret = grib_get_long_internal(gh, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->Nj, &Nj)) != GRIB_SUCCESS) + return ret; + if (jPointsAreConsecutive) { + numberOfRows = Ni; + numberOfColumns = Nj; + } + else { + numberOfRows = Nj; + numberOfColumns = Ni; + } + + numbersPerRow = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfRows); + if (!numbersPerRow) + return GRIB_OUT_OF_MEMORY; + if (bitmapPresent) { + long *bitmap, *pbitmap; + size_t numberOfPoints = Ni * Nj; + + if (plSize && pl) { + numberOfPoints = 0; + for (i = 0; i < numberOfRows; i++) + numberOfPoints += pl[i]; + } + bitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfPoints); + pbitmap = bitmap; + grib_get_long_array(gh, self->bitmap, bitmap, &numberOfPoints); + if (plSize && pl) { + for (i = 0; i < numberOfRows; i++) { + for (j = 0; j < pl[i]; j++) { + numbersPerRow[i] += *(bitmap++); + } + } + } + else { + for (i = 0; i < numberOfRows; i++) { + numbersPerRow[i] = 0; + for (j = 0; j < Ni; j++) { + numbersPerRow[i] += *(bitmap++); + } + } + } + + grib_context_free(a->context, pbitmap); + } + else { + if (plSize && pl) { + for (i = 0; i < numberOfRows; i++) + numbersPerRow[i] = pl[i]; + } + else { + for (i = 0; i < numberOfRows; i++) + numbersPerRow[i] = numberOfColumns; + } + } + + if ((ret = grib_get_long_internal(gh, self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->numberOfSecondOrderPackedValues, + &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) + return ret; + + groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + groupWidthsSize = numberOfGroups; + if ((ret = grib_get_long_array_internal(gh, self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) + return ret; + + firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); + grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); + pos = 8 * ((pos + 7) / 8); + + n = 0; + for (i = 0; i < numberOfGroups; i++) + n += numbersPerRow[i]; + + if (*len < (size_t)n) + return GRIB_ARRAY_TOO_SMALL; + + X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * n); + n = 0; + k = 0; + for (i = 0; i < numberOfGroups; i++) { + if (groupWidths[i] > 0) { + for (j = 0; j < numbersPerRow[k]; j++) { + X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); + X[n] += firstOrderValues[i]; + n++; + } + } + else { + for (j = 0; j < numbersPerRow[k]; j++) { + X[n] = firstOrderValues[i]; + n++; + } + } + k++; + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + for (i = 0; i < n; i++) { + values[i] = (T)(((X[i] * s) + reference_value) * d); + } + grib_context_free(a->context, firstOrderValues); + grib_context_free(a->context, X); + grib_context_free(a->context, groupWidths); + if (plSize) + grib_context_free(a->context, pl); + if (numbersPerRow) + grib_context_free(a->context, numbersPerRow); + + return ret; } -int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ - return unpack(a, values, len); +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) +{ + return unpack_real(a, values, len); } -int grib_accessor_class_data_g1second_order_row_by_row_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) +{ + return unpack_real(a, values, len); +} + +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len) +{ int err = 0; grib_handle* gh = grib_handle_of_accessor(a); char type[] = "grid_second_order"; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h index d2db87fe9..9b274a408 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1second_order_row_by_row_packing_h -#define eccodes_accessor_data_g1second_order_row_by_row_packing_h +#pragma once #include "grib_accessor_class_data_simple_packing.h" #include "grib_scaling.h" @@ -47,176 +46,4 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack(grib_accessor* a, T* values, size_t* len){ - grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - int ret = 0; - long numberOfGroups, numberOfSecondOrderPackedValues; - long* groupWidths = 0; - long* firstOrderValues = 0; - long* X = 0; - long numberOfRows, numberOfColumns; - long* numbersPerRow; - long pos = 0; - long widthOfFirstOrderValues = 0; - long jPointsAreConsecutive; - unsigned char* buf = (unsigned char*)gh->buffer->data; - long k, i, j, n, Ni, Nj; - double reference_value; - long binary_scale_factor; - long decimal_scale_factor; - double s, d; - size_t groupWidthsSize = 0; - int bitmapPresent = 0; - size_t plSize = 0; - long* pl = 0; - - buf += a->byte_offset(); - if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->jPointsAreConsecutive, &jPointsAreConsecutive)) != GRIB_SUCCESS) - return ret; - - if (self->bitmap) - bitmapPresent = 1; - ret = grib_get_size(gh, self->pl, &plSize); - if (ret == GRIB_SUCCESS) { - pl = (long*)grib_context_malloc_clear(a->context, sizeof(long) * plSize); - if ((ret = grib_get_long_array(gh, self->pl, pl, &plSize)) != GRIB_SUCCESS) - return ret; - } - - if ((ret = grib_get_long_internal(gh, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->Nj, &Nj)) != GRIB_SUCCESS) - return ret; - if (jPointsAreConsecutive) { - numberOfRows = Ni; - numberOfColumns = Nj; - } - else { - numberOfRows = Nj; - numberOfColumns = Ni; - } - - numbersPerRow = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfRows); - if (!numbersPerRow) - return GRIB_OUT_OF_MEMORY; - if (bitmapPresent) { - long *bitmap, *pbitmap; - size_t numberOfPoints = Ni * Nj; - - if (plSize && pl) { - numberOfPoints = 0; - for (i = 0; i < numberOfRows; i++) - numberOfPoints += pl[i]; - } - bitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfPoints); - pbitmap = bitmap; - grib_get_long_array(gh, self->bitmap, bitmap, &numberOfPoints); - if (plSize && pl) { - for (i = 0; i < numberOfRows; i++) { - for (j = 0; j < pl[i]; j++) { - numbersPerRow[i] += *(bitmap++); - } - } - } - else { - for (i = 0; i < numberOfRows; i++) { - numbersPerRow[i] = 0; - for (j = 0; j < Ni; j++) { - numbersPerRow[i] += *(bitmap++); - } - } - } - - grib_context_free(a->context, pbitmap); - } - else { - if (plSize && pl) { - for (i = 0; i < numberOfRows; i++) - numbersPerRow[i] = pl[i]; - } - else { - for (i = 0; i < numberOfRows; i++) - numbersPerRow[i] = numberOfColumns; - } - } - - if ((ret = grib_get_long_internal(gh, self->widthOfFirstOrderValues, &widthOfFirstOrderValues)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->numberOfSecondOrderPackedValues, - &numberOfSecondOrderPackedValues)) != GRIB_SUCCESS) - return ret; - - groupWidths = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - groupWidthsSize = numberOfGroups; - if ((ret = grib_get_long_array_internal(gh, self->groupWidths, groupWidths, &groupWidthsSize)) != GRIB_SUCCESS) - return ret; - - firstOrderValues = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfGroups); - grib_decode_long_array(buf, &pos, widthOfFirstOrderValues, numberOfGroups, firstOrderValues); - pos = 8 * ((pos + 7) / 8); - - n = 0; - for (i = 0; i < numberOfGroups; i++) - n += numbersPerRow[i]; - - if (*len < (size_t)n) - return GRIB_ARRAY_TOO_SMALL; - - X = (long*)grib_context_malloc_clear(a->context, sizeof(long) * n); - n = 0; - k = 0; - for (i = 0; i < numberOfGroups; i++) { - if (groupWidths[i] > 0) { - for (j = 0; j < numbersPerRow[k]; j++) { - X[n] = grib_decode_unsigned_long(buf, &pos, groupWidths[i]); - X[n] += firstOrderValues[i]; - n++; - } - } - else { - for (j = 0; j < numbersPerRow[k]; j++) { - X[n] = firstOrderValues[i]; - n++; - } - } - k++; - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - for (i = 0; i < n; i++) { - values[i] = (T)(((X[i] * s) + reference_value) * d); - } - grib_context_free(a->context, firstOrderValues); - grib_context_free(a->context, X); - grib_context_free(a->context, groupWidths); - if (plSize) - grib_context_free(a->context, pl); - if (numbersPerRow) - grib_context_free(a->context, numbersPerRow); - - return ret; -} - -#endif /* eccodes_accessor_data_g1second_order_row_by_row_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index 8fe861965..7a0d2b754 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -11,20 +11,21 @@ #include "grib_accessor_class_data_g22order_packing.h" -grib_accessor_class_data_g22order_packing_t _grib_accessor_class_data_g22order_packing{"data_g22order_packing"}; +grib_accessor_class_data_g22order_packing_t _grib_accessor_class_data_g22order_packing{ "data_g22order_packing" }; grib_accessor_class* grib_accessor_class_data_g22order_packing = &_grib_accessor_class_data_g22order_packing; -void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); - grib_handle* gh = grib_handle_of_accessor(a); + grib_handle* gh = grib_handle_of_accessor(a); - self->numberOfValues = grib_arguments_get_name(gh, args, self->carg++); - self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); - self->reference_value = grib_arguments_get_name(gh, args, self->carg++); - self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->numberOfValues = grib_arguments_get_name(gh, args, self->carg++); + self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); + self->reference_value = grib_arguments_get_name(gh, args, self->carg++); + self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); self->optimize_scale_factor = grib_arguments_get_name(gh, args, self->carg++); self->typeOfOriginalFieldValues = grib_arguments_get_name(gh, args, self->carg++); @@ -45,32 +46,34 @@ void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const l a->flags |= GRIB_ACCESSOR_FLAG_DATA; } - #define ONES (~(int)0) // #define UNDEFINED 9.999e20 // #define UNDEFINED_LOW 9.9989e20 // #define UNDEFINED_HIGH 9.9991e20 -#define UNDEFINED 9999.0 -#define UNDEFINED_LOW 9998.9 -#define UNDEFINED_HIGH 9999.1 +#define UNDEFINED 9999.0 +#define UNDEFINED_LOW 9998.9 +#define UNDEFINED_HIGH 9999.1 #define UNDEFINED_VAL(x) ((x) >= UNDEFINED_LOW && (x) <= UNDEFINED_HIGH) -#define DEFINED_VAL(x) ((x) < UNDEFINED_LOW || (x) > UNDEFINED_HIGH) -#define UNDEFINED_ANGLE 999.0 +#define DEFINED_VAL(x) ((x) < UNDEFINED_LOW || (x) > UNDEFINED_HIGH) +#define UNDEFINED_ANGLE 999.0 -struct bitstream_context { +struct bitstream_context +{ unsigned char* bitstream; int rbits; int reg; int n_bitstream; }; -void init_bitstream(bitstream_context *ctx, unsigned char* new_bitstream){ +void init_bitstream(bitstream_context* ctx, unsigned char* new_bitstream) +{ ctx->bitstream = new_bitstream; ctx->n_bitstream = ctx->reg = ctx->rbits = 0; } -void finish_bitstream(bitstream_context *ctx){ +void finish_bitstream(bitstream_context* ctx) +{ if (ctx->rbits) { ctx->n_bitstream++; *ctx->bitstream++ = (ctx->reg << (8 - ctx->rbits)) & 255; @@ -78,7 +81,8 @@ void finish_bitstream(bitstream_context *ctx){ } } -void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, int n, int n_bits){ +void add_many_bitstream(bitstream_context* ctx, grib_accessor* a, int* t, int n, int n_bits) +{ unsigned int jmask; int i; const int max_numbits = 25; @@ -101,7 +105,8 @@ void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, int n, } } -void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n_bits){ +void add_bitstream(bitstream_context* ctx, grib_accessor* a, int t, int n_bits) +{ unsigned int jmask; const int max_numbits = 25; @@ -125,7 +130,8 @@ void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n_bits){ // find min/max of an integer array // return 0: if min max found // return 1: if min max not found, min = max = 0 -int int_min_max_array(int* data, unsigned int n, int* min, int* max){ +int int_min_max_array(int* data, unsigned int n, int* min, int* max) +{ unsigned int first; int mn, mx; @@ -166,7 +172,8 @@ int int_min_max_array(int* data, unsigned int n, int* min, int* max){ return 0; } -double Int_Power(double x, int y){ +double Int_Power(double x, int y) +{ double value; if (y < 0) { @@ -185,7 +192,8 @@ double Int_Power(double x, int y){ return value; } -int min_max_array(double* data, unsigned int n, double* min, double* max){ +int min_max_array(double* data, unsigned int n, double* min, double* max) +{ unsigned int first; double mn, mx; @@ -297,7 +305,8 @@ int min_max_array(double* data, unsigned int n, double* min, double* max){ // return bms; // } -int grib_accessor_class_data_g22order_packing_t::post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]){ +static int post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]) +{ unsigned long last, penultimate = 0, j = 0; Assert(order > 0); Assert(order <= 3); @@ -358,7 +367,8 @@ int grib_accessor_class_data_g22order_packing_t::post_process(grib_context* c, l } -int find_nbits(unsigned int i){ +int find_nbits(unsigned int i) +{ #if !defined __GNUC__ || __GNUC__ < 4 int j; j = 0; @@ -396,7 +406,8 @@ struct section struct section *head, *tail; }; -int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef){ +int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef) +{ if (s->mn == INT_MAX) { // all undef return ref_bits + width_bits; } @@ -424,7 +435,8 @@ static int sizeofsection2(int mn, int mx, int n, int ref_bits, int width_bits, return find_nbits(mx - mn + has_undef) * n + ref_bits + width_bits; } -int size_all(struct section* s, int ref_bits, int width_bits, int has_undef){ +int size_all(struct section* s, int ref_bits, int width_bits, int has_undef) +{ int bits; bits = 0; @@ -435,7 +447,8 @@ int size_all(struct section* s, int ref_bits, int width_bits, int has_undef){ return (bits + 7) / 8; } -void move_one_left(struct section* s, int* v){ +void move_one_left(struct section* s, int* v) +{ struct section* t; int val, i, j, k; @@ -500,7 +513,8 @@ void move_one_left(struct section* s, int* v){ } } -void move_one_right(struct section* s, int* v){ +void move_one_right(struct section* s, int* v) +{ struct section* t; int val, i, j, k; @@ -581,7 +595,8 @@ void move_one_right(struct section* s, int* v){ return; } -void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX){ +void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) +{ struct section* t; int val0, val1, nbit_s, nbit_t; @@ -656,7 +671,8 @@ void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX){ } } -void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX){ +void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX) +{ struct section *t, *m; int size_head, size_mid, size_tail, saving_mt, saving_hm; int min0, max0, min1, max1; @@ -760,7 +776,8 @@ void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int } } -int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -800,7 +817,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) return err; - optimize_scale_factor = 1; // TODO(masn): To be reviewed + optimize_scale_factor = 1; // TODO(masn): To be reviewed if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) return err; @@ -830,7 +847,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c // orderOfSpatialDifferencing = 1 means "grid_complex_spatial_differencing" with orderOfSpatialDifferencing=1 // orderOfSpatialDifferencing = 2 means "grid_complex_spatial_differencing" with orderOfSpatialDifferencing=2 - use_bitmap = bitmap_present; + use_bitmap = bitmap_present; wanted_bits = bits_per_value; for (i = 0; i < *len; i++) { @@ -842,7 +859,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c if (ndef == 0) { // Special case: All undefined values // Section 5 const char* packing_type = "grid_complex"; - size_t packing_type_len = strlen(packing_type); + size_t packing_type_len = strlen(packing_type); grib_set_string_internal(gh, "packingType", packing_type, &packing_type_len); if ((err = grib_set_double_internal(gh, self->reference_value, grib_ieee_to_long(0.0))) != GRIB_SUCCESS) @@ -882,8 +899,8 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; // Section 7 - constexpr size_t sec7_size = 3; - unsigned char empty_sec7[sec7_size] = {255, 0, 0}; // group reference, group width, group length + constexpr size_t sec7_size = 3; + unsigned char empty_sec7[sec7_size] = { 255, 0, 0 }; // group reference, group width, group length grib_buffer_replace(a, empty_sec7, sec7_size, 1, 1); return GRIB_SUCCESS; } @@ -899,12 +916,12 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c dec_scale = -decimal_scale_factor; bin_scale = binary_scale_factor; - //compute bitmap section - //if (use_bitmap == 0 || ndef == ndata) { - // if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; - //} else { - // if ((err = grib_set_long_internal(gh, "bitmapPresent", 1)) != GRIB_SUCCESS) return err; - //} + // compute bitmap section + // if (use_bitmap == 0 || ndef == ndata) { + // if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; + // } else { + // if ((err = grib_set_long_internal(gh, "bitmapPresent", 1)) != GRIB_SUCCESS) return err; + // } nndata = use_bitmap ? ndef : ndata; has_undef = use_bitmap ? 0 : ndata != ndef; @@ -1073,7 +1090,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c #ifdef DEBUG grib_context_log(a->context, GRIB_LOG_DEBUG, "COMPLEX: 2: vmx %d vmn %d nbits %d", vmx, vmn, - find_nbits(vmx - vmn + has_undef)); + find_nbits(vmx - vmn + has_undef)); #endif for (i = 0; i < nndata; i++) { @@ -1094,7 +1111,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c list = reinterpret_cast(grib_context_malloc_clear(a->context, nstruct * sizeof(section))); if (list == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory allocation of list failed",cclass_name); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory allocation of list failed", cclass_name); return GRIB_OUT_OF_MEMORY; } @@ -1170,10 +1187,10 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c LEN_SEC_MAX); j = size_all(start.tail, vbits, LEN_BITS + est_group_width, has_undef); #ifdef DEBUG - grib_context_log(a->context, GRIB_LOG_DEBUG, - "COMPLEX: complex inc segments size size0 %d size1 %d segsize %d " - "LEN_BITS=%d", - j0, j, LEN_SEC_MAX, LEN_BITS); + grib_context_log(a->context, GRIB_LOG_DEBUG, + "COMPLEX: complex inc segments size size0 %d size1 %d segsize %d " + "LEN_BITS=%d", + j0, j, LEN_SEC_MAX, LEN_BITS); #endif if (j > j0) { memcpy(list, list_backup, nstruct * sizeof(struct section)); @@ -1181,7 +1198,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c LEN_SEC_MAX = (LEN_SEC_MAX - 1) / 2; } } - grib_context_free(a->context,list_backup); + grib_context_free(a->context, list_backup); exchange(start.tail, v, has_undef, LEN_SEC_MAX); #ifdef DEBUG @@ -1232,7 +1249,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c itmp2 = reinterpret_cast(grib_context_malloc(a->context, ngroups * sizeof(int))); if (lens == NULL || widths == NULL || refs == NULL || itmp == NULL || itmp2 == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory alloc of lens/widths/refs/itmp/itmp2 failed",cclass_name); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory alloc of lens/widths/refs/itmp/itmp2 failed", cclass_name); return GRIB_OUT_OF_MEMORY; } @@ -1289,7 +1306,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c } } - bits_per_value = find_nbits(grefmx + has_undef); + bits_per_value = find_nbits(grefmx + has_undef); numberOfBitsUsedForTheGroupWidths = find_nbits(gwidmx - gwidmn + has_undef); if ((err = grib_set_long_internal(gh, self->bits_per_value, bits_per_value)) != GRIB_SUCCESS) @@ -1445,15 +1462,269 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c return GRIB_SUCCESS; } -int grib_accessor_class_data_g22order_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +template +static int unpack(grib_accessor* a, T* val, const size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating points numbers"); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + + size_t i = 0; + size_t j = 0; + long n_vals = 0; + long vcount = 0; + int err = GRIB_SUCCESS; + long* sec_val = NULL; + unsigned char* buf = reinterpret_cast(gh->buffer->data); + unsigned char* buf_ref = NULL; + unsigned char* buf_width = NULL; + unsigned char* buf_length = NULL; + unsigned char* buf_vals = NULL; + + long length_p = 0; + long ref_p = 0; + long width_p = 0; + long vals_p = 0; + long nvals_per_group = 0; + long nbits_per_group_val = 0; + long group_ref_val = 0; + + long bits_per_value = 0; + T binary_s = 0; + T decimal_s = 0; + double reference_value = 0; + + long binary_scale_factor; + long decimal_scale_factor; + long typeOfOriginalFieldValues; + long groupSplittingMethodUsed; + long missingValueManagementUsed; + long primaryMissingValueSubstitute; + long secondaryMissingValueSubstitute; + long numberOfGroupsOfDataValues; + long referenceForGroupWidths; + long numberOfBitsUsedForTheGroupWidths; + long referenceForGroupLengths; + long lengthIncrementForTheGroupLengths; + long trueLengthOfLastGroup; + long numberOfBitsUsedForTheScaledGroupLengths; + long orderOfSpatialDifferencing = 0; + long numberOfOctetsExtraDescriptors = 0; + double missingValue = 0; + + err = a->value_count(&n_vals); + if (err) + return err; + + if (*len < static_cast(n_vals)) + return GRIB_ARRAY_TOO_SMALL; + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) + return err; + + // Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) + return err; + + self->dirty = 0; + + sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); + if (!sec_val) return GRIB_OUT_OF_MEMORY; + memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 + + buf_ref = buf + a->offset; + + ref_p = (numberOfGroupsOfDataValues * bits_per_value); + + if (orderOfSpatialDifferencing) + ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); + + buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); + + width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); + buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); + + length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); + buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); + + length_p = 0; + ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; + width_p = 0; + vals_p = 0; + vcount = 0; + + for (i = 0; i < numberOfGroupsOfDataValues; i++) { + group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); + nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); + nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); + + nvals_per_group *= lengthIncrementForTheGroupLengths; + nvals_per_group += referenceForGroupLengths; + nbits_per_group_val += referenceForGroupWidths; + + if (i == numberOfGroupsOfDataValues - 1) + nvals_per_group = trueLengthOfLastGroup; + if (n_vals < vcount + nvals_per_group) { + return GRIB_DECODING_ERROR; + } + + // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); + if (missingValueManagementUsed == 0) { + // No explicit missing values included within data values + for (j = 0; j < nvals_per_group; j++) { + DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); + sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); + } + } + else if (missingValueManagementUsed == 1) { + // Primary missing values included within data values + long maxn = 0; // (1 << bits_per_value) - 1; + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn = (1 << bits_per_value) - 1; + if (group_ref_val == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + if (temp == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + else if (missingValueManagementUsed == 2) { + // Primary and secondary missing values included within data values + long maxn = (1 << bits_per_value) - 1; + long maxn2 = 0; // maxn - 1 + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn2 = maxn - 1; + if (group_ref_val == maxn || group_ref_val == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + maxn2 = maxn - 1; + if (temp == maxn || temp == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + + vcount += nvals_per_group; + } + + if (orderOfSpatialDifferencing) { + long bias = 0; + unsigned long extras[2] = { + 0, + }; + ref_p = 0; + + // For Complex packing, order == 0 + // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) + if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); + return GRIB_INTERNAL_ERROR; + } + + for (i = 0; i < orderOfSpatialDifferencing; i++) { + extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + } + + bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + + post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); + // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); + } + + binary_s = (T)codes_power(binary_scale_factor, 2); + decimal_s = (T)codes_power(-decimal_scale_factor, 10); + + for (i = 0; i < n_vals; i++) { + if (sec_val[i] == LONG_MAX) { + val[i] = (T)missingValue; + } + else { + val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; + } + } + + grib_context_free(a->context, sec_val); + return err; +} + +int grib_accessor_class_data_g22order_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_g22order_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_g22order_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_g22order_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_g22order_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ size_t size = 0; double* values = NULL; int err = grib_get_size(grib_handle_of_accessor(a), "codedValues", &size); @@ -1473,7 +1744,8 @@ int grib_accessor_class_data_g22order_packing_t::unpack_double_element(grib_acce return GRIB_SUCCESS; } -int grib_accessor_class_data_g22order_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_g22order_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ size_t size = 0, i = 0; double* values; int err = 0; @@ -1500,8 +1772,9 @@ int grib_accessor_class_data_g22order_packing_t::unpack_double_element_set(grib_ return GRIB_SUCCESS; } -int grib_accessor_class_data_g22order_packing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_g22order_packing_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); - *count = 0; + *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, count); } diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h b/src/accessor/grib_accessor_class_data_g22order_packing.h index 0b87602a9..39d01a70b 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.h +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h @@ -9,11 +9,10 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g22order_packing_h -#define eccodes_accessor_data_g22order_packing_h +#pragma once #include "grib_accessor_class_values.h" -#include "../grib_scaling.h" +#include "grib_scaling.h" class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t { @@ -53,257 +52,4 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -private: - int post_process(grib_context*, long*, long, long, long, const unsigned long[2]); - template int unpack(grib_accessor*, T*, const size_t*); }; - - -template -int grib_accessor_class_data_g22order_packing_t::unpack(grib_accessor* a, T* val, const size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating points numbers"); - grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - - size_t i = 0; - size_t j = 0; - long n_vals = 0; - long vcount = 0; - int err = GRIB_SUCCESS; - long* sec_val = NULL; - unsigned char* buf = reinterpret_cast(gh->buffer->data); - unsigned char* buf_ref = NULL; - unsigned char* buf_width = NULL; - unsigned char* buf_length = NULL; - unsigned char* buf_vals = NULL; - - long length_p = 0; - long ref_p = 0; - long width_p = 0; - long vals_p = 0; - long nvals_per_group = 0; - long nbits_per_group_val = 0; - long group_ref_val = 0; - - long bits_per_value = 0; - T binary_s = 0; - T decimal_s = 0; - double reference_value = 0; - - long binary_scale_factor; - long decimal_scale_factor; - long typeOfOriginalFieldValues; - long groupSplittingMethodUsed; - long missingValueManagementUsed; - long primaryMissingValueSubstitute; - long secondaryMissingValueSubstitute; - long numberOfGroupsOfDataValues; - long referenceForGroupWidths; - long numberOfBitsUsedForTheGroupWidths; - long referenceForGroupLengths; - long lengthIncrementForTheGroupLengths; - long trueLengthOfLastGroup; - long numberOfBitsUsedForTheScaledGroupLengths; - long orderOfSpatialDifferencing = 0; - long numberOfOctetsExtraDescriptors = 0; - double missingValue = 0; - - err = a->value_count(&n_vals); if (err) - return err; - - if (*len < static_cast(n_vals)) - return GRIB_ARRAY_TOO_SMALL; - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) - return err; - - // Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) - return err; - - self->dirty = 0; - - sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); - if (!sec_val) return GRIB_OUT_OF_MEMORY; - memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 - - buf_ref = buf + a->offset; - - ref_p = (numberOfGroupsOfDataValues * bits_per_value); - - if (orderOfSpatialDifferencing) - ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); - - buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); - - width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); - buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); - - length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); - buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); - - length_p = 0; - ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; - width_p = 0; - vals_p = 0; - vcount = 0; - - for (i = 0; i < numberOfGroupsOfDataValues; i++) { - group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); - nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); - nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); - - nvals_per_group *= lengthIncrementForTheGroupLengths; - nvals_per_group += referenceForGroupLengths; - nbits_per_group_val += referenceForGroupWidths; - - if (i == numberOfGroupsOfDataValues - 1) - nvals_per_group = trueLengthOfLastGroup; - if (n_vals < vcount + nvals_per_group) { - return GRIB_DECODING_ERROR; - } - - // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); - if (missingValueManagementUsed == 0) { - // No explicit missing values included within data values - for (j = 0; j < nvals_per_group; j++) { - DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); - sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); - } - } - else if (missingValueManagementUsed == 1) { - // Primary missing values included within data values - long maxn = 0; // (1 << bits_per_value) - 1; - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn = (1 << bits_per_value) - 1; - if (group_ref_val == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - if (temp == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - else if (missingValueManagementUsed == 2) { - // Primary and secondary missing values included within data values - long maxn = (1 << bits_per_value) - 1; - long maxn2 = 0; // maxn - 1 - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn2 = maxn - 1; - if (group_ref_val == maxn || group_ref_val == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - maxn2 = maxn - 1; - if (temp == maxn || temp == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - - vcount += nvals_per_group; - } - - if (orderOfSpatialDifferencing) { - long bias = 0; - unsigned long extras[2] = {0, }; - ref_p = 0; - - // For Complex packing, order == 0 - // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) - if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); - return GRIB_INTERNAL_ERROR; - } - - for (i = 0; i < orderOfSpatialDifferencing; i++) { - extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - } - - bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - - post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); - // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); - } - - binary_s = (T)codes_power(binary_scale_factor, 2); - decimal_s = (T)codes_power(-decimal_scale_factor, 10); - - for (i = 0; i < n_vals; i++) { - if (sec_val[i] == LONG_MAX) { - val[i] = (T)missingValue; - } - else { - val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; - } - } - - grib_context_free(a->context, sec_val); - return err; -} - -#endif /* eccodes_accessor_data_g22order_packing_h */ From 6018a0acc7cc4d205670059582fad29c76051247 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 13:40:39 +0100 Subject: [PATCH 28/90] Fix the includes: Do not use .. --- src/accessor/grib_accessor.h | 4 +- ...grib_accessor_class_abstract_long_vector.h | 2 +- ..._accessor_class_abstract_long_vector.h.bak | 33 +++ .../grib_accessor_class_abstract_vector.h | 2 +- .../grib_accessor_class_abstract_vector.h.bak | 32 +++ src/accessor/grib_accessor_class_ascii.h | 2 +- src/accessor/grib_accessor_class_ascii.h.bak | 42 +++ src/accessor/grib_accessor_class_bit.h | 2 +- src/accessor/grib_accessor_class_bit.h.bak | 35 +++ src/accessor/grib_accessor_class_bitmap.h | 2 +- src/accessor/grib_accessor_class_bitmap.h.bak | 45 +++ src/accessor/grib_accessor_class_bits.h | 2 +- src/accessor/grib_accessor_class_bits.h.bak | 45 +++ .../grib_accessor_class_bits_per_value.h | 2 +- .../grib_accessor_class_bits_per_value.h.bak | 35 +++ src/accessor/grib_accessor_class_blob.h | 2 +- src/accessor/grib_accessor_class_blob.h.bak | 34 +++ src/accessor/grib_accessor_class_budgdate.h | 2 +- .../grib_accessor_class_budgdate.h.bak | 36 +++ .../grib_accessor_class_bufr_data_array.h.bak | 92 ++++++ .../grib_accessor_class_bufr_data_element.h | 2 +- ...rib_accessor_class_bufr_data_element.h.bak | 57 ++++ .../grib_accessor_class_bufr_elements_table.h | 2 +- ...b_accessor_class_bufr_elements_table.h.bak | 39 +++ ...accessor_class_bufr_extract_area_subsets.h | 2 +- ...ssor_class_bufr_extract_area_subsets.h.bak | 43 +++ ...ssor_class_bufr_extract_datetime_subsets.h | 2 +- ..._class_bufr_extract_datetime_subsets.h.bak | 36 +++ ...grib_accessor_class_bufr_extract_subsets.h | 2 +- ..._accessor_class_bufr_extract_subsets.h.bak | 37 +++ src/accessor/grib_accessor_class_bufr_group.h | 2 +- .../grib_accessor_class_bufr_group.h.bak | 32 +++ ...grib_accessor_class_bufr_simple_thinning.h | 2 +- ..._accessor_class_bufr_simple_thinning.h.bak | 39 +++ .../grib_accessor_class_bufr_string_values.h | 2 +- ...ib_accessor_class_bufr_string_values.h.bak | 38 +++ ...cessor_class_bufrdc_expanded_descriptors.h | 2 +- ...or_class_bufrdc_expanded_descriptors.h.bak | 37 +++ src/accessor/grib_accessor_class_bytes.h | 2 +- src/accessor/grib_accessor_class_bytes.h.bak | 35 +++ ...or_class_change_alternative_row_scanning.h | 2 +- ...lass_change_alternative_row_scanning.h.bak | 38 +++ ...accessor_class_change_scanning_direction.h | 2 +- ...ssor_class_change_scanning_direction.h.bak | 42 +++ ...ib_accessor_class_check_internal_version.h | 2 +- ...ccessor_class_check_internal_version.h.bak | 33 +++ .../grib_accessor_class_closest_date.h | 2 +- .../grib_accessor_class_closest_date.h.bak | 43 +++ src/accessor/grib_accessor_class_codeflag.h | 2 +- .../grib_accessor_class_codeflag.h.bak | 34 +++ src/accessor/grib_accessor_class_codetable.h | 2 +- .../grib_accessor_class_codetable.h.bak | 47 +++ .../grib_accessor_class_codetable_title.h | 2 +- .../grib_accessor_class_codetable_title.h.bak | 34 +++ .../grib_accessor_class_codetable_units.h | 2 +- .../grib_accessor_class_codetable_units.h.bak | 34 +++ src/accessor/grib_accessor_class_concept.h | 2 +- .../grib_accessor_class_concept.h.bak | 43 +++ src/accessor/grib_accessor_class_constant.h | 2 +- .../grib_accessor_class_constant.h.bak | 27 ++ src/accessor/grib_accessor_class_count_file.h | 2 +- .../grib_accessor_class_count_file.h.bak | 32 +++ .../grib_accessor_class_count_missing.h | 2 +- .../grib_accessor_class_count_missing.h.bak | 37 +++ .../grib_accessor_class_count_total.h | 2 +- .../grib_accessor_class_count_total.h.bak | 32 +++ .../grib_accessor_class_data_apply_bitmap.h | 2 +- ...rib_accessor_class_data_apply_bitmap.h.bak | 132 +++++++++ ...sor_class_data_apply_boustrophedonic.h.bak | 41 +++ ..._class_data_apply_boustrophedonic_bitmap.h | 2 +- ...ss_data_apply_boustrophedonic_bitmap.h.bak | 45 +++ ...ib_accessor_class_data_ccsds_packing.h.bak | 203 +++++++++++++ ..._accessor_class_data_complex_packing.h.bak | 272 ++++++++++++++++++ .../grib_accessor_class_data_dummy_field.h | 2 +- ...grib_accessor_class_data_dummy_field.h.bak | 37 +++ ...ib_accessor_class_data_g1complex_packing.h | 2 +- ...ccessor_class_data_g1complex_packing.h.bak | 37 +++ ...ta_g1second_order_constant_width_packing.h | 2 +- ...1second_order_constant_width_packing.h.bak | 53 ++++ ..._g1second_order_general_extended_packing.h | 2 +- ...econd_order_general_extended_packing.h.bak | 68 +++++ ..._data_g1second_order_general_packing.h.bak | 49 ++++ ...ta_g1second_order_row_by_row_packing.h.bak | 49 ++++ ...b_accessor_class_data_g1secondary_bitmap.h | 2 +- ...cessor_class_data_g1secondary_bitmap.h.bak | 34 +++ ...b_accessor_class_data_g1shsimple_packing.h | 2 +- ...cessor_class_data_g1shsimple_packing.h.bak | 32 +++ ...rib_accessor_class_data_g1simple_packing.h | 2 +- ...accessor_class_data_g1simple_packing.h.bak | 37 +++ ...accessor_class_data_g22order_packing.h.bak | 55 ++++ ..._accessor_class_data_g2bifourier_packing.h | 2 +- ...essor_class_data_g2bifourier_packing.h.bak | 47 +++ ...ib_accessor_class_data_g2complex_packing.h | 2 +- ...ccessor_class_data_g2complex_packing.h.bak | 34 +++ ...b_accessor_class_data_g2secondary_bitmap.h | 2 +- ...cessor_class_data_g2secondary_bitmap.h.bak | 34 +++ ...b_accessor_class_data_g2shsimple_packing.h | 2 +- ...cessor_class_data_g2shsimple_packing.h.bak | 36 +++ ...accessor_class_data_g2simple_packing.h.bak | 28 ++ ...data_g2simple_packing_with_preprocessing.h | 2 +- ..._g2simple_packing_with_preprocessing.h.bak | 36 +++ ...rib_accessor_class_data_jpeg2000_packing.h | 2 +- ...accessor_class_data_jpeg2000_packing.h.bak | 46 +++ ...grib_accessor_class_data_png_packing.h.bak | 41 +++ .../grib_accessor_class_data_raw_packing.h | 2 +- ...grib_accessor_class_data_raw_packing.h.bak | 38 +++ ...b_accessor_class_data_run_length_packing.h | 2 +- ...cessor_class_data_run_length_packing.h.bak | 40 +++ ...rib_accessor_class_data_secondary_bitmap.h | 2 +- ...accessor_class_data_secondary_bitmap.h.bak | 38 +++ .../grib_accessor_class_data_sh_packed.h | 2 +- .../grib_accessor_class_data_sh_packed.h.bak | 43 +++ .../grib_accessor_class_data_sh_unpacked.h | 2 +- ...grib_accessor_class_data_sh_unpacked.h.bak | 43 +++ ...rib_accessor_class_data_shsimple_packing.h | 2 +- ...accessor_class_data_shsimple_packing.h.bak | 37 +++ ...b_accessor_class_data_simple_packing.h.bak | 195 +++++++++++++ .../grib_accessor_class_decimal_precision.h | 2 +- ...rib_accessor_class_decimal_precision.h.bak | 37 +++ src/accessor/grib_accessor_class_dictionary.h | 2 +- .../grib_accessor_class_dictionary.h.bak | 42 +++ src/accessor/grib_accessor_class_dirty.h | 2 +- src/accessor/grib_accessor_class_dirty.h.bak | 34 +++ src/accessor/grib_accessor_class_divdouble.h | 2 +- .../grib_accessor_class_divdouble.h.bak | 34 +++ src/accessor/grib_accessor_class_double.h.bak | 30 ++ src/accessor/grib_accessor_class_element.h | 2 +- .../grib_accessor_class_element.h.bak | 36 +++ src/accessor/grib_accessor_class_evaluate.h | 2 +- .../grib_accessor_class_evaluate.h.bak | 33 +++ ...grib_accessor_class_expanded_descriptors.h | 2 +- ..._accessor_class_expanded_descriptors.h.bak | 47 +++ ...sor_class_from_scale_factor_scaled_value.h | 2 +- ...class_from_scale_factor_scaled_value.h.bak | 37 +++ ...rib_accessor_class_g1_half_byte_codeflag.h | 2 +- ...accessor_class_g1_half_byte_codeflag.h.bak | 35 +++ .../grib_accessor_class_g1_message_length.h | 2 +- ...rib_accessor_class_g1_message_length.h.bak | 34 +++ .../grib_accessor_class_g1_section4_length.h | 2 +- ...ib_accessor_class_g1_section4_length.h.bak | 34 +++ src/accessor/grib_accessor_class_g1bitmap.h | 2 +- .../grib_accessor_class_g1bitmap.h.bak | 35 +++ src/accessor/grib_accessor_class_g1date.h | 2 +- src/accessor/grib_accessor_class_g1date.h.bak | 39 +++ ...ib_accessor_class_g1day_of_the_year_date.h | 2 +- ...ccessor_class_g1day_of_the_year_date.h.bak | 33 +++ ...accessor_class_g1end_of_interval_monthly.h | 2 +- ...ssor_class_g1end_of_interval_monthly.h.bak | 36 +++ src/accessor/grib_accessor_class_g1fcperiod.h | 2 +- .../grib_accessor_class_g1fcperiod.h.bak | 31 ++ .../grib_accessor_class_g1forecastmonth.h | 2 +- .../grib_accessor_class_g1forecastmonth.h.bak | 40 +++ .../grib_accessor_class_g1monthlydate.h | 2 +- .../grib_accessor_class_g1monthlydate.h.bak | 33 +++ ...lass_g1number_of_coded_values_sh_complex.h | 2 +- ..._g1number_of_coded_values_sh_complex.h.bak | 40 +++ ...class_g1number_of_coded_values_sh_simple.h | 2 +- ...s_g1number_of_coded_values_sh_simple.h.bak | 37 +++ .../grib_accessor_class_g1step_range.h | 2 +- .../grib_accessor_class_g1step_range.h.bak | 48 ++++ .../grib_accessor_class_g1verificationdate.h | 2 +- ...ib_accessor_class_g1verificationdate.h.bak | 35 +++ src/accessor/grib_accessor_class_g2_aerosol.h | 2 +- .../grib_accessor_class_g2_aerosol.h.bak | 37 +++ .../grib_accessor_class_g2_chemical.h | 2 +- .../grib_accessor_class_g2_chemical.h.bak | 37 +++ src/accessor/grib_accessor_class_g2_eps.h | 2 +- src/accessor/grib_accessor_class_g2_eps.h.bak | 39 +++ .../grib_accessor_class_g2_mars_labeling.h | 2 +- ...grib_accessor_class_g2_mars_labeling.h.bak | 47 +++ src/accessor/grib_accessor_class_g2bitmap.h | 2 +- .../grib_accessor_class_g2bitmap.h.bak | 34 +++ .../grib_accessor_class_g2bitmap_present.h | 2 +- ...grib_accessor_class_g2bitmap_present.h.bak | 34 +++ src/accessor/grib_accessor_class_g2date.h | 2 +- src/accessor/grib_accessor_class_g2date.h.bak | 37 +++ src/accessor/grib_accessor_class_g2end_step.h | 2 +- .../grib_accessor_class_g2end_step.h.bak | 56 ++++ src/accessor/grib_accessor_class_g2grid.h | 2 +- src/accessor/grib_accessor_class_g2grid.h.bak | 42 +++ src/accessor/grib_accessor_class_g2latlon.h | 2 +- .../grib_accessor_class_g2latlon.h.bak | 38 +++ src/accessor/grib_accessor_class_g2level.h | 2 +- .../grib_accessor_class_g2level.h.bak | 40 +++ src/accessor/grib_accessor_class_g2lon.h | 2 +- src/accessor/grib_accessor_class_g2lon.h.bak | 34 +++ .../grib_accessor_class_g2step_range.cc | 4 +- .../grib_accessor_class_g2step_range.h | 2 +- .../grib_accessor_class_g2step_range.h.bak | 41 +++ .../grib_accessor_class_gaussian_grid_name.h | 2 +- ...ib_accessor_class_gaussian_grid_name.h.bak | 37 +++ .../grib_accessor_class_gds_is_present.h | 2 +- .../grib_accessor_class_gds_is_present.h.bak | 37 +++ ...ib_accessor_class_gds_not_present_bitmap.h | 2 +- ...ccessor_class_gds_not_present_bitmap.h.bak | 40 +++ src/accessor/grib_accessor_class_gen.h | 2 +- src/accessor/grib_accessor_class_gen.h.bak | 158 ++++++++++ src/accessor/grib_accessor_class_getenv.h.bak | 36 +++ .../grib_accessor_class_global_gaussian.h | 2 +- .../grib_accessor_class_global_gaussian.h.bak | 44 +++ src/accessor/grib_accessor_class_group.h | 2 +- src/accessor/grib_accessor_class_group.h.bak | 41 +++ src/accessor/grib_accessor_class_gts_header.h | 2 +- .../grib_accessor_class_gts_header.h.bak | 36 +++ src/accessor/grib_accessor_class_hash_array.h | 2 +- .../grib_accessor_class_hash_array.h.bak | 45 +++ .../grib_accessor_class_headers_only.h | 2 +- .../grib_accessor_class_headers_only.h.bak | 33 +++ src/accessor/grib_accessor_class_ibmfloat.h | 2 +- .../grib_accessor_class_ibmfloat.h.bak | 71 +++++ .../grib_accessor_class_ieeefloat.h.bak | 66 +++++ src/accessor/grib_accessor_class_ifs_param.h | 2 +- .../grib_accessor_class_ifs_param.h.bak | 36 +++ src/accessor/grib_accessor_class_iterator.h | 2 +- .../grib_accessor_class_iterator.h.bak | 36 +++ .../grib_accessor_class_julian_date.h | 2 +- .../grib_accessor_class_julian_date.h.bak | 48 ++++ src/accessor/grib_accessor_class_julian_day.h | 2 +- .../grib_accessor_class_julian_day.h.bak | 40 +++ .../grib_accessor_class_ksec1expver.h | 2 +- .../grib_accessor_class_ksec1expver.h.bak | 34 +++ src/accessor/grib_accessor_class_label.h | 2 +- src/accessor/grib_accessor_class_label.h.bak | 34 +++ src/accessor/grib_accessor_class_latitudes.h | 2 +- .../grib_accessor_class_latitudes.h.bak | 38 +++ .../grib_accessor_class_latlon_increment.h | 2 +- ...grib_accessor_class_latlon_increment.h.bak | 43 +++ .../grib_accessor_class_latlonvalues.h | 2 +- .../grib_accessor_class_latlonvalues.h.bak | 34 +++ .../grib_accessor_class_library_version.h | 2 +- .../grib_accessor_class_library_version.h.bak | 33 +++ .../grib_accessor_class_local_definition.h | 2 +- ...grib_accessor_class_local_definition.h.bak | 43 +++ src/accessor/grib_accessor_class_long.h | 2 +- src/accessor/grib_accessor_class_long.h.bak | 22 ++ .../grib_accessor_class_long_vector.h | 2 +- .../grib_accessor_class_long_vector.h.bak | 37 +++ src/accessor/grib_accessor_class_longitudes.h | 2 +- .../grib_accessor_class_longitudes.h.bak | 38 +++ src/accessor/grib_accessor_class_lookup.h.bak | 40 +++ src/accessor/grib_accessor_class_mars_param.h | 2 +- .../grib_accessor_class_mars_param.h.bak | 36 +++ src/accessor/grib_accessor_class_mars_step.h | 2 +- .../grib_accessor_class_mars_step.h.bak | 40 +++ src/accessor/grib_accessor_class_md5.h | 2 +- src/accessor/grib_accessor_class_md5.h.bak | 39 +++ src/accessor/grib_accessor_class_message.h | 2 +- .../grib_accessor_class_message.h.bak | 36 +++ .../grib_accessor_class_message_copy.h | 2 +- .../grib_accessor_class_message_copy.h.bak | 36 +++ src/accessor/grib_accessor_class_multdouble.h | 2 +- .../grib_accessor_class_multdouble.h.bak | 34 +++ src/accessor/grib_accessor_class_nearest.h | 2 +- .../grib_accessor_class_nearest.h.bak | 33 +++ src/accessor/grib_accessor_class_non_alpha.h | 2 +- .../grib_accessor_class_non_alpha.h.bak | 39 +++ ...ib_accessor_class_number_of_coded_values.h | 2 +- ...ccessor_class_number_of_coded_values.h.bak | 37 +++ .../grib_accessor_class_number_of_points.h | 2 +- ...grib_accessor_class_number_of_points.h.bak | 36 +++ ...accessor_class_number_of_points_gaussian.h | 2 +- ...ssor_class_number_of_points_gaussian.h.bak | 42 +++ .../grib_accessor_class_number_of_values.h | 2 +- ...grib_accessor_class_number_of_values.h.bak | 38 +++ ..._class_number_of_values_data_raw_packing.h | 2 +- ...ss_number_of_values_data_raw_packing.h.bak | 35 +++ .../grib_accessor_class_octahedral_gaussian.h | 2 +- ...b_accessor_class_octahedral_gaussian.h.bak | 37 +++ .../grib_accessor_class_octet_number.h | 2 +- .../grib_accessor_class_octet_number.h.bak | 35 +++ .../grib_accessor_class_offset_file.h | 2 +- .../grib_accessor_class_offset_file.h.bak | 33 +++ .../grib_accessor_class_offset_values.h | 2 +- .../grib_accessor_class_offset_values.h.bak | 35 +++ .../grib_accessor_class_optimal_step_units.h | 2 +- ...ib_accessor_class_optimal_step_units.h.bak | 44 +++ .../grib_accessor_class_pack_bufr_values.h | 2 +- ...grib_accessor_class_pack_bufr_values.h.bak | 42 +++ .../grib_accessor_class_packing_type.h | 2 +- .../grib_accessor_class_packing_type.h.bak | 37 +++ src/accessor/grib_accessor_class_pad.h | 2 +- src/accessor/grib_accessor_class_pad.h.bak | 34 +++ src/accessor/grib_accessor_class_padding.h | 2 +- .../grib_accessor_class_padding.h.bak | 37 +++ src/accessor/grib_accessor_class_padto.h | 2 +- src/accessor/grib_accessor_class_padto.h.bak | 34 +++ src/accessor/grib_accessor_class_padtoeven.h | 2 +- .../grib_accessor_class_padtoeven.h.bak | 34 +++ .../grib_accessor_class_padtomultiple.h | 2 +- .../grib_accessor_class_padtomultiple.h.bak | 34 +++ src/accessor/grib_accessor_class_position.h | 2 +- .../grib_accessor_class_position.h.bak | 34 +++ .../grib_accessor_class_proj_string.h | 2 +- .../grib_accessor_class_proj_string.h.bak | 35 +++ src/accessor/grib_accessor_class_raw.h | 2 +- src/accessor/grib_accessor_class_raw.h.bak | 41 +++ .../grib_accessor_class_rdbtime_guess_date.h | 2 +- ...ib_accessor_class_rdbtime_guess_date.h.bak | 38 +++ ...rib_accessor_class_reference_value_error.h | 2 +- ...accessor_class_reference_value_error.h.bak | 34 +++ src/accessor/grib_accessor_class_round.h | 2 +- src/accessor/grib_accessor_class_round.h.bak | 32 +++ src/accessor/grib_accessor_class_scale.h | 2 +- src/accessor/grib_accessor_class_scale.h.bak | 39 +++ .../grib_accessor_class_scale_values.h | 2 +- .../grib_accessor_class_scale_values.h.bak | 35 +++ ...cessor_class_second_order_bits_per_value.h | 2 +- ...or_class_second_order_bits_per_value.h.bak | 37 +++ .../grib_accessor_class_section.h.bak | 34 +++ .../grib_accessor_class_section_length.h | 2 +- .../grib_accessor_class_section_length.h.bak | 33 +++ .../grib_accessor_class_section_padding.h | 2 +- .../grib_accessor_class_section_padding.h.bak | 33 +++ .../grib_accessor_class_section_pointer.h | 2 +- .../grib_accessor_class_section_pointer.h.bak | 38 +++ ...grib_accessor_class_select_step_template.h | 2 +- ..._accessor_class_select_step_template.h.bak | 36 +++ .../grib_accessor_class_sexagesimal2decimal.h | 2 +- ...b_accessor_class_sexagesimal2decimal.h.bak | 34 +++ src/accessor/grib_accessor_class_signed.h | 2 +- src/accessor/grib_accessor_class_signed.h.bak | 42 +++ .../grib_accessor_class_signed_bits.h | 2 +- .../grib_accessor_class_signed_bits.h.bak | 40 +++ ...grib_accessor_class_simple_packing_error.h | 2 +- ..._accessor_class_simple_packing_error.h.bak | 37 +++ src/accessor/grib_accessor_class_size.h | 2 +- src/accessor/grib_accessor_class_size.h.bak | 33 +++ .../grib_accessor_class_smart_table.h | 2 +- .../grib_accessor_class_smart_table.h.bak | 52 ++++ ...ib_accessor_class_smart_table_column.h.bak | 37 +++ src/accessor/grib_accessor_class_spd.h | 2 +- src/accessor/grib_accessor_class_spd.h.bak | 40 +++ .../grib_accessor_class_spectral_truncation.h | 2 +- ...b_accessor_class_spectral_truncation.h.bak | 36 +++ src/accessor/grib_accessor_class_sprintf.h | 2 +- .../grib_accessor_class_sprintf.h.bak | 35 +++ src/accessor/grib_accessor_class_statistics.h | 2 +- .../grib_accessor_class_statistics.h.bak | 38 +++ .../grib_accessor_class_statistics_spectral.h | 2 +- ...b_accessor_class_statistics_spectral.h.bak | 40 +++ .../grib_accessor_class_step_human_readable.h | 2 +- ...b_accessor_class_step_human_readable.h.bak | 35 +++ .../grib_accessor_class_step_in_units.h | 2 +- .../grib_accessor_class_step_in_units.h.bak | 43 +++ src/accessor/grib_accessor_class_sum.h | 2 +- src/accessor/grib_accessor_class_sum.h.bak | 35 +++ src/accessor/grib_accessor_class_suppressed.h | 2 +- .../grib_accessor_class_suppressed.h.bak | 37 +++ src/accessor/grib_accessor_class_time.h | 2 +- src/accessor/grib_accessor_class_time.h.bak | 37 +++ src/accessor/grib_accessor_class_to_double.h | 2 +- .../grib_accessor_class_to_double.h.bak | 43 +++ src/accessor/grib_accessor_class_to_integer.h | 2 +- .../grib_accessor_class_to_integer.h.bak | 45 +++ src/accessor/grib_accessor_class_to_string.h | 2 +- .../grib_accessor_class_to_string.h.bak | 42 +++ .../grib_accessor_class_transient.h.bak | 25 ++ .../grib_accessor_class_transient_darray.h | 2 +- ...grib_accessor_class_transient_darray.h.bak | 41 +++ src/accessor/grib_accessor_class_trim.h | 2 +- src/accessor/grib_accessor_class_trim.h.bak | 37 +++ src/accessor/grib_accessor_class_uint16.h | 2 +- src/accessor/grib_accessor_class_uint16.h.bak | 32 +++ src/accessor/grib_accessor_class_uint32.h | 2 +- src/accessor/grib_accessor_class_uint32.h.bak | 32 +++ ...grib_accessor_class_uint32_little_endian.h | 2 +- ..._accessor_class_uint32_little_endian.h.bak | 32 +++ src/accessor/grib_accessor_class_uint64.h | 2 +- src/accessor/grib_accessor_class_uint64.h.bak | 32 +++ ...grib_accessor_class_uint64_little_endian.h | 2 +- ..._accessor_class_uint64_little_endian.h.bak | 32 +++ src/accessor/grib_accessor_class_uint8.h | 2 +- src/accessor/grib_accessor_class_uint8.h.bak | 32 +++ ...ib_accessor_class_unexpanded_descriptors.h | 2 +- ...ccessor_class_unexpanded_descriptors.h.bak | 39 +++ .../grib_accessor_class_unpack_bufr_values.h | 2 +- ...ib_accessor_class_unpack_bufr_values.h.bak | 42 +++ src/accessor/grib_accessor_class_unsigned.h | 2 +- .../grib_accessor_class_unsigned.h.bak | 40 +++ .../grib_accessor_class_unsigned_bits.h | 2 +- .../grib_accessor_class_unsigned_bits.h.bak | 40 +++ .../grib_accessor_class_validity_date.h | 2 +- .../grib_accessor_class_validity_date.h.bak | 39 +++ .../grib_accessor_class_validity_time.h | 2 +- .../grib_accessor_class_validity_time.h.bak | 39 +++ src/accessor/grib_accessor_class_values.h.bak | 41 +++ .../grib_accessor_class_variable.h.bak | 49 ++++ src/accessor/grib_accessor_class_vector.h | 2 +- src/accessor/grib_accessor_class_vector.h.bak | 34 +++ src/accessor/grib_accessor_class_when.h | 2 +- src/accessor/grib_accessor_class_when.h.bak | 34 +++ 391 files changed, 8812 insertions(+), 189 deletions(-) create mode 100644 src/accessor/grib_accessor_class_abstract_long_vector.h.bak create mode 100644 src/accessor/grib_accessor_class_abstract_vector.h.bak create mode 100644 src/accessor/grib_accessor_class_ascii.h.bak create mode 100644 src/accessor/grib_accessor_class_bit.h.bak create mode 100644 src/accessor/grib_accessor_class_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_bits.h.bak create mode 100644 src/accessor/grib_accessor_class_bits_per_value.h.bak create mode 100644 src/accessor/grib_accessor_class_blob.h.bak create mode 100644 src/accessor/grib_accessor_class_budgdate.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_data_array.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_data_element.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_elements_table.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_group.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak create mode 100644 src/accessor/grib_accessor_class_bufr_string_values.h.bak create mode 100644 src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak create mode 100644 src/accessor/grib_accessor_class_bytes.h.bak create mode 100644 src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak create mode 100644 src/accessor/grib_accessor_class_change_scanning_direction.h.bak create mode 100644 src/accessor/grib_accessor_class_check_internal_version.h.bak create mode 100644 src/accessor/grib_accessor_class_closest_date.h.bak create mode 100644 src/accessor/grib_accessor_class_codeflag.h.bak create mode 100644 src/accessor/grib_accessor_class_codetable.h.bak create mode 100644 src/accessor/grib_accessor_class_codetable_title.h.bak create mode 100644 src/accessor/grib_accessor_class_codetable_units.h.bak create mode 100644 src/accessor/grib_accessor_class_concept.h.bak create mode 100644 src/accessor/grib_accessor_class_constant.h.bak create mode 100644 src/accessor/grib_accessor_class_count_file.h.bak create mode 100644 src/accessor/grib_accessor_class_count_missing.h.bak create mode 100644 src/accessor/grib_accessor_class_count_total.h.bak create mode 100644 src/accessor/grib_accessor_class_data_apply_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak create mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_data_ccsds_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_complex_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_dummy_field.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1complex_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g1simple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g22order_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2complex_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_png_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_raw_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_run_length_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_data_sh_packed.h.bak create mode 100644 src/accessor/grib_accessor_class_data_sh_unpacked.h.bak create mode 100644 src/accessor/grib_accessor_class_data_shsimple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_data_simple_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_decimal_precision.h.bak create mode 100644 src/accessor/grib_accessor_class_dictionary.h.bak create mode 100644 src/accessor/grib_accessor_class_dirty.h.bak create mode 100644 src/accessor/grib_accessor_class_divdouble.h.bak create mode 100644 src/accessor/grib_accessor_class_double.h.bak create mode 100644 src/accessor/grib_accessor_class_element.h.bak create mode 100644 src/accessor/grib_accessor_class_evaluate.h.bak create mode 100644 src/accessor/grib_accessor_class_expanded_descriptors.h.bak create mode 100644 src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak create mode 100644 src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak create mode 100644 src/accessor/grib_accessor_class_g1_message_length.h.bak create mode 100644 src/accessor/grib_accessor_class_g1_section4_length.h.bak create mode 100644 src/accessor/grib_accessor_class_g1bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_g1date.h.bak create mode 100644 src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak create mode 100644 src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak create mode 100644 src/accessor/grib_accessor_class_g1fcperiod.h.bak create mode 100644 src/accessor/grib_accessor_class_g1forecastmonth.h.bak create mode 100644 src/accessor/grib_accessor_class_g1monthlydate.h.bak create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak create mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak create mode 100644 src/accessor/grib_accessor_class_g1step_range.h.bak create mode 100644 src/accessor/grib_accessor_class_g1verificationdate.h.bak create mode 100644 src/accessor/grib_accessor_class_g2_aerosol.h.bak create mode 100644 src/accessor/grib_accessor_class_g2_chemical.h.bak create mode 100644 src/accessor/grib_accessor_class_g2_eps.h.bak create mode 100644 src/accessor/grib_accessor_class_g2_mars_labeling.h.bak create mode 100644 src/accessor/grib_accessor_class_g2bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_g2bitmap_present.h.bak create mode 100644 src/accessor/grib_accessor_class_g2date.h.bak create mode 100644 src/accessor/grib_accessor_class_g2end_step.h.bak create mode 100644 src/accessor/grib_accessor_class_g2grid.h.bak create mode 100644 src/accessor/grib_accessor_class_g2latlon.h.bak create mode 100644 src/accessor/grib_accessor_class_g2level.h.bak create mode 100644 src/accessor/grib_accessor_class_g2lon.h.bak create mode 100644 src/accessor/grib_accessor_class_g2step_range.h.bak create mode 100644 src/accessor/grib_accessor_class_gaussian_grid_name.h.bak create mode 100644 src/accessor/grib_accessor_class_gds_is_present.h.bak create mode 100644 src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak create mode 100644 src/accessor/grib_accessor_class_gen.h.bak create mode 100644 src/accessor/grib_accessor_class_getenv.h.bak create mode 100644 src/accessor/grib_accessor_class_global_gaussian.h.bak create mode 100644 src/accessor/grib_accessor_class_group.h.bak create mode 100644 src/accessor/grib_accessor_class_gts_header.h.bak create mode 100644 src/accessor/grib_accessor_class_hash_array.h.bak create mode 100644 src/accessor/grib_accessor_class_headers_only.h.bak create mode 100644 src/accessor/grib_accessor_class_ibmfloat.h.bak create mode 100644 src/accessor/grib_accessor_class_ieeefloat.h.bak create mode 100644 src/accessor/grib_accessor_class_ifs_param.h.bak create mode 100644 src/accessor/grib_accessor_class_iterator.h.bak create mode 100644 src/accessor/grib_accessor_class_julian_date.h.bak create mode 100644 src/accessor/grib_accessor_class_julian_day.h.bak create mode 100644 src/accessor/grib_accessor_class_ksec1expver.h.bak create mode 100644 src/accessor/grib_accessor_class_label.h.bak create mode 100644 src/accessor/grib_accessor_class_latitudes.h.bak create mode 100644 src/accessor/grib_accessor_class_latlon_increment.h.bak create mode 100644 src/accessor/grib_accessor_class_latlonvalues.h.bak create mode 100644 src/accessor/grib_accessor_class_library_version.h.bak create mode 100644 src/accessor/grib_accessor_class_local_definition.h.bak create mode 100644 src/accessor/grib_accessor_class_long.h.bak create mode 100644 src/accessor/grib_accessor_class_long_vector.h.bak create mode 100644 src/accessor/grib_accessor_class_longitudes.h.bak create mode 100644 src/accessor/grib_accessor_class_lookup.h.bak create mode 100644 src/accessor/grib_accessor_class_mars_param.h.bak create mode 100644 src/accessor/grib_accessor_class_mars_step.h.bak create mode 100644 src/accessor/grib_accessor_class_md5.h.bak create mode 100644 src/accessor/grib_accessor_class_message.h.bak create mode 100644 src/accessor/grib_accessor_class_message_copy.h.bak create mode 100644 src/accessor/grib_accessor_class_multdouble.h.bak create mode 100644 src/accessor/grib_accessor_class_nearest.h.bak create mode 100644 src/accessor/grib_accessor_class_non_alpha.h.bak create mode 100644 src/accessor/grib_accessor_class_number_of_coded_values.h.bak create mode 100644 src/accessor/grib_accessor_class_number_of_points.h.bak create mode 100644 src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak create mode 100644 src/accessor/grib_accessor_class_number_of_values.h.bak create mode 100644 src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak create mode 100644 src/accessor/grib_accessor_class_octahedral_gaussian.h.bak create mode 100644 src/accessor/grib_accessor_class_octet_number.h.bak create mode 100644 src/accessor/grib_accessor_class_offset_file.h.bak create mode 100644 src/accessor/grib_accessor_class_offset_values.h.bak create mode 100644 src/accessor/grib_accessor_class_optimal_step_units.h.bak create mode 100644 src/accessor/grib_accessor_class_pack_bufr_values.h.bak create mode 100644 src/accessor/grib_accessor_class_packing_type.h.bak create mode 100644 src/accessor/grib_accessor_class_pad.h.bak create mode 100644 src/accessor/grib_accessor_class_padding.h.bak create mode 100644 src/accessor/grib_accessor_class_padto.h.bak create mode 100644 src/accessor/grib_accessor_class_padtoeven.h.bak create mode 100644 src/accessor/grib_accessor_class_padtomultiple.h.bak create mode 100644 src/accessor/grib_accessor_class_position.h.bak create mode 100644 src/accessor/grib_accessor_class_proj_string.h.bak create mode 100644 src/accessor/grib_accessor_class_raw.h.bak create mode 100644 src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak create mode 100644 src/accessor/grib_accessor_class_reference_value_error.h.bak create mode 100644 src/accessor/grib_accessor_class_round.h.bak create mode 100644 src/accessor/grib_accessor_class_scale.h.bak create mode 100644 src/accessor/grib_accessor_class_scale_values.h.bak create mode 100644 src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak create mode 100644 src/accessor/grib_accessor_class_section.h.bak create mode 100644 src/accessor/grib_accessor_class_section_length.h.bak create mode 100644 src/accessor/grib_accessor_class_section_padding.h.bak create mode 100644 src/accessor/grib_accessor_class_section_pointer.h.bak create mode 100644 src/accessor/grib_accessor_class_select_step_template.h.bak create mode 100644 src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak create mode 100644 src/accessor/grib_accessor_class_signed.h.bak create mode 100644 src/accessor/grib_accessor_class_signed_bits.h.bak create mode 100644 src/accessor/grib_accessor_class_simple_packing_error.h.bak create mode 100644 src/accessor/grib_accessor_class_size.h.bak create mode 100644 src/accessor/grib_accessor_class_smart_table.h.bak create mode 100644 src/accessor/grib_accessor_class_smart_table_column.h.bak create mode 100644 src/accessor/grib_accessor_class_spd.h.bak create mode 100644 src/accessor/grib_accessor_class_spectral_truncation.h.bak create mode 100644 src/accessor/grib_accessor_class_sprintf.h.bak create mode 100644 src/accessor/grib_accessor_class_statistics.h.bak create mode 100644 src/accessor/grib_accessor_class_statistics_spectral.h.bak create mode 100644 src/accessor/grib_accessor_class_step_human_readable.h.bak create mode 100644 src/accessor/grib_accessor_class_step_in_units.h.bak create mode 100644 src/accessor/grib_accessor_class_sum.h.bak create mode 100644 src/accessor/grib_accessor_class_suppressed.h.bak create mode 100644 src/accessor/grib_accessor_class_time.h.bak create mode 100644 src/accessor/grib_accessor_class_to_double.h.bak create mode 100644 src/accessor/grib_accessor_class_to_integer.h.bak create mode 100644 src/accessor/grib_accessor_class_to_string.h.bak create mode 100644 src/accessor/grib_accessor_class_transient.h.bak create mode 100644 src/accessor/grib_accessor_class_transient_darray.h.bak create mode 100644 src/accessor/grib_accessor_class_trim.h.bak create mode 100644 src/accessor/grib_accessor_class_uint16.h.bak create mode 100644 src/accessor/grib_accessor_class_uint32.h.bak create mode 100644 src/accessor/grib_accessor_class_uint32_little_endian.h.bak create mode 100644 src/accessor/grib_accessor_class_uint64.h.bak create mode 100644 src/accessor/grib_accessor_class_uint64_little_endian.h.bak create mode 100644 src/accessor/grib_accessor_class_uint8.h.bak create mode 100644 src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak create mode 100644 src/accessor/grib_accessor_class_unpack_bufr_values.h.bak create mode 100644 src/accessor/grib_accessor_class_unsigned.h.bak create mode 100644 src/accessor/grib_accessor_class_unsigned_bits.h.bak create mode 100644 src/accessor/grib_accessor_class_validity_date.h.bak create mode 100644 src/accessor/grib_accessor_class_validity_time.h.bak create mode 100644 src/accessor/grib_accessor_class_values.h.bak create mode 100644 src/accessor/grib_accessor_class_variable.h.bak create mode 100644 src/accessor/grib_accessor_class_vector.h.bak create mode 100644 src/accessor/grib_accessor_class_when.h.bak diff --git a/src/accessor/grib_accessor.h b/src/accessor/grib_accessor.h index 7220e90e7..c18a355d2 100644 --- a/src/accessor/grib_accessor.h +++ b/src/accessor/grib_accessor.h @@ -10,8 +10,8 @@ #pragma once -#include "../grib_api_internal.h" -#include "../grib_value.h" +#include "grib_api_internal.h" +#include "grib_value.h" class grib_accessor { diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h b/src/accessor/grib_accessor_class_abstract_long_vector.h index 2961979d8..5c3c6b5f9 100644 --- a/src/accessor/grib_accessor_class_abstract_long_vector.h +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_abstract_long_vector_h #define eccodes_accessor_abstract_long_vector_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h.bak b/src/accessor/grib_accessor_class_abstract_long_vector.h.bak new file mode 100644 index 000000000..2961979d8 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_abstract_long_vector_h +#define eccodes_accessor_abstract_long_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t +{ +public: + /* Members defined in abstract_long_vector */ + long* v; + long pack_index; + int number_of_elements; +}; + +class grib_accessor_class_abstract_long_vector_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_abstract_long_vector_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; } +}; +#endif /* eccodes_accessor_abstract_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_abstract_vector.h b/src/accessor/grib_accessor_class_abstract_vector.h index df7e3fdbf..d1201ede7 100644 --- a/src/accessor/grib_accessor_class_abstract_vector.h +++ b/src/accessor/grib_accessor_class_abstract_vector.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_abstract_vector_h #define eccodes_accessor_abstract_vector_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_abstract_vector_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_abstract_vector.h.bak b/src/accessor/grib_accessor_class_abstract_vector.h.bak new file mode 100644 index 000000000..df7e3fdbf --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_vector.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_abstract_vector_h +#define eccodes_accessor_abstract_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_abstract_vector_t : public grib_accessor_double_t +{ +public: + /* Members defined in abstract_vector */ + double* v; + int number_of_elements; +}; + +class grib_accessor_class_abstract_vector_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_abstract_vector_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; } +}; +#endif /* eccodes_accessor_abstract_vector_h */ diff --git a/src/accessor/grib_accessor_class_ascii.h b/src/accessor/grib_accessor_class_ascii.h index cb8e68bd7..ea00a247c 100644 --- a/src/accessor/grib_accessor_class_ascii.h +++ b/src/accessor/grib_accessor_class_ascii.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_ascii_h #define eccodes_accessor_ascii_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_ascii_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_ascii.h.bak b/src/accessor/grib_accessor_class_ascii.h.bak new file mode 100644 index 000000000..cb8e68bd7 --- /dev/null +++ b/src/accessor/grib_accessor_class_ascii.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ascii_h +#define eccodes_accessor_ascii_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_ascii_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ascii */ +}; + +class grib_accessor_class_ascii_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ascii_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ascii_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_ascii_h */ diff --git a/src/accessor/grib_accessor_class_bit.h b/src/accessor/grib_accessor_class_bit.h index 3a9eee2d7..28c001488 100644 --- a/src/accessor/grib_accessor_class_bit.h +++ b/src/accessor/grib_accessor_class_bit.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bit_h #define eccodes_accessor_bit_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bit_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bit.h.bak b/src/accessor/grib_accessor_class_bit.h.bak new file mode 100644 index 000000000..3a9eee2d7 --- /dev/null +++ b/src/accessor/grib_accessor_class_bit.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bit_h +#define eccodes_accessor_bit_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bit_t : public grib_accessor_long_t +{ +public: + /* Members defined in bit */ + const char* owner; + int bit_index; +}; + +class grib_accessor_class_bit_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bit_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bit_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bit_h */ diff --git a/src/accessor/grib_accessor_class_bitmap.h b/src/accessor/grib_accessor_class_bitmap.h index d9b3ab9df..dd66d6256 100644 --- a/src/accessor/grib_accessor_class_bitmap.h +++ b/src/accessor/grib_accessor_class_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bitmap_h #define eccodes_accessor_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_bitmap_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_bitmap.h.bak b/src/accessor/grib_accessor_class_bitmap.h.bak new file mode 100644 index 000000000..d9b3ab9df --- /dev/null +++ b/src/accessor/grib_accessor_class_bitmap.h.bak @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bitmap_h +#define eccodes_accessor_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_bitmap_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in bitmap */ + const char* tableReference; + const char* missing_value; + const char* offsetbsec; + const char* sLength; +}; + +class grib_accessor_class_bitmap_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_bitmap_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bitmap_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_bits.h b/src/accessor/grib_accessor_class_bits.h index b5dd2977b..dccc43486 100644 --- a/src/accessor/grib_accessor_class_bits.h +++ b/src/accessor/grib_accessor_class_bits.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bits_h #define eccodes_accessor_bits_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bits_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bits.h.bak b/src/accessor/grib_accessor_class_bits.h.bak new file mode 100644 index 000000000..b5dd2977b --- /dev/null +++ b/src/accessor/grib_accessor_class_bits.h.bak @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bits_h +#define eccodes_accessor_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bits_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bits */ + const char* argument; + long start; + long len; + double referenceValue; + double referenceValuePresent; + double scale; +}; + +class grib_accessor_class_bits_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bits_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bits_h */ diff --git a/src/accessor/grib_accessor_class_bits_per_value.h b/src/accessor/grib_accessor_class_bits_per_value.h index 59514fc05..3d83e07e6 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.h +++ b/src/accessor/grib_accessor_class_bits_per_value.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bits_per_value_h #define eccodes_accessor_bits_per_value_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bits_per_value_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bits_per_value.h.bak b/src/accessor/grib_accessor_class_bits_per_value.h.bak new file mode 100644 index 000000000..59514fc05 --- /dev/null +++ b/src/accessor/grib_accessor_class_bits_per_value.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bits_per_value_h +#define eccodes_accessor_bits_per_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in bits_per_value */ + const char* values; + const char* bits_per_value; +}; + +class grib_accessor_class_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_blob.h b/src/accessor/grib_accessor_class_blob.h index a2da98a03..d0dc4b290 100644 --- a/src/accessor/grib_accessor_class_blob.h +++ b/src/accessor/grib_accessor_class_blob.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_blob_h #define eccodes_accessor_blob_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_blob_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_blob.h.bak b/src/accessor/grib_accessor_class_blob.h.bak new file mode 100644 index 000000000..a2da98a03 --- /dev/null +++ b/src/accessor/grib_accessor_class_blob.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_blob_h +#define eccodes_accessor_blob_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_blob_t : public grib_accessor_gen_t +{ +public: + /* Members defined in blob */ +}; + +class grib_accessor_class_blob_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_blob_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_blob_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_blob_h */ diff --git a/src/accessor/grib_accessor_class_budgdate.h b/src/accessor/grib_accessor_class_budgdate.h index c3fc849c7..d5a75ffe1 100644 --- a/src/accessor/grib_accessor_class_budgdate.h +++ b/src/accessor/grib_accessor_class_budgdate.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_budgdate_h #define eccodes_accessor_budgdate_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_budgdate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_budgdate.h.bak b/src/accessor/grib_accessor_class_budgdate.h.bak new file mode 100644 index 000000000..c3fc849c7 --- /dev/null +++ b/src/accessor/grib_accessor_class_budgdate.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_budgdate_h +#define eccodes_accessor_budgdate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_budgdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in budgdate */ + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_budgdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_budgdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_budgdate_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_budgdate_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h.bak b/src/accessor/grib_accessor_class_bufr_data_array.h.bak new file mode 100644 index 000000000..c6089fa63 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_array.h.bak @@ -0,0 +1,92 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_data_array_h +#define eccodes_accessor_bufr_data_array_h + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_array_t : public grib_accessor_gen_t +{ +public: + const char* bufrDataEncodedName; + const char* numberOfSubsetsName; + const char* expandedDescriptorsName; + const char* flagsName; + const char* unitsName; + const char* elementsDescriptorsIndexName; + const char* compressedDataName; + bufr_descriptors_array* expanded; + grib_accessor* expandedAccessor; + int* canBeMissing; + long numberOfSubsets; + long compressedData; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + int do_decode; + int bitmapStartElementsDescriptorsIndex; + int bitmapCurrentElementsDescriptorsIndex; + int bitmapSize; + int bitmapStart; + int bitmapCurrent; + grib_accessors_list* dataAccessors; + int unpackMode; + int bitsToEndData; + grib_section* dataKeys; + double* inputBitmap; + int nInputBitmap; + int iInputBitmap; + long* inputReplications; + int nInputReplications; + int iInputReplications; + long* inputExtendedReplications; + int nInputExtendedReplications; + int iInputExtendedReplications; + long* inputShortReplications; + int nInputShortReplications; + int iInputShortReplications; + grib_iarray* iss_list; + grib_trie_with_rank* dataAccessorsTrie; + grib_sarray* tempStrings; + grib_vdarray* tempDoubleValues; + int change_ref_value_operand; + size_t refValListSize; + long* refValList; + long refValIndex; + bufr_tableb_override* tableb_override; + int set_to_missing_if_out_of_range; +}; + +class grib_accessor_class_bufr_data_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; + +grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); +grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); +grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); +void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); + +#endif /* eccodes_accessor_bufr_data_array_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h index 6cba5b91c..a8766df47 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.h +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_data_element_h #define eccodes_accessor_bufr_data_element_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h.bak b/src/accessor/grib_accessor_class_bufr_data_element.h.bak new file mode 100644 index 000000000..6cba5b91c --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_element.h.bak @@ -0,0 +1,57 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_data_element_h +#define eccodes_accessor_bufr_data_element_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_data_element */ + long index; + int type; + long compressedData; + long subsetNumber; + long numberOfSubsets; + bufr_descriptors_array* descriptors; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + char* cname; +}; + +class grib_accessor_class_bufr_data_element_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_element_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_element_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; +#endif /* eccodes_accessor_bufr_data_element_h */ diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h b/src/accessor/grib_accessor_class_bufr_elements_table.h index 8ddd8a824..1149b2ad3 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.h +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_elements_table_h #define eccodes_accessor_bufr_elements_table_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h.bak b/src/accessor/grib_accessor_class_bufr_elements_table.h.bak new file mode 100644 index 000000000..8ddd8a824 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_elements_table_h +#define eccodes_accessor_bufr_elements_table_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_elements_table */ + const char* dictionary; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_bufr_elements_table_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_elements_table_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_elements_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_elements_table_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h index d079f958e..f2e8b0ba2 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_extract_area_subsets_h #define eccodes_accessor_bufr_extract_area_subsets_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak new file mode 100644 index 000000000..d079f958e --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_area_subsets_h +#define eccodes_accessor_bufr_extract_area_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_area_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* extractAreaWestLongitude; + const char* extractAreaEastLongitude; + const char* extractAreaNorthLatitude; + const char* extractAreaSouthLatitude; + const char* extractAreaLongitudeRank; + const char* extractAreaLatitudeRank; + const char* extractedAreaNumberOfSubsets; +}; + +class grib_accessor_class_bufr_extract_area_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_area_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_area_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_area_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h index 7acfd35b3..3f7c505e0 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_extract_datetime_subsets_h #define eccodes_accessor_bufr_extract_datetime_subsets_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak new file mode 100644 index 000000000..7acfd35b3 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_datetime_subsets_h +#define eccodes_accessor_bufr_extract_datetime_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_datetime_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; +}; + +class grib_accessor_class_bufr_extract_datetime_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_datetime_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_datetime_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_datetime_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_subsets.h index 80392338d..736206c08 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_extract_subsets_h #define eccodes_accessor_bufr_extract_subsets_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak new file mode 100644 index 000000000..80392338d --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_extract_subsets_h +#define eccodes_accessor_bufr_extract_subsets_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_subsets */ + const char* numericValues; + const char* pack; + grib_accessor* numericValuesAccessor; + grib_accessor* packAccessor; +}; + +class grib_accessor_class_bufr_extract_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_extract_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h index 3bd71690f..c225cfe2d 100644 --- a/src/accessor/grib_accessor_class_bufr_group.h +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_group_h #define eccodes_accessor_bufr_group_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_variable.h" class grib_accessor_bufr_group_t : public grib_accessor_variable_t diff --git a/src/accessor/grib_accessor_class_bufr_group.h.bak b/src/accessor/grib_accessor_class_bufr_group.h.bak new file mode 100644 index 000000000..3bd71690f --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_group.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_group_h +#define eccodes_accessor_bufr_group_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_variable.h" + +class grib_accessor_bufr_group_t : public grib_accessor_variable_t +{ +public: + /* Members defined in bufr_group */ +}; + +class grib_accessor_class_bufr_group_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_bufr_group_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; } + void dump(grib_accessor*, grib_dumper*) override; + grib_accessor* next(grib_accessor* a, int explore) override; +}; +#endif /* eccodes_accessor_bufr_group_h */ diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h b/src/accessor/grib_accessor_class_bufr_simple_thinning.h index eb786f966..6971e5edb 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.h +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_simple_thinning_h #define eccodes_accessor_bufr_simple_thinning_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak b/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak new file mode 100644 index 000000000..eb786f966 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_simple_thinning_h +#define eccodes_accessor_bufr_simple_thinning_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_simple_thinning */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* simpleThinningStart; + const char* simpleThinningMissingRadius; + const char* simpleThinningSkip; +}; + +class grib_accessor_class_bufr_simple_thinning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_simple_thinning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_simple_thinning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_simple_thinning_h */ diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h b/src/accessor/grib_accessor_class_bufr_string_values.h index 9038a8d73..2262990a7 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.h +++ b/src/accessor/grib_accessor_class_bufr_string_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufr_string_values_h #define eccodes_accessor_bufr_string_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h.bak b/src/accessor/grib_accessor_class_bufr_string_values.h.bak new file mode 100644 index 000000000..9038a8d73 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_string_values.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufr_string_values_h +#define eccodes_accessor_bufr_string_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in bufr_string_values */ + const char* dataAccessorName; + grib_accessor* dataAccessor; +}; + +class grib_accessor_class_bufr_string_values_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_bufr_string_values_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_string_values_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufr_string_values_h */ diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h index 588f9d08b..9d8f551b2 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bufrdc_expanded_descriptors_h #define eccodes_accessor_bufrdc_expanded_descriptors_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak new file mode 100644 index 000000000..588f9d08b --- /dev/null +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bufrdc_expanded_descriptors_h +#define eccodes_accessor_bufrdc_expanded_descriptors_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in bufrdc_expanded_descriptors */ + const char* expandedDescriptors; + grib_accessor* expandedDescriptorsAccessor; +}; + +class grib_accessor_class_bufrdc_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bufrdc_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufrdc_expanded_descriptors_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_bufrdc_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_bytes.h b/src/accessor/grib_accessor_class_bytes.h index 8204ceba7..ee72f13c3 100644 --- a/src/accessor/grib_accessor_class_bytes.h +++ b/src/accessor/grib_accessor_class_bytes.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_bytes_h #define eccodes_accessor_bytes_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bytes_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bytes.h.bak b/src/accessor/grib_accessor_class_bytes.h.bak new file mode 100644 index 000000000..8204ceba7 --- /dev/null +++ b/src/accessor/grib_accessor_class_bytes.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_bytes_h +#define eccodes_accessor_bytes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_bytes_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bytes */ +}; + +class grib_accessor_class_bytes_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bytes_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bytes_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_bytes_h */ diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h index c893e242f..3caca2a6b 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_change_alternative_row_scanning_h #define eccodes_accessor_change_alternative_row_scanning_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak new file mode 100644 index 000000000..c893e242f --- /dev/null +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_change_alternative_row_scanning_h +#define eccodes_accessor_change_alternative_row_scanning_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_alternative_row_scanning */ + const char* values; + const char* Ni; + const char* Nj; + const char* alternativeRowScanning; +}; + +class grib_accessor_class_change_alternative_row_scanning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_alternative_row_scanning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_alternative_row_scanning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_change_alternative_row_scanning_h */ diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h b/src/accessor/grib_accessor_class_change_scanning_direction.h index 08f2ceb55..7d8ac8d6a 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.h +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_change_scanning_direction_h #define eccodes_accessor_change_scanning_direction_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h.bak b/src/accessor/grib_accessor_class_change_scanning_direction.h.bak new file mode 100644 index 000000000..08f2ceb55 --- /dev/null +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_change_scanning_direction_h +#define eccodes_accessor_change_scanning_direction_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_scanning_direction */ + const char* values; + const char* Ni; + const char* Nj; + const char* i_scans_negatively; + const char* j_scans_positively; + const char* first; + const char* last; + const char* axis; +}; + +class grib_accessor_class_change_scanning_direction_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_scanning_direction_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_scanning_direction_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_change_scanning_direction_h */ diff --git a/src/accessor/grib_accessor_class_check_internal_version.h b/src/accessor/grib_accessor_class_check_internal_version.h index 871f5a56e..222ec76ab 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.h +++ b/src/accessor/grib_accessor_class_check_internal_version.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_check_internal_version_h #define eccodes_accessor_check_internal_version_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_check_internal_version.h.bak b/src/accessor/grib_accessor_class_check_internal_version.h.bak new file mode 100644 index 000000000..871f5a56e --- /dev/null +++ b/src/accessor/grib_accessor_class_check_internal_version.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_check_internal_version_h +#define eccodes_accessor_check_internal_version_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in check_internal_version */ +}; + +class grib_accessor_class_check_internal_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_check_internal_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_check_internal_version_t{}; } + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_check_internal_version_h */ diff --git a/src/accessor/grib_accessor_class_closest_date.h b/src/accessor/grib_accessor_class_closest_date.h index b4fbace12..be6d3aa98 100644 --- a/src/accessor/grib_accessor_class_closest_date.h +++ b/src/accessor/grib_accessor_class_closest_date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_closest_date_h #define eccodes_accessor_closest_date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_closest_date_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_closest_date.h.bak b/src/accessor/grib_accessor_class_closest_date.h.bak new file mode 100644 index 000000000..b4fbace12 --- /dev/null +++ b/src/accessor/grib_accessor_class_closest_date.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_closest_date_h +#define eccodes_accessor_closest_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_closest_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in closest_date */ + const char *dateLocal; + const char *timeLocal; + const char *numForecasts; + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_closest_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_closest_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_closest_date_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_closest_date_h */ diff --git a/src/accessor/grib_accessor_class_codeflag.h b/src/accessor/grib_accessor_class_codeflag.h index 734369b74..f74af599a 100644 --- a/src/accessor/grib_accessor_class_codeflag.h +++ b/src/accessor/grib_accessor_class_codeflag.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_codeflag_h #define eccodes_accessor_codeflag_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_codeflag_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_codeflag.h.bak b/src/accessor/grib_accessor_class_codeflag.h.bak new file mode 100644 index 000000000..734369b74 --- /dev/null +++ b/src/accessor/grib_accessor_class_codeflag.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codeflag_h +#define eccodes_accessor_codeflag_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_codeflag_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in codeflag */ + const char* tablename; +}; + +class grib_accessor_class_codeflag_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_codeflag_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codeflag_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_codetable.h b/src/accessor/grib_accessor_class_codetable.h index c77c6f72d..48ae07502 100644 --- a/src/accessor/grib_accessor_class_codetable.h +++ b/src/accessor/grib_accessor_class_codetable.h @@ -14,7 +14,7 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" #include diff --git a/src/accessor/grib_accessor_class_codetable.h.bak b/src/accessor/grib_accessor_class_codetable.h.bak new file mode 100644 index 000000000..c77c6f72d --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable.h.bak @@ -0,0 +1,47 @@ +/* + * (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. + */ + +/***************************************** + * Enrico Fucile + ****************************************/ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" +#include + + +class grib_accessor_codetable_t : public grib_accessor_unsigned_t +{ +public: + const char* tablename; + const char* masterDir; + const char* localDir; + grib_codetable* table; + int table_loaded; +}; + +class grib_accessor_class_codetable_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_t{}; } + grib_accessor_class_codetable_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_codetable_title.h b/src/accessor/grib_accessor_class_codetable_title.h index e115a9c28..873b3e0a1 100644 --- a/src/accessor/grib_accessor_class_codetable_title.h +++ b/src/accessor/grib_accessor_class_codetable_title.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_codetable_title_h #define eccodes_accessor_codetable_title_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_codetable_title_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_codetable_title.h.bak b/src/accessor/grib_accessor_class_codetable_title.h.bak new file mode 100644 index 000000000..e115a9c28 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_title.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codetable_title_h +#define eccodes_accessor_codetable_title_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_title_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_title */ + const char* codetable; +}; + +class grib_accessor_class_codetable_title_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_title_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_title_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codetable_title_h */ diff --git a/src/accessor/grib_accessor_class_codetable_units.h b/src/accessor/grib_accessor_class_codetable_units.h index b5cfb75c8..913afb1d2 100644 --- a/src/accessor/grib_accessor_class_codetable_units.h +++ b/src/accessor/grib_accessor_class_codetable_units.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_codetable_units_h #define eccodes_accessor_codetable_units_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_codetable_units_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_codetable_units.h.bak b/src/accessor/grib_accessor_class_codetable_units.h.bak new file mode 100644 index 000000000..b5cfb75c8 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_units.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_codetable_units_h +#define eccodes_accessor_codetable_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_units */ + const char* codetable; +}; + +class grib_accessor_class_codetable_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_units_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_codetable_units_h */ diff --git a/src/accessor/grib_accessor_class_concept.h b/src/accessor/grib_accessor_class_concept.h index 99405ed48..436e5b95e 100644 --- a/src/accessor/grib_accessor_class_concept.h +++ b/src/accessor/grib_accessor_class_concept.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_concept_h #define eccodes_accessor_concept_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_concept_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_concept.h.bak b/src/accessor/grib_accessor_class_concept.h.bak new file mode 100644 index 000000000..99405ed48 --- /dev/null +++ b/src/accessor/grib_accessor_class_concept.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_concept_h +#define eccodes_accessor_concept_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_concept_t : public grib_accessor_gen_t +{ +public: + /* Members defined in concept */ +}; + +class grib_accessor_class_concept_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_concept_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_concept_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_concept_h */ diff --git a/src/accessor/grib_accessor_class_constant.h b/src/accessor/grib_accessor_class_constant.h index 0c4944c68..029c51e79 100644 --- a/src/accessor/grib_accessor_class_constant.h +++ b/src/accessor/grib_accessor_class_constant.h @@ -13,7 +13,7 @@ * Enrico Fucile **************************************/ -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_variable.h" class grib_accessor_constant_t : public grib_accessor_variable_t {}; diff --git a/src/accessor/grib_accessor_class_constant.h.bak b/src/accessor/grib_accessor_class_constant.h.bak new file mode 100644 index 000000000..0c4944c68 --- /dev/null +++ b/src/accessor/grib_accessor_class_constant.h.bak @@ -0,0 +1,27 @@ +/* + * (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. + */ + + +/************************************* + * Enrico Fucile + **************************************/ + +#include "../grib_api_internal.h" +#include "grib_accessor_class_variable.h" + +class grib_accessor_constant_t : public grib_accessor_variable_t {}; + +class grib_accessor_class_constant_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_constant_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_constant_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_count_file.h b/src/accessor/grib_accessor_class_count_file.h index 4b9a0b4f0..fd2251045 100644 --- a/src/accessor/grib_accessor_class_count_file.h +++ b/src/accessor/grib_accessor_class_count_file.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_count_file_h #define eccodes_accessor_count_file_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_file_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_count_file.h.bak b/src/accessor/grib_accessor_class_count_file.h.bak new file mode 100644 index 000000000..4b9a0b4f0 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_file.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_file_h +#define eccodes_accessor_count_file_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_file_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_file */ +}; + +class grib_accessor_class_count_file_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_file_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_file_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_file_h */ diff --git a/src/accessor/grib_accessor_class_count_missing.h b/src/accessor/grib_accessor_class_count_missing.h index fbf583109..d43c6f22e 100644 --- a/src/accessor/grib_accessor_class_count_missing.h +++ b/src/accessor/grib_accessor_class_count_missing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_count_missing_h #define eccodes_accessor_count_missing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_missing_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_count_missing.h.bak b/src/accessor/grib_accessor_class_count_missing.h.bak new file mode 100644 index 000000000..fbf583109 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_missing.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_missing_h +#define eccodes_accessor_count_missing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_missing_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_missing */ + const char* bitmap; + const char* unusedBitsInBitmap; + const char* numberOfDataPoints; + const char* missingValueManagementUsed; +}; + +class grib_accessor_class_count_missing_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_missing_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_missing_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_missing_h */ diff --git a/src/accessor/grib_accessor_class_count_total.h b/src/accessor/grib_accessor_class_count_total.h index ab044e8a9..9c242b5c6 100644 --- a/src/accessor/grib_accessor_class_count_total.h +++ b/src/accessor/grib_accessor_class_count_total.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_count_total_h #define eccodes_accessor_count_total_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_total_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_count_total.h.bak b/src/accessor/grib_accessor_class_count_total.h.bak new file mode 100644 index 000000000..ab044e8a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_total.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_count_total_h +#define eccodes_accessor_count_total_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_count_total_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_total */ +}; + +class grib_accessor_class_count_total_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_total_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_total_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_count_total_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h b/src/accessor/grib_accessor_class_data_apply_bitmap.h index b2516ec4e..9e5e2955e 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_apply_bitmap_h #define eccodes_accessor_data_apply_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_apply_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak b/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak new file mode 100644 index 000000000..b2516ec4e --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak @@ -0,0 +1,132 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_apply_bitmap_h +#define eccodes_accessor_data_apply_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_bitmap */ + const char* coded_values; + const char* bitmap; + const char* missing_value; + const char* number_of_data_points; + const char* number_of_values; + const char* binary_scale_factor; +}; + +class grib_accessor_class_data_apply_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); +}; + + +template +int grib_accessor_class_data_apply_bitmap_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + + size_t i = 0; + size_t j = 0; + size_t n_vals = 0; + long nn = 0; + int err = 0; + size_t coded_n_vals = 0; + T* coded_vals = NULL; + double missing_value = 0; + + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) + return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if (coded_n_vals == 0) { + for (i = 0; i < n_vals; i++) + val[i] = missing_value; + + *len = n_vals; + return GRIB_SUCCESS; + } + + if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) + return err; + + coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); + if (coded_vals == NULL) + return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { + grib_context_free(a->context, coded_vals); + return err; + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", + __func__, + a->name, n_vals); + + for (i = 0; i < n_vals; i++) { + if (val[i] == 0) { + val[i] = missing_value; + } + else { + val[i] = coded_vals[j++]; + if (j > coded_n_vals) { + grib_context_free(a->context, coded_vals); + grib_context_log(a->context, GRIB_LOG_ERROR, + "grib_accessor_class_data_apply_bitmap [%s]:" + " %s : number of coded values does not match bitmap %ld %ld", + a->name, __func__, coded_n_vals, n_vals); + + return GRIB_ARRAY_TOO_SMALL; + } + } + } + + *len = n_vals; + + grib_context_free(a->context, coded_vals); + return err; +} + +#endif /* eccodes_accessor_data_apply_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak new file mode 100644 index 000000000..9b101e7ed --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic */ + const char* values; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; + const char* pl; +}; + +class grib_accessor_class_data_apply_boustrophedonic_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h index e92299eab..c03416060 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h #define eccodes_accessor_data_apply_boustrophedonic_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak new file mode 100644 index 000000000..e92299eab --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h +#define eccodes_accessor_data_apply_boustrophedonic_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic_bitmap */ + const char* coded_values; + const char* bitmap; + const char* missing_value; + const char* binary_scale_factor; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; +}; + +class grib_accessor_class_data_apply_boustrophedonic_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_apply_boustrophedonic_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak b/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak new file mode 100644 index 000000000..19889e937 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak @@ -0,0 +1,203 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_ccsds_packing_h +#define eccodes_accessor_data_ccsds_packing_h + +#include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) +#include +#endif + +#ifndef LIBAEC_DLL_EXPORTED + #error Version of libaec appears to be too old. Please upgrade. +#endif + +class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_ccsds_packing */ + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; + const char* bits_per_value; + const char* number_of_data_points; + const char* ccsds_flags; + const char* ccsds_block_size; + const char* ccsds_rsi; +}; + + + +// TODO(maee): if libaec is not available, this class should not be defined +class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_ccsds_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_ccsds_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + template int unpack(grib_accessor*, T*, size_t* ); + void print_aec_stream_info(struct aec_stream*, const char*); + void modify_aec_flags(long*); + const char* aec_get_error_message(int); + bool is_big_endian(); +}; + + +template +int grib_accessor_class_data_ccsds_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + int err = GRIB_SUCCESS, i = 0; + size_t buflen = 0; + struct aec_stream strm; + double bscale = 0; + double dscale = 0; + unsigned char* buf = NULL; + size_t n_vals = 0; + size_t size = 0; + unsigned char* decoded = NULL; + // unsigned char* p = NULL; + long nn = 0; + + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + double reference_value = 0; + long bits_per_value = 0; + + long ccsds_flags; + long ccsds_block_size; + long ccsds_rsi; + size_t nbytes; + + self->dirty = 0; + + if ((err = a->value_count(&nn)) != GRIB_SUCCESS) + return err; + n_vals = nn; + + if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + // ECC-477: Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) + return err; + + modify_aec_flags(&ccsds_flags); + + // TODO(masn): This should be called upstream + if (*len < n_vals) + return GRIB_ARRAY_TOO_SMALL; + + // Special case + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + bscale = codes_power(binary_scale_factor, 2); + dscale = codes_power(-decimal_scale_factor, 10); + + buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; + buf += a->byte_offset(); + strm.flags = ccsds_flags; + strm.bits_per_sample = bits_per_value; + strm.block_size = ccsds_block_size; + strm.rsi = ccsds_rsi; + + strm.next_in = buf; + strm.avail_in = buflen; + + nbytes = (bits_per_value + 7) / 8; + if (nbytes == 3) + nbytes = 4; + + size = n_vals * nbytes; + decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); + if (!decoded) { + err = GRIB_OUT_OF_MEMORY; + goto cleanup; + } + strm.next_out = decoded; + strm.avail_out = size; + + if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); + + if ((err = aec_buffer_decode(&strm)) != AEC_OK) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", + cclass_name, __func__, err, aec_get_error_message(err)); + err = GRIB_DECODING_ERROR; + goto cleanup; + } + + // ECC-1427: Performance improvement (replaced by ECC-1602) + //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); + + // ECC-1602: Performance improvement + switch (nbytes) { + case 1: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 2: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 4: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + default: + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", + cclass_name, __func__, a->name, bits_per_value); + err = GRIB_INVALID_BPV; + goto cleanup; + } + + *len = n_vals; + +cleanup: + grib_context_buffer_free(a->context, decoded); + return err; +} + +#endif /* eccodes_accessor_data_ccsds_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h.bak b/src/accessor/grib_accessor_class_data_complex_packing.h.bak new file mode 100644 index 000000000..d588eef38 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_complex_packing.h.bak @@ -0,0 +1,272 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_complex_packing_h +#define eccodes_accessor_data_complex_packing_h + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" +#include "grib_ieeefloat.h" + +typedef unsigned long (*encode_float_proc)(double); +typedef double (*decode_float_proc)(unsigned long); + +class grib_accessor_data_complex_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_complex_packing */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_complex_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_complex_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); +}; + +template +int grib_accessor_class_data_complex_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + size_t i = 0; + int ret = GRIB_SUCCESS; + long hcount = 0; + long lcount = 0; + long hpos = 0; + long lup = 0; + long mmax = 0; + long n_vals = 0; + T* scals = NULL; + T* pscals = NULL, *pval = NULL; + + T s = 0; + T d = 0; + T laplacianOperator = 0; + unsigned char* buf = NULL; + unsigned char* hres = NULL; + unsigned char* lres = NULL; + unsigned long packed_offset; + long lpos = 0; + + long maxv = 0; + long GRIBEX_sh_bug_present = 0; + long ieee_floats = 0; + + long offsetdata = 0; + long bits_per_value = 0; + T reference_value = 0; + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + + long sub_j = 0; + long sub_k = 0; + long sub_m = 0; + long pen_j = 0; + long pen_k = 0; + long pen_m = 0; + + T operat = 0; + int bytes; + int err = 0; + double tmp; + + decode_float_proc decode_float = NULL; + + err = a->value_count(&n_vals); if (err) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) + return ret; + reference_value = tmp; + if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) + return ret; + + /* ECC-774: don't use grib_get_long_internal */ + if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) + return ret; + laplacianOperator = tmp; + + if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) + return ret; + + self->dirty = 0; + + switch (ieee_floats) { + case 0: + decode_float = grib_long_to_ibm; + bytes = 4; + break; + case 1: + decode_float = grib_long_to_ieee; + bytes = 4; + break; + case 2: + decode_float = grib_long_to_ieee64; + bytes = 8; + break; + default: + return GRIB_NOT_IMPLEMENTED; + } + + if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); + return GRIB_DECODING_ERROR; + } + + buf = (unsigned char*)gh->buffer->data; + + maxv = pen_j + 1; + + buf += a->byte_offset(); hres = buf; + lres = buf; + + if (pen_j == sub_j) { + n_vals = (pen_j + 1) * (pen_j + 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); + if (d) { + for (i = 0; i < n_vals; i++) + val[i] *= d; + } + return 0; + } + + packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); + lpos = 8 * (packed_offset - offsetdata); + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); + if (!scals) return GRIB_OUT_OF_MEMORY; + + scals[0] = 0; + for (i = 1; i < maxv; i++) { + operat = pow(i * (i + 1), laplacianOperator); + if (operat != 0) + scals[i] = (1.0 / operat); + else { + grib_context_log(a->context, GRIB_LOG_WARNING, + "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); + scals[i] = 0; + } + } + + /* + printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); + printf("packed offset=%ld\n",packed_offset); + for(i=0;i 0) { + lup = mmax; + if (sub_k >= 0) { + for (hcount = 0; hcount < sub_k + 1; hcount++) { + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + + if (GRIBEX_sh_bug_present && hcount == sub_k) { + /* bug in ecmwf data, last row (K+1)is scaled but should not */ + val[i - 2] *= scals[lup]; + val[i - 1] *= scals[lup]; + } + lup++; + } + sub_k--; + } + + pscals = scals + lup; + pval = val + i; +#if FAST_BIG_ENDIAN + grib_decode_double_array_complex(lres, + &lpos, bits_per_value, + reference_value, s, pscals, (maxv - hcount) * 2, pval); + i += (maxv - hcount) * 2; +#else + (void)pscals; /* suppress gcc warning */ + (void)pval; /* suppress gcc warning */ + for (lcount = hcount; lcount < maxv; lcount++) { + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + /* These values should always be zero, but as they are packed, + it is necessary to force them back to zero */ + if (mmax == 0) + val[i - 1] = 0; + lup++; + } +#endif + + maxv--; + hcount = 0; + mmax++; + } + + Assert(*len >= i); + *len = i; + + grib_context_free(a->context, scals); + + return ret; +} + +#endif /* eccodes_accessor_data_complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h b/src/accessor/grib_accessor_class_data_dummy_field.h index 00de1fe73..31d6d27b8 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.h +++ b/src/accessor/grib_accessor_class_data_dummy_field.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_dummy_field_h #define eccodes_accessor_data_dummy_field_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_g1simple_packing.h" class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h.bak b/src/accessor/grib_accessor_class_data_dummy_field.h.bak new file mode 100644 index 000000000..00de1fe73 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_dummy_field.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_dummy_field_h +#define eccodes_accessor_data_dummy_field_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_g1simple_packing.h" + +class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t +{ +public: + /* Members defined in data_dummy_field */ + const char* missing_value; + const char* numberOfPoints; + const char* bitmap; +}; + +class grib_accessor_class_data_dummy_field_t : public grib_accessor_class_data_g1simple_packing_t +{ +public: + grib_accessor_class_data_dummy_field_t(const char* name) : grib_accessor_class_data_g1simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_dummy_field_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_dummy_field_h */ diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h b/src/accessor/grib_accessor_class_data_g1complex_packing.h index cc6208c95..a3c916606 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1complex_packing_h #define eccodes_accessor_data_g1complex_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_complex_packing.h" class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak b/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak new file mode 100644 index 000000000..cc6208c95 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1complex_packing_h +#define eccodes_accessor_data_g1complex_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g1complex_packing */ + const char* N; + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g1complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h index adfc36716..8c190bd12 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1second_order_constant_width_packing_h #define eccodes_accessor_data_g1second_order_constant_width_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak new file mode 100644 index 000000000..adfc36716 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak @@ -0,0 +1,53 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_constant_width_packing_h +#define eccodes_accessor_data_g1second_order_constant_width_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_constant_width_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidth; +}; + +class grib_accessor_class_data_g1second_order_constant_width_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_constant_width_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_constant_width_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_g1second_order_constant_width_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h index 245217f7f..fb2356a4f 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1second_order_general_extended_packing_h #define eccodes_accessor_data_g1second_order_general_extended_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak new file mode 100644 index 000000000..245217f7f --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak @@ -0,0 +1,68 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1second_order_general_extended_packing_h +#define eccodes_accessor_data_g1second_order_general_extended_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_extended_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* firstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* codedNumberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* groupWidths; + const char* widthOfWidths; + const char* groupLengths; + const char* widthOfLengths; + const char* NL; + const char* SPD; + const char* widthOfSPD; + const char* orderOfSPD; + const char* numberOfPoints; + const char* dataFlag; + double* dvalues; + float* fvalues; + int double_dirty; + int float_dirty; + size_t size; +}; + +class grib_accessor_class_data_g1second_order_general_extended_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_extended_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_extended_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + int unpack(grib_accessor* a, double*, float*, size_t*); +}; +#endif /* eccodes_accessor_data_g1second_order_general_extended_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak new file mode 100644 index 000000000..2e8bb3620 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak @@ -0,0 +1,49 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" + +class grib_accessor_data_g1second_order_general_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_general_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak new file mode 100644 index 000000000..9b274a408 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak @@ -0,0 +1,49 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" + +class grib_accessor_data_g1second_order_row_by_row_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_row_by_row_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_row_by_row_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_row_by_row_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_row_by_row_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h index e963d6f44..d0eaedb55 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1secondary_bitmap_h #define eccodes_accessor_data_g1secondary_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_secondary_bitmap.h" class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak new file mode 100644 index 000000000..e963d6f44 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1secondary_bitmap_h +#define eccodes_accessor_data_g1secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g1secondary_bitmap */ + const char* number_of_ones; +}; + +class grib_accessor_class_data_g1secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g1secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h index 0c8efffa1..8a212b5df 100644 --- a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1shsimple_packing_h #define eccodes_accessor_data_g1shsimple_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_shsimple_packing.h" class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak new file mode 100644 index 000000000..0c8efffa1 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1shsimple_packing_h +#define eccodes_accessor_data_g1shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g1shsimple_packing */ +}; + +class grib_accessor_class_data_g1shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g1shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1shsimple_packing_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; +}; +#endif /* eccodes_accessor_data_g1shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h b/src/accessor/grib_accessor_class_data_g1simple_packing.h index 3a351d17f..9d210ab63 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g1simple_packing_h #define eccodes_accessor_data_g1simple_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak b/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak new file mode 100644 index 000000000..3a351d17f --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g1simple_packing_h +#define eccodes_accessor_data_g1simple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1simple_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g1simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h.bak b/src/accessor/grib_accessor_class_data_g22order_packing.h.bak new file mode 100644 index 000000000..39d01a70b --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h.bak @@ -0,0 +1,55 @@ + +/* + * (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. + */ + +#pragma once + +#include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_g22order_packing */ + const char* numberOfValues; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scale_factor; + const char* typeOfOriginalFieldValues; + const char* groupSplittingMethodUsed; + const char* missingValueManagementUsed; + const char* primaryMissingValueSubstitute; + const char* secondaryMissingValueSubstitute; + const char* numberOfGroupsOfDataValues; + const char* referenceForGroupWidths; + const char* numberOfBitsUsedForTheGroupWidths; + const char* referenceForGroupLengths; + const char* lengthIncrementForTheGroupLengths; + const char* trueLengthOfLastGroup; + const char* numberOfBitsUsedForTheScaledGroupLengths; + const char* orderOfSpatialDifferencing; + const char* numberOfOctetsExtraDescriptors; +}; + +class grib_accessor_class_data_g22order_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_g22order_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g22order_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h index f4033a1ba..1d2838414 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g2bifourier_packing_h #define eccodes_accessor_data_g2bifourier_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak new file mode 100644 index 000000000..f4033a1ba --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2bifourier_packing_h +#define eccodes_accessor_data_g2bifourier_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g2bifourier_packing */ + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* biFourierTruncationType; + const char* sub_i; + const char* sub_j; + const char* bif_i; + const char* bif_j; + const char* biFourierSubTruncationType; + const char* biFourierDoNotPackAxes; + const char* biFourierMakeTemplate; + const char* totalNumberOfValuesInUnpackedSubset; + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2bifourier_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2bifourier_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2bifourier_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2bifourier_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h b/src/accessor/grib_accessor_class_data_g2complex_packing.h index e77b89276..ec7ab213e 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g2complex_packing_h #define eccodes_accessor_data_g2complex_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_complex_packing.h" class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak b/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak new file mode 100644 index 000000000..e77b89276 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2complex_packing_h +#define eccodes_accessor_data_g2complex_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g2complex_packing */ + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g2complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h index 394c79bfa..abc550a97 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g2secondary_bitmap_h #define eccodes_accessor_data_g2secondary_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_secondary_bitmap.h" class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak new file mode 100644 index 000000000..394c79bfa --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2secondary_bitmap_h +#define eccodes_accessor_data_g2secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g2secondary_bitmap */ + const char* number_of_values; +}; + +class grib_accessor_class_data_g2secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g2secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h index 28e7a7c06..30899788b 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g2shsimple_packing_h #define eccodes_accessor_data_g2shsimple_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_shsimple_packing.h" class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak new file mode 100644 index 000000000..28e7a7c06 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2shsimple_packing_h +#define eccodes_accessor_data_g2shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g2shsimple_packing */ + const char* numberOfValues; + const char* numberOfDataPoints; +}; + +class grib_accessor_class_data_g2shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g2shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2shsimple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak b/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak new file mode 100644 index 000000000..4f27ab87c --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak @@ -0,0 +1,28 @@ +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2simple_packing_h +#define eccodes_accessor_data_g2simple_packing_h + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t {}; + +class grib_accessor_class_data_g2simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_t{}; } + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h index ac2bc2d27..797815bd3 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_g2simple_packing_with_preprocessing_h #define eccodes_accessor_data_g2simple_packing_with_preprocessing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_g2simple_packing.h" class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak new file mode 100644 index 000000000..ac2bc2d27 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_g2simple_packing_with_preprocessing_h +#define eccodes_accessor_data_g2simple_packing_with_preprocessing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_g2simple_packing.h" + +class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t +{ +public: + /* Members defined in data_g2simple_packing_with_preprocessing */ + const char* pre_processing; + const char* pre_processing_parameter; +}; + +class grib_accessor_class_data_g2simple_packing_with_preprocessing_t : public grib_accessor_class_data_g2simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_with_preprocessing_t(const char* name) : grib_accessor_class_data_g2simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_with_preprocessing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_g2simple_packing_with_preprocessing_h */ diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h index a04ee58d5..4802dd2ac 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_jpeg2000_packing_h #define eccodes_accessor_data_jpeg2000_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak new file mode 100644 index 000000000..a04ee58d5 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak @@ -0,0 +1,46 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_jpeg2000_packing_h +#define eccodes_accessor_data_jpeg2000_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_jpeg2000_packing */ + const char* type_of_compression_used; + const char* target_compression_ratio; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; + int jpeg_lib; + const char* dump_jpg; +}; + +class grib_accessor_class_data_jpeg2000_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_jpeg2000_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_jpeg2000_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_jpeg2000_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_png_packing.h.bak b/src/accessor/grib_accessor_class_data_png_packing.h.bak new file mode 100644 index 000000000..841ed9d31 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_png_packing.h.bak @@ -0,0 +1,41 @@ +/* + * (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. + */ + +#pragma once + +#include "grib_accessor_class_values.h" + +class grib_accessor_data_png_packing_t : public grib_accessor_values_t +{ +public: + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* bits_per_value; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; +}; + +class grib_accessor_class_data_png_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_png_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_png_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/accessor/grib_accessor_class_data_raw_packing.h b/src/accessor/grib_accessor_class_data_raw_packing.h index 5b1b103e0..075cc470e 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_data_raw_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_raw_packing_h #define eccodes_accessor_data_raw_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_values.h" class grib_accessor_data_raw_packing_t : public grib_accessor_values_t diff --git a/src/accessor/grib_accessor_class_data_raw_packing.h.bak b/src/accessor/grib_accessor_class_data_raw_packing.h.bak new file mode 100644 index 000000000..5b1b103e0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_raw_packing.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_raw_packing_h +#define eccodes_accessor_data_raw_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_raw_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_raw_packing */ + const char* number_of_values; + const char* precision; +}; + +class grib_accessor_class_data_raw_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_raw_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_raw_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; +#endif /* eccodes_accessor_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h b/src/accessor/grib_accessor_class_data_run_length_packing.h index 3125fdcf4..f57d69c39 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.h +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_run_length_packing_h #define eccodes_accessor_data_run_length_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_values.h" class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h.bak b/src/accessor/grib_accessor_class_data_run_length_packing.h.bak new file mode 100644 index 000000000..3125fdcf4 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_run_length_packing_h +#define eccodes_accessor_data_run_length_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_values.h" + +class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_run_length_packing */ + const char* number_of_values; + const char* bits_per_value; + const char* max_level_value; + const char* number_of_level_values; + const char* decimal_scale_factor; + const char* level_values; +}; + +class grib_accessor_class_data_run_length_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_run_length_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_run_length_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_run_length_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h b/src/accessor/grib_accessor_class_data_secondary_bitmap.h index 3ac86e324..06a2ab576 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_secondary_bitmap_h #define eccodes_accessor_data_secondary_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak new file mode 100644 index 000000000..3ac86e324 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_secondary_bitmap_h +#define eccodes_accessor_data_secondary_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_secondary_bitmap */ + const char* primary_bitmap; + const char* secondary_bitmap; + const char* missing_value; + const char* expand_by; +}; + +class grib_accessor_class_data_secondary_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_secondary_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_secondary_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h b/src/accessor/grib_accessor_class_data_sh_packed.h index 2d7cbdf47..109534010 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.h +++ b/src/accessor/grib_accessor_class_data_sh_packed.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_sh_packed_h #define eccodes_accessor_data_sh_packed_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h.bak b/src/accessor/grib_accessor_class_data_sh_packed.h.bak new file mode 100644 index 000000000..2d7cbdf47 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_packed.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_sh_packed_h +#define eccodes_accessor_data_sh_packed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_packed */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_packed_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_packed_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_packed_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_sh_packed_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h b/src/accessor/grib_accessor_class_data_sh_unpacked.h index 4b1e893c0..3f9c57dc8 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.h +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_sh_unpacked_h #define eccodes_accessor_data_sh_unpacked_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak b/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak new file mode 100644 index 000000000..4b1e893c0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_sh_unpacked_h +#define eccodes_accessor_data_sh_unpacked_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_unpacked */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_unpacked_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_unpacked_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_unpacked_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_sh_unpacked_h */ diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h b/src/accessor/grib_accessor_class_data_shsimple_packing.h index 851907eb9..b4c388902 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_data_shsimple_packing_h #define eccodes_accessor_data_shsimple_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak new file mode 100644 index 000000000..851907eb9 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_shsimple_packing_h +#define eccodes_accessor_data_shsimple_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_shsimple_packing */ + const char* coded_values; + const char* real_part; + int dirty; +}; + +class grib_accessor_class_data_shsimple_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_shsimple_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_shsimple_packing_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_data_shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h.bak b/src/accessor/grib_accessor_class_data_simple_packing.h.bak new file mode 100644 index 000000000..92f355b3f --- /dev/null +++ b/src/accessor/grib_accessor_class_data_simple_packing.h.bak @@ -0,0 +1,195 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_data_simple_packing_h +#define eccodes_accessor_data_simple_packing_h + +#include "grib_accessor_class_values.h" +#include "grib_bits_any_endian_simple.h" +#include "grib_scaling.h" + +class grib_accessor_data_simple_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_simple_packing */ + int edition; + const char* units_factor; + const char* units_bias; + const char* changing_precision; + const char* number_of_values; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; +}; + +class grib_accessor_class_data_simple_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_simple_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); +}; + + +template +int grib_accessor_class_data_simple_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + + size_t i = 0; + int err = 0; + size_t n_vals = 0; + long pos = 0; + long count = 0; + + double reference_value; + long binary_scale_factor; + long bits_per_value; + long decimal_scale_factor; + long offsetBeforeData; + double s = 0; + double d = 0; + double units_factor = 1.0; + double units_bias = 0.0; + + err = a->value_count(&count); if (err) + return err; + n_vals = count; + + if (*len < n_vals) { + *len = (long)n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + + /* + * check we don't decode bpv > max(ulong) as it is + * not currently supported by the algorithm + */ + if (bits_per_value > (sizeof(long) * 8)) { + return GRIB_INVALID_BPV; + } + + if (self->units_factor && + (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_factor, 1.0); + } + + if (self->units_bias && + (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_bias, 0.0); + } + + if (n_vals == 0) { + *len = 0; + return GRIB_SUCCESS; + } + + self->dirty = 0; + + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + /* Special case */ + + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); + + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; + + /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + + /* ECC-941 */ + if (!a->context->ieee_packing) { + /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ + long offsetAfterData = 0; + err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); + if (!err && offsetAfterData > offsetBeforeData) { + const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ + if (offsetBeforeData + valuesSize > offsetAfterData) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Data section size mismatch: " + "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", + cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); + return GRIB_DECODING_ERROR; + } + } + // if (offsetBeforeData == offsetAfterData) { + // /* Crazy case: Constant field with bitsPerValue > 0 */ + // for (i = 0; i < n_vals; i++) + // val[i] = reference_value; + // *len = n_vals; + // return GRIB_SUCCESS; + // } + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", + cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); + grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); + + *len = (long)n_vals; + + if (units_factor != 1.0) { + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] = val[i] * units_factor + units_bias; + } + } else { + for (i = 0; i < n_vals; i++) { + val[i] *= units_factor; + } + } + } + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] += units_bias; + } + } + return err; +} + + +#endif /* eccodes_accessor_data_simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_decimal_precision.h b/src/accessor/grib_accessor_class_decimal_precision.h index 455d77946..a3e3e3024 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.h +++ b/src/accessor/grib_accessor_class_decimal_precision.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_decimal_precision_h #define eccodes_accessor_decimal_precision_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_decimal_precision_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_decimal_precision.h.bak b/src/accessor/grib_accessor_class_decimal_precision.h.bak new file mode 100644 index 000000000..455d77946 --- /dev/null +++ b/src/accessor/grib_accessor_class_decimal_precision.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_decimal_precision_h +#define eccodes_accessor_decimal_precision_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_decimal_precision_t : public grib_accessor_long_t +{ +public: + /* Members defined in decimal_precision */ + const char* values; + const char* bits_per_value; + const char* changing_precision; + const char* decimal_scale_factor; +}; + +class grib_accessor_class_decimal_precision_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_decimal_precision_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_decimal_precision_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_decimal_precision_h */ diff --git a/src/accessor/grib_accessor_class_dictionary.h b/src/accessor/grib_accessor_class_dictionary.h index 7f86a44ae..353cb9efa 100644 --- a/src/accessor/grib_accessor_class_dictionary.h +++ b/src/accessor/grib_accessor_class_dictionary.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_dictionary_h #define eccodes_accessor_dictionary_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_dictionary_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_dictionary.h.bak b/src/accessor/grib_accessor_class_dictionary.h.bak new file mode 100644 index 000000000..7f86a44ae --- /dev/null +++ b/src/accessor/grib_accessor_class_dictionary.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_dictionary_h +#define eccodes_accessor_dictionary_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_dictionary_t : public grib_accessor_gen_t +{ +public: + /* Members defined in dictionary */ + const char* dictionary; + const char* key; + long column; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_dictionary_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_dictionary_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dictionary_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_dictionary_h */ diff --git a/src/accessor/grib_accessor_class_dirty.h b/src/accessor/grib_accessor_class_dirty.h index 7a008ce29..78d4fcb64 100644 --- a/src/accessor/grib_accessor_class_dirty.h +++ b/src/accessor/grib_accessor_class_dirty.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_dirty_h #define eccodes_accessor_dirty_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_dirty_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_dirty.h.bak b/src/accessor/grib_accessor_class_dirty.h.bak new file mode 100644 index 000000000..7a008ce29 --- /dev/null +++ b/src/accessor/grib_accessor_class_dirty.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_dirty_h +#define eccodes_accessor_dirty_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_dirty_t : public grib_accessor_long_t +{ +public: + /* Members defined in dirty */ + const char* accessor; +}; + +class grib_accessor_class_dirty_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_dirty_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dirty_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_dirty_h */ diff --git a/src/accessor/grib_accessor_class_divdouble.h b/src/accessor/grib_accessor_class_divdouble.h index e10239676..eb2357a3e 100644 --- a/src/accessor/grib_accessor_class_divdouble.h +++ b/src/accessor/grib_accessor_class_divdouble.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_divdouble_h #define eccodes_accessor_divdouble_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_divdouble_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_divdouble.h.bak b/src/accessor/grib_accessor_class_divdouble.h.bak new file mode 100644 index 000000000..e10239676 --- /dev/null +++ b/src/accessor/grib_accessor_class_divdouble.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_divdouble_h +#define eccodes_accessor_divdouble_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_divdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in divdouble */ + const char* val; + double divisor; +}; + +class grib_accessor_class_divdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_divdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_divdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_divdouble_h */ diff --git a/src/accessor/grib_accessor_class_double.h.bak b/src/accessor/grib_accessor_class_double.h.bak new file mode 100644 index 000000000..1c1e2fb4f --- /dev/null +++ b/src/accessor/grib_accessor_class_double.h.bak @@ -0,0 +1,30 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_double_h +#define eccodes_accessor_double_h + +#include "grib_accessor_class_gen.h" + +class grib_accessor_double_t : public grib_accessor_gen_t {}; + +class grib_accessor_class_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_double_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_double_h */ diff --git a/src/accessor/grib_accessor_class_element.h b/src/accessor/grib_accessor_class_element.h index f22109be2..fe1d58ecd 100644 --- a/src/accessor/grib_accessor_class_element.h +++ b/src/accessor/grib_accessor_class_element.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_element_h #define eccodes_accessor_element_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_element_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_element.h.bak b/src/accessor/grib_accessor_class_element.h.bak new file mode 100644 index 000000000..f22109be2 --- /dev/null +++ b/src/accessor/grib_accessor_class_element.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_element_h +#define eccodes_accessor_element_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_element_t : public grib_accessor_long_t +{ +public: + /* Members defined in element */ + const char* array; + long element; +}; + +class grib_accessor_class_element_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_element_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_element_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_element_h */ diff --git a/src/accessor/grib_accessor_class_evaluate.h b/src/accessor/grib_accessor_class_evaluate.h index e65c6473b..cfaf92c00 100644 --- a/src/accessor/grib_accessor_class_evaluate.h +++ b/src/accessor/grib_accessor_class_evaluate.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_evaluate_h #define eccodes_accessor_evaluate_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_evaluate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_evaluate.h.bak b/src/accessor/grib_accessor_class_evaluate.h.bak new file mode 100644 index 000000000..e65c6473b --- /dev/null +++ b/src/accessor/grib_accessor_class_evaluate.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_evaluate_h +#define eccodes_accessor_evaluate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_evaluate_t : public grib_accessor_long_t +{ +public: + /* Members defined in evaluate */ + grib_arguments* arg; +}; + +class grib_accessor_class_evaluate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_evaluate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_evaluate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_evaluate_h */ diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h b/src/accessor/grib_accessor_class_expanded_descriptors.h index be2094d4f..419b28c61 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_expanded_descriptors_h #define eccodes_accessor_expanded_descriptors_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h.bak b/src/accessor/grib_accessor_class_expanded_descriptors.h.bak new file mode 100644 index 000000000..be2094d4f --- /dev/null +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h.bak @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_expanded_descriptors_h +#define eccodes_accessor_expanded_descriptors_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in expanded_descriptors */ + const char* unexpandedDescriptors; + const char* sequence; + const char* expandedName; + const char* tablesAccessorName; + bufr_descriptors_array* expanded; + int rank; + grib_accessor* expandedAccessor; + int do_expand; + grib_accessor* tablesAccessor; +}; + +class grib_accessor_class_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_expanded_descriptors_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h index 1874c559f..d14cb9c56 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_from_scale_factor_scaled_value_h #define eccodes_accessor_from_scale_factor_scaled_value_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak new file mode 100644 index 000000000..1874c559f --- /dev/null +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_from_scale_factor_scaled_value_h +#define eccodes_accessor_from_scale_factor_scaled_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t +{ +public: + /* Members defined in from_scale_factor_scaled_value */ + const char* scaleFactor; + const char* scaledValue; +}; + +class grib_accessor_class_from_scale_factor_scaled_value_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_from_scale_factor_scaled_value_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_from_scale_factor_scaled_value_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_from_scale_factor_scaled_value_h */ diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h index 9c5890aa3..bf6ae7372 100644 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1_half_byte_codeflag_h #define eccodes_accessor_g1_half_byte_codeflag_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak new file mode 100644 index 000000000..9c5890aa3 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_half_byte_codeflag_h +#define eccodes_accessor_g1_half_byte_codeflag_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g1_half_byte_codeflag */ +}; + +class grib_accessor_class_g1_half_byte_codeflag_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g1_half_byte_codeflag_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_half_byte_codeflag_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_half_byte_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_g1_message_length.h b/src/accessor/grib_accessor_class_g1_message_length.h index c3b865ec0..65d1983a9 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.h +++ b/src/accessor/grib_accessor_class_g1_message_length.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1_message_length_h #define eccodes_accessor_g1_message_length_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_section_length.h" class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t diff --git a/src/accessor/grib_accessor_class_g1_message_length.h.bak b/src/accessor/grib_accessor_class_g1_message_length.h.bak new file mode 100644 index 000000000..c3b865ec0 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_message_length.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_message_length_h +#define eccodes_accessor_g1_message_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_message_length */ + const char *sec4_length; +}; + +class grib_accessor_class_g1_message_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_message_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_message_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_message_length_h */ diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h b/src/accessor/grib_accessor_class_g1_section4_length.h index 0a1b0c768..0cb88362a 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.h +++ b/src/accessor/grib_accessor_class_g1_section4_length.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1_section4_length_h #define eccodes_accessor_g1_section4_length_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_section_length.h" class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h.bak b/src/accessor/grib_accessor_class_g1_section4_length.h.bak new file mode 100644 index 000000000..0a1b0c768 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_section4_length.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1_section4_length_h +#define eccodes_accessor_g1_section4_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_section4_length */ + const char* total_length; +}; + +class grib_accessor_class_g1_section4_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_section4_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_section4_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1_section4_length_h */ diff --git a/src/accessor/grib_accessor_class_g1bitmap.h b/src/accessor/grib_accessor_class_g1bitmap.h index b34344d1f..d27f6b4eb 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.h +++ b/src/accessor/grib_accessor_class_g1bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1bitmap_h #define eccodes_accessor_g1bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_bitmap.h" class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t diff --git a/src/accessor/grib_accessor_class_g1bitmap.h.bak b/src/accessor/grib_accessor_class_g1bitmap.h.bak new file mode 100644 index 000000000..b34344d1f --- /dev/null +++ b/src/accessor/grib_accessor_class_g1bitmap.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1bitmap_h +#define eccodes_accessor_g1bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g1bitmap */ + const char* unusedBits; +}; + +class grib_accessor_class_g1bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g1bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g1date.h b/src/accessor/grib_accessor_class_g1date.h index 27e71189f..734b2a3b5 100644 --- a/src/accessor/grib_accessor_class_g1date.h +++ b/src/accessor/grib_accessor_class_g1date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1date_h #define eccodes_accessor_g1date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1date.h.bak b/src/accessor/grib_accessor_class_g1date.h.bak new file mode 100644 index 000000000..27e71189f --- /dev/null +++ b/src/accessor/grib_accessor_class_g1date.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1date_h +#define eccodes_accessor_g1date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g1date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1date_h */ diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h index 1563cdb9d..bc12f541e 100644 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1day_of_the_year_date_h #define eccodes_accessor_g1day_of_the_year_date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_g1date.h" class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak new file mode 100644 index 000000000..1563cdb9d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1day_of_the_year_date_h +#define eccodes_accessor_g1day_of_the_year_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_g1date.h" + +class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t +{ +public: + /* Members defined in g1day_of_the_year_date */ +}; + +class grib_accessor_class_g1day_of_the_year_date_t : public grib_accessor_class_g1date_t +{ +public: + grib_accessor_class_g1day_of_the_year_date_t(const char* name) : grib_accessor_class_g1date_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1day_of_the_year_date_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1day_of_the_year_date_h */ diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h index a1e29a76c..7e6ac3563 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1end_of_interval_monthly_h #define eccodes_accessor_g1end_of_interval_monthly_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak new file mode 100644 index 000000000..a1e29a76c --- /dev/null +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1end_of_interval_monthly_h +#define eccodes_accessor_g1end_of_interval_monthly_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in g1end_of_interval_monthly */ + const char* verifyingMonth; +}; + +class grib_accessor_class_g1end_of_interval_monthly_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_g1end_of_interval_monthly_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1end_of_interval_monthly_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_g1end_of_interval_monthly_h */ diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h b/src/accessor/grib_accessor_class_g1fcperiod.h index 3c0ff2c49..b2862cb78 100644 --- a/src/accessor/grib_accessor_class_g1fcperiod.h +++ b/src/accessor/grib_accessor_class_g1fcperiod.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1fcperiod_h #define eccodes_accessor_g1fcperiod_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_g1step_range.h" class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h.bak b/src/accessor/grib_accessor_class_g1fcperiod.h.bak new file mode 100644 index 000000000..3c0ff2c49 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1fcperiod.h.bak @@ -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. + */ + +#ifndef eccodes_accessor_g1fcperiod_h +#define eccodes_accessor_g1fcperiod_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_g1step_range.h" + +class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t +{ +public: + /* Members defined in g1fcperiod */ +}; + +class grib_accessor_class_g1fcperiod_t : public grib_accessor_class_g1step_range_t +{ +public: + grib_accessor_class_g1fcperiod_t(const char* name) : grib_accessor_class_g1step_range_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1fcperiod_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; +#endif /* eccodes_accessor_g1fcperiod_h */ diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h b/src/accessor/grib_accessor_class_g1forecastmonth.h index 6d2b9ee63..3a5fbb89b 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.h +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1forecastmonth_h #define eccodes_accessor_g1forecastmonth_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h.bak b/src/accessor/grib_accessor_class_g1forecastmonth.h.bak new file mode 100644 index 000000000..6d2b9ee63 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1forecastmonth_h +#define eccodes_accessor_g1forecastmonth_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1forecastmonth */ + const char* verification_yearmonth; + const char* base_date; + const char* day; + const char* hour; + const char* fcmonth; + const char* check; +}; + +class grib_accessor_class_g1forecastmonth_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1forecastmonth_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1forecastmonth_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1forecastmonth_h */ diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h b/src/accessor/grib_accessor_class_g1monthlydate.h index 8efa9cf16..b279e56c3 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.h +++ b/src/accessor/grib_accessor_class_g1monthlydate.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1monthlydate_h #define eccodes_accessor_g1monthlydate_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1monthlydate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h.bak b/src/accessor/grib_accessor_class_g1monthlydate.h.bak new file mode 100644 index 000000000..8efa9cf16 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1monthlydate.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1monthlydate_h +#define eccodes_accessor_g1monthlydate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1monthlydate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1monthlydate */ + const char* date; +}; + +class grib_accessor_class_g1monthlydate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1monthlydate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1monthlydate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1monthlydate_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h index 764bfa04d..75b21875b 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h #define eccodes_accessor_g1number_of_coded_values_sh_complex_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak new file mode 100644 index 000000000..764bfa04d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h +#define eccodes_accessor_g1number_of_coded_values_sh_complex_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_complex */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; + const char* JS; + const char* KS; + const char* MS; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_complex_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_complex_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_complex_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1number_of_coded_values_sh_complex_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h index fb5ab298d..d59e4999c 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h #define eccodes_accessor_g1number_of_coded_values_sh_simple_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak new file mode 100644 index 000000000..fb5ab298d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h +#define eccodes_accessor_g1number_of_coded_values_sh_simple_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_simple */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_simple_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_simple_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_simple_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1number_of_coded_values_sh_simple_h */ diff --git a/src/accessor/grib_accessor_class_g1step_range.h b/src/accessor/grib_accessor_class_g1step_range.h index c9c3dd911..26d7116e8 100644 --- a/src/accessor/grib_accessor_class_g1step_range.h +++ b/src/accessor/grib_accessor_class_g1step_range.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1step_range_h #define eccodes_accessor_g1step_range_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_long_vector.h" class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t diff --git a/src/accessor/grib_accessor_class_g1step_range.h.bak b/src/accessor/grib_accessor_class_g1step_range.h.bak new file mode 100644 index 000000000..c9c3dd911 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1step_range.h.bak @@ -0,0 +1,48 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1step_range_h +#define eccodes_accessor_g1step_range_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in g1step_range */ + const char* p1; + const char* p2; + const char* timeRangeIndicator; + const char *unit; + const char *step_unit; + const char *stepType; + const char *patch_fp_precip; + int error_on_units; +}; + +class grib_accessor_class_g1step_range_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_g1step_range_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1step_range_h */ diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h b/src/accessor/grib_accessor_class_g1verificationdate.h index 198801aba..70edcf7d8 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.h +++ b/src/accessor/grib_accessor_class_g1verificationdate.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g1verificationdate_h #define eccodes_accessor_g1verificationdate_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1verificationdate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h.bak b/src/accessor/grib_accessor_class_g1verificationdate.h.bak new file mode 100644 index 000000000..198801aba --- /dev/null +++ b/src/accessor/grib_accessor_class_g1verificationdate.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g1verificationdate_h +#define eccodes_accessor_g1verificationdate_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g1verificationdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1verificationdate */ + const char* date; + const char* time; + const char* step; +}; + +class grib_accessor_class_g1verificationdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1verificationdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1verificationdate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g1verificationdate_h */ diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h b/src/accessor/grib_accessor_class_g2_aerosol.h index fb29a9561..f9feaa5e8 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.h +++ b/src/accessor/grib_accessor_class_g2_aerosol.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2_aerosol_h #define eccodes_accessor_g2_aerosol_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h.bak b/src/accessor/grib_accessor_class_g2_aerosol.h.bak new file mode 100644 index 000000000..fb29a9561 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_aerosol.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_aerosol_h +#define eccodes_accessor_g2_aerosol_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_aerosol */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int optical; +}; + +class grib_accessor_class_g2_aerosol_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_aerosol_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_aerosol_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_aerosol_h */ diff --git a/src/accessor/grib_accessor_class_g2_chemical.h b/src/accessor/grib_accessor_class_g2_chemical.h index 9cfe4f8bc..01a159008 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.h +++ b/src/accessor/grib_accessor_class_g2_chemical.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2_chemical_h #define eccodes_accessor_g2_chemical_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_chemical.h.bak b/src/accessor/grib_accessor_class_g2_chemical.h.bak new file mode 100644 index 000000000..9cfe4f8bc --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_chemical.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_chemical_h +#define eccodes_accessor_g2_chemical_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_chemical */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int chemical_type; +}; + +class grib_accessor_class_g2_chemical_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_chemical_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_chemical_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_chemical_h */ diff --git a/src/accessor/grib_accessor_class_g2_eps.h b/src/accessor/grib_accessor_class_g2_eps.h index 7c39dd580..a29e975ea 100644 --- a/src/accessor/grib_accessor_class_g2_eps.h +++ b/src/accessor/grib_accessor_class_g2_eps.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2_eps_h #define eccodes_accessor_g2_eps_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_eps.h.bak b/src/accessor/grib_accessor_class_g2_eps.h.bak new file mode 100644 index 000000000..7c39dd580 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_eps.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_eps_h +#define eccodes_accessor_g2_eps_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_eps */ + const char* productDefinitionTemplateNumber; + const char* stream; + const char* type; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_g2_eps_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_eps_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_eps_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_eps_h */ diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h b/src/accessor/grib_accessor_class_g2_mars_labeling.h index 0a678174f..a73962542 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.h +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2_mars_labeling_h #define eccodes_accessor_g2_mars_labeling_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak b/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak new file mode 100644 index 000000000..0a678174f --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak @@ -0,0 +1,47 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2_mars_labeling_h +#define eccodes_accessor_g2_mars_labeling_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2_mars_labeling */ + int index; + const char* the_class; + const char* stream; + const char* type; + const char* expver; + const char* typeOfProcessedData; + const char* productDefinitionTemplateNumber; + const char* stepType; + const char* derivedForecast; + const char* typeOfGeneratingProcess; +}; + +class grib_accessor_class_g2_mars_labeling_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2_mars_labeling_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_mars_labeling_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2_mars_labeling_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap.h b/src/accessor/grib_accessor_class_g2bitmap.h index 9af7a3b27..3f1b85d23 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.h +++ b/src/accessor/grib_accessor_class_g2bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2bitmap_h #define eccodes_accessor_g2bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_bitmap.h" class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t diff --git a/src/accessor/grib_accessor_class_g2bitmap.h.bak b/src/accessor/grib_accessor_class_g2bitmap.h.bak new file mode 100644 index 000000000..9af7a3b27 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2bitmap_h +#define eccodes_accessor_g2bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g2bitmap */ + const char* numberOfValues; +}; + +class grib_accessor_class_g2bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g2bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h b/src/accessor/grib_accessor_class_g2bitmap_present.h index 7b5cd3f66..18c7ac3f7 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.h +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2bitmap_present_h #define eccodes_accessor_g2bitmap_present_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h.bak b/src/accessor/grib_accessor_class_g2bitmap_present.h.bak new file mode 100644 index 000000000..7b5cd3f66 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2bitmap_present_h +#define eccodes_accessor_g2bitmap_present_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2bitmap_present */ + const char* bitmapIndicator; +}; + +class grib_accessor_class_g2bitmap_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2bitmap_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2bitmap_present_h */ diff --git a/src/accessor/grib_accessor_class_g2date.h b/src/accessor/grib_accessor_class_g2date.h index 20276c6fe..1c7a8a02d 100644 --- a/src/accessor/grib_accessor_class_g2date.h +++ b/src/accessor/grib_accessor_class_g2date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2date_h #define eccodes_accessor_g2date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2date.h.bak b/src/accessor/grib_accessor_class_g2date.h.bak new file mode 100644 index 000000000..20276c6fe --- /dev/null +++ b/src/accessor/grib_accessor_class_g2date.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2date_h +#define eccodes_accessor_g2date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g2date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2date_h */ diff --git a/src/accessor/grib_accessor_class_g2end_step.h b/src/accessor/grib_accessor_class_g2end_step.h index 7a2d8ab21..b408681a0 100644 --- a/src/accessor/grib_accessor_class_g2end_step.h +++ b/src/accessor/grib_accessor_class_g2end_step.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2end_step_h #define eccodes_accessor_g2end_step_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2end_step_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2end_step.h.bak b/src/accessor/grib_accessor_class_g2end_step.h.bak new file mode 100644 index 000000000..7a2d8ab21 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2end_step.h.bak @@ -0,0 +1,56 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2end_step_h +#define eccodes_accessor_g2end_step_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2end_step_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2end_step */ + const char* start_step_value; + const char* step_units; + const char* year; + const char* month; + const char* day; + const char* hour; + const char* minute; + const char* second; + const char* year_of_end_of_interval; + const char* month_of_end_of_interval; + const char* day_of_end_of_interval; + const char* hour_of_end_of_interval; + const char* minute_of_end_of_interval; + const char* second_of_end_of_interval; + const char* time_range_unit; + const char* time_range_value; + const char* typeOfTimeIncrement; + const char* numberOfTimeRange; +}; + +class grib_accessor_class_g2end_step_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2end_step_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2end_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2end_step_h */ diff --git a/src/accessor/grib_accessor_class_g2grid.h b/src/accessor/grib_accessor_class_g2grid.h index 0cd177ce5..25a527b69 100644 --- a/src/accessor/grib_accessor_class_g2grid.h +++ b/src/accessor/grib_accessor_class_g2grid.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2grid_h #define eccodes_accessor_g2grid_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2grid_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g2grid.h.bak b/src/accessor/grib_accessor_class_g2grid.h.bak new file mode 100644 index 000000000..0cd177ce5 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2grid.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2grid_h +#define eccodes_accessor_g2grid_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2grid_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2grid */ + const char* latitude_first; + const char* longitude_first; + const char* latitude_last; + const char* longitude_last; + const char* i_increment; + const char* j_increment; + const char* basic_angle; + const char* sub_division; +}; + +class grib_accessor_class_g2grid_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2grid_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2grid_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2grid_h */ diff --git a/src/accessor/grib_accessor_class_g2latlon.h b/src/accessor/grib_accessor_class_g2latlon.h index f16e2623e..c179bdd60 100644 --- a/src/accessor/grib_accessor_class_g2latlon.h +++ b/src/accessor/grib_accessor_class_g2latlon.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2latlon_h #define eccodes_accessor_g2latlon_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2latlon_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g2latlon.h.bak b/src/accessor/grib_accessor_class_g2latlon.h.bak new file mode 100644 index 000000000..f16e2623e --- /dev/null +++ b/src/accessor/grib_accessor_class_g2latlon.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2latlon_h +#define eccodes_accessor_g2latlon_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2latlon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2latlon */ + const char* grid; + int index; + const char* given; +}; + +class grib_accessor_class_g2latlon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2latlon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2latlon_t{}; } + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2latlon_h */ diff --git a/src/accessor/grib_accessor_class_g2level.h b/src/accessor/grib_accessor_class_g2level.h index 567b8c1b4..a0163be8b 100644 --- a/src/accessor/grib_accessor_class_g2level.h +++ b/src/accessor/grib_accessor_class_g2level.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2level_h #define eccodes_accessor_g2level_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2level_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2level.h.bak b/src/accessor/grib_accessor_class_g2level.h.bak new file mode 100644 index 000000000..567b8c1b4 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2level.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2level_h +#define eccodes_accessor_g2level_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_g2level_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2level */ + const char* type_first; + const char* scale_first; + const char* value_first; + const char* pressure_units; +}; + +class grib_accessor_class_g2level_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2level_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2level_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2level_h */ diff --git a/src/accessor/grib_accessor_class_g2lon.h b/src/accessor/grib_accessor_class_g2lon.h index d17a68c14..dd631adf4 100644 --- a/src/accessor/grib_accessor_class_g2lon.h +++ b/src/accessor/grib_accessor_class_g2lon.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2lon_h #define eccodes_accessor_g2lon_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2lon_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g2lon.h.bak b/src/accessor/grib_accessor_class_g2lon.h.bak new file mode 100644 index 000000000..d17a68c14 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2lon.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2lon_h +#define eccodes_accessor_g2lon_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_g2lon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2lon */ + const char* longitude; +}; + +class grib_accessor_class_g2lon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2lon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2lon_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2lon_h */ diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc index ae2b9976d..28019a783 100644 --- a/src/accessor/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -11,8 +11,8 @@ #include "grib_api_internal.h" #include "grib_accessor_class_g2step_range.h" -#include "../step.h" -#include "../step_utilities.h" +#include "step.h" +#include "step_utilities.h" #include #include #include diff --git a/src/accessor/grib_accessor_class_g2step_range.h b/src/accessor/grib_accessor_class_g2step_range.h index c5a007806..45b50690c 100644 --- a/src/accessor/grib_accessor_class_g2step_range.h +++ b/src/accessor/grib_accessor_class_g2step_range.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_g2step_range_h #define eccodes_accessor_g2step_range_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g2step_range_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g2step_range.h.bak b/src/accessor/grib_accessor_class_g2step_range.h.bak new file mode 100644 index 000000000..c5a007806 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2step_range.h.bak @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_g2step_range_h +#define eccodes_accessor_g2step_range_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2step_range_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2step_range */ + const char* start_step; + const char* end_step; +}; + +class grib_accessor_class_g2step_range_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2step_range_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_g2step_range_h */ diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h b/src/accessor/grib_accessor_class_gaussian_grid_name.h index 1c12bfacd..a6be9dc33 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.h +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_gaussian_grid_name_h #define eccodes_accessor_gaussian_grid_name_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak b/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak new file mode 100644 index 000000000..1c12bfacd --- /dev/null +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gaussian_grid_name_h +#define eccodes_accessor_gaussian_grid_name_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gaussian_grid_name */ + const char* N; + const char* Ni; + const char* isOctahedral; +}; + +class grib_accessor_class_gaussian_grid_name_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gaussian_grid_name_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gaussian_grid_name_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gaussian_grid_name_h */ diff --git a/src/accessor/grib_accessor_class_gds_is_present.h b/src/accessor/grib_accessor_class_gds_is_present.h index fa1c5ca55..8dad7dd21 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.h +++ b/src/accessor/grib_accessor_class_gds_is_present.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_gds_is_present_h #define eccodes_accessor_gds_is_present_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_gds_is_present_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_gds_is_present.h.bak b/src/accessor/grib_accessor_class_gds_is_present.h.bak new file mode 100644 index 000000000..fa1c5ca55 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_is_present.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gds_is_present_h +#define eccodes_accessor_gds_is_present_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_gds_is_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in gds_is_present */ + const char* gds_present; + const char* grid_definition; + const char* bitmap_present; + const char* values; +}; + +class grib_accessor_class_gds_is_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_gds_is_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_is_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gds_is_present_h */ diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h index 68641a8e2..377fac8b4 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_gds_not_present_bitmap_h #define eccodes_accessor_gds_not_present_bitmap_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak new file mode 100644 index 000000000..68641a8e2 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gds_not_present_bitmap_h +#define eccodes_accessor_gds_not_present_bitmap_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gds_not_present_bitmap */ + const char* missing_value; + const char* number_of_values; + const char* number_of_points; + const char* latitude_of_first_point; + const char* ni; +}; + +class grib_accessor_class_gds_not_present_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gds_not_present_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_not_present_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gds_not_present_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h index 2d76361ae..9baf3e2dd 100644 --- a/src/accessor/grib_accessor_class_gen.h +++ b/src/accessor/grib_accessor_class_gen.h @@ -1,6 +1,6 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor.h" #include diff --git a/src/accessor/grib_accessor_class_gen.h.bak b/src/accessor/grib_accessor_class_gen.h.bak new file mode 100644 index 000000000..2d76361ae --- /dev/null +++ b/src/accessor/grib_accessor_class_gen.h.bak @@ -0,0 +1,158 @@ +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor.h" +#include + +class grib_accessor_gen_t : public grib_accessor { + void init_accessor(const long, grib_arguments*) override; + void dump(grib_dumper* f) override; + int pack_missing() override; + //int grib_pack_zero(grib_accessor* a) override; + int is_missing_internal() override; + int pack_double(const double* v, size_t* len) override; + int pack_float(const float* v, size_t* len) override; + int pack_expression(grib_expression* e) override; + int pack_string(const char* v, size_t* len) override; + int pack_string_array(const char** v, size_t* len) override; + int pack_long(const long* v, size_t* len) override; + int pack_bytes(const unsigned char* v, size_t* len) override; + int unpack_bytes(unsigned char* v, size_t* len) override; + int unpack_double_subarray(double* v, size_t start, size_t len) override; + int unpack_double(double* v, size_t* len) override; + int unpack_float(float* v, size_t* len) override; + int unpack_double_element(size_t i, double* v) override; + int unpack_float_element(size_t i, float* v) override; + int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) override; + int unpack_string(char* v, size_t* len) override; + int unpack_string_array(char** v, size_t* len) override; + int unpack_long(long* v, size_t* len) override; + long get_native_type() override; + long get_next_position_offset() override; + long string_length() override; + long byte_offset() override; + long byte_count() override; + int value_count(long* count) override; + int notify_change(grib_accessor* changed) override; + grib_accessor* clone(grib_section* s, int* err) override; + void update_size(size_t len) override; + int nearest_smaller_value(double val, double* nearest) override; + size_t preferred_size(int from_handle) override; + grib_accessor* next_accessor() override; + void resize(size_t new_size) override; + void destroy(grib_context* ct) override; +}; + +class grib_accessor_class_gen_t : public grib_accessor_class +{ +public: + grib_accessor_class_gen_t(const char* name) : grib_accessor_class{name} {} + ~grib_accessor_class_gen_t(); + + grib_accessor* create_empty_accessor() override{ return new grib_accessor_gen_t(); } + grib_section* sub_section(grib_accessor* a) override; + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; + void update_size(grib_accessor*, size_t) override; + size_t preferred_size(grib_accessor*, int) override; + void resize(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; + grib_accessor* next(grib_accessor*, int) override; + int compare(grib_accessor*, grib_accessor*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_float_element(grib_accessor*, size_t i, float* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; + int clear(grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; + + template + int unpack_helper(grib_accessor* a, T* v, size_t* len); + +private: + enum { + PACK_DOUBLE, + PACK_FLOAT, + PACK_LONG, + PACK_STRING, + UNPACK_DOUBLE, + UNPACK_FLOAT, + UNPACK_LONG, + UNPACK_STRING, + }; + std::bitset<8> is_overridden_ = 0b11111111; +}; + + +template +int grib_accessor_class_gen_t::unpack_helper(grib_accessor* a, T* v, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + int type = GRIB_TYPE_UNDEFINED; + const char* Tname = type_to_string(*v); + + if constexpr (std::is_same_v) { + is_overridden_[UNPACK_FLOAT] = 0; + } + else if constexpr (std::is_same_v) { + is_overridden_[UNPACK_DOUBLE] = 0; + } + + if (is_overridden_[UNPACK_LONG]) { + long val = 0; + size_t l = 1; + a->unpack_long(&val, &l); + if (is_overridden_[UNPACK_LONG]) { + *v = val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + + if (is_overridden_[UNPACK_STRING]) { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + if (is_overridden_[UNPACK_STRING]) { + *v = strtod(val, &last); + if (*last == 0) { /* conversion of string to double worked */ + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_getenv.h.bak b/src/accessor/grib_accessor_class_getenv.h.bak new file mode 100644 index 000000000..5068dad2c --- /dev/null +++ b/src/accessor/grib_accessor_class_getenv.h.bak @@ -0,0 +1,36 @@ +/* + * (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. + */ + +#ifndef eccodes_accessor_getenv_h +#define eccodes_accessor_getenv_h + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_getenv_t : public grib_accessor_ascii_t +{ +public: + const char* name; + char* value; + const char* default_value; +}; + +class grib_accessor_class_getenv_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_getenv_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_getenv_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; + +#endif /* eccodes_accessor_getenv_h */ diff --git a/src/accessor/grib_accessor_class_global_gaussian.h b/src/accessor/grib_accessor_class_global_gaussian.h index f1e8bf53b..5bd73dd8f 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.h +++ b/src/accessor/grib_accessor_class_global_gaussian.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_global_gaussian_h #define eccodes_accessor_global_gaussian_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_global_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_global_gaussian.h.bak b/src/accessor/grib_accessor_class_global_gaussian.h.bak new file mode 100644 index 000000000..f1e8bf53b --- /dev/null +++ b/src/accessor/grib_accessor_class_global_gaussian.h.bak @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_global_gaussian_h +#define eccodes_accessor_global_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_global_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in global_gaussian */ + const char* N; + const char* Ni; + const char* di; + const char* latfirst; + const char* lonfirst; + const char* latlast; + const char* lonlast; + const char* plpresent; + const char* pl; + const char* basic_angle; + const char* subdivision; +}; + +class grib_accessor_class_global_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_global_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_global_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_global_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_group.h b/src/accessor/grib_accessor_class_group.h index 085b91a8a..ab56f174e 100644 --- a/src/accessor/grib_accessor_class_group.h +++ b/src/accessor/grib_accessor_class_group.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_group_h #define eccodes_accessor_group_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_group_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_group.h.bak b/src/accessor/grib_accessor_class_group.h.bak new file mode 100644 index 000000000..085b91a8a --- /dev/null +++ b/src/accessor/grib_accessor_class_group.h.bak @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_group_h +#define eccodes_accessor_group_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_group_t : public grib_accessor_gen_t +{ +public: + /* Members defined in group */ + char endCharacter; +}; + +class grib_accessor_class_group_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_group_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_group_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_group_h */ diff --git a/src/accessor/grib_accessor_class_gts_header.h b/src/accessor/grib_accessor_class_gts_header.h index c164a9df9..15f2bfd9e 100644 --- a/src/accessor/grib_accessor_class_gts_header.h +++ b/src/accessor/grib_accessor_class_gts_header.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_gts_header_h #define eccodes_accessor_gts_header_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_gts_header_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_gts_header.h.bak b/src/accessor/grib_accessor_class_gts_header.h.bak new file mode 100644 index 000000000..c164a9df9 --- /dev/null +++ b/src/accessor/grib_accessor_class_gts_header.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_gts_header_h +#define eccodes_accessor_gts_header_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_gts_header_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in gts_header */ + int gts_offset; + int gts_length; +}; + +class grib_accessor_class_gts_header_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_gts_header_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gts_header_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_gts_header_h */ diff --git a/src/accessor/grib_accessor_class_hash_array.h b/src/accessor/grib_accessor_class_hash_array.h index 78856c7e7..7ebd98929 100644 --- a/src/accessor/grib_accessor_class_hash_array.h +++ b/src/accessor/grib_accessor_class_hash_array.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_hash_array_h #define eccodes_accessor_hash_array_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_hash_array_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_hash_array.h.bak b/src/accessor/grib_accessor_class_hash_array.h.bak new file mode 100644 index 000000000..78856c7e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_hash_array.h.bak @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_hash_array_h +#define eccodes_accessor_hash_array_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_hash_array_t : public grib_accessor_gen_t +{ +public: + /* Members defined in hash_array */ + char* key; + grib_hash_array_value* ha; +}; + +class grib_accessor_class_hash_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_hash_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_hash_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_hash_array_h */ diff --git a/src/accessor/grib_accessor_class_headers_only.h b/src/accessor/grib_accessor_class_headers_only.h index 29d7e8bf5..d5743cf90 100644 --- a/src/accessor/grib_accessor_class_headers_only.h +++ b/src/accessor/grib_accessor_class_headers_only.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_headers_only_h #define eccodes_accessor_headers_only_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_headers_only_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_headers_only.h.bak b/src/accessor/grib_accessor_class_headers_only.h.bak new file mode 100644 index 000000000..29d7e8bf5 --- /dev/null +++ b/src/accessor/grib_accessor_class_headers_only.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_headers_only_h +#define eccodes_accessor_headers_only_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_headers_only_t : public grib_accessor_gen_t +{ +public: + /* Members defined in headers_only */ +}; + +class grib_accessor_class_headers_only_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_headers_only_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_headers_only_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_headers_only_h */ diff --git a/src/accessor/grib_accessor_class_ibmfloat.h b/src/accessor/grib_accessor_class_ibmfloat.h index d98864516..9291d30a3 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.h +++ b/src/accessor/grib_accessor_class_ibmfloat.h @@ -11,7 +11,7 @@ #ifndef eccodes_accessor_ibmfloat_h #define eccodes_accessor_ibmfloat_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_ibmfloat_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_ibmfloat.h.bak b/src/accessor/grib_accessor_class_ibmfloat.h.bak new file mode 100644 index 000000000..d98864516 --- /dev/null +++ b/src/accessor/grib_accessor_class_ibmfloat.h.bak @@ -0,0 +1,71 @@ +/* + * (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. + */ + +#ifndef eccodes_accessor_ibmfloat_h +#define eccodes_accessor_ibmfloat_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_ibmfloat_t : public grib_accessor_double_t +{ +public: + /* Members defined in ibmfloat */ + grib_arguments* arg; +}; + +class grib_accessor_class_ibmfloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ibmfloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ibmfloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; +private: + template int unpack(grib_accessor*, T*, size_t*); +}; + + +template +int grib_accessor_class_ibmfloat_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + unsigned long rlen = 0; + long count = 0; + int err = 0; + unsigned long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&count); if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +#endif /* eccodes_accessor_ibmfloat_h */ diff --git a/src/accessor/grib_accessor_class_ieeefloat.h.bak b/src/accessor/grib_accessor_class_ieeefloat.h.bak new file mode 100644 index 000000000..100b2ad6a --- /dev/null +++ b/src/accessor/grib_accessor_class_ieeefloat.h.bak @@ -0,0 +1,66 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ieeefloat_h +#define eccodes_accessor_ieeefloat_h + +#include "grib_accessor_class_double.h" + +class grib_accessor_ieeefloat_t : public grib_accessor_double_t +{ +public: + grib_arguments* arg; +}; + +class grib_accessor_class_ieeefloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ieeefloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ieeefloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; + +private: + template int unpack(grib_accessor*, T*, size_t*); +}; + + +template +int grib_accessor_class_ieeefloat_t::unpack(grib_accessor* a, T* val, size_t* len){ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + long rlen = 0; + int err = 0; + long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&rlen); if (err) + return err; + + if (*len < (size_t)rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +#endif /* eccodes_accessor_ieeefloat_h */ diff --git a/src/accessor/grib_accessor_class_ifs_param.h b/src/accessor/grib_accessor_class_ifs_param.h index d41da1723..b9fe2bd33 100644 --- a/src/accessor/grib_accessor_class_ifs_param.h +++ b/src/accessor/grib_accessor_class_ifs_param.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_ifs_param_h #define eccodes_accessor_ifs_param_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_ifs_param_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_ifs_param.h.bak b/src/accessor/grib_accessor_class_ifs_param.h.bak new file mode 100644 index 000000000..d41da1723 --- /dev/null +++ b/src/accessor/grib_accessor_class_ifs_param.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ifs_param_h +#define eccodes_accessor_ifs_param_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_ifs_param_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ifs_param */ + const char* paramId; + const char* type; +}; + +class grib_accessor_class_ifs_param_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ifs_param_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ifs_param_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_ifs_param_h */ diff --git a/src/accessor/grib_accessor_class_iterator.h b/src/accessor/grib_accessor_class_iterator.h index 7288fa205..5f809c90e 100644 --- a/src/accessor/grib_accessor_class_iterator.h +++ b/src/accessor/grib_accessor_class_iterator.h @@ -14,7 +14,7 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_iterator_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_iterator.h.bak b/src/accessor/grib_accessor_class_iterator.h.bak new file mode 100644 index 000000000..7288fa205 --- /dev/null +++ b/src/accessor/grib_accessor_class_iterator.h.bak @@ -0,0 +1,36 @@ +/* + * (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. + */ + +/*************************** + * Enrico Fucile + *************************/ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_iterator_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + +class grib_accessor_class_iterator_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_iterator_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_iterator_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + + +//grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) diff --git a/src/accessor/grib_accessor_class_julian_date.h b/src/accessor/grib_accessor_class_julian_date.h index 68008fec6..944e85996 100644 --- a/src/accessor/grib_accessor_class_julian_date.h +++ b/src/accessor/grib_accessor_class_julian_date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_julian_date_h #define eccodes_accessor_julian_date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_julian_date_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_julian_date.h.bak b/src/accessor/grib_accessor_class_julian_date.h.bak new file mode 100644 index 000000000..68008fec6 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_date.h.bak @@ -0,0 +1,48 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_julian_date_h +#define eccodes_accessor_julian_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_date */ + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; + const char *ymd; + const char *hms; + char sep[5]; +}; + +class grib_accessor_class_julian_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_date_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_julian_date_h */ diff --git a/src/accessor/grib_accessor_class_julian_day.h b/src/accessor/grib_accessor_class_julian_day.h index 1d21fb920..b31f3b0dd 100644 --- a/src/accessor/grib_accessor_class_julian_day.h +++ b/src/accessor/grib_accessor_class_julian_day.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_julian_day_h #define eccodes_accessor_julian_day_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_julian_day_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_julian_day.h.bak b/src/accessor/grib_accessor_class_julian_day.h.bak new file mode 100644 index 000000000..1d21fb920 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_day.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_julian_day_h +#define eccodes_accessor_julian_day_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_day_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_day */ + const char *date; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_julian_day_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_day_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_day_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_julian_day_h */ diff --git a/src/accessor/grib_accessor_class_ksec1expver.h b/src/accessor/grib_accessor_class_ksec1expver.h index 3884a7709..ca0a18695 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.h +++ b/src/accessor/grib_accessor_class_ksec1expver.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_ksec1expver_h #define eccodes_accessor_ksec1expver_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_ksec1expver.h.bak b/src/accessor/grib_accessor_class_ksec1expver.h.bak new file mode 100644 index 000000000..3884a7709 --- /dev/null +++ b/src/accessor/grib_accessor_class_ksec1expver.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_ksec1expver_h +#define eccodes_accessor_ksec1expver_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in ksec1expver */ +}; + +class grib_accessor_class_ksec1expver_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_ksec1expver_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ksec1expver_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_ksec1expver_h */ diff --git a/src/accessor/grib_accessor_class_label.h b/src/accessor/grib_accessor_class_label.h index c4e64b322..01b7ac392 100644 --- a/src/accessor/grib_accessor_class_label.h +++ b/src/accessor/grib_accessor_class_label.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_label_h #define eccodes_accessor_label_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_label_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_label.h.bak b/src/accessor/grib_accessor_class_label.h.bak new file mode 100644 index 000000000..c4e64b322 --- /dev/null +++ b/src/accessor/grib_accessor_class_label.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_label_h +#define eccodes_accessor_label_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_label_t : public grib_accessor_gen_t +{ +public: + /* Members defined in label */ +}; + +class grib_accessor_class_label_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_label_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_label_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_label_h */ diff --git a/src/accessor/grib_accessor_class_latitudes.h b/src/accessor/grib_accessor_class_latitudes.h index 10344c7cb..e89db49e4 100644 --- a/src/accessor/grib_accessor_class_latitudes.h +++ b/src/accessor/grib_accessor_class_latitudes.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_latitudes_h #define eccodes_accessor_latitudes_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latitudes_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_latitudes.h.bak b/src/accessor/grib_accessor_class_latitudes.h.bak new file mode 100644 index 000000000..10344c7cb --- /dev/null +++ b/src/accessor/grib_accessor_class_latitudes.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latitudes_h +#define eccodes_accessor_latitudes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in latitudes */ + const char* values; + long distinct; + double* lats; + long size; + int save; +}; + +class grib_accessor_class_latitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latitudes_h */ diff --git a/src/accessor/grib_accessor_class_latlon_increment.h b/src/accessor/grib_accessor_class_latlon_increment.h index 4f5402e6a..e85d1ec91 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.h +++ b/src/accessor/grib_accessor_class_latlon_increment.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_latlon_increment_h #define eccodes_accessor_latlon_increment_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latlon_increment_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_latlon_increment.h.bak b/src/accessor/grib_accessor_class_latlon_increment.h.bak new file mode 100644 index 000000000..4f5402e6a --- /dev/null +++ b/src/accessor/grib_accessor_class_latlon_increment.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latlon_increment_h +#define eccodes_accessor_latlon_increment_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latlon_increment_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlon_increment */ + const char* directionIncrementGiven; + const char* directionIncrement; + const char* scansPositively; + const char* first; + const char* last; + const char* numberOfPoints; + const char* angleMultiplier; + const char* angleDivisor; + long isLongitude; +}; + +class grib_accessor_class_latlon_increment_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlon_increment_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlon_increment_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latlon_increment_h */ diff --git a/src/accessor/grib_accessor_class_latlonvalues.h b/src/accessor/grib_accessor_class_latlonvalues.h index ed040f543..56faec4d9 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.h +++ b/src/accessor/grib_accessor_class_latlonvalues.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_latlonvalues_h #define eccodes_accessor_latlonvalues_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latlonvalues_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_latlonvalues.h.bak b/src/accessor/grib_accessor_class_latlonvalues.h.bak new file mode 100644 index 000000000..ed040f543 --- /dev/null +++ b/src/accessor/grib_accessor_class_latlonvalues.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_latlonvalues_h +#define eccodes_accessor_latlonvalues_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_latlonvalues_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlonvalues */ + const char* values; +}; + +class grib_accessor_class_latlonvalues_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlonvalues_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlonvalues_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_latlonvalues_h */ diff --git a/src/accessor/grib_accessor_class_library_version.h b/src/accessor/grib_accessor_class_library_version.h index 28de10364..66099c2c0 100644 --- a/src/accessor/grib_accessor_class_library_version.h +++ b/src/accessor/grib_accessor_class_library_version.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_library_version_h #define eccodes_accessor_library_version_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_library_version_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_library_version.h.bak b/src/accessor/grib_accessor_class_library_version.h.bak new file mode 100644 index 000000000..28de10364 --- /dev/null +++ b/src/accessor/grib_accessor_class_library_version.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_library_version_h +#define eccodes_accessor_library_version_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_library_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in library_version */ +}; + +class grib_accessor_class_library_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_library_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_library_version_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; +}; +#endif /* eccodes_accessor_library_version_h */ diff --git a/src/accessor/grib_accessor_class_local_definition.h b/src/accessor/grib_accessor_class_local_definition.h index 296bab69d..9be7d7e9a 100644 --- a/src/accessor/grib_accessor_class_local_definition.h +++ b/src/accessor/grib_accessor_class_local_definition.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_local_definition_h #define eccodes_accessor_local_definition_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_local_definition_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_local_definition.h.bak b/src/accessor/grib_accessor_class_local_definition.h.bak new file mode 100644 index 000000000..296bab69d --- /dev/null +++ b/src/accessor/grib_accessor_class_local_definition.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_local_definition_h +#define eccodes_accessor_local_definition_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_local_definition_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in local_definition */ + const char* productDefinitionTemplateNumber; + const char* productDefinitionTemplateNumberInternal; + const char* grib2LocalSectionNumber; + const char* type; + const char* stream; + const char* the_class; + const char* eps; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_local_definition_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_local_definition_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_local_definition_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_local_definition_h */ diff --git a/src/accessor/grib_accessor_class_long.h b/src/accessor/grib_accessor_class_long.h index a0b01f9ae..acabf2612 100644 --- a/src/accessor/grib_accessor_class_long.h +++ b/src/accessor/grib_accessor_class_long.h @@ -1,6 +1,6 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_long_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_long.h.bak b/src/accessor/grib_accessor_class_long.h.bak new file mode 100644 index 000000000..a0b01f9ae --- /dev/null +++ b/src/accessor/grib_accessor_class_long.h.bak @@ -0,0 +1,22 @@ +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_long_t : public grib_accessor_gen_t +{}; + +class grib_accessor_class_long_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_long_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + int get_native_type(grib_accessor* a) override; + int pack_missing(grib_accessor* a) override; + int pack_string(grib_accessor* a, const char*, size_t* len) override; + int unpack_double(grib_accessor* a, double* val, size_t* len) override; + int unpack_string(grib_accessor* a, char*, size_t* len) override; + void dump(grib_accessor* a, grib_dumper*) override; + int compare(grib_accessor* a, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_long_vector.h b/src/accessor/grib_accessor_class_long_vector.h index 66fab29e6..b2d3a4a67 100644 --- a/src/accessor/grib_accessor_class_long_vector.h +++ b/src/accessor/grib_accessor_class_long_vector.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_long_vector_h #define eccodes_accessor_long_vector_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_long_vector.h" class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t diff --git a/src/accessor/grib_accessor_class_long_vector.h.bak b/src/accessor/grib_accessor_class_long_vector.h.bak new file mode 100644 index 000000000..66fab29e6 --- /dev/null +++ b/src/accessor/grib_accessor_class_long_vector.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_long_vector_h +#define eccodes_accessor_long_vector_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in long_vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_long_vector_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_long_vector_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_vector_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_longitudes.h b/src/accessor/grib_accessor_class_longitudes.h index 782b4d764..0825f5a90 100644 --- a/src/accessor/grib_accessor_class_longitudes.h +++ b/src/accessor/grib_accessor_class_longitudes.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_longitudes_h #define eccodes_accessor_longitudes_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_longitudes_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_longitudes.h.bak b/src/accessor/grib_accessor_class_longitudes.h.bak new file mode 100644 index 000000000..782b4d764 --- /dev/null +++ b/src/accessor/grib_accessor_class_longitudes.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_longitudes_h +#define eccodes_accessor_longitudes_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_longitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in longitudes */ + const char* values; + long distinct; + double* lons; + long size; + int save; +}; + +class grib_accessor_class_longitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_longitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_longitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_longitudes_h */ diff --git a/src/accessor/grib_accessor_class_lookup.h.bak b/src/accessor/grib_accessor_class_lookup.h.bak new file mode 100644 index 000000000..1fba42fe5 --- /dev/null +++ b/src/accessor/grib_accessor_class_lookup.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_lookup_h +#define eccodes_accessor_lookup_h + +#include "grib_accessor_class_long.h" + +class grib_accessor_lookup_t : public grib_accessor_long_t +{ +public: + long llength; + long loffset; + grib_expression* real_name; +}; + +class grib_accessor_class_lookup_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_lookup_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_lookup_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_lookup_h */ diff --git a/src/accessor/grib_accessor_class_mars_param.h b/src/accessor/grib_accessor_class_mars_param.h index 87bcaad41..87400a5f7 100644 --- a/src/accessor/grib_accessor_class_mars_param.h +++ b/src/accessor/grib_accessor_class_mars_param.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_mars_param_h #define eccodes_accessor_mars_param_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_mars_param_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_mars_param.h.bak b/src/accessor/grib_accessor_class_mars_param.h.bak new file mode 100644 index 000000000..87bcaad41 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_param.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_mars_param_h +#define eccodes_accessor_mars_param_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_param_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_param */ + const char* paramId; + const char* table; + const char* param; +}; + +class grib_accessor_class_mars_param_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_param_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_param_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_mars_param_h */ diff --git a/src/accessor/grib_accessor_class_mars_step.h b/src/accessor/grib_accessor_class_mars_step.h index db3042648..67d95ef9a 100644 --- a/src/accessor/grib_accessor_class_mars_step.h +++ b/src/accessor/grib_accessor_class_mars_step.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_mars_step_h #define eccodes_accessor_mars_step_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_mars_step_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_mars_step.h.bak b/src/accessor/grib_accessor_class_mars_step.h.bak new file mode 100644 index 000000000..db3042648 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_step.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_mars_step_h +#define eccodes_accessor_mars_step_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_step_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_step */ + const char* stepRange; + const char* stepType; +}; + +class grib_accessor_class_mars_step_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_step_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_mars_step_h */ diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h index 8d819cc9d..7b265f797 100644 --- a/src/accessor/grib_accessor_class_md5.h +++ b/src/accessor/grib_accessor_class_md5.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_md5_h #define eccodes_accessor_md5_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_md5_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_md5.h.bak b/src/accessor/grib_accessor_class_md5.h.bak new file mode 100644 index 000000000..8d819cc9d --- /dev/null +++ b/src/accessor/grib_accessor_class_md5.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_md5_h +#define eccodes_accessor_md5_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_md5_t : public grib_accessor_gen_t +{ +public: + /* Members defined in md5 */ + const char* offset; + grib_expression* length; + grib_string_list* blocklist; +}; + +class grib_accessor_class_md5_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_md5_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_md5_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_md5_h */ diff --git a/src/accessor/grib_accessor_class_message.h b/src/accessor/grib_accessor_class_message.h index 912e8be4b..c81e23750 100644 --- a/src/accessor/grib_accessor_class_message.h +++ b/src/accessor/grib_accessor_class_message.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_message_h #define eccodes_accessor_message_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_message_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_message.h.bak b/src/accessor/grib_accessor_class_message.h.bak new file mode 100644 index 000000000..912e8be4b --- /dev/null +++ b/src/accessor/grib_accessor_class_message.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_message_h +#define eccodes_accessor_message_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_message_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in message */ +}; + +class grib_accessor_class_message_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_message_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; +}; +#endif /* eccodes_accessor_message_h */ diff --git a/src/accessor/grib_accessor_class_message_copy.h b/src/accessor/grib_accessor_class_message_copy.h index 37072c685..53002c968 100644 --- a/src/accessor/grib_accessor_class_message_copy.h +++ b/src/accessor/grib_accessor_class_message_copy.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_message_copy_h #define eccodes_accessor_message_copy_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_message_copy_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_message_copy.h.bak b/src/accessor/grib_accessor_class_message_copy.h.bak new file mode 100644 index 000000000..37072c685 --- /dev/null +++ b/src/accessor/grib_accessor_class_message_copy.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_message_copy_h +#define eccodes_accessor_message_copy_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_message_copy_t : public grib_accessor_gen_t +{ +public: + /* Members defined in message_copy */ +}; + +class grib_accessor_class_message_copy_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_message_copy_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_copy_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_message_copy_h */ diff --git a/src/accessor/grib_accessor_class_multdouble.h b/src/accessor/grib_accessor_class_multdouble.h index 9d6d76285..c9847dde1 100644 --- a/src/accessor/grib_accessor_class_multdouble.h +++ b/src/accessor/grib_accessor_class_multdouble.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_multdouble_h #define eccodes_accessor_multdouble_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_multdouble_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_multdouble.h.bak b/src/accessor/grib_accessor_class_multdouble.h.bak new file mode 100644 index 000000000..9d6d76285 --- /dev/null +++ b/src/accessor/grib_accessor_class_multdouble.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_multdouble_h +#define eccodes_accessor_multdouble_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_multdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in multdouble */ + const char* val; + double multiplier; +}; + +class grib_accessor_class_multdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_multdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_multdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_multdouble_h */ diff --git a/src/accessor/grib_accessor_class_nearest.h b/src/accessor/grib_accessor_class_nearest.h index 831afea60..098eb69a8 100644 --- a/src/accessor/grib_accessor_class_nearest.h +++ b/src/accessor/grib_accessor_class_nearest.h @@ -10,7 +10,7 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_nearest_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_nearest.h.bak b/src/accessor/grib_accessor_class_nearest.h.bak new file mode 100644 index 000000000..831afea60 --- /dev/null +++ b/src/accessor/grib_accessor_class_nearest.h.bak @@ -0,0 +1,33 @@ +/* + * (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. + */ + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_nearest_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + + +class grib_accessor_class_nearest_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_nearest_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_nearest_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + + +//grib_nearest* grib_nearest_new(const grib_handle* ch, int* error); diff --git a/src/accessor/grib_accessor_class_non_alpha.h b/src/accessor/grib_accessor_class_non_alpha.h index 1b1b9d830..e9f910723 100644 --- a/src/accessor/grib_accessor_class_non_alpha.h +++ b/src/accessor/grib_accessor_class_non_alpha.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_non_alpha_h #define eccodes_accessor_non_alpha_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_non_alpha_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_non_alpha.h.bak b/src/accessor/grib_accessor_class_non_alpha.h.bak new file mode 100644 index 000000000..1b1b9d830 --- /dev/null +++ b/src/accessor/grib_accessor_class_non_alpha.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_non_alpha_h +#define eccodes_accessor_non_alpha_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_non_alpha_t : public grib_accessor_gen_t +{ +public: + /* Members defined in non_alpha */ +}; + +class grib_accessor_class_non_alpha_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_non_alpha_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_non_alpha_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_non_alpha_h */ diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h b/src/accessor/grib_accessor_class_number_of_coded_values.h index de5e3b76b..7cb74d1c2 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.h +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_number_of_coded_values_h #define eccodes_accessor_number_of_coded_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h.bak b/src/accessor/grib_accessor_class_number_of_coded_values.h.bak new file mode 100644 index 000000000..de5e3b76b --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_coded_values_h +#define eccodes_accessor_number_of_coded_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_coded_values */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_number_of_coded_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_coded_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_coded_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_coded_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points.h b/src/accessor/grib_accessor_class_number_of_points.h index db3521c05..3ca18b6e9 100644 --- a/src/accessor/grib_accessor_class_number_of_points.h +++ b/src/accessor/grib_accessor_class_number_of_points.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_number_of_points_h #define eccodes_accessor_number_of_points_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_points_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_points.h.bak b/src/accessor/grib_accessor_class_number_of_points.h.bak new file mode 100644 index 000000000..db3521c05 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_points_h +#define eccodes_accessor_number_of_points_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_number_of_points_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_points_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h b/src/accessor/grib_accessor_class_number_of_points_gaussian.h index f01224f17..70ba3d6d4 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.h +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_number_of_points_gaussian_h #define eccodes_accessor_number_of_points_gaussian_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak b/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak new file mode 100644 index 000000000..f01224f17 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_points_gaussian_h +#define eccodes_accessor_number_of_points_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points_gaussian */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; + const char* order; + const char* lat_first; + const char* lon_first; + const char* lat_last; + const char* lon_last; + const char* support_legacy; +}; + +class grib_accessor_class_number_of_points_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_gaussian_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_points_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values.h b/src/accessor/grib_accessor_class_number_of_values.h index 88b18cd6f..246c29cbd 100644 --- a/src/accessor/grib_accessor_class_number_of_values.h +++ b/src/accessor/grib_accessor_class_number_of_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_number_of_values_h #define eccodes_accessor_number_of_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_values_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_values.h.bak b/src/accessor/grib_accessor_class_number_of_values.h.bak new file mode 100644 index 000000000..88b18cd6f --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_values_h +#define eccodes_accessor_number_of_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_values */ + const char* values; + const char* bitsPerValue; + const char* numberOfPoints; + const char* bitmapPresent; + const char* bitmap; + const char* numberOfCodedValues; +}; + +class grib_accessor_class_number_of_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h index c0a6e9fcb..ff57531d2 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_number_of_values_data_raw_packing_h #define eccodes_accessor_number_of_values_data_raw_packing_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak new file mode 100644 index 000000000..c0a6e9fcb --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_number_of_values_data_raw_packing_h +#define eccodes_accessor_number_of_values_data_raw_packing_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in number_of_values_data_raw_packing */ + const char* values; + const char* precision; +}; + +class grib_accessor_class_number_of_values_data_raw_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_number_of_values_data_raw_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_data_raw_packing_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_number_of_values_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h b/src/accessor/grib_accessor_class_octahedral_gaussian.h index 31784d000..f9aee3d78 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.h +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_octahedral_gaussian_h #define eccodes_accessor_octahedral_gaussian_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak b/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak new file mode 100644 index 000000000..31784d000 --- /dev/null +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_octahedral_gaussian_h +#define eccodes_accessor_octahedral_gaussian_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in octahedral_gaussian */ + const char* N; + const char* Ni; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_octahedral_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octahedral_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octahedral_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_octahedral_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_octet_number.h b/src/accessor/grib_accessor_class_octet_number.h index 4d6145742..6be9134af 100644 --- a/src/accessor/grib_accessor_class_octet_number.h +++ b/src/accessor/grib_accessor_class_octet_number.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_octet_number_h #define eccodes_accessor_octet_number_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_octet_number_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_octet_number.h.bak b/src/accessor/grib_accessor_class_octet_number.h.bak new file mode 100644 index 000000000..4d6145742 --- /dev/null +++ b/src/accessor/grib_accessor_class_octet_number.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_octet_number_h +#define eccodes_accessor_octet_number_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_octet_number_t : public grib_accessor_long_t +{ +public: + /* Members defined in octet_number */ + const char* left; + long right; +}; + +class grib_accessor_class_octet_number_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octet_number_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octet_number_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_octet_number_h */ diff --git a/src/accessor/grib_accessor_class_offset_file.h b/src/accessor/grib_accessor_class_offset_file.h index 34243b5a4..8806590f7 100644 --- a/src/accessor/grib_accessor_class_offset_file.h +++ b/src/accessor/grib_accessor_class_offset_file.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_offset_file_h #define eccodes_accessor_offset_file_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_offset_file_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_offset_file.h.bak b/src/accessor/grib_accessor_class_offset_file.h.bak new file mode 100644 index 000000000..34243b5a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_file.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_offset_file_h +#define eccodes_accessor_offset_file_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_file_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_file */ +}; + +class grib_accessor_class_offset_file_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_file_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_file_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_offset_file_h */ diff --git a/src/accessor/grib_accessor_class_offset_values.h b/src/accessor/grib_accessor_class_offset_values.h index 51e0f0f16..17d31a91a 100644 --- a/src/accessor/grib_accessor_class_offset_values.h +++ b/src/accessor/grib_accessor_class_offset_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_offset_values_h #define eccodes_accessor_offset_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_offset_values_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_offset_values.h.bak b/src/accessor/grib_accessor_class_offset_values.h.bak new file mode 100644 index 000000000..51e0f0f16 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_values.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_offset_values_h +#define eccodes_accessor_offset_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_offset_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_offset_values_h */ diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h b/src/accessor/grib_accessor_class_optimal_step_units.h index 96383b291..5ab2249ae 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.h +++ b/src/accessor/grib_accessor_class_optimal_step_units.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_optimal_step_units_h #define eccodes_accessor_optimal_step_units_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_optimal_step_units_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h.bak b/src/accessor/grib_accessor_class_optimal_step_units.h.bak new file mode 100644 index 000000000..96383b291 --- /dev/null +++ b/src/accessor/grib_accessor_class_optimal_step_units.h.bak @@ -0,0 +1,44 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_optimal_step_units_h +#define eccodes_accessor_optimal_step_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_optimal_step_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in optimal_step_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* time_range_value; + const char* time_range_unit; +}; + +class grib_accessor_class_optimal_step_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_optimal_step_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_optimal_step_units_t{}; } + int get_native_type(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_optimal_step_units_h */ diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h b/src/accessor/grib_accessor_class_pack_bufr_values.h index b4bdaf43c..feef9ef37 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.h +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_pack_bufr_values_h #define eccodes_accessor_pack_bufr_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h.bak b/src/accessor/grib_accessor_class_pack_bufr_values.h.bak new file mode 100644 index 000000000..b4bdaf43c --- /dev/null +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_pack_bufr_values_h +#define eccodes_accessor_pack_bufr_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in pack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_pack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_pack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_pack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_packing_type.h b/src/accessor/grib_accessor_class_packing_type.h index 3451db189..69c52f866 100644 --- a/src/accessor/grib_accessor_class_packing_type.h +++ b/src/accessor/grib_accessor_class_packing_type.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_packing_type_h #define eccodes_accessor_packing_type_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_packing_type_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_packing_type.h.bak b/src/accessor/grib_accessor_class_packing_type.h.bak new file mode 100644 index 000000000..3451db189 --- /dev/null +++ b/src/accessor/grib_accessor_class_packing_type.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_packing_type_h +#define eccodes_accessor_packing_type_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_packing_type_t : public grib_accessor_gen_t +{ +public: + /* Members defined in packing_type */ + const char* values; + const char* packing_type; +}; + +class grib_accessor_class_packing_type_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_packing_type_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_packing_type_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_packing_type_h */ diff --git a/src/accessor/grib_accessor_class_pad.h b/src/accessor/grib_accessor_class_pad.h index 8ca8bb09b..28fefc891 100644 --- a/src/accessor/grib_accessor_class_pad.h +++ b/src/accessor/grib_accessor_class_pad.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_pad_h #define eccodes_accessor_pad_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_pad_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_pad.h.bak b/src/accessor/grib_accessor_class_pad.h.bak new file mode 100644 index 000000000..8ca8bb09b --- /dev/null +++ b/src/accessor/grib_accessor_class_pad.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_pad_h +#define eccodes_accessor_pad_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_pad_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padding */ + /* Members defined in pad */ + grib_expression* expression; +}; + +class grib_accessor_class_pad_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_pad_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pad_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_pad_h */ diff --git a/src/accessor/grib_accessor_class_padding.h b/src/accessor/grib_accessor_class_padding.h index 65a416c4c..2d53ed7c8 100644 --- a/src/accessor/grib_accessor_class_padding.h +++ b/src/accessor/grib_accessor_class_padding.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_padding_h #define eccodes_accessor_padding_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_padding_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_padding.h.bak b/src/accessor/grib_accessor_class_padding.h.bak new file mode 100644 index 000000000..65a416c4c --- /dev/null +++ b/src/accessor/grib_accessor_class_padding.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padding_h +#define eccodes_accessor_padding_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_bytes.h" + +class grib_accessor_padding_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in padding */ +}; + +class grib_accessor_class_padding_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_padding_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padding_t{}; } + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_padding_h */ diff --git a/src/accessor/grib_accessor_class_padto.h b/src/accessor/grib_accessor_class_padto.h index f7203b2cb..5b7867019 100644 --- a/src/accessor/grib_accessor_class_padto.h +++ b/src/accessor/grib_accessor_class_padto.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_padto_h #define eccodes_accessor_padto_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padto_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padto.h.bak b/src/accessor/grib_accessor_class_padto.h.bak new file mode 100644 index 000000000..f7203b2cb --- /dev/null +++ b/src/accessor/grib_accessor_class_padto.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padto_h +#define eccodes_accessor_padto_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padto_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padto */ + grib_expression* expression; +}; + +class grib_accessor_class_padto_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padto_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padto_t{}; } + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padto_h */ diff --git a/src/accessor/grib_accessor_class_padtoeven.h b/src/accessor/grib_accessor_class_padtoeven.h index 08f8fc072..2f9ccc1ff 100644 --- a/src/accessor/grib_accessor_class_padtoeven.h +++ b/src/accessor/grib_accessor_class_padtoeven.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_padtoeven_h #define eccodes_accessor_padtoeven_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padtoeven_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padtoeven.h.bak b/src/accessor/grib_accessor_class_padtoeven.h.bak new file mode 100644 index 000000000..08f8fc072 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtoeven.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padtoeven_h +#define eccodes_accessor_padtoeven_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtoeven_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtoeven */ + const char* section_offset; + const char* section_length; +}; + +class grib_accessor_class_padtoeven_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtoeven_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtoeven_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padtoeven_h */ diff --git a/src/accessor/grib_accessor_class_padtomultiple.h b/src/accessor/grib_accessor_class_padtomultiple.h index f57afad37..f391fbe58 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.h +++ b/src/accessor/grib_accessor_class_padtomultiple.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_padtomultiple_h #define eccodes_accessor_padtomultiple_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padtomultiple_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padtomultiple.h.bak b/src/accessor/grib_accessor_class_padtomultiple.h.bak new file mode 100644 index 000000000..f57afad37 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtomultiple.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_padtomultiple_h +#define eccodes_accessor_padtomultiple_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtomultiple_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtomultiple */ + grib_expression* begin; + grib_expression* multiple; +}; + +class grib_accessor_class_padtomultiple_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtomultiple_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtomultiple_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_padtomultiple_h */ diff --git a/src/accessor/grib_accessor_class_position.h b/src/accessor/grib_accessor_class_position.h index 40d690694..05564e503 100644 --- a/src/accessor/grib_accessor_class_position.h +++ b/src/accessor/grib_accessor_class_position.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_position_h #define eccodes_accessor_position_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_position_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_position.h.bak b/src/accessor/grib_accessor_class_position.h.bak new file mode 100644 index 000000000..40d690694 --- /dev/null +++ b/src/accessor/grib_accessor_class_position.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_position_h +#define eccodes_accessor_position_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_position_t : public grib_accessor_gen_t +{ +public: + /* Members defined in position */ +}; + +class grib_accessor_class_position_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_position_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_position_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_position_h */ diff --git a/src/accessor/grib_accessor_class_proj_string.h b/src/accessor/grib_accessor_class_proj_string.h index c49c0f868..bb4fa76a7 100644 --- a/src/accessor/grib_accessor_class_proj_string.h +++ b/src/accessor/grib_accessor_class_proj_string.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_proj_string_h #define eccodes_accessor_proj_string_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_proj_string_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_proj_string.h.bak b/src/accessor/grib_accessor_class_proj_string.h.bak new file mode 100644 index 000000000..c49c0f868 --- /dev/null +++ b/src/accessor/grib_accessor_class_proj_string.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_proj_string_h +#define eccodes_accessor_proj_string_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_proj_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in proj_string */ + const char* grid_type; + int endpoint; +}; + +class grib_accessor_class_proj_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_proj_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_proj_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_proj_string_h */ diff --git a/src/accessor/grib_accessor_class_raw.h b/src/accessor/grib_accessor_class_raw.h index 30a2603e7..d754deb63 100644 --- a/src/accessor/grib_accessor_class_raw.h +++ b/src/accessor/grib_accessor_class_raw.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_raw_h #define eccodes_accessor_raw_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_raw_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_raw.h.bak b/src/accessor/grib_accessor_class_raw.h.bak new file mode 100644 index 000000000..30a2603e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_raw.h.bak @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_raw_h +#define eccodes_accessor_raw_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_raw_t : public grib_accessor_gen_t +{ +public: + /* Members defined in raw */ + const char* totalLength; + const char* sectionLength; + long relativeOffset; +}; + +class grib_accessor_class_raw_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_raw_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_raw_t{}; } + int get_native_type(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_raw_h */ diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h b/src/accessor/grib_accessor_class_rdbtime_guess_date.h index e9ef0b4d3..1c75f1556 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.h +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_rdbtime_guess_date_h #define eccodes_accessor_rdbtime_guess_date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak b/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak new file mode 100644 index 000000000..e9ef0b4d3 --- /dev/null +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_rdbtime_guess_date_h +#define eccodes_accessor_rdbtime_guess_date_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in rdbtime_guess_date */ + const char* typicalYear; + const char* typicalMonth; + const char* typicalDay; + const char* rdbDay; + long yearOrMonth; +}; + +class grib_accessor_class_rdbtime_guess_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_rdbtime_guess_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_rdbtime_guess_date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_rdbtime_guess_date_h */ diff --git a/src/accessor/grib_accessor_class_reference_value_error.h b/src/accessor/grib_accessor_class_reference_value_error.h index e0b948e97..aea5e95e5 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.h +++ b/src/accessor/grib_accessor_class_reference_value_error.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_reference_value_error_h #define eccodes_accessor_reference_value_error_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_reference_value_error_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_reference_value_error.h.bak b/src/accessor/grib_accessor_class_reference_value_error.h.bak new file mode 100644 index 000000000..e0b948e97 --- /dev/null +++ b/src/accessor/grib_accessor_class_reference_value_error.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_reference_value_error_h +#define eccodes_accessor_reference_value_error_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_reference_value_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in reference_value_error */ + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_reference_value_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_reference_value_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_reference_value_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_reference_value_error_h */ diff --git a/src/accessor/grib_accessor_class_round.h b/src/accessor/grib_accessor_class_round.h index c38d7b6e8..ed94f9804 100644 --- a/src/accessor/grib_accessor_class_round.h +++ b/src/accessor/grib_accessor_class_round.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_round_h #define eccodes_accessor_round_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_evaluate.h" class grib_accessor_round_t : public grib_accessor_evaluate_t diff --git a/src/accessor/grib_accessor_class_round.h.bak b/src/accessor/grib_accessor_class_round.h.bak new file mode 100644 index 000000000..c38d7b6e8 --- /dev/null +++ b/src/accessor/grib_accessor_class_round.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_round_h +#define eccodes_accessor_round_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_evaluate.h" + +class grib_accessor_round_t : public grib_accessor_evaluate_t +{ +public: + /* Members defined in round */ +}; + +class grib_accessor_class_round_t : public grib_accessor_class_evaluate_t +{ +public: + grib_accessor_class_round_t(const char* name) : grib_accessor_class_evaluate_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_round_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; +#endif /* eccodes_accessor_round_h */ diff --git a/src/accessor/grib_accessor_class_scale.h b/src/accessor/grib_accessor_class_scale.h index 7e1f0d80d..5a44f8013 100644 --- a/src/accessor/grib_accessor_class_scale.h +++ b/src/accessor/grib_accessor_class_scale.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_scale_h #define eccodes_accessor_scale_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_scale_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_scale.h.bak b/src/accessor/grib_accessor_class_scale.h.bak new file mode 100644 index 000000000..7e1f0d80d --- /dev/null +++ b/src/accessor/grib_accessor_class_scale.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_scale_h +#define eccodes_accessor_scale_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale */ + const char* value; + const char* multiplier; + const char* divisor; + const char* truncating; +}; + +class grib_accessor_class_scale_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_scale_h */ diff --git a/src/accessor/grib_accessor_class_scale_values.h b/src/accessor/grib_accessor_class_scale_values.h index cb94e16b8..ab644956b 100644 --- a/src/accessor/grib_accessor_class_scale_values.h +++ b/src/accessor/grib_accessor_class_scale_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_scale_values_h #define eccodes_accessor_scale_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_scale_values_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_scale_values.h.bak b/src/accessor/grib_accessor_class_scale_values.h.bak new file mode 100644 index 000000000..cb94e16b8 --- /dev/null +++ b/src/accessor/grib_accessor_class_scale_values.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_scale_values_h +#define eccodes_accessor_scale_values_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_scale_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_scale_values_h */ diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h b/src/accessor/grib_accessor_class_second_order_bits_per_value.h index 370b364dd..5c30e9e19 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.h +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_second_order_bits_per_value_h #define eccodes_accessor_second_order_bits_per_value_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak b/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak new file mode 100644 index 000000000..370b364dd --- /dev/null +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_second_order_bits_per_value_h +#define eccodes_accessor_second_order_bits_per_value_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in second_order_bits_per_value */ + const char* values; + const char* binaryScaleFactor; + const char* decimalScaleFactor; + long bitsPerValue; +}; + +class grib_accessor_class_second_order_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_second_order_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_second_order_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_second_order_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_section.h.bak b/src/accessor/grib_accessor_class_section.h.bak new file mode 100644 index 000000000..b1905b182 --- /dev/null +++ b/src/accessor/grib_accessor_class_section.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_h +#define eccodes_accessor_section_h + +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_t : public grib_accessor_gen_t {}; + +class grib_accessor_class_section_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_t{}; } + int get_native_type(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + grib_section* sub_section(grib_accessor*) override; + grib_accessor* next(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_section_h */ diff --git a/src/accessor/grib_accessor_class_section_length.h b/src/accessor/grib_accessor_class_section_length.h index 09490bebd..5c9b810d0 100644 --- a/src/accessor/grib_accessor_class_section_length.h +++ b/src/accessor/grib_accessor_class_section_length.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_section_length_h #define eccodes_accessor_section_length_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_section_length_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_section_length.h.bak b/src/accessor/grib_accessor_class_section_length.h.bak new file mode 100644 index 000000000..09490bebd --- /dev/null +++ b/src/accessor/grib_accessor_class_section_length.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_length_h +#define eccodes_accessor_section_length_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_section_length_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in section_length */ +}; + +class grib_accessor_class_section_length_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_section_length_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_length_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_section_length_h */ diff --git a/src/accessor/grib_accessor_class_section_padding.h b/src/accessor/grib_accessor_class_section_padding.h index b6fce7f34..b039ed838 100644 --- a/src/accessor/grib_accessor_class_section_padding.h +++ b/src/accessor/grib_accessor_class_section_padding.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_section_padding_h #define eccodes_accessor_section_padding_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_section_padding_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_section_padding.h.bak b/src/accessor/grib_accessor_class_section_padding.h.bak new file mode 100644 index 000000000..b6fce7f34 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_padding.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_padding_h +#define eccodes_accessor_section_padding_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_padding.h" + +class grib_accessor_section_padding_t : public grib_accessor_padding_t +{ +public: + /* Members defined in section_padding */ + int preserve; +}; + +class grib_accessor_class_section_padding_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_section_padding_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_padding_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; +#endif /* eccodes_accessor_section_padding_h */ diff --git a/src/accessor/grib_accessor_class_section_pointer.h b/src/accessor/grib_accessor_class_section_pointer.h index 45e77fbb9..0f92439a4 100644 --- a/src/accessor/grib_accessor_class_section_pointer.h +++ b/src/accessor/grib_accessor_class_section_pointer.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_section_pointer_h #define eccodes_accessor_section_pointer_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_section_pointer_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_section_pointer.h.bak b/src/accessor/grib_accessor_class_section_pointer.h.bak new file mode 100644 index 000000000..45e77fbb9 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_pointer.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_section_pointer_h +#define eccodes_accessor_section_pointer_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_pointer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in section_pointer */ + const char* sectionOffset; + const char* sectionLength; + long sectionNumber; +}; + +class grib_accessor_class_section_pointer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_pointer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_pointer_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_section_pointer_h */ diff --git a/src/accessor/grib_accessor_class_select_step_template.h b/src/accessor/grib_accessor_class_select_step_template.h index a83d3ddfd..ad6548aa4 100644 --- a/src/accessor/grib_accessor_class_select_step_template.h +++ b/src/accessor/grib_accessor_class_select_step_template.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_select_step_template_h #define eccodes_accessor_select_step_template_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_select_step_template.h.bak b/src/accessor/grib_accessor_class_select_step_template.h.bak new file mode 100644 index 000000000..a83d3ddfd --- /dev/null +++ b/src/accessor/grib_accessor_class_select_step_template.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_select_step_template_h +#define eccodes_accessor_select_step_template_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in select_step_template */ + const char* productDefinitionTemplateNumber; + int instant; +}; + +class grib_accessor_class_select_step_template_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_select_step_template_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_select_step_template_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_select_step_template_h */ diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h b/src/accessor/grib_accessor_class_sexagesimal2decimal.h index c9009293e..32fa3498d 100644 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.h +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_sexagesimal2decimal_h #define eccodes_accessor_sexagesimal2decimal_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_to_double.h" class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak b/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak new file mode 100644 index 000000000..c9009293e --- /dev/null +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sexagesimal2decimal_h +#define eccodes_accessor_sexagesimal2decimal_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_to_double.h" + +class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t +{ +public: + /* Members defined in sexagesimal2decimal */ +}; + +class grib_accessor_class_sexagesimal2decimal_t : public grib_accessor_class_to_double_t +{ +public: + grib_accessor_class_sexagesimal2decimal_t(const char* name) : grib_accessor_class_to_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sexagesimal2decimal_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sexagesimal2decimal_h */ diff --git a/src/accessor/grib_accessor_class_signed.h b/src/accessor/grib_accessor_class_signed.h index 23c9829a4..c25fc1752 100644 --- a/src/accessor/grib_accessor_class_signed.h +++ b/src/accessor/grib_accessor_class_signed.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_signed_h #define eccodes_accessor_signed_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_signed_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_signed.h.bak b/src/accessor/grib_accessor_class_signed.h.bak new file mode 100644 index 000000000..23c9829a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_signed_h +#define eccodes_accessor_signed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed */ + grib_arguments* arg; + int nbytes; +}; + +class grib_accessor_class_signed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_t{}; } + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_signed_h */ diff --git a/src/accessor/grib_accessor_class_signed_bits.h b/src/accessor/grib_accessor_class_signed_bits.h index 96ba5f592..05cf524aa 100644 --- a/src/accessor/grib_accessor_class_signed_bits.h +++ b/src/accessor/grib_accessor_class_signed_bits.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_signed_bits_h #define eccodes_accessor_signed_bits_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_signed_bits_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_signed_bits.h.bak b/src/accessor/grib_accessor_class_signed_bits.h.bak new file mode 100644 index 000000000..96ba5f592 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed_bits.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_signed_bits_h +#define eccodes_accessor_signed_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_signed_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_signed_bits_h */ diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h b/src/accessor/grib_accessor_class_simple_packing_error.h index 6c90188c5..950716638 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.h +++ b/src/accessor/grib_accessor_class_simple_packing_error.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_simple_packing_error_h #define eccodes_accessor_simple_packing_error_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_simple_packing_error_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h.bak b/src/accessor/grib_accessor_class_simple_packing_error.h.bak new file mode 100644 index 000000000..6c90188c5 --- /dev/null +++ b/src/accessor/grib_accessor_class_simple_packing_error.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_simple_packing_error_h +#define eccodes_accessor_simple_packing_error_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_simple_packing_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in simple_packing_error */ + const char* binaryScaleFactor; + const char* bitsPerValue; + const char* decimalScaleFactor; + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_simple_packing_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_simple_packing_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_simple_packing_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_simple_packing_error_h */ diff --git a/src/accessor/grib_accessor_class_size.h b/src/accessor/grib_accessor_class_size.h index dbf47f8bd..7cfb325f5 100644 --- a/src/accessor/grib_accessor_class_size.h +++ b/src/accessor/grib_accessor_class_size.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_size_h #define eccodes_accessor_size_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_size_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_size.h.bak b/src/accessor/grib_accessor_class_size.h.bak new file mode 100644 index 000000000..dbf47f8bd --- /dev/null +++ b/src/accessor/grib_accessor_class_size.h.bak @@ -0,0 +1,33 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_size_h +#define eccodes_accessor_size_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_size_t : public grib_accessor_long_t +{ +public: + /* Members defined in size */ + const char* accessor; +}; + +class grib_accessor_class_size_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_size_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_size_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_size_h */ diff --git a/src/accessor/grib_accessor_class_smart_table.h b/src/accessor/grib_accessor_class_smart_table.h index b6146a981..93a6ea682 100644 --- a/src/accessor/grib_accessor_class_smart_table.h +++ b/src/accessor/grib_accessor_class_smart_table.h @@ -15,7 +15,7 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" #include diff --git a/src/accessor/grib_accessor_class_smart_table.h.bak b/src/accessor/grib_accessor_class_smart_table.h.bak new file mode 100644 index 000000000..b6146a981 --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table.h.bak @@ -0,0 +1,52 @@ +/* + * (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. + */ + +/***************************************** + * Enrico Fucile + ****************************************/ + + +#pragma once + +#include "../grib_api_internal.h" +#include "grib_accessor_class_unsigned.h" +#include + + +class grib_accessor_smart_table_t : public grib_accessor_unsigned_t +{ +public: + const char* values; + const char* tablename; + const char* masterDir; + const char* localDir; + const char* extraDir; + const char* extraTable; + int widthOfCode; + long* tableCodes; + size_t tableCodesSize; + grib_smart_table* table; + int dirty; +}; + + +class grib_accessor_class_smart_table_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_smart_table_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_smart_table_column.h.bak b/src/accessor/grib_accessor_class_smart_table_column.h.bak new file mode 100644 index 000000000..f5787f780 --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table_column.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_smart_table_column_h +#define eccodes_accessor_smart_table_column_h + +#include "grib_accessor_class_gen.h" + +class grib_accessor_smart_table_column_t : public grib_accessor_gen_t +{ +public: + const char* smartTable; + int index; +}; + +class grib_accessor_class_smart_table_column_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_smart_table_column_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_column_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_smart_table_column_h */ diff --git a/src/accessor/grib_accessor_class_spd.h b/src/accessor/grib_accessor_class_spd.h index c35e5c742..3c47458d3 100644 --- a/src/accessor/grib_accessor_class_spd.h +++ b/src/accessor/grib_accessor_class_spd.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_spd_h #define eccodes_accessor_spd_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_spd_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_spd.h.bak b/src/accessor/grib_accessor_class_spd.h.bak new file mode 100644 index 000000000..c35e5c742 --- /dev/null +++ b/src/accessor/grib_accessor_class_spd.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_spd_h +#define eccodes_accessor_spd_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_spd_t : public grib_accessor_long_t +{ +public: + /* Members defined in spd */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_spd_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spd_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spd_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_spd_h */ diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h b/src/accessor/grib_accessor_class_spectral_truncation.h index 0ab43b1fd..329c59155 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.h +++ b/src/accessor/grib_accessor_class_spectral_truncation.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_spectral_truncation_h #define eccodes_accessor_spectral_truncation_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_spectral_truncation_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h.bak b/src/accessor/grib_accessor_class_spectral_truncation.h.bak new file mode 100644 index 000000000..0ab43b1fd --- /dev/null +++ b/src/accessor/grib_accessor_class_spectral_truncation.h.bak @@ -0,0 +1,36 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_spectral_truncation_h +#define eccodes_accessor_spectral_truncation_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_spectral_truncation_t : public grib_accessor_long_t +{ +public: + /* Members defined in spectral_truncation */ + const char* J; + const char* K; + const char* M; + const char* T; +}; + +class grib_accessor_class_spectral_truncation_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spectral_truncation_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spectral_truncation_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_spectral_truncation_h */ diff --git a/src/accessor/grib_accessor_class_sprintf.h b/src/accessor/grib_accessor_class_sprintf.h index 9bfb1c83e..360cd3b1b 100644 --- a/src/accessor/grib_accessor_class_sprintf.h +++ b/src/accessor/grib_accessor_class_sprintf.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_sprintf_h #define eccodes_accessor_sprintf_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_sprintf_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_sprintf.h.bak b/src/accessor/grib_accessor_class_sprintf.h.bak new file mode 100644 index 000000000..9bfb1c83e --- /dev/null +++ b/src/accessor/grib_accessor_class_sprintf.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sprintf_h +#define eccodes_accessor_sprintf_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_sprintf_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in sprintf */ + grib_arguments* args; +}; + +class grib_accessor_class_sprintf_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_sprintf_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sprintf_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sprintf_h */ diff --git a/src/accessor/grib_accessor_class_statistics.h b/src/accessor/grib_accessor_class_statistics.h index 4eea0b546..e4ffed90d 100644 --- a/src/accessor/grib_accessor_class_statistics.h +++ b/src/accessor/grib_accessor_class_statistics.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_statistics_h #define eccodes_accessor_statistics_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_statistics_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_statistics.h.bak b/src/accessor/grib_accessor_class_statistics.h.bak new file mode 100644 index 000000000..4eea0b546 --- /dev/null +++ b/src/accessor/grib_accessor_class_statistics.h.bak @@ -0,0 +1,38 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_statistics_h +#define eccodes_accessor_statistics_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_statistics_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in statistics */ + const char* values; + const char* missing_value; +}; + +class grib_accessor_class_statistics_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_statistics_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_statistics_h */ diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h b/src/accessor/grib_accessor_class_statistics_spectral.h index 8075ddf31..c47f2385a 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.h +++ b/src/accessor/grib_accessor_class_statistics_spectral.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_statistics_spectral_h #define eccodes_accessor_statistics_spectral_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h.bak b/src/accessor/grib_accessor_class_statistics_spectral.h.bak new file mode 100644 index 000000000..8075ddf31 --- /dev/null +++ b/src/accessor/grib_accessor_class_statistics_spectral.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_statistics_spectral_h +#define eccodes_accessor_statistics_spectral_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in statistics_spectral */ + const char* values; + const char* J; + const char* K; + const char* M; + const char* JS; +}; + +class grib_accessor_class_statistics_spectral_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_statistics_spectral_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_spectral_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_statistics_spectral_h */ diff --git a/src/accessor/grib_accessor_class_step_human_readable.h b/src/accessor/grib_accessor_class_step_human_readable.h index 793ecb618..9d902f324 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.h +++ b/src/accessor/grib_accessor_class_step_human_readable.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_step_human_readable_h #define eccodes_accessor_step_human_readable_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_step_human_readable_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_step_human_readable.h.bak b/src/accessor/grib_accessor_class_step_human_readable.h.bak new file mode 100644 index 000000000..793ecb618 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_human_readable.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_step_human_readable_h +#define eccodes_accessor_step_human_readable_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_step_human_readable_t : public grib_accessor_gen_t +{ +public: + /* Members defined in step_human_readable */ + const char* stepUnits; + const char* step; +}; + +class grib_accessor_class_step_human_readable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_step_human_readable_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_human_readable_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_step_human_readable_h */ diff --git a/src/accessor/grib_accessor_class_step_in_units.h b/src/accessor/grib_accessor_class_step_in_units.h index ba088db79..e6fe8a6f6 100644 --- a/src/accessor/grib_accessor_class_step_in_units.h +++ b/src/accessor/grib_accessor_class_step_in_units.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_step_in_units_h #define eccodes_accessor_step_in_units_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_step_in_units_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_step_in_units.h.bak b/src/accessor/grib_accessor_class_step_in_units.h.bak new file mode 100644 index 000000000..ba088db79 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_in_units.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_step_in_units_h +#define eccodes_accessor_step_in_units_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_step_in_units_t : public grib_accessor_long_t +{ +public: + /* Members defined in step_in_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* step_units; + const char* time_range_unit; + const char* time_range_value; +}; + +class grib_accessor_class_step_in_units_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_step_in_units_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_in_units_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_step_in_units_h */ diff --git a/src/accessor/grib_accessor_class_sum.h b/src/accessor/grib_accessor_class_sum.h index ceedb788a..c05c7c6d1 100644 --- a/src/accessor/grib_accessor_class_sum.h +++ b/src/accessor/grib_accessor_class_sum.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_sum_h #define eccodes_accessor_sum_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_sum_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_sum.h.bak b/src/accessor/grib_accessor_class_sum.h.bak new file mode 100644 index 000000000..ceedb788a --- /dev/null +++ b/src/accessor/grib_accessor_class_sum.h.bak @@ -0,0 +1,35 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_sum_h +#define eccodes_accessor_sum_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_double.h" + +class grib_accessor_sum_t : public grib_accessor_double_t +{ +public: + /* Members defined in sum */ + const char* values; +}; + +class grib_accessor_class_sum_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_sum_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sum_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_sum_h */ diff --git a/src/accessor/grib_accessor_class_suppressed.h b/src/accessor/grib_accessor_class_suppressed.h index c8a93274e..844c1fb6b 100644 --- a/src/accessor/grib_accessor_class_suppressed.h +++ b/src/accessor/grib_accessor_class_suppressed.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_suppressed_h #define eccodes_accessor_suppressed_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_suppressed_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_suppressed.h.bak b/src/accessor/grib_accessor_class_suppressed.h.bak new file mode 100644 index 000000000..c8a93274e --- /dev/null +++ b/src/accessor/grib_accessor_class_suppressed.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_suppressed_h +#define eccodes_accessor_suppressed_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_suppressed_t : public grib_accessor_long_t +{ +public: + /* Members defined in suppressed */ + grib_arguments* args; +}; + +class grib_accessor_class_suppressed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_suppressed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_suppressed_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_suppressed_h */ diff --git a/src/accessor/grib_accessor_class_time.h b/src/accessor/grib_accessor_class_time.h index b1826e1d6..247e4a08d 100644 --- a/src/accessor/grib_accessor_class_time.h +++ b/src/accessor/grib_accessor_class_time.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_time_h #define eccodes_accessor_time_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_time_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_time.h.bak b/src/accessor/grib_accessor_class_time.h.bak new file mode 100644 index 000000000..b1826e1d6 --- /dev/null +++ b/src/accessor/grib_accessor_class_time.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_time_h +#define eccodes_accessor_time_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in time */ + const char* hour; + const char* minute; + const char* second; +}; + +class grib_accessor_class_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_time_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_time_h */ diff --git a/src/accessor/grib_accessor_class_to_double.h b/src/accessor/grib_accessor_class_to_double.h index a2010cc1e..639cc98f5 100644 --- a/src/accessor/grib_accessor_class_to_double.h +++ b/src/accessor/grib_accessor_class_to_double.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_to_double_h #define eccodes_accessor_to_double_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_double_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_to_double.h.bak b/src/accessor/grib_accessor_class_to_double.h.bak new file mode 100644 index 000000000..a2010cc1e --- /dev/null +++ b/src/accessor/grib_accessor_class_to_double.h.bak @@ -0,0 +1,43 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_double_h +#define eccodes_accessor_to_double_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_double_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_double */ + const char* key; + long start; + size_t length; + long scale; +}; + +class grib_accessor_class_to_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_double_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_double_h */ diff --git a/src/accessor/grib_accessor_class_to_integer.h b/src/accessor/grib_accessor_class_to_integer.h index 3ee9dd87b..ec3505c75 100644 --- a/src/accessor/grib_accessor_class_to_integer.h +++ b/src/accessor/grib_accessor_class_to_integer.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_to_integer_h #define eccodes_accessor_to_integer_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_integer_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_to_integer.h.bak b/src/accessor/grib_accessor_class_to_integer.h.bak new file mode 100644 index 000000000..3ee9dd87b --- /dev/null +++ b/src/accessor/grib_accessor_class_to_integer.h.bak @@ -0,0 +1,45 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_integer_h +#define eccodes_accessor_to_integer_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_integer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_integer */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_integer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_integer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_integer_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_integer_h */ diff --git a/src/accessor/grib_accessor_class_to_string.h b/src/accessor/grib_accessor_class_to_string.h index 0907cb82c..6dd1e4de8 100644 --- a/src/accessor/grib_accessor_class_to_string.h +++ b/src/accessor/grib_accessor_class_to_string.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_to_string_h #define eccodes_accessor_to_string_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_string_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_to_string.h.bak b/src/accessor/grib_accessor_class_to_string.h.bak new file mode 100644 index 000000000..0907cb82c --- /dev/null +++ b/src/accessor/grib_accessor_class_to_string.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_to_string_h +#define eccodes_accessor_to_string_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_string */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_to_string_h */ diff --git a/src/accessor/grib_accessor_class_transient.h.bak b/src/accessor/grib_accessor_class_transient.h.bak new file mode 100644 index 000000000..e330ad686 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient.h.bak @@ -0,0 +1,25 @@ +/* + * (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. + */ + +#pragma once + +#include "grib_accessor_class_variable.h" + +class grib_accessor_transient_t : public grib_accessor_variable_t { +public: +}; + +class grib_accessor_class_transient_t : public grib_accessor_class_variable_t { +public: + void init(grib_accessor* a, const long l, grib_arguments* args) override; + grib_accessor_class_transient_t(const char* name) : grib_accessor_class_variable_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_t{}; } +}; + diff --git a/src/accessor/grib_accessor_class_transient_darray.h b/src/accessor/grib_accessor_class_transient_darray.h index fe918bd55..6aeff1491 100644 --- a/src/accessor/grib_accessor_class_transient_darray.h +++ b/src/accessor/grib_accessor_class_transient_darray.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_transient_darray_h #define eccodes_accessor_transient_darray_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_transient_darray_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_transient_darray.h.bak b/src/accessor/grib_accessor_class_transient_darray.h.bak new file mode 100644 index 000000000..fe918bd55 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient_darray.h.bak @@ -0,0 +1,41 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_transient_darray_h +#define eccodes_accessor_transient_darray_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_transient_darray_t : public grib_accessor_gen_t +{ +public: + /* Members defined in transient_darray */ + grib_darray* arr; + int type; +}; + +class grib_accessor_class_transient_darray_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_transient_darray_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_darray_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_transient_darray_h */ diff --git a/src/accessor/grib_accessor_class_trim.h b/src/accessor/grib_accessor_class_trim.h index 9fd6b9230..664ccc528 100644 --- a/src/accessor/grib_accessor_class_trim.h +++ b/src/accessor/grib_accessor_class_trim.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_trim_h #define eccodes_accessor_trim_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_trim_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_trim.h.bak b/src/accessor/grib_accessor_class_trim.h.bak new file mode 100644 index 000000000..664ccc528 --- /dev/null +++ b/src/accessor/grib_accessor_class_trim.h.bak @@ -0,0 +1,37 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_trim_h +#define eccodes_accessor_trim_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_ascii.h" + +class grib_accessor_trim_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in trim */ + const char* input; + int trim_left; + int trim_right; +}; + +class grib_accessor_class_trim_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_trim_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_trim_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_trim_h */ diff --git a/src/accessor/grib_accessor_class_uint16.h b/src/accessor/grib_accessor_class_uint16.h index 0291df85c..0952e2d57 100644 --- a/src/accessor/grib_accessor_class_uint16.h +++ b/src/accessor/grib_accessor_class_uint16.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint16_h #define eccodes_accessor_uint16_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint16_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint16.h.bak b/src/accessor/grib_accessor_class_uint16.h.bak new file mode 100644 index 000000000..0952e2d57 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint16.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint16_h +#define eccodes_accessor_uint16_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint16_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint16 */ +}; + +class grib_accessor_class_uint16_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint16_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint16_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint16_h */ diff --git a/src/accessor/grib_accessor_class_uint32.h b/src/accessor/grib_accessor_class_uint32.h index be0457156..0cf8a0bd9 100644 --- a/src/accessor/grib_accessor_class_uint32.h +++ b/src/accessor/grib_accessor_class_uint32.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint32_h #define eccodes_accessor_uint32_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint32_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint32.h.bak b/src/accessor/grib_accessor_class_uint32.h.bak new file mode 100644 index 000000000..0cf8a0bd9 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint32_h +#define eccodes_accessor_uint32_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32 */ +}; + +class grib_accessor_class_uint32_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint32_h */ diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h b/src/accessor/grib_accessor_class_uint32_little_endian.h index 4f51d3113..357791081 100644 --- a/src/accessor/grib_accessor_class_uint32_little_endian.h +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint32_little_endian_h #define eccodes_accessor_uint32_little_endian_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h.bak b/src/accessor/grib_accessor_class_uint32_little_endian.h.bak new file mode 100644 index 000000000..357791081 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint32_little_endian_h +#define eccodes_accessor_uint32_little_endian_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32_little_endian */ +}; + +class grib_accessor_class_uint32_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint32_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint64.h b/src/accessor/grib_accessor_class_uint64.h index 04d96b1b8..55215c77f 100644 --- a/src/accessor/grib_accessor_class_uint64.h +++ b/src/accessor/grib_accessor_class_uint64.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint64_h #define eccodes_accessor_uint64_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint64_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint64.h.bak b/src/accessor/grib_accessor_class_uint64.h.bak new file mode 100644 index 000000000..55215c77f --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint64_h +#define eccodes_accessor_uint64_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64 */ +}; + +class grib_accessor_class_uint64_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint64_h */ diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h b/src/accessor/grib_accessor_class_uint64_little_endian.h index 5eb0068bb..8c04a5398 100644 --- a/src/accessor/grib_accessor_class_uint64_little_endian.h +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint64_little_endian_h #define eccodes_accessor_uint64_little_endian_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h.bak b/src/accessor/grib_accessor_class_uint64_little_endian.h.bak new file mode 100644 index 000000000..8c04a5398 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint64_little_endian_h +#define eccodes_accessor_uint64_little_endian_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64_little_endian */ +}; + +class grib_accessor_class_uint64_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint64_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint8.h b/src/accessor/grib_accessor_class_uint8.h index 8a06d0ceb..04dcb1075 100644 --- a/src/accessor/grib_accessor_class_uint8.h +++ b/src/accessor/grib_accessor_class_uint8.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_uint8_h #define eccodes_accessor_uint8_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint8_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint8.h.bak b/src/accessor/grib_accessor_class_uint8.h.bak new file mode 100644 index 000000000..04dcb1075 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint8.h.bak @@ -0,0 +1,32 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_uint8_h +#define eccodes_accessor_uint8_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint8_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint8 */ +}; + +class grib_accessor_class_uint8_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint8_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint8_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; +#endif /* eccodes_accessor_uint8_h */ diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h b/src/accessor/grib_accessor_class_unexpanded_descriptors.h index 12c89f308..2db5b51b3 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.h +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_unexpanded_descriptors_h #define eccodes_accessor_unexpanded_descriptors_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak b/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak new file mode 100644 index 000000000..2db5b51b3 --- /dev/null +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unexpanded_descriptors_h +#define eccodes_accessor_unexpanded_descriptors_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in unexpanded_descriptors */ + grib_accessor* unexpandedDescriptorsEncoded; + const char* createNewData; +}; + +class grib_accessor_class_unexpanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unexpanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unexpanded_descriptors_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_unexpanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h b/src/accessor/grib_accessor_class_unpack_bufr_values.h index 7890e7bad..0eea70de4 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.h +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_unpack_bufr_values_h #define eccodes_accessor_unpack_bufr_values_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak b/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak new file mode 100644 index 000000000..0eea70de4 --- /dev/null +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak @@ -0,0 +1,42 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unpack_bufr_values_h +#define eccodes_accessor_unpack_bufr_values_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in unpack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_unpack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_unpack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unpack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_unpack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_unsigned.h b/src/accessor/grib_accessor_class_unsigned.h index 99aadb93a..0523974ca 100644 --- a/src/accessor/grib_accessor_class_unsigned.h +++ b/src/accessor/grib_accessor_class_unsigned.h @@ -10,7 +10,7 @@ #pragma once -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unsigned_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_unsigned.h.bak b/src/accessor/grib_accessor_class_unsigned.h.bak new file mode 100644 index 000000000..0523974ca --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned.h.bak @@ -0,0 +1,40 @@ +/* + * (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. + */ + +#pragma once + +#include "grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_t : public grib_accessor_long_t +{ +public: + long nbytes; + grib_arguments* arg; +}; + + +class grib_accessor_class_unsigned_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; + int unpack_long(grib_accessor* a, long* val, size_t* len) override; + int pack_long(grib_accessor* a, const long* val, size_t* len) override; + long byte_count(grib_accessor* a) override; + int value_count(grib_accessor* a, long* len) override; + long byte_offset(grib_accessor* a) override; + void update_size(grib_accessor* a, size_t s) override; + long next_offset(grib_accessor* a) override; + int is_missing(grib_accessor* a) override; + void destroy(grib_context* context, grib_accessor* a) override; +}; diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h b/src/accessor/grib_accessor_class_unsigned_bits.h index 62ae48e60..ae20b0a5a 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.h +++ b/src/accessor/grib_accessor_class_unsigned_bits.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_unsigned_bits_h #define eccodes_accessor_unsigned_bits_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unsigned_bits_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h.bak b/src/accessor/grib_accessor_class_unsigned_bits.h.bak new file mode 100644 index 000000000..62ae48e60 --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned_bits.h.bak @@ -0,0 +1,40 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_unsigned_bits_h +#define eccodes_accessor_unsigned_bits_h + +#include "../grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in unsigned_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_unsigned_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; +#endif /* eccodes_accessor_unsigned_bits_h */ diff --git a/src/accessor/grib_accessor_class_validity_date.h b/src/accessor/grib_accessor_class_validity_date.h index 7a7eea971..dfd8eb320 100644 --- a/src/accessor/grib_accessor_class_validity_date.h +++ b/src/accessor/grib_accessor_class_validity_date.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_validity_date_h #define eccodes_accessor_validity_date_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_validity_date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_validity_date.h.bak b/src/accessor/grib_accessor_class_validity_date.h.bak new file mode 100644 index 000000000..dfd8eb320 --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_date.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_validity_date_h +#define eccodes_accessor_validity_date_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_date */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_validity_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_date_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_validity_date_h */ diff --git a/src/accessor/grib_accessor_class_validity_time.h b/src/accessor/grib_accessor_class_validity_time.h index 7fe86648a..3f7c27f7b 100644 --- a/src/accessor/grib_accessor_class_validity_time.h +++ b/src/accessor/grib_accessor_class_validity_time.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_validity_time_h #define eccodes_accessor_validity_time_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_validity_time_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_validity_time.h.bak b/src/accessor/grib_accessor_class_validity_time.h.bak new file mode 100644 index 000000000..3f7c27f7b --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_time.h.bak @@ -0,0 +1,39 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_validity_time_h +#define eccodes_accessor_validity_time_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_time */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* hours; + const char* minutes; +}; + +class grib_accessor_class_validity_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_time_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_validity_time_h */ diff --git a/src/accessor/grib_accessor_class_values.h.bak b/src/accessor/grib_accessor_class_values.h.bak new file mode 100644 index 000000000..c7cbf54e7 --- /dev/null +++ b/src/accessor/grib_accessor_class_values.h.bak @@ -0,0 +1,41 @@ +/* + * (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. + */ + +#ifndef eccodes_accessor_values_h +#define eccodes_accessor_values_h + +#include "grib_accessor_class_gen.h" + +class grib_accessor_values_t : public grib_accessor_gen_t +{ +public: + int carg; + const char* seclen; + const char* offsetdata; + const char* offsetsection; + int dirty; +}; + +class grib_accessor_class_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_values_h */ diff --git a/src/accessor/grib_accessor_class_variable.h.bak b/src/accessor/grib_accessor_class_variable.h.bak new file mode 100644 index 000000000..90ff71238 --- /dev/null +++ b/src/accessor/grib_accessor_class_variable.h.bak @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor.h" +#include "grib_accessor_class_gen.h" + + +class grib_accessor_variable_t : public grib_accessor_gen_t +{ +public: + double dval; + float fval; + char* cval; + char* cname; + int type; +}; + +class grib_accessor_class_variable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_variable_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_variable_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; diff --git a/src/accessor/grib_accessor_class_vector.h b/src/accessor/grib_accessor_class_vector.h index df12303cd..671441001 100644 --- a/src/accessor/grib_accessor_class_vector.h +++ b/src/accessor/grib_accessor_class_vector.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_vector_h #define eccodes_accessor_vector_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_vector_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_vector.h.bak b/src/accessor/grib_accessor_class_vector.h.bak new file mode 100644 index 000000000..671441001 --- /dev/null +++ b/src/accessor/grib_accessor_class_vector.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_vector_h +#define eccodes_accessor_vector_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_vector_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_vector_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_vector_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_vector_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; +#endif /* eccodes_accessor_vector_h */ diff --git a/src/accessor/grib_accessor_class_when.h b/src/accessor/grib_accessor_class_when.h index 69f1dffbb..b2ddcc0b0 100644 --- a/src/accessor/grib_accessor_class_when.h +++ b/src/accessor/grib_accessor_class_when.h @@ -12,7 +12,7 @@ #ifndef eccodes_accessor_when_h #define eccodes_accessor_when_h -#include "../grib_api_internal.h" +#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_when_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_when.h.bak b/src/accessor/grib_accessor_class_when.h.bak new file mode 100644 index 000000000..b2ddcc0b0 --- /dev/null +++ b/src/accessor/grib_accessor_class_when.h.bak @@ -0,0 +1,34 @@ + +/* + * (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. + */ + +#ifndef eccodes_accessor_when_h +#define eccodes_accessor_when_h + +#include "grib_api_internal.h" +#include "grib_accessor_class_gen.h" + +class grib_accessor_when_t : public grib_accessor_gen_t +{ +public: + /* Members defined in when */ +}; + +class grib_accessor_class_when_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_when_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_when_t{}; } + int get_native_type(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; +#endif /* eccodes_accessor_when_h */ From bbcf302f48959f2640074b7f26d9519978578231 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 13:54:06 +0100 Subject: [PATCH 29/90] Copyright notices --- ..._accessor_class_abstract_long_vector.h.bak | 33 --- .../grib_accessor_class_abstract_vector.h.bak | 32 --- src/accessor/grib_accessor_class_ascii.h.bak | 42 --- src/accessor/grib_accessor_class_bit.h.bak | 35 --- src/accessor/grib_accessor_class_bitmap.h.bak | 45 --- src/accessor/grib_accessor_class_bits.h.bak | 45 --- .../grib_accessor_class_bits_per_value.h.bak | 35 --- src/accessor/grib_accessor_class_blob.h.bak | 34 --- .../grib_accessor_class_budgdate.h.bak | 36 --- .../grib_accessor_class_bufr_data_array.h.bak | 92 ------ ...rib_accessor_class_bufr_data_element.h.bak | 57 ---- ...b_accessor_class_bufr_elements_table.h.bak | 39 --- ...ssor_class_bufr_extract_area_subsets.h.bak | 43 --- ..._class_bufr_extract_datetime_subsets.h.bak | 36 --- ..._accessor_class_bufr_extract_subsets.h.bak | 37 --- .../grib_accessor_class_bufr_group.h.bak | 32 --- ..._accessor_class_bufr_simple_thinning.h.bak | 39 --- ...ib_accessor_class_bufr_string_values.h.bak | 38 --- ...or_class_bufrdc_expanded_descriptors.h.bak | 37 --- src/accessor/grib_accessor_class_bytes.h.bak | 35 --- ...lass_change_alternative_row_scanning.h.bak | 38 --- ...ssor_class_change_scanning_direction.h.bak | 42 --- ...ccessor_class_check_internal_version.h.bak | 33 --- .../grib_accessor_class_closest_date.h.bak | 43 --- .../grib_accessor_class_codeflag.h.bak | 34 --- .../grib_accessor_class_codetable.h.bak | 47 --- .../grib_accessor_class_codetable_title.h.bak | 34 --- .../grib_accessor_class_codetable_units.h.bak | 34 --- .../grib_accessor_class_concept.h.bak | 43 --- .../grib_accessor_class_constant.h.bak | 27 -- .../grib_accessor_class_count_file.h.bak | 32 --- .../grib_accessor_class_count_missing.h.bak | 37 --- .../grib_accessor_class_count_total.h.bak | 32 --- ...rib_accessor_class_data_apply_bitmap.h.bak | 132 --------- ...sor_class_data_apply_boustrophedonic.h.bak | 41 --- ...ss_data_apply_boustrophedonic_bitmap.h.bak | 45 --- ...ib_accessor_class_data_ccsds_packing.h.bak | 203 ------------- ..._accessor_class_data_complex_packing.h.bak | 272 ------------------ ...grib_accessor_class_data_dummy_field.h.bak | 37 --- ...ccessor_class_data_g1complex_packing.h.bak | 37 --- ...1second_order_constant_width_packing.h.bak | 53 ---- ...econd_order_general_extended_packing.h.bak | 68 ----- ..._data_g1second_order_general_packing.h.bak | 49 ---- ...ta_g1second_order_row_by_row_packing.h.bak | 49 ---- ...cessor_class_data_g1secondary_bitmap.h.bak | 34 --- ...cessor_class_data_g1shsimple_packing.h.bak | 32 --- ...accessor_class_data_g1simple_packing.h.bak | 37 --- ...accessor_class_data_g22order_packing.h.bak | 55 ---- ...essor_class_data_g2bifourier_packing.h.bak | 47 --- ...ccessor_class_data_g2complex_packing.h.bak | 34 --- ...cessor_class_data_g2secondary_bitmap.h.bak | 34 --- ...cessor_class_data_g2shsimple_packing.h.bak | 36 --- ...accessor_class_data_g2simple_packing.h.bak | 28 -- ..._g2simple_packing_with_preprocessing.h.bak | 36 --- ...accessor_class_data_jpeg2000_packing.h.bak | 46 --- ...grib_accessor_class_data_png_packing.h.bak | 41 --- ...grib_accessor_class_data_raw_packing.h.bak | 38 --- ...cessor_class_data_run_length_packing.h.bak | 40 --- ...accessor_class_data_secondary_bitmap.h.bak | 38 --- .../grib_accessor_class_data_sh_packed.h.bak | 43 --- ...grib_accessor_class_data_sh_unpacked.h.bak | 43 --- ...accessor_class_data_shsimple_packing.h.bak | 37 --- ...b_accessor_class_data_simple_packing.h.bak | 195 ------------- ...rib_accessor_class_decimal_precision.h.bak | 37 --- .../grib_accessor_class_dictionary.h.bak | 42 --- src/accessor/grib_accessor_class_dirty.h.bak | 34 --- .../grib_accessor_class_divdouble.h.bak | 34 --- src/accessor/grib_accessor_class_double.h.bak | 30 -- .../grib_accessor_class_element.h.bak | 36 --- .../grib_accessor_class_evaluate.h.bak | 33 --- ..._accessor_class_expanded_descriptors.h.bak | 47 --- ...class_from_scale_factor_scaled_value.h.bak | 37 --- ...accessor_class_g1_half_byte_codeflag.h.bak | 35 --- ...rib_accessor_class_g1_message_length.h.bak | 34 --- ...ib_accessor_class_g1_section4_length.h.bak | 34 --- .../grib_accessor_class_g1bitmap.h.bak | 35 --- src/accessor/grib_accessor_class_g1date.h.bak | 39 --- ...ccessor_class_g1day_of_the_year_date.h.bak | 33 --- ...ssor_class_g1end_of_interval_monthly.h.bak | 36 --- .../grib_accessor_class_g1fcperiod.h.bak | 31 -- .../grib_accessor_class_g1forecastmonth.h.bak | 40 --- .../grib_accessor_class_g1monthlydate.h.bak | 33 --- ..._g1number_of_coded_values_sh_complex.h.bak | 40 --- ...s_g1number_of_coded_values_sh_simple.h.bak | 37 --- .../grib_accessor_class_g1step_range.h.bak | 48 ---- ...ib_accessor_class_g1verificationdate.h.bak | 35 --- .../grib_accessor_class_g2_aerosol.h.bak | 37 --- .../grib_accessor_class_g2_chemical.h.bak | 37 --- src/accessor/grib_accessor_class_g2_eps.h.bak | 39 --- ...grib_accessor_class_g2_mars_labeling.h.bak | 47 --- .../grib_accessor_class_g2bitmap.h.bak | 34 --- ...grib_accessor_class_g2bitmap_present.h.bak | 34 --- src/accessor/grib_accessor_class_g2date.h.bak | 37 --- .../grib_accessor_class_g2end_step.h.bak | 56 ---- src/accessor/grib_accessor_class_g2grid.h.bak | 42 --- .../grib_accessor_class_g2latlon.h.bak | 38 --- .../grib_accessor_class_g2level.h.bak | 40 --- src/accessor/grib_accessor_class_g2lon.h.bak | 34 --- .../grib_accessor_class_g2step_range.cc | 114 ++++---- .../grib_accessor_class_g2step_range.h | 2 - .../grib_accessor_class_g2step_range.h.bak | 41 --- ...ib_accessor_class_gaussian_grid_name.h.bak | 37 --- .../grib_accessor_class_gds_is_present.h.bak | 37 --- ...ccessor_class_gds_not_present_bitmap.h.bak | 40 --- src/accessor/grib_accessor_class_gen.cc | 13 +- src/accessor/grib_accessor_class_gen.h | 10 + src/accessor/grib_accessor_class_gen.h.bak | 158 ---------- src/accessor/grib_accessor_class_getenv.h.bak | 36 --- .../grib_accessor_class_global_gaussian.h.bak | 44 --- src/accessor/grib_accessor_class_group.h.bak | 41 --- .../grib_accessor_class_gts_header.h.bak | 36 --- .../grib_accessor_class_hash_array.h.bak | 45 --- .../grib_accessor_class_headers_only.h.bak | 33 --- .../grib_accessor_class_ibmfloat.h.bak | 71 ----- .../grib_accessor_class_ieeefloat.h.bak | 66 ----- .../grib_accessor_class_ifs_param.h.bak | 36 --- .../grib_accessor_class_iterator.h.bak | 36 --- .../grib_accessor_class_julian_date.h.bak | 48 ---- .../grib_accessor_class_julian_day.h.bak | 40 --- .../grib_accessor_class_ksec1expver.h.bak | 34 --- src/accessor/grib_accessor_class_label.h.bak | 34 --- .../grib_accessor_class_latitudes.h.bak | 38 --- ...grib_accessor_class_latlon_increment.h.bak | 43 --- .../grib_accessor_class_latlonvalues.h.bak | 34 --- .../grib_accessor_class_library_version.h.bak | 33 --- ...grib_accessor_class_local_definition.h.bak | 43 --- src/accessor/grib_accessor_class_long.cc | 10 + src/accessor/grib_accessor_class_long.h | 10 + src/accessor/grib_accessor_class_long.h.bak | 22 -- .../grib_accessor_class_long_vector.h.bak | 37 --- .../grib_accessor_class_longitudes.h.bak | 38 --- src/accessor/grib_accessor_class_lookup.h.bak | 40 --- .../grib_accessor_class_mars_param.h.bak | 36 --- .../grib_accessor_class_mars_step.h.bak | 40 --- src/accessor/grib_accessor_class_md5.h.bak | 39 --- .../grib_accessor_class_message.h.bak | 36 --- .../grib_accessor_class_message_copy.h.bak | 36 --- .../grib_accessor_class_multdouble.h.bak | 34 --- .../grib_accessor_class_nearest.h.bak | 33 --- .../grib_accessor_class_non_alpha.h.bak | 39 --- ...ccessor_class_number_of_coded_values.h.bak | 37 --- ...grib_accessor_class_number_of_points.h.bak | 36 --- ...ssor_class_number_of_points_gaussian.h.bak | 42 --- ...grib_accessor_class_number_of_values.h.bak | 38 --- ...ss_number_of_values_data_raw_packing.h.bak | 35 --- ...b_accessor_class_octahedral_gaussian.h.bak | 37 --- .../grib_accessor_class_octet_number.h.bak | 35 --- .../grib_accessor_class_offset_file.h.bak | 33 --- .../grib_accessor_class_offset_values.h.bak | 35 --- ...ib_accessor_class_optimal_step_units.h.bak | 44 --- ...grib_accessor_class_pack_bufr_values.h.bak | 42 --- .../grib_accessor_class_packing_type.h.bak | 37 --- src/accessor/grib_accessor_class_pad.h.bak | 34 --- .../grib_accessor_class_padding.h.bak | 37 --- src/accessor/grib_accessor_class_padto.h.bak | 34 --- .../grib_accessor_class_padtoeven.h.bak | 34 --- .../grib_accessor_class_padtomultiple.h.bak | 34 --- .../grib_accessor_class_position.h.bak | 34 --- .../grib_accessor_class_proj_string.h.bak | 35 --- src/accessor/grib_accessor_class_raw.h.bak | 41 --- ...ib_accessor_class_rdbtime_guess_date.h.bak | 38 --- ...accessor_class_reference_value_error.h.bak | 34 --- src/accessor/grib_accessor_class_round.h.bak | 32 --- src/accessor/grib_accessor_class_scale.h.bak | 39 --- .../grib_accessor_class_scale_values.h.bak | 35 --- ...or_class_second_order_bits_per_value.h.bak | 37 --- .../grib_accessor_class_section.h.bak | 34 --- .../grib_accessor_class_section_length.h.bak | 33 --- .../grib_accessor_class_section_padding.h.bak | 33 --- .../grib_accessor_class_section_pointer.h.bak | 38 --- ..._accessor_class_select_step_template.h.bak | 36 --- ...b_accessor_class_sexagesimal2decimal.h.bak | 34 --- src/accessor/grib_accessor_class_signed.h.bak | 42 --- .../grib_accessor_class_signed_bits.h.bak | 40 --- ..._accessor_class_simple_packing_error.h.bak | 37 --- src/accessor/grib_accessor_class_size.h.bak | 33 --- .../grib_accessor_class_smart_table.h.bak | 52 ---- ...ib_accessor_class_smart_table_column.h.bak | 37 --- src/accessor/grib_accessor_class_spd.h.bak | 40 --- ...b_accessor_class_spectral_truncation.h.bak | 36 --- .../grib_accessor_class_sprintf.h.bak | 35 --- .../grib_accessor_class_statistics.h.bak | 38 --- ...b_accessor_class_statistics_spectral.h.bak | 40 --- ...b_accessor_class_step_human_readable.h.bak | 35 --- .../grib_accessor_class_step_in_units.h.bak | 43 --- src/accessor/grib_accessor_class_sum.h.bak | 35 --- .../grib_accessor_class_suppressed.h.bak | 37 --- src/accessor/grib_accessor_class_time.h.bak | 37 --- .../grib_accessor_class_to_double.h.bak | 43 --- .../grib_accessor_class_to_integer.h.bak | 45 --- .../grib_accessor_class_to_string.h.bak | 42 --- .../grib_accessor_class_transient.h.bak | 25 -- ...grib_accessor_class_transient_darray.h.bak | 41 --- src/accessor/grib_accessor_class_trim.h.bak | 37 --- src/accessor/grib_accessor_class_uint16.h.bak | 32 --- src/accessor/grib_accessor_class_uint32.h.bak | 32 --- ..._accessor_class_uint32_little_endian.h.bak | 32 --- src/accessor/grib_accessor_class_uint64.h.bak | 32 --- ..._accessor_class_uint64_little_endian.h.bak | 32 --- src/accessor/grib_accessor_class_uint8.h.bak | 32 --- ...ccessor_class_unexpanded_descriptors.h.bak | 39 --- ...ib_accessor_class_unpack_bufr_values.h.bak | 42 --- .../grib_accessor_class_unsigned.h.bak | 40 --- .../grib_accessor_class_unsigned_bits.h.bak | 40 --- .../grib_accessor_class_validity_date.h.bak | 39 --- .../grib_accessor_class_validity_time.h.bak | 39 --- src/accessor/grib_accessor_class_values.h.bak | 41 --- .../grib_accessor_class_variable.h.bak | 49 ---- src/accessor/grib_accessor_class_vector.h.bak | 34 --- src/accessor/grib_accessor_class_when.h.bak | 34 --- src/accessor/grib_accessors_list.cc | 9 + src/accessor/grib_accessors_list.h | 10 + 212 files changed, 117 insertions(+), 8684 deletions(-) delete mode 100644 src/accessor/grib_accessor_class_abstract_long_vector.h.bak delete mode 100644 src/accessor/grib_accessor_class_abstract_vector.h.bak delete mode 100644 src/accessor/grib_accessor_class_ascii.h.bak delete mode 100644 src/accessor/grib_accessor_class_bit.h.bak delete mode 100644 src/accessor/grib_accessor_class_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_bits.h.bak delete mode 100644 src/accessor/grib_accessor_class_bits_per_value.h.bak delete mode 100644 src/accessor/grib_accessor_class_blob.h.bak delete mode 100644 src/accessor/grib_accessor_class_budgdate.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_data_array.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_data_element.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_elements_table.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_group.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufr_string_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak delete mode 100644 src/accessor/grib_accessor_class_bytes.h.bak delete mode 100644 src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak delete mode 100644 src/accessor/grib_accessor_class_change_scanning_direction.h.bak delete mode 100644 src/accessor/grib_accessor_class_check_internal_version.h.bak delete mode 100644 src/accessor/grib_accessor_class_closest_date.h.bak delete mode 100644 src/accessor/grib_accessor_class_codeflag.h.bak delete mode 100644 src/accessor/grib_accessor_class_codetable.h.bak delete mode 100644 src/accessor/grib_accessor_class_codetable_title.h.bak delete mode 100644 src/accessor/grib_accessor_class_codetable_units.h.bak delete mode 100644 src/accessor/grib_accessor_class_concept.h.bak delete mode 100644 src/accessor/grib_accessor_class_constant.h.bak delete mode 100644 src/accessor/grib_accessor_class_count_file.h.bak delete mode 100644 src/accessor/grib_accessor_class_count_missing.h.bak delete mode 100644 src/accessor/grib_accessor_class_count_total.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_apply_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_ccsds_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_complex_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_dummy_field.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1complex_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g1simple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g22order_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2complex_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_png_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_raw_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_run_length_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_sh_packed.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_sh_unpacked.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_shsimple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_data_simple_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_decimal_precision.h.bak delete mode 100644 src/accessor/grib_accessor_class_dictionary.h.bak delete mode 100644 src/accessor/grib_accessor_class_dirty.h.bak delete mode 100644 src/accessor/grib_accessor_class_divdouble.h.bak delete mode 100644 src/accessor/grib_accessor_class_double.h.bak delete mode 100644 src/accessor/grib_accessor_class_element.h.bak delete mode 100644 src/accessor/grib_accessor_class_evaluate.h.bak delete mode 100644 src/accessor/grib_accessor_class_expanded_descriptors.h.bak delete mode 100644 src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1_message_length.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1_section4_length.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1date.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1fcperiod.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1forecastmonth.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1monthlydate.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1step_range.h.bak delete mode 100644 src/accessor/grib_accessor_class_g1verificationdate.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2_aerosol.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2_chemical.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2_eps.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2_mars_labeling.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2bitmap_present.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2date.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2end_step.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2grid.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2latlon.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2level.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2lon.h.bak delete mode 100644 src/accessor/grib_accessor_class_g2step_range.h.bak delete mode 100644 src/accessor/grib_accessor_class_gaussian_grid_name.h.bak delete mode 100644 src/accessor/grib_accessor_class_gds_is_present.h.bak delete mode 100644 src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak delete mode 100644 src/accessor/grib_accessor_class_gen.h.bak delete mode 100644 src/accessor/grib_accessor_class_getenv.h.bak delete mode 100644 src/accessor/grib_accessor_class_global_gaussian.h.bak delete mode 100644 src/accessor/grib_accessor_class_group.h.bak delete mode 100644 src/accessor/grib_accessor_class_gts_header.h.bak delete mode 100644 src/accessor/grib_accessor_class_hash_array.h.bak delete mode 100644 src/accessor/grib_accessor_class_headers_only.h.bak delete mode 100644 src/accessor/grib_accessor_class_ibmfloat.h.bak delete mode 100644 src/accessor/grib_accessor_class_ieeefloat.h.bak delete mode 100644 src/accessor/grib_accessor_class_ifs_param.h.bak delete mode 100644 src/accessor/grib_accessor_class_iterator.h.bak delete mode 100644 src/accessor/grib_accessor_class_julian_date.h.bak delete mode 100644 src/accessor/grib_accessor_class_julian_day.h.bak delete mode 100644 src/accessor/grib_accessor_class_ksec1expver.h.bak delete mode 100644 src/accessor/grib_accessor_class_label.h.bak delete mode 100644 src/accessor/grib_accessor_class_latitudes.h.bak delete mode 100644 src/accessor/grib_accessor_class_latlon_increment.h.bak delete mode 100644 src/accessor/grib_accessor_class_latlonvalues.h.bak delete mode 100644 src/accessor/grib_accessor_class_library_version.h.bak delete mode 100644 src/accessor/grib_accessor_class_local_definition.h.bak delete mode 100644 src/accessor/grib_accessor_class_long.h.bak delete mode 100644 src/accessor/grib_accessor_class_long_vector.h.bak delete mode 100644 src/accessor/grib_accessor_class_longitudes.h.bak delete mode 100644 src/accessor/grib_accessor_class_lookup.h.bak delete mode 100644 src/accessor/grib_accessor_class_mars_param.h.bak delete mode 100644 src/accessor/grib_accessor_class_mars_step.h.bak delete mode 100644 src/accessor/grib_accessor_class_md5.h.bak delete mode 100644 src/accessor/grib_accessor_class_message.h.bak delete mode 100644 src/accessor/grib_accessor_class_message_copy.h.bak delete mode 100644 src/accessor/grib_accessor_class_multdouble.h.bak delete mode 100644 src/accessor/grib_accessor_class_nearest.h.bak delete mode 100644 src/accessor/grib_accessor_class_non_alpha.h.bak delete mode 100644 src/accessor/grib_accessor_class_number_of_coded_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_number_of_points.h.bak delete mode 100644 src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak delete mode 100644 src/accessor/grib_accessor_class_number_of_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak delete mode 100644 src/accessor/grib_accessor_class_octahedral_gaussian.h.bak delete mode 100644 src/accessor/grib_accessor_class_octet_number.h.bak delete mode 100644 src/accessor/grib_accessor_class_offset_file.h.bak delete mode 100644 src/accessor/grib_accessor_class_offset_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_optimal_step_units.h.bak delete mode 100644 src/accessor/grib_accessor_class_pack_bufr_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_packing_type.h.bak delete mode 100644 src/accessor/grib_accessor_class_pad.h.bak delete mode 100644 src/accessor/grib_accessor_class_padding.h.bak delete mode 100644 src/accessor/grib_accessor_class_padto.h.bak delete mode 100644 src/accessor/grib_accessor_class_padtoeven.h.bak delete mode 100644 src/accessor/grib_accessor_class_padtomultiple.h.bak delete mode 100644 src/accessor/grib_accessor_class_position.h.bak delete mode 100644 src/accessor/grib_accessor_class_proj_string.h.bak delete mode 100644 src/accessor/grib_accessor_class_raw.h.bak delete mode 100644 src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak delete mode 100644 src/accessor/grib_accessor_class_reference_value_error.h.bak delete mode 100644 src/accessor/grib_accessor_class_round.h.bak delete mode 100644 src/accessor/grib_accessor_class_scale.h.bak delete mode 100644 src/accessor/grib_accessor_class_scale_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak delete mode 100644 src/accessor/grib_accessor_class_section.h.bak delete mode 100644 src/accessor/grib_accessor_class_section_length.h.bak delete mode 100644 src/accessor/grib_accessor_class_section_padding.h.bak delete mode 100644 src/accessor/grib_accessor_class_section_pointer.h.bak delete mode 100644 src/accessor/grib_accessor_class_select_step_template.h.bak delete mode 100644 src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak delete mode 100644 src/accessor/grib_accessor_class_signed.h.bak delete mode 100644 src/accessor/grib_accessor_class_signed_bits.h.bak delete mode 100644 src/accessor/grib_accessor_class_simple_packing_error.h.bak delete mode 100644 src/accessor/grib_accessor_class_size.h.bak delete mode 100644 src/accessor/grib_accessor_class_smart_table.h.bak delete mode 100644 src/accessor/grib_accessor_class_smart_table_column.h.bak delete mode 100644 src/accessor/grib_accessor_class_spd.h.bak delete mode 100644 src/accessor/grib_accessor_class_spectral_truncation.h.bak delete mode 100644 src/accessor/grib_accessor_class_sprintf.h.bak delete mode 100644 src/accessor/grib_accessor_class_statistics.h.bak delete mode 100644 src/accessor/grib_accessor_class_statistics_spectral.h.bak delete mode 100644 src/accessor/grib_accessor_class_step_human_readable.h.bak delete mode 100644 src/accessor/grib_accessor_class_step_in_units.h.bak delete mode 100644 src/accessor/grib_accessor_class_sum.h.bak delete mode 100644 src/accessor/grib_accessor_class_suppressed.h.bak delete mode 100644 src/accessor/grib_accessor_class_time.h.bak delete mode 100644 src/accessor/grib_accessor_class_to_double.h.bak delete mode 100644 src/accessor/grib_accessor_class_to_integer.h.bak delete mode 100644 src/accessor/grib_accessor_class_to_string.h.bak delete mode 100644 src/accessor/grib_accessor_class_transient.h.bak delete mode 100644 src/accessor/grib_accessor_class_transient_darray.h.bak delete mode 100644 src/accessor/grib_accessor_class_trim.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint16.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint32.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint32_little_endian.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint64.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint64_little_endian.h.bak delete mode 100644 src/accessor/grib_accessor_class_uint8.h.bak delete mode 100644 src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak delete mode 100644 src/accessor/grib_accessor_class_unpack_bufr_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_unsigned.h.bak delete mode 100644 src/accessor/grib_accessor_class_unsigned_bits.h.bak delete mode 100644 src/accessor/grib_accessor_class_validity_date.h.bak delete mode 100644 src/accessor/grib_accessor_class_validity_time.h.bak delete mode 100644 src/accessor/grib_accessor_class_values.h.bak delete mode 100644 src/accessor/grib_accessor_class_variable.h.bak delete mode 100644 src/accessor/grib_accessor_class_vector.h.bak delete mode 100644 src/accessor/grib_accessor_class_when.h.bak diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h.bak b/src/accessor/grib_accessor_class_abstract_long_vector.h.bak deleted file mode 100644 index 2961979d8..000000000 --- a/src/accessor/grib_accessor_class_abstract_long_vector.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_abstract_long_vector_h -#define eccodes_accessor_abstract_long_vector_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t -{ -public: - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; -}; - -class grib_accessor_class_abstract_long_vector_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_abstract_long_vector_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; } -}; -#endif /* eccodes_accessor_abstract_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_abstract_vector.h.bak b/src/accessor/grib_accessor_class_abstract_vector.h.bak deleted file mode 100644 index df7e3fdbf..000000000 --- a/src/accessor/grib_accessor_class_abstract_vector.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_abstract_vector_h -#define eccodes_accessor_abstract_vector_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_abstract_vector_t : public grib_accessor_double_t -{ -public: - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; -}; - -class grib_accessor_class_abstract_vector_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_abstract_vector_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; } -}; -#endif /* eccodes_accessor_abstract_vector_h */ diff --git a/src/accessor/grib_accessor_class_ascii.h.bak b/src/accessor/grib_accessor_class_ascii.h.bak deleted file mode 100644 index cb8e68bd7..000000000 --- a/src/accessor/grib_accessor_class_ascii.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_ascii_h -#define eccodes_accessor_ascii_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_ascii_t : public grib_accessor_gen_t -{ -public: - /* Members defined in ascii */ -}; - -class grib_accessor_class_ascii_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_ascii_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_ascii_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_ascii_h */ diff --git a/src/accessor/grib_accessor_class_bit.h.bak b/src/accessor/grib_accessor_class_bit.h.bak deleted file mode 100644 index 3a9eee2d7..000000000 --- a/src/accessor/grib_accessor_class_bit.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bit_h -#define eccodes_accessor_bit_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_bit_t : public grib_accessor_long_t -{ -public: - /* Members defined in bit */ - const char* owner; - int bit_index; -}; - -class grib_accessor_class_bit_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_bit_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bit_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bit_h */ diff --git a/src/accessor/grib_accessor_class_bitmap.h.bak b/src/accessor/grib_accessor_class_bitmap.h.bak deleted file mode 100644 index d9b3ab9df..000000000 --- a/src/accessor/grib_accessor_class_bitmap.h.bak +++ /dev/null @@ -1,45 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bitmap_h -#define eccodes_accessor_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_bytes.h" - -class grib_accessor_bitmap_t : public grib_accessor_bytes_t -{ -public: - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; -}; - -class grib_accessor_class_bitmap_t : public grib_accessor_class_bytes_t -{ -public: - grib_accessor_class_bitmap_t(const char* name) : grib_accessor_class_bytes_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bitmap_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; -#endif /* eccodes_accessor_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_bits.h.bak b/src/accessor/grib_accessor_class_bits.h.bak deleted file mode 100644 index b5dd2977b..000000000 --- a/src/accessor/grib_accessor_class_bits.h.bak +++ /dev/null @@ -1,45 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bits_h -#define eccodes_accessor_bits_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bits_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bits */ - const char* argument; - long start; - long len; - double referenceValue; - double referenceValuePresent; - double scale; -}; - -class grib_accessor_class_bits_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bits_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - long byte_count(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bits_h */ diff --git a/src/accessor/grib_accessor_class_bits_per_value.h.bak b/src/accessor/grib_accessor_class_bits_per_value.h.bak deleted file mode 100644 index 59514fc05..000000000 --- a/src/accessor/grib_accessor_class_bits_per_value.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bits_per_value_h -#define eccodes_accessor_bits_per_value_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_bits_per_value_t : public grib_accessor_long_t -{ -public: - /* Members defined in bits_per_value */ - const char* values; - const char* bits_per_value; -}; - -class grib_accessor_class_bits_per_value_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_per_value_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_blob.h.bak b/src/accessor/grib_accessor_class_blob.h.bak deleted file mode 100644 index a2da98a03..000000000 --- a/src/accessor/grib_accessor_class_blob.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_blob_h -#define eccodes_accessor_blob_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_blob_t : public grib_accessor_gen_t -{ -public: - /* Members defined in blob */ -}; - -class grib_accessor_class_blob_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_blob_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_blob_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_blob_h */ diff --git a/src/accessor/grib_accessor_class_budgdate.h.bak b/src/accessor/grib_accessor_class_budgdate.h.bak deleted file mode 100644 index c3fc849c7..000000000 --- a/src/accessor/grib_accessor_class_budgdate.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_budgdate_h -#define eccodes_accessor_budgdate_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_budgdate_t : public grib_accessor_long_t -{ -public: - /* Members defined in budgdate */ - const char* year; - const char* month; - const char* day; -}; - -class grib_accessor_class_budgdate_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_budgdate_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_budgdate_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_budgdate_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h.bak b/src/accessor/grib_accessor_class_bufr_data_array.h.bak deleted file mode 100644 index c6089fa63..000000000 --- a/src/accessor/grib_accessor_class_bufr_data_array.h.bak +++ /dev/null @@ -1,92 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_data_array_h -#define eccodes_accessor_bufr_data_array_h - -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_data_array_t : public grib_accessor_gen_t -{ -public: - const char* bufrDataEncodedName; - const char* numberOfSubsetsName; - const char* expandedDescriptorsName; - const char* flagsName; - const char* unitsName; - const char* elementsDescriptorsIndexName; - const char* compressedDataName; - bufr_descriptors_array* expanded; - grib_accessor* expandedAccessor; - int* canBeMissing; - long numberOfSubsets; - long compressedData; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - int do_decode; - int bitmapStartElementsDescriptorsIndex; - int bitmapCurrentElementsDescriptorsIndex; - int bitmapSize; - int bitmapStart; - int bitmapCurrent; - grib_accessors_list* dataAccessors; - int unpackMode; - int bitsToEndData; - grib_section* dataKeys; - double* inputBitmap; - int nInputBitmap; - int iInputBitmap; - long* inputReplications; - int nInputReplications; - int iInputReplications; - long* inputExtendedReplications; - int nInputExtendedReplications; - int iInputExtendedReplications; - long* inputShortReplications; - int nInputShortReplications; - int iInputShortReplications; - grib_iarray* iss_list; - grib_trie_with_rank* dataAccessorsTrie; - grib_sarray* tempStrings; - grib_vdarray* tempDoubleValues; - int change_ref_value_operand; - size_t refValListSize; - long* refValList; - long refValIndex; - bufr_tableb_override* tableb_override; - int set_to_missing_if_out_of_range; -}; - -class grib_accessor_class_bufr_data_array_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_data_array_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_array_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; - -grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); -grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); -grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); -void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); - -#endif /* eccodes_accessor_bufr_data_array_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h.bak b/src/accessor/grib_accessor_class_bufr_data_element.h.bak deleted file mode 100644 index 6cba5b91c..000000000 --- a/src/accessor/grib_accessor_class_bufr_data_element.h.bak +++ /dev/null @@ -1,57 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_data_element_h -#define eccodes_accessor_bufr_data_element_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_data_element */ - long index; - int type; - long compressedData; - long subsetNumber; - long numberOfSubsets; - bufr_descriptors_array* descriptors; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - char* cname; -}; - -class grib_accessor_class_bufr_data_element_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_data_element_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_element_t{}; } - int get_native_type(grib_accessor*) override; - int pack_missing(grib_accessor*) override; - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int pack_string_array(grib_accessor*, const char**, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; -}; -#endif /* eccodes_accessor_bufr_data_element_h */ diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h.bak b/src/accessor/grib_accessor_class_bufr_elements_table.h.bak deleted file mode 100644 index 8ddd8a824..000000000 --- a/src/accessor/grib_accessor_class_bufr_elements_table.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_elements_table_h -#define eccodes_accessor_bufr_elements_table_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_elements_table */ - const char* dictionary; - const char* masterDir; - const char* localDir; -}; - -class grib_accessor_class_bufr_elements_table_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_elements_table_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_elements_table_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_elements_table_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak deleted file mode 100644 index d079f958e..000000000 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_extract_area_subsets_h -#define eccodes_accessor_bufr_extract_area_subsets_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_extract_area_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* extractAreaWestLongitude; - const char* extractAreaEastLongitude; - const char* extractAreaNorthLatitude; - const char* extractAreaSouthLatitude; - const char* extractAreaLongitudeRank; - const char* extractAreaLatitudeRank; - const char* extractedAreaNumberOfSubsets; -}; - -class grib_accessor_class_bufr_extract_area_subsets_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_extract_area_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_area_subsets_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_extract_area_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak deleted file mode 100644 index 7acfd35b3..000000000 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_extract_datetime_subsets_h -#define eccodes_accessor_bufr_extract_datetime_subsets_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_extract_datetime_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; -}; - -class grib_accessor_class_bufr_extract_datetime_subsets_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_extract_datetime_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_datetime_subsets_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_extract_datetime_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak b/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak deleted file mode 100644 index 80392338d..000000000 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_extract_subsets_h -#define eccodes_accessor_bufr_extract_subsets_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_extract_subsets */ - const char* numericValues; - const char* pack; - grib_accessor* numericValuesAccessor; - grib_accessor* packAccessor; -}; - -class grib_accessor_class_bufr_extract_subsets_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_extract_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_subsets_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_extract_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_group.h.bak b/src/accessor/grib_accessor_class_bufr_group.h.bak deleted file mode 100644 index 3bd71690f..000000000 --- a/src/accessor/grib_accessor_class_bufr_group.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_group_h -#define eccodes_accessor_bufr_group_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_variable.h" - -class grib_accessor_bufr_group_t : public grib_accessor_variable_t -{ -public: - /* Members defined in bufr_group */ -}; - -class grib_accessor_class_bufr_group_t : public grib_accessor_class_variable_t -{ -public: - grib_accessor_class_bufr_group_t(const char* name) : grib_accessor_class_variable_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; } - void dump(grib_accessor*, grib_dumper*) override; - grib_accessor* next(grib_accessor* a, int explore) override; -}; -#endif /* eccodes_accessor_bufr_group_h */ diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak b/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak deleted file mode 100644 index eb786f966..000000000 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_simple_thinning_h -#define eccodes_accessor_bufr_simple_thinning_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bufr_simple_thinning */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* simpleThinningStart; - const char* simpleThinningMissingRadius; - const char* simpleThinningSkip; -}; - -class grib_accessor_class_bufr_simple_thinning_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bufr_simple_thinning_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_simple_thinning_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_simple_thinning_h */ diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h.bak b/src/accessor/grib_accessor_class_bufr_string_values.h.bak deleted file mode 100644 index 9038a8d73..000000000 --- a/src/accessor/grib_accessor_class_bufr_string_values.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufr_string_values_h -#define eccodes_accessor_bufr_string_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in bufr_string_values */ - const char* dataAccessorName; - grib_accessor* dataAccessor; -}; - -class grib_accessor_class_bufr_string_values_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_bufr_string_values_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_string_values_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufr_string_values_h */ diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak deleted file mode 100644 index 588f9d08b..000000000 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bufrdc_expanded_descriptors_h -#define eccodes_accessor_bufrdc_expanded_descriptors_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t -{ -public: - /* Members defined in bufrdc_expanded_descriptors */ - const char* expandedDescriptors; - grib_accessor* expandedDescriptorsAccessor; -}; - -class grib_accessor_class_bufrdc_expanded_descriptors_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_bufrdc_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bufrdc_expanded_descriptors_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_bufrdc_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_bytes.h.bak b/src/accessor/grib_accessor_class_bytes.h.bak deleted file mode 100644 index 8204ceba7..000000000 --- a/src/accessor/grib_accessor_class_bytes.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_bytes_h -#define eccodes_accessor_bytes_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_bytes_t : public grib_accessor_gen_t -{ -public: - /* Members defined in bytes */ -}; - -class grib_accessor_class_bytes_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_bytes_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_bytes_t{}; } - int get_native_type(grib_accessor*) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_bytes_h */ diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak deleted file mode 100644 index c893e242f..000000000 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_change_alternative_row_scanning_h -#define eccodes_accessor_change_alternative_row_scanning_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t -{ -public: - /* Members defined in change_alternative_row_scanning */ - const char* values; - const char* Ni; - const char* Nj; - const char* alternativeRowScanning; -}; - -class grib_accessor_class_change_alternative_row_scanning_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_change_alternative_row_scanning_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_change_alternative_row_scanning_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_change_alternative_row_scanning_h */ diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h.bak b/src/accessor/grib_accessor_class_change_scanning_direction.h.bak deleted file mode 100644 index 08f2ceb55..000000000 --- a/src/accessor/grib_accessor_class_change_scanning_direction.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_change_scanning_direction_h -#define eccodes_accessor_change_scanning_direction_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t -{ -public: - /* Members defined in change_scanning_direction */ - const char* values; - const char* Ni; - const char* Nj; - const char* i_scans_negatively; - const char* j_scans_positively; - const char* first; - const char* last; - const char* axis; -}; - -class grib_accessor_class_change_scanning_direction_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_change_scanning_direction_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_change_scanning_direction_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_change_scanning_direction_h */ diff --git a/src/accessor/grib_accessor_class_check_internal_version.h.bak b/src/accessor/grib_accessor_class_check_internal_version.h.bak deleted file mode 100644 index 871f5a56e..000000000 --- a/src/accessor/grib_accessor_class_check_internal_version.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_check_internal_version_h -#define eccodes_accessor_check_internal_version_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in check_internal_version */ -}; - -class grib_accessor_class_check_internal_version_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_check_internal_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_check_internal_version_t{}; } - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_check_internal_version_h */ diff --git a/src/accessor/grib_accessor_class_closest_date.h.bak b/src/accessor/grib_accessor_class_closest_date.h.bak deleted file mode 100644 index b4fbace12..000000000 --- a/src/accessor/grib_accessor_class_closest_date.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_closest_date_h -#define eccodes_accessor_closest_date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_closest_date_t : public grib_accessor_double_t -{ -public: - /* Members defined in closest_date */ - const char *dateLocal; - const char *timeLocal; - const char *numForecasts; - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; -}; - -class grib_accessor_class_closest_date_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_closest_date_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_closest_date_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_closest_date_h */ diff --git a/src/accessor/grib_accessor_class_codeflag.h.bak b/src/accessor/grib_accessor_class_codeflag.h.bak deleted file mode 100644 index 734369b74..000000000 --- a/src/accessor/grib_accessor_class_codeflag.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_codeflag_h -#define eccodes_accessor_codeflag_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_codeflag_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in codeflag */ - const char* tablename; -}; - -class grib_accessor_class_codeflag_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_codeflag_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_codeflag_t{}; } - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_codetable.h.bak b/src/accessor/grib_accessor_class_codetable.h.bak deleted file mode 100644 index c77c6f72d..000000000 --- a/src/accessor/grib_accessor_class_codetable.h.bak +++ /dev/null @@ -1,47 +0,0 @@ -/* - * (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. - */ - -/***************************************** - * Enrico Fucile - ****************************************/ - -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" -#include - - -class grib_accessor_codetable_t : public grib_accessor_unsigned_t -{ -public: - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; - int table_loaded; -}; - -class grib_accessor_class_codetable_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_t{}; } - grib_accessor_class_codetable_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - int get_native_type(grib_accessor*) override; - int pack_missing(grib_accessor*) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int pack_expression(grib_accessor*, grib_expression*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; diff --git a/src/accessor/grib_accessor_class_codetable_title.h.bak b/src/accessor/grib_accessor_class_codetable_title.h.bak deleted file mode 100644 index e115a9c28..000000000 --- a/src/accessor/grib_accessor_class_codetable_title.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_codetable_title_h -#define eccodes_accessor_codetable_title_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_codetable_title_t : public grib_accessor_gen_t -{ -public: - /* Members defined in codetable_title */ - const char* codetable; -}; - -class grib_accessor_class_codetable_title_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_codetable_title_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_title_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_codetable_title_h */ diff --git a/src/accessor/grib_accessor_class_codetable_units.h.bak b/src/accessor/grib_accessor_class_codetable_units.h.bak deleted file mode 100644 index b5cfb75c8..000000000 --- a/src/accessor/grib_accessor_class_codetable_units.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_codetable_units_h -#define eccodes_accessor_codetable_units_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_codetable_units_t : public grib_accessor_gen_t -{ -public: - /* Members defined in codetable_units */ - const char* codetable; -}; - -class grib_accessor_class_codetable_units_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_codetable_units_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_units_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_codetable_units_h */ diff --git a/src/accessor/grib_accessor_class_concept.h.bak b/src/accessor/grib_accessor_class_concept.h.bak deleted file mode 100644 index 99405ed48..000000000 --- a/src/accessor/grib_accessor_class_concept.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_concept_h -#define eccodes_accessor_concept_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_concept_t : public grib_accessor_gen_t -{ -public: - /* Members defined in concept */ -}; - -class grib_accessor_class_concept_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_concept_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_concept_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_concept_h */ diff --git a/src/accessor/grib_accessor_class_constant.h.bak b/src/accessor/grib_accessor_class_constant.h.bak deleted file mode 100644 index 0c4944c68..000000000 --- a/src/accessor/grib_accessor_class_constant.h.bak +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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. - */ - - -/************************************* - * Enrico Fucile - **************************************/ - -#include "../grib_api_internal.h" -#include "grib_accessor_class_variable.h" - -class grib_accessor_constant_t : public grib_accessor_variable_t {}; - -class grib_accessor_class_constant_t : public grib_accessor_class_variable_t -{ -public: - grib_accessor_class_constant_t(const char* name) : grib_accessor_class_variable_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_constant_t{}; } - void init(grib_accessor*, const long, grib_arguments*) override; -}; diff --git a/src/accessor/grib_accessor_class_count_file.h.bak b/src/accessor/grib_accessor_class_count_file.h.bak deleted file mode 100644 index 4b9a0b4f0..000000000 --- a/src/accessor/grib_accessor_class_count_file.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_count_file_h -#define eccodes_accessor_count_file_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_count_file_t : public grib_accessor_long_t -{ -public: - /* Members defined in count_file */ -}; - -class grib_accessor_class_count_file_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_count_file_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_count_file_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_count_file_h */ diff --git a/src/accessor/grib_accessor_class_count_missing.h.bak b/src/accessor/grib_accessor_class_count_missing.h.bak deleted file mode 100644 index fbf583109..000000000 --- a/src/accessor/grib_accessor_class_count_missing.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_count_missing_h -#define eccodes_accessor_count_missing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_count_missing_t : public grib_accessor_long_t -{ -public: - /* Members defined in count_missing */ - const char* bitmap; - const char* unusedBitsInBitmap; - const char* numberOfDataPoints; - const char* missingValueManagementUsed; -}; - -class grib_accessor_class_count_missing_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_count_missing_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_count_missing_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_count_missing_h */ diff --git a/src/accessor/grib_accessor_class_count_total.h.bak b/src/accessor/grib_accessor_class_count_total.h.bak deleted file mode 100644 index ab044e8a9..000000000 --- a/src/accessor/grib_accessor_class_count_total.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_count_total_h -#define eccodes_accessor_count_total_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_count_total_t : public grib_accessor_long_t -{ -public: - /* Members defined in count_total */ -}; - -class grib_accessor_class_count_total_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_count_total_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_count_total_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_count_total_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak b/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak deleted file mode 100644 index b2516ec4e..000000000 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.h.bak +++ /dev/null @@ -1,132 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_apply_bitmap_h -#define eccodes_accessor_data_apply_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_data_apply_bitmap_t : public grib_accessor_gen_t -{ -public: - /* Members defined in data_apply_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* number_of_data_points; - const char* number_of_values; - const char* binary_scale_factor; -}; - -class grib_accessor_class_data_apply_bitmap_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_data_apply_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_bitmap_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); -}; - - -template -int grib_accessor_class_data_apply_bitmap_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - - size_t i = 0; - size_t j = 0; - size_t n_vals = 0; - long nn = 0; - int err = 0; - size_t coded_n_vals = 0; - T* coded_vals = NULL; - double missing_value = 0; - - err = a->value_count(&nn); n_vals = nn; - if (err) - return err; - - if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) - return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if (coded_n_vals == 0) { - for (i = 0; i < n_vals; i++) - val[i] = missing_value; - - *len = n_vals; - return GRIB_SUCCESS; - } - - if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) - return err; - - coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); - if (coded_vals == NULL) - return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { - grib_context_free(a->context, coded_vals); - return err; - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", - __func__, - a->name, n_vals); - - for (i = 0; i < n_vals; i++) { - if (val[i] == 0) { - val[i] = missing_value; - } - else { - val[i] = coded_vals[j++]; - if (j > coded_n_vals) { - grib_context_free(a->context, coded_vals); - grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_class_data_apply_bitmap [%s]:" - " %s : number of coded values does not match bitmap %ld %ld", - a->name, __func__, coded_n_vals, n_vals); - - return GRIB_ARRAY_TOO_SMALL; - } - } - } - - *len = n_vals; - - grib_context_free(a->context, coded_vals); - return err; -} - -#endif /* eccodes_accessor_data_apply_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak deleted file mode 100644 index 9b101e7ed..000000000 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h.bak +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_gen.h" - -class grib_accessor_data_apply_boustrophedonic_t : public grib_accessor_gen_t -{ -public: - /* Members defined in data_apply_boustrophedonic */ - const char* values; - const char* numberOfRows; - const char* numberOfColumns; - const char* numberOfPoints; - const char* pl; -}; - -class grib_accessor_class_data_apply_boustrophedonic_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_data_apply_boustrophedonic_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak deleted file mode 100644 index e92299eab..000000000 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h.bak +++ /dev/null @@ -1,45 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h -#define eccodes_accessor_data_apply_boustrophedonic_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t -{ -public: - /* Members defined in data_apply_boustrophedonic_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* binary_scale_factor; - const char* numberOfRows; - const char* numberOfColumns; - const char* numberOfPoints; -}; - -class grib_accessor_class_data_apply_boustrophedonic_bitmap_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_data_apply_boustrophedonic_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_bitmap_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; -#endif /* eccodes_accessor_data_apply_boustrophedonic_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak b/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak deleted file mode 100644 index 19889e937..000000000 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.h.bak +++ /dev/null @@ -1,203 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_ccsds_packing_h -#define eccodes_accessor_data_ccsds_packing_h - -#include "grib_accessor_class_values.h" -#include "grib_scaling.h" - -#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) -#include -#endif - -#ifndef LIBAEC_DLL_EXPORTED - #error Version of libaec appears to be too old. Please upgrade. -#endif - -class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t -{ -public: - /* Members defined in data_ccsds_packing */ - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - const char* bits_per_value; - const char* number_of_data_points; - const char* ccsds_flags; - const char* ccsds_block_size; - const char* ccsds_rsi; -}; - - - -// TODO(maee): if libaec is not available, this class should not be defined -class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_ccsds_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_ccsds_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - -private: - template int unpack(grib_accessor*, T*, size_t* ); - void print_aec_stream_info(struct aec_stream*, const char*); - void modify_aec_flags(long*); - const char* aec_get_error_message(int); - bool is_big_endian(); -}; - - -template -int grib_accessor_class_data_ccsds_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - int err = GRIB_SUCCESS, i = 0; - size_t buflen = 0; - struct aec_stream strm; - double bscale = 0; - double dscale = 0; - unsigned char* buf = NULL; - size_t n_vals = 0; - size_t size = 0; - unsigned char* decoded = NULL; - // unsigned char* p = NULL; - long nn = 0; - - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - double reference_value = 0; - long bits_per_value = 0; - - long ccsds_flags; - long ccsds_block_size; - long ccsds_rsi; - size_t nbytes; - - self->dirty = 0; - - if ((err = a->value_count(&nn)) != GRIB_SUCCESS) - return err; - n_vals = nn; - - if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - // ECC-477: Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) - return err; - - modify_aec_flags(&ccsds_flags); - - // TODO(masn): This should be called upstream - if (*len < n_vals) - return GRIB_ARRAY_TOO_SMALL; - - // Special case - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - bscale = codes_power(binary_scale_factor, 2); - dscale = codes_power(-decimal_scale_factor, 10); - - buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; - buf += a->byte_offset(); - strm.flags = ccsds_flags; - strm.bits_per_sample = bits_per_value; - strm.block_size = ccsds_block_size; - strm.rsi = ccsds_rsi; - - strm.next_in = buf; - strm.avail_in = buflen; - - nbytes = (bits_per_value + 7) / 8; - if (nbytes == 3) - nbytes = 4; - - size = n_vals * nbytes; - decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); - if (!decoded) { - err = GRIB_OUT_OF_MEMORY; - goto cleanup; - } - strm.next_out = decoded; - strm.avail_out = size; - - if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); - - if ((err = aec_buffer_decode(&strm)) != AEC_OK) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); - err = GRIB_DECODING_ERROR; - goto cleanup; - } - - // ECC-1427: Performance improvement (replaced by ECC-1602) - //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); - - // ECC-1602: Performance improvement - switch (nbytes) { - case 1: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 2: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 4: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - default: - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", - cclass_name, __func__, a->name, bits_per_value); - err = GRIB_INVALID_BPV; - goto cleanup; - } - - *len = n_vals; - -cleanup: - grib_context_buffer_free(a->context, decoded); - return err; -} - -#endif /* eccodes_accessor_data_ccsds_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h.bak b/src/accessor/grib_accessor_class_data_complex_packing.h.bak deleted file mode 100644 index d588eef38..000000000 --- a/src/accessor/grib_accessor_class_data_complex_packing.h.bak +++ /dev/null @@ -1,272 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_complex_packing_h -#define eccodes_accessor_data_complex_packing_h - -#include "grib_accessor_class_data_simple_packing.h" -#include "grib_scaling.h" -#include "grib_ieeefloat.h" - -typedef unsigned long (*encode_float_proc)(double); -typedef double (*decode_float_proc)(unsigned long); - -class grib_accessor_data_complex_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -}; - -class grib_accessor_class_data_complex_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_complex_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_complex_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); -}; - -template -int grib_accessor_class_data_complex_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - size_t i = 0; - int ret = GRIB_SUCCESS; - long hcount = 0; - long lcount = 0; - long hpos = 0; - long lup = 0; - long mmax = 0; - long n_vals = 0; - T* scals = NULL; - T* pscals = NULL, *pval = NULL; - - T s = 0; - T d = 0; - T laplacianOperator = 0; - unsigned char* buf = NULL; - unsigned char* hres = NULL; - unsigned char* lres = NULL; - unsigned long packed_offset; - long lpos = 0; - - long maxv = 0; - long GRIBEX_sh_bug_present = 0; - long ieee_floats = 0; - - long offsetdata = 0; - long bits_per_value = 0; - T reference_value = 0; - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - - long sub_j = 0; - long sub_k = 0; - long sub_m = 0; - long pen_j = 0; - long pen_k = 0; - long pen_m = 0; - - T operat = 0; - int bytes; - int err = 0; - double tmp; - - decode_float_proc decode_float = NULL; - - err = a->value_count(&n_vals); if (err) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) - return ret; - reference_value = tmp; - if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) - return ret; - - /* ECC-774: don't use grib_get_long_internal */ - if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) - return ret; - laplacianOperator = tmp; - - if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) - return ret; - - self->dirty = 0; - - switch (ieee_floats) { - case 0: - decode_float = grib_long_to_ibm; - bytes = 4; - break; - case 1: - decode_float = grib_long_to_ieee; - bytes = 4; - break; - case 2: - decode_float = grib_long_to_ieee64; - bytes = 8; - break; - default: - return GRIB_NOT_IMPLEMENTED; - } - - if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); - return GRIB_DECODING_ERROR; - } - - buf = (unsigned char*)gh->buffer->data; - - maxv = pen_j + 1; - - buf += a->byte_offset(); hres = buf; - lres = buf; - - if (pen_j == sub_j) { - n_vals = (pen_j + 1) * (pen_j + 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); - if (d) { - for (i = 0; i < n_vals; i++) - val[i] *= d; - } - return 0; - } - - packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); - lpos = 8 * (packed_offset - offsetdata); - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); - if (!scals) return GRIB_OUT_OF_MEMORY; - - scals[0] = 0; - for (i = 1; i < maxv; i++) { - operat = pow(i * (i + 1), laplacianOperator); - if (operat != 0) - scals[i] = (1.0 / operat); - else { - grib_context_log(a->context, GRIB_LOG_WARNING, - "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); - scals[i] = 0; - } - } - - /* - printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); - printf("packed offset=%ld\n",packed_offset); - for(i=0;i 0) { - lup = mmax; - if (sub_k >= 0) { - for (hcount = 0; hcount < sub_k + 1; hcount++) { - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - - if (GRIBEX_sh_bug_present && hcount == sub_k) { - /* bug in ecmwf data, last row (K+1)is scaled but should not */ - val[i - 2] *= scals[lup]; - val[i - 1] *= scals[lup]; - } - lup++; - } - sub_k--; - } - - pscals = scals + lup; - pval = val + i; -#if FAST_BIG_ENDIAN - grib_decode_double_array_complex(lres, - &lpos, bits_per_value, - reference_value, s, pscals, (maxv - hcount) * 2, pval); - i += (maxv - hcount) * 2; -#else - (void)pscals; /* suppress gcc warning */ - (void)pval; /* suppress gcc warning */ - for (lcount = hcount; lcount < maxv; lcount++) { - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - /* These values should always be zero, but as they are packed, - it is necessary to force them back to zero */ - if (mmax == 0) - val[i - 1] = 0; - lup++; - } -#endif - - maxv--; - hcount = 0; - mmax++; - } - - Assert(*len >= i); - *len = i; - - grib_context_free(a->context, scals); - - return ret; -} - -#endif /* eccodes_accessor_data_complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h.bak b/src/accessor/grib_accessor_class_data_dummy_field.h.bak deleted file mode 100644 index 00de1fe73..000000000 --- a/src/accessor/grib_accessor_class_data_dummy_field.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_dummy_field_h -#define eccodes_accessor_data_dummy_field_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_g1simple_packing.h" - -class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t -{ -public: - /* Members defined in data_dummy_field */ - const char* missing_value; - const char* numberOfPoints; - const char* bitmap; -}; - -class grib_accessor_class_data_dummy_field_t : public grib_accessor_class_data_g1simple_packing_t -{ -public: - grib_accessor_class_data_dummy_field_t(const char* name) : grib_accessor_class_data_g1simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_dummy_field_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_dummy_field_h */ diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak b/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak deleted file mode 100644 index cc6208c95..000000000 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1complex_packing_h -#define eccodes_accessor_data_g1complex_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_complex_packing.h" - -class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t -{ -public: - /* Members defined in data_g1complex_packing */ - const char* N; - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -}; - -class grib_accessor_class_data_g1complex_packing_t : public grib_accessor_class_data_complex_packing_t -{ -public: - grib_accessor_class_data_g1complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1complex_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g1complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak deleted file mode 100644 index adfc36716..000000000 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h.bak +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1second_order_constant_width_packing_h -#define eccodes_accessor_data_g1second_order_constant_width_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g1second_order_constant_width_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidth; -}; - -class grib_accessor_class_data_g1second_order_constant_width_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g1second_order_constant_width_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_constant_width_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; -#endif /* eccodes_accessor_data_g1second_order_constant_width_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak deleted file mode 100644 index 245217f7f..000000000 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h.bak +++ /dev/null @@ -1,68 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1second_order_general_extended_packing_h -#define eccodes_accessor_data_g1second_order_general_extended_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g1second_order_general_extended_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* firstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* codedNumberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* groupWidths; - const char* widthOfWidths; - const char* groupLengths; - const char* widthOfLengths; - const char* NL; - const char* SPD; - const char* widthOfSPD; - const char* orderOfSPD; - const char* numberOfPoints; - const char* dataFlag; - double* dvalues; - float* fvalues; - int double_dirty; - int float_dirty; - size_t size; -}; - -class grib_accessor_class_data_g1second_order_general_extended_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g1second_order_general_extended_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_extended_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - -private: - int unpack(grib_accessor* a, double*, float*, size_t*); -}; -#endif /* eccodes_accessor_data_g1second_order_general_extended_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak deleted file mode 100644 index 2e8bb3620..000000000 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h.bak +++ /dev/null @@ -1,49 +0,0 @@ - -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_data_simple_packing.h" -#include "grib_scaling.h" - -class grib_accessor_data_g1second_order_general_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g1second_order_general_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -}; - -class grib_accessor_class_data_g1second_order_general_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g1second_order_general_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak deleted file mode 100644 index 9b274a408..000000000 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h.bak +++ /dev/null @@ -1,49 +0,0 @@ - -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_data_simple_packing.h" -#include "grib_scaling.h" - -class grib_accessor_data_g1second_order_row_by_row_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g1second_order_row_by_row_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -}; - -class grib_accessor_class_data_g1second_order_row_by_row_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g1second_order_row_by_row_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_row_by_row_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak deleted file mode 100644 index e963d6f44..000000000 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1secondary_bitmap_h -#define eccodes_accessor_data_g1secondary_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_secondary_bitmap.h" - -class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t -{ -public: - /* Members defined in data_g1secondary_bitmap */ - const char* number_of_ones; -}; - -class grib_accessor_class_data_g1secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t -{ -public: - grib_accessor_class_data_g1secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1secondary_bitmap_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g1secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak deleted file mode 100644 index 0c8efffa1..000000000 --- a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1shsimple_packing_h -#define eccodes_accessor_data_g1shsimple_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_shsimple_packing.h" - -class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t -{ -public: - /* Members defined in data_g1shsimple_packing */ -}; - -class grib_accessor_class_data_g1shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t -{ -public: - grib_accessor_class_data_g1shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1shsimple_packing_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; -}; -#endif /* eccodes_accessor_data_g1shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak b/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak deleted file mode 100644 index 3a351d17f..000000000 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g1simple_packing_h -#define eccodes_accessor_data_g1simple_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g1simple_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -}; - -class grib_accessor_class_data_g1simple_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g1simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1simple_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g1simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h.bak b/src/accessor/grib_accessor_class_data_g22order_packing.h.bak deleted file mode 100644 index 39d01a70b..000000000 --- a/src/accessor/grib_accessor_class_data_g22order_packing.h.bak +++ /dev/null @@ -1,55 +0,0 @@ - -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_values.h" -#include "grib_scaling.h" - -class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t -{ -public: - /* Members defined in data_g22order_packing */ - const char* numberOfValues; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scale_factor; - const char* typeOfOriginalFieldValues; - const char* groupSplittingMethodUsed; - const char* missingValueManagementUsed; - const char* primaryMissingValueSubstitute; - const char* secondaryMissingValueSubstitute; - const char* numberOfGroupsOfDataValues; - const char* referenceForGroupWidths; - const char* numberOfBitsUsedForTheGroupWidths; - const char* referenceForGroupLengths; - const char* lengthIncrementForTheGroupLengths; - const char* trueLengthOfLastGroup; - const char* numberOfBitsUsedForTheScaledGroupLengths; - const char* orderOfSpatialDifferencing; - const char* numberOfOctetsExtraDescriptors; -}; - -class grib_accessor_class_data_g22order_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_g22order_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g22order_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak deleted file mode 100644 index f4033a1ba..000000000 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h.bak +++ /dev/null @@ -1,47 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2bifourier_packing_h -#define eccodes_accessor_data_g2bifourier_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_g2bifourier_packing */ - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* biFourierTruncationType; - const char* sub_i; - const char* sub_j; - const char* bif_i; - const char* bif_j; - const char* biFourierSubTruncationType; - const char* biFourierDoNotPackAxes; - const char* biFourierMakeTemplate; - const char* totalNumberOfValuesInUnpackedSubset; - const char* numberOfValues; -}; - -class grib_accessor_class_data_g2bifourier_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g2bifourier_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2bifourier_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2bifourier_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak b/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak deleted file mode 100644 index e77b89276..000000000 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2complex_packing_h -#define eccodes_accessor_data_g2complex_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_complex_packing.h" - -class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t -{ -public: - /* Members defined in data_g2complex_packing */ - const char* numberOfValues; -}; - -class grib_accessor_class_data_g2complex_packing_t : public grib_accessor_class_data_complex_packing_t -{ -public: - grib_accessor_class_data_g2complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2complex_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak deleted file mode 100644 index 394c79bfa..000000000 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2secondary_bitmap_h -#define eccodes_accessor_data_g2secondary_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_secondary_bitmap.h" - -class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t -{ -public: - /* Members defined in data_g2secondary_bitmap */ - const char* number_of_values; -}; - -class grib_accessor_class_data_g2secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t -{ -public: - grib_accessor_class_data_g2secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2secondary_bitmap_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak deleted file mode 100644 index 28e7a7c06..000000000 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2shsimple_packing_h -#define eccodes_accessor_data_g2shsimple_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_shsimple_packing.h" - -class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t -{ -public: - /* Members defined in data_g2shsimple_packing */ - const char* numberOfValues; - const char* numberOfDataPoints; -}; - -class grib_accessor_class_data_g2shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t -{ -public: - grib_accessor_class_data_g2shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2shsimple_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak b/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak deleted file mode 100644 index 4f27ab87c..000000000 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.h.bak +++ /dev/null @@ -1,28 +0,0 @@ -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2simple_packing_h -#define eccodes_accessor_data_g2simple_packing_h - -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t {}; - -class grib_accessor_class_data_g2simple_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_g2simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_t{}; } - int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak deleted file mode 100644 index ac2bc2d27..000000000 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_g2simple_packing_with_preprocessing_h -#define eccodes_accessor_data_g2simple_packing_with_preprocessing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_g2simple_packing.h" - -class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t -{ -public: - /* Members defined in data_g2simple_packing_with_preprocessing */ - const char* pre_processing; - const char* pre_processing_parameter; -}; - -class grib_accessor_class_data_g2simple_packing_with_preprocessing_t : public grib_accessor_class_data_g2simple_packing_t -{ -public: - grib_accessor_class_data_g2simple_packing_with_preprocessing_t(const char* name) : grib_accessor_class_data_g2simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_with_preprocessing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_g2simple_packing_with_preprocessing_h */ diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak deleted file mode 100644 index a04ee58d5..000000000 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h.bak +++ /dev/null @@ -1,46 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_jpeg2000_packing_h -#define eccodes_accessor_data_jpeg2000_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_jpeg2000_packing */ - const char* type_of_compression_used; - const char* target_compression_ratio; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; - int jpeg_lib; - const char* dump_jpg; -}; - -class grib_accessor_class_data_jpeg2000_packing_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_jpeg2000_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_jpeg2000_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; -#endif /* eccodes_accessor_data_jpeg2000_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_png_packing.h.bak b/src/accessor/grib_accessor_class_data_png_packing.h.bak deleted file mode 100644 index 841ed9d31..000000000 --- a/src/accessor/grib_accessor_class_data_png_packing.h.bak +++ /dev/null @@ -1,41 +0,0 @@ -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_values.h" - -class grib_accessor_data_png_packing_t : public grib_accessor_values_t -{ -public: - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* bits_per_value; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; -}; - -class grib_accessor_class_data_png_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_png_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_png_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; diff --git a/src/accessor/grib_accessor_class_data_raw_packing.h.bak b/src/accessor/grib_accessor_class_data_raw_packing.h.bak deleted file mode 100644 index 5b1b103e0..000000000 --- a/src/accessor/grib_accessor_class_data_raw_packing.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_raw_packing_h -#define eccodes_accessor_data_raw_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_values.h" - -class grib_accessor_data_raw_packing_t : public grib_accessor_values_t -{ -public: - /* Members defined in data_raw_packing */ - const char* number_of_values; - const char* precision; -}; - -class grib_accessor_class_data_raw_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_raw_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_raw_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; -}; -#endif /* eccodes_accessor_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h.bak b/src/accessor/grib_accessor_class_data_run_length_packing.h.bak deleted file mode 100644 index 3125fdcf4..000000000 --- a/src/accessor/grib_accessor_class_data_run_length_packing.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_run_length_packing_h -#define eccodes_accessor_data_run_length_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_values.h" - -class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t -{ -public: - /* Members defined in data_run_length_packing */ - const char* number_of_values; - const char* bits_per_value; - const char* max_level_value; - const char* number_of_level_values; - const char* decimal_scale_factor; - const char* level_values; -}; - -class grib_accessor_class_data_run_length_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_run_length_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_run_length_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_run_length_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak b/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak deleted file mode 100644 index 3ac86e324..000000000 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_secondary_bitmap_h -#define eccodes_accessor_data_secondary_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t -{ -public: - /* Members defined in data_secondary_bitmap */ - const char* primary_bitmap; - const char* secondary_bitmap; - const char* missing_value; - const char* expand_by; -}; - -class grib_accessor_class_data_secondary_bitmap_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_data_secondary_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_secondary_bitmap_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h.bak b/src/accessor/grib_accessor_class_data_sh_packed.h.bak deleted file mode 100644 index 2d7cbdf47..000000000 --- a/src/accessor/grib_accessor_class_data_sh_packed.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_sh_packed_h -#define eccodes_accessor_data_sh_packed_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_sh_packed */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -}; - -class grib_accessor_class_data_sh_packed_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_sh_packed_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_packed_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_sh_packed_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak b/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak deleted file mode 100644 index 4b1e893c0..000000000 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_sh_unpacked_h -#define eccodes_accessor_data_sh_unpacked_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_data_simple_packing.h" - -class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t -{ -public: - /* Members defined in data_sh_unpacked */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -}; - -class grib_accessor_class_data_sh_unpacked_t : public grib_accessor_class_data_simple_packing_t -{ -public: - grib_accessor_class_data_sh_unpacked_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_unpacked_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_sh_unpacked_h */ diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak b/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak deleted file mode 100644 index 851907eb9..000000000 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_shsimple_packing_h -#define eccodes_accessor_data_shsimple_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t -{ -public: - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; -}; - -class grib_accessor_class_data_shsimple_packing_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_data_shsimple_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_shsimple_packing_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_data_shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h.bak b/src/accessor/grib_accessor_class_data_simple_packing.h.bak deleted file mode 100644 index 92f355b3f..000000000 --- a/src/accessor/grib_accessor_class_data_simple_packing.h.bak +++ /dev/null @@ -1,195 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_data_simple_packing_h -#define eccodes_accessor_data_simple_packing_h - -#include "grib_accessor_class_values.h" -#include "grib_bits_any_endian_simple.h" -#include "grib_scaling.h" - -class grib_accessor_data_simple_packing_t : public grib_accessor_values_t -{ -public: - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; -}; - -class grib_accessor_class_data_simple_packing_t : public grib_accessor_class_values_t -{ -public: - grib_accessor_class_data_simple_packing_t(const char* name) : grib_accessor_class_values_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_data_simple_packing_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); -}; - - -template -int grib_accessor_class_data_simple_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - - grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - - size_t i = 0; - int err = 0; - size_t n_vals = 0; - long pos = 0; - long count = 0; - - double reference_value; - long binary_scale_factor; - long bits_per_value; - long decimal_scale_factor; - long offsetBeforeData; - double s = 0; - double d = 0; - double units_factor = 1.0; - double units_bias = 0.0; - - err = a->value_count(&count); if (err) - return err; - n_vals = count; - - if (*len < n_vals) { - *len = (long)n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - - /* - * check we don't decode bpv > max(ulong) as it is - * not currently supported by the algorithm - */ - if (bits_per_value > (sizeof(long) * 8)) { - return GRIB_INVALID_BPV; - } - - if (self->units_factor && - (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_factor, 1.0); - } - - if (self->units_bias && - (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_bias, 0.0); - } - - if (n_vals == 0) { - *len = 0; - return GRIB_SUCCESS; - } - - self->dirty = 0; - - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - /* Special case */ - - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - - offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; - - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ - - /* ECC-941 */ - if (!a->context->ieee_packing) { - /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ - long offsetAfterData = 0; - err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); - if (!err && offsetAfterData > offsetBeforeData) { - const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ - if (offsetBeforeData + valuesSize > offsetAfterData) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Data section size mismatch: " - "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", - cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); - return GRIB_DECODING_ERROR; - } - } - // if (offsetBeforeData == offsetAfterData) { - // /* Crazy case: Constant field with bitsPerValue > 0 */ - // for (i = 0; i < n_vals; i++) - // val[i] = reference_value; - // *len = n_vals; - // return GRIB_SUCCESS; - // } - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", - cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); - grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); - - *len = (long)n_vals; - - if (units_factor != 1.0) { - if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] = val[i] * units_factor + units_bias; - } - } else { - for (i = 0; i < n_vals; i++) { - val[i] *= units_factor; - } - } - } - else if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] += units_bias; - } - } - return err; -} - - -#endif /* eccodes_accessor_data_simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_decimal_precision.h.bak b/src/accessor/grib_accessor_class_decimal_precision.h.bak deleted file mode 100644 index 455d77946..000000000 --- a/src/accessor/grib_accessor_class_decimal_precision.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_decimal_precision_h -#define eccodes_accessor_decimal_precision_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_decimal_precision_t : public grib_accessor_long_t -{ -public: - /* Members defined in decimal_precision */ - const char* values; - const char* bits_per_value; - const char* changing_precision; - const char* decimal_scale_factor; -}; - -class grib_accessor_class_decimal_precision_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_decimal_precision_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_decimal_precision_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_decimal_precision_h */ diff --git a/src/accessor/grib_accessor_class_dictionary.h.bak b/src/accessor/grib_accessor_class_dictionary.h.bak deleted file mode 100644 index 7f86a44ae..000000000 --- a/src/accessor/grib_accessor_class_dictionary.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_dictionary_h -#define eccodes_accessor_dictionary_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_dictionary_t : public grib_accessor_gen_t -{ -public: - /* Members defined in dictionary */ - const char* dictionary; - const char* key; - long column; - const char* masterDir; - const char* localDir; -}; - -class grib_accessor_class_dictionary_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_dictionary_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_dictionary_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_dictionary_h */ diff --git a/src/accessor/grib_accessor_class_dirty.h.bak b/src/accessor/grib_accessor_class_dirty.h.bak deleted file mode 100644 index 7a008ce29..000000000 --- a/src/accessor/grib_accessor_class_dirty.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_dirty_h -#define eccodes_accessor_dirty_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_dirty_t : public grib_accessor_long_t -{ -public: - /* Members defined in dirty */ - const char* accessor; -}; - -class grib_accessor_class_dirty_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_dirty_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_dirty_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_dirty_h */ diff --git a/src/accessor/grib_accessor_class_divdouble.h.bak b/src/accessor/grib_accessor_class_divdouble.h.bak deleted file mode 100644 index e10239676..000000000 --- a/src/accessor/grib_accessor_class_divdouble.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_divdouble_h -#define eccodes_accessor_divdouble_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_divdouble_t : public grib_accessor_double_t -{ -public: - /* Members defined in divdouble */ - const char* val; - double divisor; -}; - -class grib_accessor_class_divdouble_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_divdouble_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_divdouble_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_divdouble_h */ diff --git a/src/accessor/grib_accessor_class_double.h.bak b/src/accessor/grib_accessor_class_double.h.bak deleted file mode 100644 index 1c1e2fb4f..000000000 --- a/src/accessor/grib_accessor_class_double.h.bak +++ /dev/null @@ -1,30 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_double_h -#define eccodes_accessor_double_h - -#include "grib_accessor_class_gen.h" - -class grib_accessor_double_t : public grib_accessor_gen_t {}; - -class grib_accessor_class_double_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_double_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_double_t{}; } - int get_native_type(grib_accessor*) override; - int pack_missing(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_double_h */ diff --git a/src/accessor/grib_accessor_class_element.h.bak b/src/accessor/grib_accessor_class_element.h.bak deleted file mode 100644 index f22109be2..000000000 --- a/src/accessor/grib_accessor_class_element.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_element_h -#define eccodes_accessor_element_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_element_t : public grib_accessor_long_t -{ -public: - /* Members defined in element */ - const char* array; - long element; -}; - -class grib_accessor_class_element_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_element_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_element_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_element_h */ diff --git a/src/accessor/grib_accessor_class_evaluate.h.bak b/src/accessor/grib_accessor_class_evaluate.h.bak deleted file mode 100644 index e65c6473b..000000000 --- a/src/accessor/grib_accessor_class_evaluate.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_evaluate_h -#define eccodes_accessor_evaluate_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_evaluate_t : public grib_accessor_long_t -{ -public: - /* Members defined in evaluate */ - grib_arguments* arg; -}; - -class grib_accessor_class_evaluate_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_evaluate_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_evaluate_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_evaluate_h */ diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h.bak b/src/accessor/grib_accessor_class_expanded_descriptors.h.bak deleted file mode 100644 index be2094d4f..000000000 --- a/src/accessor/grib_accessor_class_expanded_descriptors.h.bak +++ /dev/null @@ -1,47 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_expanded_descriptors_h -#define eccodes_accessor_expanded_descriptors_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t -{ -public: - /* Members defined in expanded_descriptors */ - const char* unexpandedDescriptors; - const char* sequence; - const char* expandedName; - const char* tablesAccessorName; - bufr_descriptors_array* expanded; - int rank; - grib_accessor* expandedAccessor; - int do_expand; - grib_accessor* tablesAccessor; -}; - -class grib_accessor_class_expanded_descriptors_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_expanded_descriptors_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak deleted file mode 100644 index 1874c559f..000000000 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_from_scale_factor_scaled_value_h -#define eccodes_accessor_from_scale_factor_scaled_value_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t -{ -public: - /* Members defined in from_scale_factor_scaled_value */ - const char* scaleFactor; - const char* scaledValue; -}; - -class grib_accessor_class_from_scale_factor_scaled_value_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_from_scale_factor_scaled_value_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_from_scale_factor_scaled_value_t{}; } - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_from_scale_factor_scaled_value_h */ diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak deleted file mode 100644 index 9c5890aa3..000000000 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1_half_byte_codeflag_h -#define eccodes_accessor_g1_half_byte_codeflag_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t -{ -public: - /* Members defined in g1_half_byte_codeflag */ -}; - -class grib_accessor_class_g1_half_byte_codeflag_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_g1_half_byte_codeflag_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_half_byte_codeflag_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1_half_byte_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_g1_message_length.h.bak b/src/accessor/grib_accessor_class_g1_message_length.h.bak deleted file mode 100644 index c3b865ec0..000000000 --- a/src/accessor/grib_accessor_class_g1_message_length.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1_message_length_h -#define eccodes_accessor_g1_message_length_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_section_length.h" - -class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t -{ -public: - /* Members defined in g1_message_length */ - const char *sec4_length; -}; - -class grib_accessor_class_g1_message_length_t : public grib_accessor_class_section_length_t -{ -public: - grib_accessor_class_g1_message_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_message_length_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1_message_length_h */ diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h.bak b/src/accessor/grib_accessor_class_g1_section4_length.h.bak deleted file mode 100644 index 0a1b0c768..000000000 --- a/src/accessor/grib_accessor_class_g1_section4_length.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1_section4_length_h -#define eccodes_accessor_g1_section4_length_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_section_length.h" - -class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t -{ -public: - /* Members defined in g1_section4_length */ - const char* total_length; -}; - -class grib_accessor_class_g1_section4_length_t : public grib_accessor_class_section_length_t -{ -public: - grib_accessor_class_g1_section4_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_section4_length_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1_section4_length_h */ diff --git a/src/accessor/grib_accessor_class_g1bitmap.h.bak b/src/accessor/grib_accessor_class_g1bitmap.h.bak deleted file mode 100644 index b34344d1f..000000000 --- a/src/accessor/grib_accessor_class_g1bitmap.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1bitmap_h -#define eccodes_accessor_g1bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_bitmap.h" - -class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t -{ -public: - /* Members defined in g1bitmap */ - const char* unusedBits; -}; - -class grib_accessor_class_g1bitmap_t : public grib_accessor_class_bitmap_t -{ -public: - grib_accessor_class_g1bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1bitmap_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g1date.h.bak b/src/accessor/grib_accessor_class_g1date.h.bak deleted file mode 100644 index 27e71189f..000000000 --- a/src/accessor/grib_accessor_class_g1date.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1date_h -#define eccodes_accessor_g1date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1date_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1date */ - const char* century; - const char* year; - const char* month; - const char* day; -}; - -class grib_accessor_class_g1date_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1date_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1date_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1date_h */ diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak deleted file mode 100644 index 1563cdb9d..000000000 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1day_of_the_year_date_h -#define eccodes_accessor_g1day_of_the_year_date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_g1date.h" - -class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t -{ -public: - /* Members defined in g1day_of_the_year_date */ -}; - -class grib_accessor_class_g1day_of_the_year_date_t : public grib_accessor_class_g1date_t -{ -public: - grib_accessor_class_g1day_of_the_year_date_t(const char* name) : grib_accessor_class_g1date_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1day_of_the_year_date_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1day_of_the_year_date_h */ diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak deleted file mode 100644 index a1e29a76c..000000000 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1end_of_interval_monthly_h -#define eccodes_accessor_g1end_of_interval_monthly_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_abstract_vector.h" - -class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t -{ -public: - /* Members defined in g1end_of_interval_monthly */ - const char* verifyingMonth; -}; - -class grib_accessor_class_g1end_of_interval_monthly_t : public grib_accessor_class_abstract_vector_t -{ -public: - grib_accessor_class_g1end_of_interval_monthly_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1end_of_interval_monthly_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_g1end_of_interval_monthly_h */ diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h.bak b/src/accessor/grib_accessor_class_g1fcperiod.h.bak deleted file mode 100644 index 3c0ff2c49..000000000 --- a/src/accessor/grib_accessor_class_g1fcperiod.h.bak +++ /dev/null @@ -1,31 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1fcperiod_h -#define eccodes_accessor_g1fcperiod_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_g1step_range.h" - -class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t -{ -public: - /* Members defined in g1fcperiod */ -}; - -class grib_accessor_class_g1fcperiod_t : public grib_accessor_class_g1step_range_t -{ -public: - grib_accessor_class_g1fcperiod_t(const char* name) : grib_accessor_class_g1step_range_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1fcperiod_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; -}; -#endif /* eccodes_accessor_g1fcperiod_h */ diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h.bak b/src/accessor/grib_accessor_class_g1forecastmonth.h.bak deleted file mode 100644 index 6d2b9ee63..000000000 --- a/src/accessor/grib_accessor_class_g1forecastmonth.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1forecastmonth_h -#define eccodes_accessor_g1forecastmonth_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1forecastmonth */ - const char* verification_yearmonth; - const char* base_date; - const char* day; - const char* hour; - const char* fcmonth; - const char* check; -}; - -class grib_accessor_class_g1forecastmonth_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1forecastmonth_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1forecastmonth_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1forecastmonth_h */ diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h.bak b/src/accessor/grib_accessor_class_g1monthlydate.h.bak deleted file mode 100644 index 8efa9cf16..000000000 --- a/src/accessor/grib_accessor_class_g1monthlydate.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1monthlydate_h -#define eccodes_accessor_g1monthlydate_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1monthlydate_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1monthlydate */ - const char* date; -}; - -class grib_accessor_class_g1monthlydate_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1monthlydate_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1monthlydate_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1monthlydate_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak deleted file mode 100644 index 764bfa04d..000000000 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h -#define eccodes_accessor_g1number_of_coded_values_sh_complex_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1number_of_coded_values_sh_complex */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; - const char* JS; - const char* KS; - const char* MS; -}; - -class grib_accessor_class_g1number_of_coded_values_sh_complex_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1number_of_coded_values_sh_complex_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_complex_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1number_of_coded_values_sh_complex_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak deleted file mode 100644 index fb5ab298d..000000000 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h -#define eccodes_accessor_g1number_of_coded_values_sh_simple_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1number_of_coded_values_sh_simple */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -}; - -class grib_accessor_class_g1number_of_coded_values_sh_simple_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1number_of_coded_values_sh_simple_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_simple_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1number_of_coded_values_sh_simple_h */ diff --git a/src/accessor/grib_accessor_class_g1step_range.h.bak b/src/accessor/grib_accessor_class_g1step_range.h.bak deleted file mode 100644 index c9c3dd911..000000000 --- a/src/accessor/grib_accessor_class_g1step_range.h.bak +++ /dev/null @@ -1,48 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1step_range_h -#define eccodes_accessor_g1step_range_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_abstract_long_vector.h" - -class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t -{ -public: - /* Members defined in g1step_range */ - const char* p1; - const char* p2; - const char* timeRangeIndicator; - const char *unit; - const char *step_unit; - const char *stepType; - const char *patch_fp_precip; - int error_on_units; -}; - -class grib_accessor_class_g1step_range_t : public grib_accessor_class_abstract_long_vector_t -{ -public: - grib_accessor_class_g1step_range_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1step_range_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1step_range_h */ diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h.bak b/src/accessor/grib_accessor_class_g1verificationdate.h.bak deleted file mode 100644 index 198801aba..000000000 --- a/src/accessor/grib_accessor_class_g1verificationdate.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g1verificationdate_h -#define eccodes_accessor_g1verificationdate_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g1verificationdate_t : public grib_accessor_long_t -{ -public: - /* Members defined in g1verificationdate */ - const char* date; - const char* time; - const char* step; -}; - -class grib_accessor_class_g1verificationdate_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g1verificationdate_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g1verificationdate_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g1verificationdate_h */ diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h.bak b/src/accessor/grib_accessor_class_g2_aerosol.h.bak deleted file mode 100644 index fb29a9561..000000000 --- a/src/accessor/grib_accessor_class_g2_aerosol.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2_aerosol_h -#define eccodes_accessor_g2_aerosol_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in g2_aerosol */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int optical; -}; - -class grib_accessor_class_g2_aerosol_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_g2_aerosol_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_aerosol_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2_aerosol_h */ diff --git a/src/accessor/grib_accessor_class_g2_chemical.h.bak b/src/accessor/grib_accessor_class_g2_chemical.h.bak deleted file mode 100644 index 9cfe4f8bc..000000000 --- a/src/accessor/grib_accessor_class_g2_chemical.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2_chemical_h -#define eccodes_accessor_g2_chemical_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in g2_chemical */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int chemical_type; -}; - -class grib_accessor_class_g2_chemical_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_g2_chemical_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_chemical_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2_chemical_h */ diff --git a/src/accessor/grib_accessor_class_g2_eps.h.bak b/src/accessor/grib_accessor_class_g2_eps.h.bak deleted file mode 100644 index 7c39dd580..000000000 --- a/src/accessor/grib_accessor_class_g2_eps.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2_eps_h -#define eccodes_accessor_g2_eps_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in g2_eps */ - const char* productDefinitionTemplateNumber; - const char* stream; - const char* type; - const char* stepType; - const char* derivedForecast; -}; - -class grib_accessor_class_g2_eps_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_g2_eps_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_eps_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2_eps_h */ diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak b/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak deleted file mode 100644 index 0a678174f..000000000 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.h.bak +++ /dev/null @@ -1,47 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2_mars_labeling_h -#define eccodes_accessor_g2_mars_labeling_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t -{ -public: - /* Members defined in g2_mars_labeling */ - int index; - const char* the_class; - const char* stream; - const char* type; - const char* expver; - const char* typeOfProcessedData; - const char* productDefinitionTemplateNumber; - const char* stepType; - const char* derivedForecast; - const char* typeOfGeneratingProcess; -}; - -class grib_accessor_class_g2_mars_labeling_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_g2_mars_labeling_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_mars_labeling_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2_mars_labeling_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap.h.bak b/src/accessor/grib_accessor_class_g2bitmap.h.bak deleted file mode 100644 index 9af7a3b27..000000000 --- a/src/accessor/grib_accessor_class_g2bitmap.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2bitmap_h -#define eccodes_accessor_g2bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_bitmap.h" - -class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t -{ -public: - /* Members defined in g2bitmap */ - const char* numberOfValues; -}; - -class grib_accessor_class_g2bitmap_t : public grib_accessor_class_bitmap_t -{ -public: - grib_accessor_class_g2bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h.bak b/src/accessor/grib_accessor_class_g2bitmap_present.h.bak deleted file mode 100644 index 7b5cd3f66..000000000 --- a/src/accessor/grib_accessor_class_g2bitmap_present.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2bitmap_present_h -#define eccodes_accessor_g2bitmap_present_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t -{ -public: - /* Members defined in g2bitmap_present */ - const char* bitmapIndicator; -}; - -class grib_accessor_class_g2bitmap_present_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g2bitmap_present_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_present_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2bitmap_present_h */ diff --git a/src/accessor/grib_accessor_class_g2date.h.bak b/src/accessor/grib_accessor_class_g2date.h.bak deleted file mode 100644 index 20276c6fe..000000000 --- a/src/accessor/grib_accessor_class_g2date.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2date_h -#define eccodes_accessor_g2date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g2date_t : public grib_accessor_long_t -{ -public: - /* Members defined in g2date */ - const char* century; - const char* year; - const char* month; - const char* day; -}; - -class grib_accessor_class_g2date_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g2date_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2date_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2date_h */ diff --git a/src/accessor/grib_accessor_class_g2end_step.h.bak b/src/accessor/grib_accessor_class_g2end_step.h.bak deleted file mode 100644 index 7a2d8ab21..000000000 --- a/src/accessor/grib_accessor_class_g2end_step.h.bak +++ /dev/null @@ -1,56 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2end_step_h -#define eccodes_accessor_g2end_step_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g2end_step_t : public grib_accessor_long_t -{ -public: - /* Members defined in g2end_step */ - const char* start_step_value; - const char* step_units; - const char* year; - const char* month; - const char* day; - const char* hour; - const char* minute; - const char* second; - const char* year_of_end_of_interval; - const char* month_of_end_of_interval; - const char* day_of_end_of_interval; - const char* hour_of_end_of_interval; - const char* minute_of_end_of_interval; - const char* second_of_end_of_interval; - const char* time_range_unit; - const char* time_range_value; - const char* typeOfTimeIncrement; - const char* numberOfTimeRange; -}; - -class grib_accessor_class_g2end_step_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g2end_step_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2end_step_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2end_step_h */ diff --git a/src/accessor/grib_accessor_class_g2grid.h.bak b/src/accessor/grib_accessor_class_g2grid.h.bak deleted file mode 100644 index 0cd177ce5..000000000 --- a/src/accessor/grib_accessor_class_g2grid.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2grid_h -#define eccodes_accessor_g2grid_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_g2grid_t : public grib_accessor_double_t -{ -public: - /* Members defined in g2grid */ - const char* latitude_first; - const char* longitude_first; - const char* latitude_last; - const char* longitude_last; - const char* i_increment; - const char* j_increment; - const char* basic_angle; - const char* sub_division; -}; - -class grib_accessor_class_g2grid_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_g2grid_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2grid_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2grid_h */ diff --git a/src/accessor/grib_accessor_class_g2latlon.h.bak b/src/accessor/grib_accessor_class_g2latlon.h.bak deleted file mode 100644 index f16e2623e..000000000 --- a/src/accessor/grib_accessor_class_g2latlon.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2latlon_h -#define eccodes_accessor_g2latlon_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_g2latlon_t : public grib_accessor_double_t -{ -public: - /* Members defined in g2latlon */ - const char* grid; - int index; - const char* given; -}; - -class grib_accessor_class_g2latlon_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_g2latlon_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2latlon_t{}; } - int pack_missing(grib_accessor*) override; - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2latlon_h */ diff --git a/src/accessor/grib_accessor_class_g2level.h.bak b/src/accessor/grib_accessor_class_g2level.h.bak deleted file mode 100644 index 567b8c1b4..000000000 --- a/src/accessor/grib_accessor_class_g2level.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2level_h -#define eccodes_accessor_g2level_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_g2level_t : public grib_accessor_long_t -{ -public: - /* Members defined in g2level */ - const char* type_first; - const char* scale_first; - const char* value_first; - const char* pressure_units; -}; - -class grib_accessor_class_g2level_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_g2level_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2level_t{}; } - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2level_h */ diff --git a/src/accessor/grib_accessor_class_g2lon.h.bak b/src/accessor/grib_accessor_class_g2lon.h.bak deleted file mode 100644 index d17a68c14..000000000 --- a/src/accessor/grib_accessor_class_g2lon.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2lon_h -#define eccodes_accessor_g2lon_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_g2lon_t : public grib_accessor_double_t -{ -public: - /* Members defined in g2lon */ - const char* longitude; -}; - -class grib_accessor_class_g2lon_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_g2lon_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2lon_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2lon_h */ diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc index 28019a783..0c1b49e21 100644 --- a/src/accessor/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,20 +8,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2step_range.h" #include "step.h" #include "step_utilities.h" -#include -#include #include -grib_accessor_class_g2step_range_t _grib_accessor_class_g2step_range{"g2step_range"}; +grib_accessor_class_g2step_range_t _grib_accessor_class_g2step_range{ "g2step_range" }; grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2step_range; -void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_gen_t::init(a, l, c); grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; @@ -34,39 +31,40 @@ void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, gr a->length = 0; } -//static void dump(grib_accessor* a, grib_dumper* dumper) +// static void dump(grib_accessor* a, grib_dumper* dumper) //{ - //grib_dump_string(dumper, a, NULL); +// grib_dump_string(dumper, a, NULL); //} -int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - size_t size = 0; - double start_step_value = 0; - double end_step_value = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + size_t size = 0; + double start_step_value = 0; + double end_step_value = 0; long step_units; int show_hours = a->context->grib_hourly_steps_with_units; if ((ret = grib_get_double_internal(h, self->start_step, &start_step_value)) != GRIB_SUCCESS) return ret; - if ((ret= grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) return ret; try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) return ret; } - char fp_format[128] = "%g"; + char fp_format[128] = "%g"; size_t fp_format_len = sizeof(fp_format); if ((ret = grib_get_string_internal(h, "formatForDoubles", fp_format, &fp_format_len)) != GRIB_SUCCESS) return ret; std::stringstream ss; - eccodes::Step start_step{start_step_value, step_units}; + eccodes::Step start_step{ start_step_value, step_units }; if (self->end_step == NULL) { ss << start_step.value(fp_format, show_hours); } @@ -74,7 +72,7 @@ int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* va if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) return ret; - eccodes::Step end_step{end_step_value, step_units}; + eccodes::Step end_step{ end_step_value, step_units }; if (start_step_value == end_step_value) { ss << end_step.value(fp_format, show_hours); @@ -101,15 +99,15 @@ int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* va return GRIB_SUCCESS; } - // Step range format: [-] // and can be in different units // stepRange="X" in instantaneous field is equivalent to set step=X // stepRange="X" in accumulated field is equivalent to startStep=X, endStep=startStep -int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; long force_step_units; if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) @@ -121,12 +119,12 @@ int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char // If this key is defined (!= 255), it indicates that the stepUnits have been defined by the user. // Once this key is set, it has the highest priority: it automatically overrides certain units and the default value in stepUnits - if (h->loader) { // h->loader is set only when rebuilding or reparsing - force_step_units = 255; // See ECC-1768 and ECC-1800 + if (h->loader) { // h->loader is set only when rebuilding or reparsing + force_step_units = 255; // See ECC-1768 and ECC-1800 } try { - std::vector steps = parse_range(val, eccodes::Unit{force_step_units}); + std::vector steps = parse_range(val, eccodes::Unit{ force_step_units }); if (steps.size() == 0) { grib_context_log(a->context, GRIB_LOG_ERROR, "Could not parse step range: %s", val); return GRIB_INVALID_ARGUMENT; @@ -134,22 +132,22 @@ int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char eccodes::Step step_0; eccodes::Step step_1; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if (steps.size() > 1) std::tie(step_0, step_1) = find_common_units(steps[0].optimize_unit(), steps[1].optimize_unit()); else step_0 = steps[0].optimize_unit(); } else { - step_0 = eccodes::Step{steps[0].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; + step_0 = eccodes::Step{ steps[0].value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; if (steps.size() > 1) { - step_1 = eccodes::Step{steps[1].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; + step_1 = eccodes::Step{ steps[1].value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; } } if ((ret = grib_set_long_internal(h, "startStepUnit", step_0.unit().value()))) return ret; - if ((ret = set_step(h, "forecastTime" , "indicatorOfUnitOfTimeRange", step_0)) != GRIB_SUCCESS) + if ((ret = set_step(h, "forecastTime", "indicatorOfUnitOfTimeRange", step_0)) != GRIB_SUCCESS) return ret; if (self->end_step != NULL) { @@ -158,7 +156,8 @@ int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char return ret; if ((ret = grib_set_long_internal(h, self->end_step, step_1.value()))) return ret; - } else { + } + else { if ((ret = grib_set_long_internal(h, "endStepUnit", step_0.unit().value()))) return ret; if ((ret = grib_set_long_internal(h, self->end_step, step_0.value()))) @@ -173,16 +172,19 @@ int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char return GRIB_SUCCESS; } -int grib_accessor_class_g2step_range_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_g2step_range_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -size_t grib_accessor_class_g2step_range_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_g2step_range_t::string_length(grib_accessor* a) +{ return 255; } -int grib_accessor_class_g2step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g2step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ char buff[100]; size_t bufflen = 100; @@ -190,33 +192,33 @@ int grib_accessor_class_g2step_range_t::pack_long(grib_accessor* a, const long* return pack_string(a, buff, &bufflen); } - -int grib_accessor_class_g2step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_g2step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - long end_start_value = 0; - long end_step_value = 0; - long step_units = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + long end_start_value = 0; + long end_step_value = 0; + long step_units = 0; if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) return ret; try { if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) throw std::runtime_error("Failed to get stepUnits"); - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) return ret; } - eccodes::Step start_step{end_start_value, step_units}; + eccodes::Step start_step{ end_start_value, step_units }; if (self->end_step == NULL) { *val = start_step.value(); } else { if ((ret = grib_get_long_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) return ret; - eccodes::Step end_step{end_step_value, step_units}; + eccodes::Step end_step{ end_step_value, step_units }; *val = end_step.value(); } } @@ -228,14 +230,14 @@ int grib_accessor_class_g2step_range_t::unpack_long(grib_accessor* a, long* val, return GRIB_SUCCESS; } - -int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - double end_start_value = 0; - double end_step_value = 0; - long step_units = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + double end_start_value = 0; + double end_step_value = 0; + long step_units = 0; if ((ret = grib_get_double_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) return ret; @@ -243,19 +245,19 @@ int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* throw std::runtime_error("Failed to get stepUnits"); try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) return ret; } - eccodes::Step start_step{end_start_value, step_units}; + eccodes::Step start_step{ end_start_value, step_units }; if (self->end_step == NULL) { *val = start_step.value(); } else { if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) return ret; - eccodes::Step end_step{end_step_value, step_units}; + eccodes::Step end_step{ end_step_value, step_units }; *val = end_step.value(); } } @@ -267,7 +269,7 @@ int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* return GRIB_SUCCESS; } - -int grib_accessor_class_g2step_range_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_g2step_range_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } diff --git a/src/accessor/grib_accessor_class_g2step_range.h b/src/accessor/grib_accessor_class_g2step_range.h index 45b50690c..d15fa5e36 100644 --- a/src/accessor/grib_accessor_class_g2step_range.h +++ b/src/accessor/grib_accessor_class_g2step_range.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -12,7 +11,6 @@ #ifndef eccodes_accessor_g2step_range_h #define eccodes_accessor_g2step_range_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g2step_range_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g2step_range.h.bak b/src/accessor/grib_accessor_class_g2step_range.h.bak deleted file mode 100644 index c5a007806..000000000 --- a/src/accessor/grib_accessor_class_g2step_range.h.bak +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_g2step_range_h -#define eccodes_accessor_g2step_range_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_g2step_range_t : public grib_accessor_gen_t -{ -public: - /* Members defined in g2step_range */ - const char* start_step; - const char* end_step; -}; - -class grib_accessor_class_g2step_range_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_g2step_range_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_g2step_range_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_g2step_range_h */ diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak b/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak deleted file mode 100644 index 1c12bfacd..000000000 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_gaussian_grid_name_h -#define eccodes_accessor_gaussian_grid_name_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t -{ -public: - /* Members defined in gaussian_grid_name */ - const char* N; - const char* Ni; - const char* isOctahedral; -}; - -class grib_accessor_class_gaussian_grid_name_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_gaussian_grid_name_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_gaussian_grid_name_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_gaussian_grid_name_h */ diff --git a/src/accessor/grib_accessor_class_gds_is_present.h.bak b/src/accessor/grib_accessor_class_gds_is_present.h.bak deleted file mode 100644 index fa1c5ca55..000000000 --- a/src/accessor/grib_accessor_class_gds_is_present.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_gds_is_present_h -#define eccodes_accessor_gds_is_present_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_gds_is_present_t : public grib_accessor_long_t -{ -public: - /* Members defined in gds_is_present */ - const char* gds_present; - const char* grid_definition; - const char* bitmap_present; - const char* values; -}; - -class grib_accessor_class_gds_is_present_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_gds_is_present_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_is_present_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_gds_is_present_h */ diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak deleted file mode 100644 index 68641a8e2..000000000 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_gds_not_present_bitmap_h -#define eccodes_accessor_gds_not_present_bitmap_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t -{ -public: - /* Members defined in gds_not_present_bitmap */ - const char* missing_value; - const char* number_of_values; - const char* number_of_points; - const char* latitude_of_first_point; - const char* ni; -}; - -class grib_accessor_class_gds_not_present_bitmap_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_gds_not_present_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_not_present_bitmap_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_gds_not_present_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index f118d45e3..0c522cadd 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -1,11 +1,18 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + #include "grib_accessor.h" #include "grib_accessor_class_gen.h" #include // ======================== grib_accessor_gen ======================== - - - void grib_accessor_gen_t::dump(grib_dumper* f) { return cclass->dump(this, f); diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h index 9baf3e2dd..deba6cad2 100644 --- a/src/accessor/grib_accessor_class_gen.h +++ b/src/accessor/grib_accessor_class_gen.h @@ -1,3 +1,13 @@ +/* + * (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. + */ + #pragma once #include "grib_api_internal.h" diff --git a/src/accessor/grib_accessor_class_gen.h.bak b/src/accessor/grib_accessor_class_gen.h.bak deleted file mode 100644 index 2d76361ae..000000000 --- a/src/accessor/grib_accessor_class_gen.h.bak +++ /dev/null @@ -1,158 +0,0 @@ -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor.h" -#include - -class grib_accessor_gen_t : public grib_accessor { - void init_accessor(const long, grib_arguments*) override; - void dump(grib_dumper* f) override; - int pack_missing() override; - //int grib_pack_zero(grib_accessor* a) override; - int is_missing_internal() override; - int pack_double(const double* v, size_t* len) override; - int pack_float(const float* v, size_t* len) override; - int pack_expression(grib_expression* e) override; - int pack_string(const char* v, size_t* len) override; - int pack_string_array(const char** v, size_t* len) override; - int pack_long(const long* v, size_t* len) override; - int pack_bytes(const unsigned char* v, size_t* len) override; - int unpack_bytes(unsigned char* v, size_t* len) override; - int unpack_double_subarray(double* v, size_t start, size_t len) override; - int unpack_double(double* v, size_t* len) override; - int unpack_float(float* v, size_t* len) override; - int unpack_double_element(size_t i, double* v) override; - int unpack_float_element(size_t i, float* v) override; - int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override; - int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) override; - int unpack_string(char* v, size_t* len) override; - int unpack_string_array(char** v, size_t* len) override; - int unpack_long(long* v, size_t* len) override; - long get_native_type() override; - long get_next_position_offset() override; - long string_length() override; - long byte_offset() override; - long byte_count() override; - int value_count(long* count) override; - int notify_change(grib_accessor* changed) override; - grib_accessor* clone(grib_section* s, int* err) override; - void update_size(size_t len) override; - int nearest_smaller_value(double val, double* nearest) override; - size_t preferred_size(int from_handle) override; - grib_accessor* next_accessor() override; - void resize(size_t new_size) override; - void destroy(grib_context* ct) override; -}; - -class grib_accessor_class_gen_t : public grib_accessor_class -{ -public: - grib_accessor_class_gen_t(const char* name) : grib_accessor_class{name} {} - ~grib_accessor_class_gen_t(); - - grib_accessor* create_empty_accessor() override{ return new grib_accessor_gen_t(); } - grib_section* sub_section(grib_accessor* a) override; - int get_native_type(grib_accessor*) override; - int pack_missing(grib_accessor*) override; - int is_missing(grib_accessor*) override; - int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_float(grib_accessor*, const float* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int pack_string_array(grib_accessor*, const char**, size_t* len) override; - int pack_expression(grib_accessor*, grib_expression*) override; - int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - size_t string_length(grib_accessor*) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void post_init(grib_accessor*) override; - int notify_change(grib_accessor*, grib_accessor*) override; - void update_size(grib_accessor*, size_t) override; - size_t preferred_size(grib_accessor*, int) override; - void resize(grib_accessor*, size_t) override; - int nearest_smaller_value(grib_accessor*, double, double*) override; - grib_accessor* next(grib_accessor*, int) override; - int compare(grib_accessor*, grib_accessor*) override; - int unpack_double_element(grib_accessor*, size_t i, double* val) override; - int unpack_float_element(grib_accessor*, size_t i, float* val) override; - int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) override; - int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; - int clear(grib_accessor*) override; - grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; - - template - int unpack_helper(grib_accessor* a, T* v, size_t* len); - -private: - enum { - PACK_DOUBLE, - PACK_FLOAT, - PACK_LONG, - PACK_STRING, - UNPACK_DOUBLE, - UNPACK_FLOAT, - UNPACK_LONG, - UNPACK_STRING, - }; - std::bitset<8> is_overridden_ = 0b11111111; -}; - - -template -int grib_accessor_class_gen_t::unpack_helper(grib_accessor* a, T* v, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - int type = GRIB_TYPE_UNDEFINED; - const char* Tname = type_to_string(*v); - - if constexpr (std::is_same_v) { - is_overridden_[UNPACK_FLOAT] = 0; - } - else if constexpr (std::is_same_v) { - is_overridden_[UNPACK_DOUBLE] = 0; - } - - if (is_overridden_[UNPACK_LONG]) { - long val = 0; - size_t l = 1; - a->unpack_long(&val, &l); - if (is_overridden_[UNPACK_LONG]) { - *v = val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - - if (is_overridden_[UNPACK_STRING]) { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - a->unpack_string(val, &l); - if (is_overridden_[UNPACK_STRING]) { - *v = strtod(val, &last); - if (*last == 0) { /* conversion of string to double worked */ - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/accessor/grib_accessor_class_getenv.h.bak b/src/accessor/grib_accessor_class_getenv.h.bak deleted file mode 100644 index 5068dad2c..000000000 --- a/src/accessor/grib_accessor_class_getenv.h.bak +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (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. - */ - -#ifndef eccodes_accessor_getenv_h -#define eccodes_accessor_getenv_h - -#include "grib_accessor_class_ascii.h" - -class grib_accessor_getenv_t : public grib_accessor_ascii_t -{ -public: - const char* name; - char* value; - const char* default_value; -}; - -class grib_accessor_class_getenv_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_getenv_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_getenv_t{}; } - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; - -#endif /* eccodes_accessor_getenv_h */ diff --git a/src/accessor/grib_accessor_class_global_gaussian.h.bak b/src/accessor/grib_accessor_class_global_gaussian.h.bak deleted file mode 100644 index f1e8bf53b..000000000 --- a/src/accessor/grib_accessor_class_global_gaussian.h.bak +++ /dev/null @@ -1,44 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_global_gaussian_h -#define eccodes_accessor_global_gaussian_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_global_gaussian_t : public grib_accessor_long_t -{ -public: - /* Members defined in global_gaussian */ - const char* N; - const char* Ni; - const char* di; - const char* latfirst; - const char* lonfirst; - const char* latlast; - const char* lonlast; - const char* plpresent; - const char* pl; - const char* basic_angle; - const char* subdivision; -}; - -class grib_accessor_class_global_gaussian_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_global_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_global_gaussian_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_global_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_group.h.bak b/src/accessor/grib_accessor_class_group.h.bak deleted file mode 100644 index 085b91a8a..000000000 --- a/src/accessor/grib_accessor_class_group.h.bak +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_group_h -#define eccodes_accessor_group_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_group_t : public grib_accessor_gen_t -{ -public: - /* Members defined in group */ - char endCharacter; -}; - -class grib_accessor_class_group_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_group_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_group_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_group_h */ diff --git a/src/accessor/grib_accessor_class_gts_header.h.bak b/src/accessor/grib_accessor_class_gts_header.h.bak deleted file mode 100644 index c164a9df9..000000000 --- a/src/accessor/grib_accessor_class_gts_header.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_gts_header_h -#define eccodes_accessor_gts_header_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_gts_header_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in gts_header */ - int gts_offset; - int gts_length; -}; - -class grib_accessor_class_gts_header_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_gts_header_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_gts_header_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_gts_header_h */ diff --git a/src/accessor/grib_accessor_class_hash_array.h.bak b/src/accessor/grib_accessor_class_hash_array.h.bak deleted file mode 100644 index 78856c7e7..000000000 --- a/src/accessor/grib_accessor_class_hash_array.h.bak +++ /dev/null @@ -1,45 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_hash_array_h -#define eccodes_accessor_hash_array_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_hash_array_t : public grib_accessor_gen_t -{ -public: - /* Members defined in hash_array */ - char* key; - grib_hash_array_value* ha; -}; - -class grib_accessor_class_hash_array_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_hash_array_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_hash_array_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_hash_array_h */ diff --git a/src/accessor/grib_accessor_class_headers_only.h.bak b/src/accessor/grib_accessor_class_headers_only.h.bak deleted file mode 100644 index 29d7e8bf5..000000000 --- a/src/accessor/grib_accessor_class_headers_only.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_headers_only_h -#define eccodes_accessor_headers_only_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_headers_only_t : public grib_accessor_gen_t -{ -public: - /* Members defined in headers_only */ -}; - -class grib_accessor_class_headers_only_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_headers_only_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_headers_only_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_headers_only_h */ diff --git a/src/accessor/grib_accessor_class_ibmfloat.h.bak b/src/accessor/grib_accessor_class_ibmfloat.h.bak deleted file mode 100644 index d98864516..000000000 --- a/src/accessor/grib_accessor_class_ibmfloat.h.bak +++ /dev/null @@ -1,71 +0,0 @@ -/* - * (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. - */ - -#ifndef eccodes_accessor_ibmfloat_h -#define eccodes_accessor_ibmfloat_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_ibmfloat_t : public grib_accessor_double_t -{ -public: - /* Members defined in ibmfloat */ - grib_arguments* arg; -}; - -class grib_accessor_class_ibmfloat_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_ibmfloat_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_ibmfloat_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - int nearest_smaller_value(grib_accessor*, double, double*) override; -private: - template int unpack(grib_accessor*, T*, size_t*); -}; - - -template -int grib_accessor_class_ibmfloat_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - unsigned long rlen = 0; - long count = 0; - int err = 0; - unsigned long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&count); if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -#endif /* eccodes_accessor_ibmfloat_h */ diff --git a/src/accessor/grib_accessor_class_ieeefloat.h.bak b/src/accessor/grib_accessor_class_ieeefloat.h.bak deleted file mode 100644 index 100b2ad6a..000000000 --- a/src/accessor/grib_accessor_class_ieeefloat.h.bak +++ /dev/null @@ -1,66 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_ieeefloat_h -#define eccodes_accessor_ieeefloat_h - -#include "grib_accessor_class_double.h" - -class grib_accessor_ieeefloat_t : public grib_accessor_double_t -{ -public: - grib_arguments* arg; -}; - -class grib_accessor_class_ieeefloat_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_ieeefloat_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_ieeefloat_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); -}; - - -template -int grib_accessor_class_ieeefloat_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long rlen = 0; - int err = 0; - long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&rlen); if (err) - return err; - - if (*len < (size_t)rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -#endif /* eccodes_accessor_ieeefloat_h */ diff --git a/src/accessor/grib_accessor_class_ifs_param.h.bak b/src/accessor/grib_accessor_class_ifs_param.h.bak deleted file mode 100644 index d41da1723..000000000 --- a/src/accessor/grib_accessor_class_ifs_param.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_ifs_param_h -#define eccodes_accessor_ifs_param_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_ifs_param_t : public grib_accessor_gen_t -{ -public: - /* Members defined in ifs_param */ - const char* paramId; - const char* type; -}; - -class grib_accessor_class_ifs_param_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_ifs_param_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_ifs_param_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_ifs_param_h */ diff --git a/src/accessor/grib_accessor_class_iterator.h.bak b/src/accessor/grib_accessor_class_iterator.h.bak deleted file mode 100644 index 7288fa205..000000000 --- a/src/accessor/grib_accessor_class_iterator.h.bak +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (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. - */ - -/*************************** - * Enrico Fucile - *************************/ - -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_iterator_t : public grib_accessor_gen_t -{ -public: - grib_arguments* args; -}; - -class grib_accessor_class_iterator_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_iterator_t(const char* name) : grib_accessor_class_gen_t(name) {}; - grib_accessor* create_empty_accessor() override { return new grib_accessor_iterator_t{}; } - void init(grib_accessor* a, const long l, grib_arguments* args) override; - void dump(grib_accessor* a, grib_dumper* dumper) override; -}; - - -//grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) diff --git a/src/accessor/grib_accessor_class_julian_date.h.bak b/src/accessor/grib_accessor_class_julian_date.h.bak deleted file mode 100644 index 68008fec6..000000000 --- a/src/accessor/grib_accessor_class_julian_date.h.bak +++ /dev/null @@ -1,48 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_julian_date_h -#define eccodes_accessor_julian_date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_julian_date_t : public grib_accessor_double_t -{ -public: - /* Members defined in julian_date */ - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; - const char *ymd; - const char *hms; - char sep[5]; -}; - -class grib_accessor_class_julian_date_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_julian_date_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_date_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int pack_expression(grib_accessor*, grib_expression*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_julian_date_h */ diff --git a/src/accessor/grib_accessor_class_julian_day.h.bak b/src/accessor/grib_accessor_class_julian_day.h.bak deleted file mode 100644 index 1d21fb920..000000000 --- a/src/accessor/grib_accessor_class_julian_day.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_julian_day_h -#define eccodes_accessor_julian_day_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_julian_day_t : public grib_accessor_double_t -{ -public: - /* Members defined in julian_day */ - const char *date; - const char *hour; - const char *minute; - const char *second; -}; - -class grib_accessor_class_julian_day_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_julian_day_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_day_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_julian_day_h */ diff --git a/src/accessor/grib_accessor_class_ksec1expver.h.bak b/src/accessor/grib_accessor_class_ksec1expver.h.bak deleted file mode 100644 index 3884a7709..000000000 --- a/src/accessor/grib_accessor_class_ksec1expver.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_ksec1expver_h -#define eccodes_accessor_ksec1expver_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in ksec1expver */ -}; - -class grib_accessor_class_ksec1expver_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_ksec1expver_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_ksec1expver_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_ksec1expver_h */ diff --git a/src/accessor/grib_accessor_class_label.h.bak b/src/accessor/grib_accessor_class_label.h.bak deleted file mode 100644 index c4e64b322..000000000 --- a/src/accessor/grib_accessor_class_label.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_label_h -#define eccodes_accessor_label_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_label_t : public grib_accessor_gen_t -{ -public: - /* Members defined in label */ -}; - -class grib_accessor_class_label_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_label_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_label_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_label_h */ diff --git a/src/accessor/grib_accessor_class_latitudes.h.bak b/src/accessor/grib_accessor_class_latitudes.h.bak deleted file mode 100644 index 10344c7cb..000000000 --- a/src/accessor/grib_accessor_class_latitudes.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_latitudes_h -#define eccodes_accessor_latitudes_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_latitudes_t : public grib_accessor_double_t -{ -public: - /* Members defined in latitudes */ - const char* values; - long distinct; - double* lats; - long size; - int save; -}; - -class grib_accessor_class_latitudes_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_latitudes_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_latitudes_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_latitudes_h */ diff --git a/src/accessor/grib_accessor_class_latlon_increment.h.bak b/src/accessor/grib_accessor_class_latlon_increment.h.bak deleted file mode 100644 index 4f5402e6a..000000000 --- a/src/accessor/grib_accessor_class_latlon_increment.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_latlon_increment_h -#define eccodes_accessor_latlon_increment_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_latlon_increment_t : public grib_accessor_double_t -{ -public: - /* Members defined in latlon_increment */ - const char* directionIncrementGiven; - const char* directionIncrement; - const char* scansPositively; - const char* first; - const char* last; - const char* numberOfPoints; - const char* angleMultiplier; - const char* angleDivisor; - long isLongitude; -}; - -class grib_accessor_class_latlon_increment_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_latlon_increment_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_latlon_increment_t{}; } - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_latlon_increment_h */ diff --git a/src/accessor/grib_accessor_class_latlonvalues.h.bak b/src/accessor/grib_accessor_class_latlonvalues.h.bak deleted file mode 100644 index ed040f543..000000000 --- a/src/accessor/grib_accessor_class_latlonvalues.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_latlonvalues_h -#define eccodes_accessor_latlonvalues_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_latlonvalues_t : public grib_accessor_double_t -{ -public: - /* Members defined in latlonvalues */ - const char* values; -}; - -class grib_accessor_class_latlonvalues_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_latlonvalues_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_latlonvalues_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_latlonvalues_h */ diff --git a/src/accessor/grib_accessor_class_library_version.h.bak b/src/accessor/grib_accessor_class_library_version.h.bak deleted file mode 100644 index 28de10364..000000000 --- a/src/accessor/grib_accessor_class_library_version.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_library_version_h -#define eccodes_accessor_library_version_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_library_version_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in library_version */ -}; - -class grib_accessor_class_library_version_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_library_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_library_version_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; -}; -#endif /* eccodes_accessor_library_version_h */ diff --git a/src/accessor/grib_accessor_class_local_definition.h.bak b/src/accessor/grib_accessor_class_local_definition.h.bak deleted file mode 100644 index 296bab69d..000000000 --- a/src/accessor/grib_accessor_class_local_definition.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_local_definition_h -#define eccodes_accessor_local_definition_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_local_definition_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in local_definition */ - const char* productDefinitionTemplateNumber; - const char* productDefinitionTemplateNumberInternal; - const char* grib2LocalSectionNumber; - const char* type; - const char* stream; - const char* the_class; - const char* eps; - const char* stepType; - const char* derivedForecast; -}; - -class grib_accessor_class_local_definition_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_local_definition_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_local_definition_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_local_definition_h */ diff --git a/src/accessor/grib_accessor_class_long.cc b/src/accessor/grib_accessor_class_long.cc index 89d757acb..588083c49 100644 --- a/src/accessor/grib_accessor_class_long.cc +++ b/src/accessor/grib_accessor_class_long.cc @@ -1,3 +1,13 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + #include "grib_accessor_class_long.h" grib_accessor_class_long_t _grib_accessor_class_long{"long"}; diff --git a/src/accessor/grib_accessor_class_long.h b/src/accessor/grib_accessor_class_long.h index acabf2612..fea39235e 100644 --- a/src/accessor/grib_accessor_class_long.h +++ b/src/accessor/grib_accessor_class_long.h @@ -1,3 +1,13 @@ +/* + * (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. + */ + #pragma once #include "grib_api_internal.h" diff --git a/src/accessor/grib_accessor_class_long.h.bak b/src/accessor/grib_accessor_class_long.h.bak deleted file mode 100644 index a0b01f9ae..000000000 --- a/src/accessor/grib_accessor_class_long.h.bak +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_long_t : public grib_accessor_gen_t -{}; - -class grib_accessor_class_long_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_long_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_long_t{}; } - void init(grib_accessor* a, const long len, grib_arguments* arg) override; - int get_native_type(grib_accessor* a) override; - int pack_missing(grib_accessor* a) override; - int pack_string(grib_accessor* a, const char*, size_t* len) override; - int unpack_double(grib_accessor* a, double* val, size_t* len) override; - int unpack_string(grib_accessor* a, char*, size_t* len) override; - void dump(grib_accessor* a, grib_dumper*) override; - int compare(grib_accessor* a, grib_accessor*) override; -}; diff --git a/src/accessor/grib_accessor_class_long_vector.h.bak b/src/accessor/grib_accessor_class_long_vector.h.bak deleted file mode 100644 index 66fab29e6..000000000 --- a/src/accessor/grib_accessor_class_long_vector.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_long_vector_h -#define eccodes_accessor_long_vector_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_abstract_long_vector.h" - -class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t -{ -public: - /* Members defined in long_vector */ - const char* vector; - int index; -}; - -class grib_accessor_class_long_vector_t : public grib_accessor_class_abstract_long_vector_t -{ -public: - grib_accessor_class_long_vector_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_long_vector_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_longitudes.h.bak b/src/accessor/grib_accessor_class_longitudes.h.bak deleted file mode 100644 index 782b4d764..000000000 --- a/src/accessor/grib_accessor_class_longitudes.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_longitudes_h -#define eccodes_accessor_longitudes_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_longitudes_t : public grib_accessor_double_t -{ -public: - /* Members defined in longitudes */ - const char* values; - long distinct; - double* lons; - long size; - int save; -}; - -class grib_accessor_class_longitudes_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_longitudes_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_longitudes_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_longitudes_h */ diff --git a/src/accessor/grib_accessor_class_lookup.h.bak b/src/accessor/grib_accessor_class_lookup.h.bak deleted file mode 100644 index 1fba42fe5..000000000 --- a/src/accessor/grib_accessor_class_lookup.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_lookup_h -#define eccodes_accessor_lookup_h - -#include "grib_accessor_class_long.h" - -class grib_accessor_lookup_t : public grib_accessor_long_t -{ -public: - long llength; - long loffset; - grib_expression* real_name; -}; - -class grib_accessor_class_lookup_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_lookup_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_lookup_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void post_init(grib_accessor*) override; - int notify_change(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_lookup_h */ diff --git a/src/accessor/grib_accessor_class_mars_param.h.bak b/src/accessor/grib_accessor_class_mars_param.h.bak deleted file mode 100644 index 87bcaad41..000000000 --- a/src/accessor/grib_accessor_class_mars_param.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_mars_param_h -#define eccodes_accessor_mars_param_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_mars_param_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in mars_param */ - const char* paramId; - const char* table; - const char* param; -}; - -class grib_accessor_class_mars_param_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_mars_param_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_param_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_mars_param_h */ diff --git a/src/accessor/grib_accessor_class_mars_step.h.bak b/src/accessor/grib_accessor_class_mars_step.h.bak deleted file mode 100644 index db3042648..000000000 --- a/src/accessor/grib_accessor_class_mars_step.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_mars_step_h -#define eccodes_accessor_mars_step_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_mars_step_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in mars_step */ - const char* stepRange; - const char* stepType; -}; - -class grib_accessor_class_mars_step_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_mars_step_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_step_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_mars_step_h */ diff --git a/src/accessor/grib_accessor_class_md5.h.bak b/src/accessor/grib_accessor_class_md5.h.bak deleted file mode 100644 index 8d819cc9d..000000000 --- a/src/accessor/grib_accessor_class_md5.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_md5_h -#define eccodes_accessor_md5_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_md5_t : public grib_accessor_gen_t -{ -public: - /* Members defined in md5 */ - const char* offset; - grib_expression* length; - grib_string_list* blocklist; -}; - -class grib_accessor_class_md5_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_md5_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_md5_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_md5_h */ diff --git a/src/accessor/grib_accessor_class_message.h.bak b/src/accessor/grib_accessor_class_message.h.bak deleted file mode 100644 index 912e8be4b..000000000 --- a/src/accessor/grib_accessor_class_message.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_message_h -#define eccodes_accessor_message_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_bytes.h" - -class grib_accessor_message_t : public grib_accessor_bytes_t -{ -public: - /* Members defined in message */ -}; - -class grib_accessor_class_message_t : public grib_accessor_class_bytes_t -{ -public: - grib_accessor_class_message_t(const char* name) : grib_accessor_class_bytes_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_message_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - void resize(grib_accessor*,size_t) override; -}; -#endif /* eccodes_accessor_message_h */ diff --git a/src/accessor/grib_accessor_class_message_copy.h.bak b/src/accessor/grib_accessor_class_message_copy.h.bak deleted file mode 100644 index 37072c685..000000000 --- a/src/accessor/grib_accessor_class_message_copy.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_message_copy_h -#define eccodes_accessor_message_copy_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_message_copy_t : public grib_accessor_gen_t -{ -public: - /* Members defined in message_copy */ -}; - -class grib_accessor_class_message_copy_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_message_copy_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_message_copy_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long byte_count(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_message_copy_h */ diff --git a/src/accessor/grib_accessor_class_multdouble.h.bak b/src/accessor/grib_accessor_class_multdouble.h.bak deleted file mode 100644 index 9d6d76285..000000000 --- a/src/accessor/grib_accessor_class_multdouble.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_multdouble_h -#define eccodes_accessor_multdouble_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_multdouble_t : public grib_accessor_double_t -{ -public: - /* Members defined in multdouble */ - const char* val; - double multiplier; -}; - -class grib_accessor_class_multdouble_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_multdouble_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_multdouble_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_multdouble_h */ diff --git a/src/accessor/grib_accessor_class_nearest.h.bak b/src/accessor/grib_accessor_class_nearest.h.bak deleted file mode 100644 index 831afea60..000000000 --- a/src/accessor/grib_accessor_class_nearest.h.bak +++ /dev/null @@ -1,33 +0,0 @@ -/* - * (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. - */ - -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_nearest_t : public grib_accessor_gen_t -{ -public: - grib_arguments* args; -}; - - -class grib_accessor_class_nearest_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_nearest_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_nearest_t{}; } - void init(grib_accessor* a, const long l, grib_arguments* args) override; - void dump(grib_accessor* a, grib_dumper* dumper) override; -}; - - -//grib_nearest* grib_nearest_new(const grib_handle* ch, int* error); diff --git a/src/accessor/grib_accessor_class_non_alpha.h.bak b/src/accessor/grib_accessor_class_non_alpha.h.bak deleted file mode 100644 index 1b1b9d830..000000000 --- a/src/accessor/grib_accessor_class_non_alpha.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_non_alpha_h -#define eccodes_accessor_non_alpha_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_non_alpha_t : public grib_accessor_gen_t -{ -public: - /* Members defined in non_alpha */ -}; - -class grib_accessor_class_non_alpha_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_non_alpha_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_non_alpha_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_non_alpha_h */ diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h.bak b/src/accessor/grib_accessor_class_number_of_coded_values.h.bak deleted file mode 100644 index de5e3b76b..000000000 --- a/src/accessor/grib_accessor_class_number_of_coded_values.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_number_of_coded_values_h -#define eccodes_accessor_number_of_coded_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t -{ -public: - /* Members defined in number_of_coded_values */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -}; - -class grib_accessor_class_number_of_coded_values_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_number_of_coded_values_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_coded_values_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_number_of_coded_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points.h.bak b/src/accessor/grib_accessor_class_number_of_points.h.bak deleted file mode 100644 index db3521c05..000000000 --- a/src/accessor/grib_accessor_class_number_of_points.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_number_of_points_h -#define eccodes_accessor_number_of_points_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_number_of_points_t : public grib_accessor_long_t -{ -public: - /* Members defined in number_of_points */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; -}; - -class grib_accessor_class_number_of_points_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_number_of_points_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_number_of_points_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak b/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak deleted file mode 100644 index f01224f17..000000000 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_number_of_points_gaussian_h -#define eccodes_accessor_number_of_points_gaussian_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t -{ -public: - /* Members defined in number_of_points_gaussian */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; - const char* order; - const char* lat_first; - const char* lon_first; - const char* lat_last; - const char* lon_last; - const char* support_legacy; -}; - -class grib_accessor_class_number_of_points_gaussian_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_number_of_points_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_gaussian_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_number_of_points_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values.h.bak b/src/accessor/grib_accessor_class_number_of_values.h.bak deleted file mode 100644 index 88b18cd6f..000000000 --- a/src/accessor/grib_accessor_class_number_of_values.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_number_of_values_h -#define eccodes_accessor_number_of_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_number_of_values_t : public grib_accessor_long_t -{ -public: - /* Members defined in number_of_values */ - const char* values; - const char* bitsPerValue; - const char* numberOfPoints; - const char* bitmapPresent; - const char* bitmap; - const char* numberOfCodedValues; -}; - -class grib_accessor_class_number_of_values_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_number_of_values_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_number_of_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak deleted file mode 100644 index c0a6e9fcb..000000000 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_number_of_values_data_raw_packing_h -#define eccodes_accessor_number_of_values_data_raw_packing_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t -{ -public: - /* Members defined in number_of_values_data_raw_packing */ - const char* values; - const char* precision; -}; - -class grib_accessor_class_number_of_values_data_raw_packing_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_number_of_values_data_raw_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_data_raw_packing_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_number_of_values_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak b/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak deleted file mode 100644 index 31784d000..000000000 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_octahedral_gaussian_h -#define eccodes_accessor_octahedral_gaussian_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t -{ -public: - /* Members defined in octahedral_gaussian */ - const char* N; - const char* Ni; - const char* plpresent; - const char* pl; -}; - -class grib_accessor_class_octahedral_gaussian_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_octahedral_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_octahedral_gaussian_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_octahedral_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_octet_number.h.bak b/src/accessor/grib_accessor_class_octet_number.h.bak deleted file mode 100644 index 4d6145742..000000000 --- a/src/accessor/grib_accessor_class_octet_number.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_octet_number_h -#define eccodes_accessor_octet_number_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_octet_number_t : public grib_accessor_long_t -{ -public: - /* Members defined in octet_number */ - const char* left; - long right; -}; - -class grib_accessor_class_octet_number_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_octet_number_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_octet_number_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_octet_number_h */ diff --git a/src/accessor/grib_accessor_class_offset_file.h.bak b/src/accessor/grib_accessor_class_offset_file.h.bak deleted file mode 100644 index 34243b5a4..000000000 --- a/src/accessor/grib_accessor_class_offset_file.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_offset_file_h -#define eccodes_accessor_offset_file_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_offset_file_t : public grib_accessor_double_t -{ -public: - /* Members defined in offset_file */ -}; - -class grib_accessor_class_offset_file_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_offset_file_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_file_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_offset_file_h */ diff --git a/src/accessor/grib_accessor_class_offset_values.h.bak b/src/accessor/grib_accessor_class_offset_values.h.bak deleted file mode 100644 index 51e0f0f16..000000000 --- a/src/accessor/grib_accessor_class_offset_values.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_offset_values_h -#define eccodes_accessor_offset_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_offset_values_t : public grib_accessor_double_t -{ -public: - /* Members defined in offset_values */ - const char* values; - const char* missingValue; -}; - -class grib_accessor_class_offset_values_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_offset_values_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_values_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_offset_values_h */ diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h.bak b/src/accessor/grib_accessor_class_optimal_step_units.h.bak deleted file mode 100644 index 96383b291..000000000 --- a/src/accessor/grib_accessor_class_optimal_step_units.h.bak +++ /dev/null @@ -1,44 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_optimal_step_units_h -#define eccodes_accessor_optimal_step_units_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_optimal_step_units_t : public grib_accessor_gen_t -{ -public: - /* Members defined in optimal_step_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* time_range_value; - const char* time_range_unit; -}; - -class grib_accessor_class_optimal_step_units_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_optimal_step_units_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_optimal_step_units_t{}; } - int get_native_type(grib_accessor*) override; - int is_missing(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int pack_expression(grib_accessor*, grib_expression*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_optimal_step_units_h */ diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h.bak b/src/accessor/grib_accessor_class_pack_bufr_values.h.bak deleted file mode 100644 index b4bdaf43c..000000000 --- a/src/accessor/grib_accessor_class_pack_bufr_values.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_pack_bufr_values_h -#define eccodes_accessor_pack_bufr_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t -{ -public: - /* Members defined in pack_bufr_values */ - grib_accessor* data_accessor; -}; - -class grib_accessor_class_pack_bufr_values_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_pack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_pack_bufr_values_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_pack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_packing_type.h.bak b/src/accessor/grib_accessor_class_packing_type.h.bak deleted file mode 100644 index 3451db189..000000000 --- a/src/accessor/grib_accessor_class_packing_type.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_packing_type_h -#define eccodes_accessor_packing_type_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_packing_type_t : public grib_accessor_gen_t -{ -public: - /* Members defined in packing_type */ - const char* values; - const char* packing_type; -}; - -class grib_accessor_class_packing_type_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_packing_type_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_packing_type_t{}; } - int get_native_type(grib_accessor*) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_packing_type_h */ diff --git a/src/accessor/grib_accessor_class_pad.h.bak b/src/accessor/grib_accessor_class_pad.h.bak deleted file mode 100644 index 8ca8bb09b..000000000 --- a/src/accessor/grib_accessor_class_pad.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_pad_h -#define eccodes_accessor_pad_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_padding.h" - -class grib_accessor_pad_t : public grib_accessor_padding_t -{ -public: - /* Members defined in padding */ - /* Members defined in pad */ - grib_expression* expression; -}; - -class grib_accessor_class_pad_t : public grib_accessor_class_padding_t -{ -public: - grib_accessor_class_pad_t(const char* name) : grib_accessor_class_padding_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_pad_t{}; } - void init(grib_accessor*, const long, grib_arguments*) override; - size_t preferred_size(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_pad_h */ diff --git a/src/accessor/grib_accessor_class_padding.h.bak b/src/accessor/grib_accessor_class_padding.h.bak deleted file mode 100644 index 65a416c4c..000000000 --- a/src/accessor/grib_accessor_class_padding.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_padding_h -#define eccodes_accessor_padding_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_bytes.h" - -class grib_accessor_padding_t : public grib_accessor_bytes_t -{ -public: - /* Members defined in padding */ -}; - -class grib_accessor_class_padding_t : public grib_accessor_class_bytes_t -{ -public: - grib_accessor_class_padding_t(const char* name) : grib_accessor_class_bytes_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_padding_t{}; } - size_t string_length(grib_accessor*) override; - long byte_count(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - void resize(grib_accessor*,size_t) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_padding_h */ diff --git a/src/accessor/grib_accessor_class_padto.h.bak b/src/accessor/grib_accessor_class_padto.h.bak deleted file mode 100644 index f7203b2cb..000000000 --- a/src/accessor/grib_accessor_class_padto.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_padto_h -#define eccodes_accessor_padto_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_padding.h" - -class grib_accessor_padto_t : public grib_accessor_padding_t -{ -public: - /* Members defined in padto */ - grib_expression* expression; -}; - -class grib_accessor_class_padto_t : public grib_accessor_class_padding_t -{ -public: - grib_accessor_class_padto_t(const char* name) : grib_accessor_class_padding_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_padto_t{}; } - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - size_t preferred_size(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_padto_h */ diff --git a/src/accessor/grib_accessor_class_padtoeven.h.bak b/src/accessor/grib_accessor_class_padtoeven.h.bak deleted file mode 100644 index 08f8fc072..000000000 --- a/src/accessor/grib_accessor_class_padtoeven.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_padtoeven_h -#define eccodes_accessor_padtoeven_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_padding.h" - -class grib_accessor_padtoeven_t : public grib_accessor_padding_t -{ -public: - /* Members defined in padtoeven */ - const char* section_offset; - const char* section_length; -}; - -class grib_accessor_class_padtoeven_t : public grib_accessor_class_padding_t -{ -public: - grib_accessor_class_padtoeven_t(const char* name) : grib_accessor_class_padding_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_padtoeven_t{}; } - void init(grib_accessor*, const long, grib_arguments*) override; - size_t preferred_size(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_padtoeven_h */ diff --git a/src/accessor/grib_accessor_class_padtomultiple.h.bak b/src/accessor/grib_accessor_class_padtomultiple.h.bak deleted file mode 100644 index f57afad37..000000000 --- a/src/accessor/grib_accessor_class_padtomultiple.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_padtomultiple_h -#define eccodes_accessor_padtomultiple_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_padding.h" - -class grib_accessor_padtomultiple_t : public grib_accessor_padding_t -{ -public: - /* Members defined in padtomultiple */ - grib_expression* begin; - grib_expression* multiple; -}; - -class grib_accessor_class_padtomultiple_t : public grib_accessor_class_padding_t -{ -public: - grib_accessor_class_padtomultiple_t(const char* name) : grib_accessor_class_padding_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_padtomultiple_t{}; } - void init(grib_accessor*, const long, grib_arguments*) override; - size_t preferred_size(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_padtomultiple_h */ diff --git a/src/accessor/grib_accessor_class_position.h.bak b/src/accessor/grib_accessor_class_position.h.bak deleted file mode 100644 index 40d690694..000000000 --- a/src/accessor/grib_accessor_class_position.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_position_h -#define eccodes_accessor_position_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_position_t : public grib_accessor_gen_t -{ -public: - /* Members defined in position */ -}; - -class grib_accessor_class_position_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_position_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_position_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_position_h */ diff --git a/src/accessor/grib_accessor_class_proj_string.h.bak b/src/accessor/grib_accessor_class_proj_string.h.bak deleted file mode 100644 index c49c0f868..000000000 --- a/src/accessor/grib_accessor_class_proj_string.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_proj_string_h -#define eccodes_accessor_proj_string_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_proj_string_t : public grib_accessor_gen_t -{ -public: - /* Members defined in proj_string */ - const char* grid_type; - int endpoint; -}; - -class grib_accessor_class_proj_string_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_proj_string_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_proj_string_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_proj_string_h */ diff --git a/src/accessor/grib_accessor_class_raw.h.bak b/src/accessor/grib_accessor_class_raw.h.bak deleted file mode 100644 index 30a2603e7..000000000 --- a/src/accessor/grib_accessor_class_raw.h.bak +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_raw_h -#define eccodes_accessor_raw_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_raw_t : public grib_accessor_gen_t -{ -public: - /* Members defined in raw */ - const char* totalLength; - const char* sectionLength; - long relativeOffset; -}; - -class grib_accessor_class_raw_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_raw_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_raw_t{}; } - int get_native_type(grib_accessor*) override; - int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; - int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; - long byte_count(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_raw_h */ diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak b/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak deleted file mode 100644 index e9ef0b4d3..000000000 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_rdbtime_guess_date_h -#define eccodes_accessor_rdbtime_guess_date_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t -{ -public: - /* Members defined in rdbtime_guess_date */ - const char* typicalYear; - const char* typicalMonth; - const char* typicalDay; - const char* rdbDay; - long yearOrMonth; -}; - -class grib_accessor_class_rdbtime_guess_date_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_rdbtime_guess_date_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_rdbtime_guess_date_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_rdbtime_guess_date_h */ diff --git a/src/accessor/grib_accessor_class_reference_value_error.h.bak b/src/accessor/grib_accessor_class_reference_value_error.h.bak deleted file mode 100644 index e0b948e97..000000000 --- a/src/accessor/grib_accessor_class_reference_value_error.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_reference_value_error_h -#define eccodes_accessor_reference_value_error_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_reference_value_error_t : public grib_accessor_double_t -{ -public: - /* Members defined in reference_value_error */ - const char* referenceValue; - const char* floatType; -}; - -class grib_accessor_class_reference_value_error_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_reference_value_error_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_reference_value_error_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_reference_value_error_h */ diff --git a/src/accessor/grib_accessor_class_round.h.bak b/src/accessor/grib_accessor_class_round.h.bak deleted file mode 100644 index c38d7b6e8..000000000 --- a/src/accessor/grib_accessor_class_round.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_round_h -#define eccodes_accessor_round_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_evaluate.h" - -class grib_accessor_round_t : public grib_accessor_evaluate_t -{ -public: - /* Members defined in round */ -}; - -class grib_accessor_class_round_t : public grib_accessor_class_evaluate_t -{ -public: - grib_accessor_class_round_t(const char* name) : grib_accessor_class_evaluate_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_round_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; -}; -#endif /* eccodes_accessor_round_h */ diff --git a/src/accessor/grib_accessor_class_scale.h.bak b/src/accessor/grib_accessor_class_scale.h.bak deleted file mode 100644 index 7e1f0d80d..000000000 --- a/src/accessor/grib_accessor_class_scale.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_scale_h -#define eccodes_accessor_scale_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_scale_t : public grib_accessor_double_t -{ -public: - /* Members defined in scale */ - const char* value; - const char* multiplier; - const char* divisor; - const char* truncating; -}; - -class grib_accessor_class_scale_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_scale_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_t{}; } - int is_missing(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_scale_h */ diff --git a/src/accessor/grib_accessor_class_scale_values.h.bak b/src/accessor/grib_accessor_class_scale_values.h.bak deleted file mode 100644 index cb94e16b8..000000000 --- a/src/accessor/grib_accessor_class_scale_values.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_scale_values_h -#define eccodes_accessor_scale_values_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_scale_values_t : public grib_accessor_double_t -{ -public: - /* Members defined in scale_values */ - const char* values; - const char* missingValue; -}; - -class grib_accessor_class_scale_values_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_scale_values_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_values_t{}; } - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_scale_values_h */ diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak b/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak deleted file mode 100644 index 370b364dd..000000000 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_second_order_bits_per_value_h -#define eccodes_accessor_second_order_bits_per_value_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t -{ -public: - /* Members defined in second_order_bits_per_value */ - const char* values; - const char* binaryScaleFactor; - const char* decimalScaleFactor; - long bitsPerValue; -}; - -class grib_accessor_class_second_order_bits_per_value_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_second_order_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_second_order_bits_per_value_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_second_order_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_section.h.bak b/src/accessor/grib_accessor_class_section.h.bak deleted file mode 100644 index b1905b182..000000000 --- a/src/accessor/grib_accessor_class_section.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_section_h -#define eccodes_accessor_section_h - -#include "grib_accessor_class_gen.h" - -class grib_accessor_section_t : public grib_accessor_gen_t {}; - -class grib_accessor_class_section_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_section_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_section_t{}; } - int get_native_type(grib_accessor*) override; - long byte_count(grib_accessor*) override; - long next_offset(grib_accessor*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - grib_section* sub_section(grib_accessor*) override; - grib_accessor* next(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_section_h */ diff --git a/src/accessor/grib_accessor_class_section_length.h.bak b/src/accessor/grib_accessor_class_section_length.h.bak deleted file mode 100644 index 09490bebd..000000000 --- a/src/accessor/grib_accessor_class_section_length.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_section_length_h -#define eccodes_accessor_section_length_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_section_length_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in section_length */ -}; - -class grib_accessor_class_section_length_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_section_length_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_section_length_t{}; } - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_section_length_h */ diff --git a/src/accessor/grib_accessor_class_section_padding.h.bak b/src/accessor/grib_accessor_class_section_padding.h.bak deleted file mode 100644 index b6fce7f34..000000000 --- a/src/accessor/grib_accessor_class_section_padding.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_section_padding_h -#define eccodes_accessor_section_padding_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_padding.h" - -class grib_accessor_section_padding_t : public grib_accessor_padding_t -{ -public: - /* Members defined in section_padding */ - int preserve; -}; - -class grib_accessor_class_section_padding_t : public grib_accessor_class_padding_t -{ -public: - grib_accessor_class_section_padding_t(const char* name) : grib_accessor_class_padding_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_section_padding_t{}; } - void init(grib_accessor*, const long, grib_arguments*) override; - size_t preferred_size(grib_accessor*, int) override; -}; -#endif /* eccodes_accessor_section_padding_h */ diff --git a/src/accessor/grib_accessor_class_section_pointer.h.bak b/src/accessor/grib_accessor_class_section_pointer.h.bak deleted file mode 100644 index 45e77fbb9..000000000 --- a/src/accessor/grib_accessor_class_section_pointer.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_section_pointer_h -#define eccodes_accessor_section_pointer_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_section_pointer_t : public grib_accessor_gen_t -{ -public: - /* Members defined in section_pointer */ - const char* sectionOffset; - const char* sectionLength; - long sectionNumber; -}; - -class grib_accessor_class_section_pointer_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_section_pointer_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_section_pointer_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_section_pointer_h */ diff --git a/src/accessor/grib_accessor_class_select_step_template.h.bak b/src/accessor/grib_accessor_class_select_step_template.h.bak deleted file mode 100644 index a83d3ddfd..000000000 --- a/src/accessor/grib_accessor_class_select_step_template.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_select_step_template_h -#define eccodes_accessor_select_step_template_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" - -class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t -{ -public: - /* Members defined in select_step_template */ - const char* productDefinitionTemplateNumber; - int instant; -}; - -class grib_accessor_class_select_step_template_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_select_step_template_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_select_step_template_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_select_step_template_h */ diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak b/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak deleted file mode 100644 index c9009293e..000000000 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_sexagesimal2decimal_h -#define eccodes_accessor_sexagesimal2decimal_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_to_double.h" - -class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t -{ -public: - /* Members defined in sexagesimal2decimal */ -}; - -class grib_accessor_class_sexagesimal2decimal_t : public grib_accessor_class_to_double_t -{ -public: - grib_accessor_class_sexagesimal2decimal_t(const char* name) : grib_accessor_class_to_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_sexagesimal2decimal_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_sexagesimal2decimal_h */ diff --git a/src/accessor/grib_accessor_class_signed.h.bak b/src/accessor/grib_accessor_class_signed.h.bak deleted file mode 100644 index 23c9829a4..000000000 --- a/src/accessor/grib_accessor_class_signed.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_signed_h -#define eccodes_accessor_signed_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_signed_t : public grib_accessor_long_t -{ -public: - /* Members defined in signed */ - grib_arguments* arg; - int nbytes; -}; - -class grib_accessor_class_signed_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_signed_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_t{}; } - int is_missing(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; -}; -#endif /* eccodes_accessor_signed_h */ diff --git a/src/accessor/grib_accessor_class_signed_bits.h.bak b/src/accessor/grib_accessor_class_signed_bits.h.bak deleted file mode 100644 index 96ba5f592..000000000 --- a/src/accessor/grib_accessor_class_signed_bits.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_signed_bits_h -#define eccodes_accessor_signed_bits_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_signed_bits_t : public grib_accessor_long_t -{ -public: - /* Members defined in signed_bits */ - const char* numberOfBits; - const char* numberOfElements; -}; - -class grib_accessor_class_signed_bits_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_signed_bits_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_bits_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; -}; -#endif /* eccodes_accessor_signed_bits_h */ diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h.bak b/src/accessor/grib_accessor_class_simple_packing_error.h.bak deleted file mode 100644 index 6c90188c5..000000000 --- a/src/accessor/grib_accessor_class_simple_packing_error.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_simple_packing_error_h -#define eccodes_accessor_simple_packing_error_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_simple_packing_error_t : public grib_accessor_double_t -{ -public: - /* Members defined in simple_packing_error */ - const char* binaryScaleFactor; - const char* bitsPerValue; - const char* decimalScaleFactor; - const char* referenceValue; - const char* floatType; -}; - -class grib_accessor_class_simple_packing_error_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_simple_packing_error_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_simple_packing_error_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_simple_packing_error_h */ diff --git a/src/accessor/grib_accessor_class_size.h.bak b/src/accessor/grib_accessor_class_size.h.bak deleted file mode 100644 index dbf47f8bd..000000000 --- a/src/accessor/grib_accessor_class_size.h.bak +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_size_h -#define eccodes_accessor_size_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_size_t : public grib_accessor_long_t -{ -public: - /* Members defined in size */ - const char* accessor; -}; - -class grib_accessor_class_size_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_size_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_size_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_size_h */ diff --git a/src/accessor/grib_accessor_class_smart_table.h.bak b/src/accessor/grib_accessor_class_smart_table.h.bak deleted file mode 100644 index b6146a981..000000000 --- a/src/accessor/grib_accessor_class_smart_table.h.bak +++ /dev/null @@ -1,52 +0,0 @@ -/* - * (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. - */ - -/***************************************** - * Enrico Fucile - ****************************************/ - - -#pragma once - -#include "../grib_api_internal.h" -#include "grib_accessor_class_unsigned.h" -#include - - -class grib_accessor_smart_table_t : public grib_accessor_unsigned_t -{ -public: - const char* values; - const char* tablename; - const char* masterDir; - const char* localDir; - const char* extraDir; - const char* extraTable; - int widthOfCode; - long* tableCodes; - size_t tableCodesSize; - grib_smart_table* table; - int dirty; -}; - - -class grib_accessor_class_smart_table_t : public grib_accessor_class_unsigned_t -{ -public: - grib_accessor_class_smart_table_t(const char* name) : grib_accessor_class_unsigned_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; diff --git a/src/accessor/grib_accessor_class_smart_table_column.h.bak b/src/accessor/grib_accessor_class_smart_table_column.h.bak deleted file mode 100644 index f5787f780..000000000 --- a/src/accessor/grib_accessor_class_smart_table_column.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_smart_table_column_h -#define eccodes_accessor_smart_table_column_h - -#include "grib_accessor_class_gen.h" - -class grib_accessor_smart_table_column_t : public grib_accessor_gen_t -{ -public: - const char* smartTable; - int index; -}; - -class grib_accessor_class_smart_table_column_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_smart_table_column_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_column_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_smart_table_column_h */ diff --git a/src/accessor/grib_accessor_class_spd.h.bak b/src/accessor/grib_accessor_class_spd.h.bak deleted file mode 100644 index c35e5c742..000000000 --- a/src/accessor/grib_accessor_class_spd.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_spd_h -#define eccodes_accessor_spd_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_spd_t : public grib_accessor_long_t -{ -public: - /* Members defined in spd */ - const char* numberOfBits; - const char* numberOfElements; -}; - -class grib_accessor_class_spd_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_spd_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_spd_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; -}; -#endif /* eccodes_accessor_spd_h */ diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h.bak b/src/accessor/grib_accessor_class_spectral_truncation.h.bak deleted file mode 100644 index 0ab43b1fd..000000000 --- a/src/accessor/grib_accessor_class_spectral_truncation.h.bak +++ /dev/null @@ -1,36 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_spectral_truncation_h -#define eccodes_accessor_spectral_truncation_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_spectral_truncation_t : public grib_accessor_long_t -{ -public: - /* Members defined in spectral_truncation */ - const char* J; - const char* K; - const char* M; - const char* T; -}; - -class grib_accessor_class_spectral_truncation_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_spectral_truncation_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_spectral_truncation_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_spectral_truncation_h */ diff --git a/src/accessor/grib_accessor_class_sprintf.h.bak b/src/accessor/grib_accessor_class_sprintf.h.bak deleted file mode 100644 index 9bfb1c83e..000000000 --- a/src/accessor/grib_accessor_class_sprintf.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_sprintf_h -#define eccodes_accessor_sprintf_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_sprintf_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in sprintf */ - grib_arguments* args; -}; - -class grib_accessor_class_sprintf_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_sprintf_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_sprintf_t{}; } - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_sprintf_h */ diff --git a/src/accessor/grib_accessor_class_statistics.h.bak b/src/accessor/grib_accessor_class_statistics.h.bak deleted file mode 100644 index 4eea0b546..000000000 --- a/src/accessor/grib_accessor_class_statistics.h.bak +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_statistics_h -#define eccodes_accessor_statistics_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_abstract_vector.h" - -class grib_accessor_statistics_t : public grib_accessor_abstract_vector_t -{ -public: - /* Members defined in statistics */ - const char* values; - const char* missing_value; -}; - -class grib_accessor_class_statistics_t : public grib_accessor_class_abstract_vector_t -{ -public: - grib_accessor_class_statistics_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_statistics_h */ diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h.bak b/src/accessor/grib_accessor_class_statistics_spectral.h.bak deleted file mode 100644 index 8075ddf31..000000000 --- a/src/accessor/grib_accessor_class_statistics_spectral.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_statistics_spectral_h -#define eccodes_accessor_statistics_spectral_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_abstract_vector.h" - -class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t -{ -public: - /* Members defined in statistics_spectral */ - const char* values; - const char* J; - const char* K; - const char* M; - const char* JS; -}; - -class grib_accessor_class_statistics_spectral_t : public grib_accessor_class_abstract_vector_t -{ -public: - grib_accessor_class_statistics_spectral_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_spectral_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_statistics_spectral_h */ diff --git a/src/accessor/grib_accessor_class_step_human_readable.h.bak b/src/accessor/grib_accessor_class_step_human_readable.h.bak deleted file mode 100644 index 793ecb618..000000000 --- a/src/accessor/grib_accessor_class_step_human_readable.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_step_human_readable_h -#define eccodes_accessor_step_human_readable_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_step_human_readable_t : public grib_accessor_gen_t -{ -public: - /* Members defined in step_human_readable */ - const char* stepUnits; - const char* step; -}; - -class grib_accessor_class_step_human_readable_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_step_human_readable_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_step_human_readable_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_step_human_readable_h */ diff --git a/src/accessor/grib_accessor_class_step_in_units.h.bak b/src/accessor/grib_accessor_class_step_in_units.h.bak deleted file mode 100644 index ba088db79..000000000 --- a/src/accessor/grib_accessor_class_step_in_units.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_step_in_units_h -#define eccodes_accessor_step_in_units_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_step_in_units_t : public grib_accessor_long_t -{ -public: - /* Members defined in step_in_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* step_units; - const char* time_range_unit; - const char* time_range_value; -}; - -class grib_accessor_class_step_in_units_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_step_in_units_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_step_in_units_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_step_in_units_h */ diff --git a/src/accessor/grib_accessor_class_sum.h.bak b/src/accessor/grib_accessor_class_sum.h.bak deleted file mode 100644 index ceedb788a..000000000 --- a/src/accessor/grib_accessor_class_sum.h.bak +++ /dev/null @@ -1,35 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_sum_h -#define eccodes_accessor_sum_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_double.h" - -class grib_accessor_sum_t : public grib_accessor_double_t -{ -public: - /* Members defined in sum */ - const char* values; -}; - -class grib_accessor_class_sum_t : public grib_accessor_class_double_t -{ -public: - grib_accessor_class_sum_t(const char* name) : grib_accessor_class_double_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_sum_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_sum_h */ diff --git a/src/accessor/grib_accessor_class_suppressed.h.bak b/src/accessor/grib_accessor_class_suppressed.h.bak deleted file mode 100644 index c8a93274e..000000000 --- a/src/accessor/grib_accessor_class_suppressed.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_suppressed_h -#define eccodes_accessor_suppressed_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_suppressed_t : public grib_accessor_long_t -{ -public: - /* Members defined in suppressed */ - grib_arguments* args; -}; - -class grib_accessor_class_suppressed_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_suppressed_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_suppressed_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_suppressed_h */ diff --git a/src/accessor/grib_accessor_class_time.h.bak b/src/accessor/grib_accessor_class_time.h.bak deleted file mode 100644 index b1826e1d6..000000000 --- a/src/accessor/grib_accessor_class_time.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_time_h -#define eccodes_accessor_time_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_time_t : public grib_accessor_long_t -{ -public: - /* Members defined in time */ - const char* hour; - const char* minute; - const char* second; -}; - -class grib_accessor_class_time_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_time_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_time_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_time_h */ diff --git a/src/accessor/grib_accessor_class_to_double.h.bak b/src/accessor/grib_accessor_class_to_double.h.bak deleted file mode 100644 index a2010cc1e..000000000 --- a/src/accessor/grib_accessor_class_to_double.h.bak +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_to_double_h -#define eccodes_accessor_to_double_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_to_double_t : public grib_accessor_gen_t -{ -public: - /* Members defined in to_double */ - const char* key; - long start; - size_t length; - long scale; -}; - -class grib_accessor_class_to_double_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_to_double_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_to_double_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_to_double_h */ diff --git a/src/accessor/grib_accessor_class_to_integer.h.bak b/src/accessor/grib_accessor_class_to_integer.h.bak deleted file mode 100644 index 3ee9dd87b..000000000 --- a/src/accessor/grib_accessor_class_to_integer.h.bak +++ /dev/null @@ -1,45 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_to_integer_h -#define eccodes_accessor_to_integer_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_to_integer_t : public grib_accessor_gen_t -{ -public: - /* Members defined in to_integer */ - const char* key; - long start; - size_t length; -}; - -class grib_accessor_class_to_integer_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_to_integer_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_to_integer_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_to_integer_h */ diff --git a/src/accessor/grib_accessor_class_to_string.h.bak b/src/accessor/grib_accessor_class_to_string.h.bak deleted file mode 100644 index 0907cb82c..000000000 --- a/src/accessor/grib_accessor_class_to_string.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_to_string_h -#define eccodes_accessor_to_string_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_to_string_t : public grib_accessor_gen_t -{ -public: - /* Members defined in to_string */ - const char* key; - long start; - size_t length; -}; - -class grib_accessor_class_to_string_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_to_string_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_to_string_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_to_string_h */ diff --git a/src/accessor/grib_accessor_class_transient.h.bak b/src/accessor/grib_accessor_class_transient.h.bak deleted file mode 100644 index e330ad686..000000000 --- a/src/accessor/grib_accessor_class_transient.h.bak +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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. - */ - -#pragma once - -#include "grib_accessor_class_variable.h" - -class grib_accessor_transient_t : public grib_accessor_variable_t { -public: -}; - -class grib_accessor_class_transient_t : public grib_accessor_class_variable_t { -public: - void init(grib_accessor* a, const long l, grib_arguments* args) override; - grib_accessor_class_transient_t(const char* name) : grib_accessor_class_variable_t(name) {}; - grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_t{}; } -}; - diff --git a/src/accessor/grib_accessor_class_transient_darray.h.bak b/src/accessor/grib_accessor_class_transient_darray.h.bak deleted file mode 100644 index fe918bd55..000000000 --- a/src/accessor/grib_accessor_class_transient_darray.h.bak +++ /dev/null @@ -1,41 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_transient_darray_h -#define eccodes_accessor_transient_darray_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_transient_darray_t : public grib_accessor_gen_t -{ -public: - /* Members defined in transient_darray */ - grib_darray* arr; - int type; -}; - -class grib_accessor_class_transient_darray_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_transient_darray_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_darray_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_transient_darray_h */ diff --git a/src/accessor/grib_accessor_class_trim.h.bak b/src/accessor/grib_accessor_class_trim.h.bak deleted file mode 100644 index 664ccc528..000000000 --- a/src/accessor/grib_accessor_class_trim.h.bak +++ /dev/null @@ -1,37 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_trim_h -#define eccodes_accessor_trim_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_ascii.h" - -class grib_accessor_trim_t : public grib_accessor_ascii_t -{ -public: - /* Members defined in trim */ - const char* input; - int trim_left; - int trim_right; -}; - -class grib_accessor_class_trim_t : public grib_accessor_class_ascii_t -{ -public: - grib_accessor_class_trim_t(const char* name) : grib_accessor_class_ascii_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_trim_t{}; } - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_trim_h */ diff --git a/src/accessor/grib_accessor_class_uint16.h.bak b/src/accessor/grib_accessor_class_uint16.h.bak deleted file mode 100644 index 0952e2d57..000000000 --- a/src/accessor/grib_accessor_class_uint16.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint16_h -#define eccodes_accessor_uint16_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint16_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint16 */ -}; - -class grib_accessor_class_uint16_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint16_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint16_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint16_h */ diff --git a/src/accessor/grib_accessor_class_uint32.h.bak b/src/accessor/grib_accessor_class_uint32.h.bak deleted file mode 100644 index 0cf8a0bd9..000000000 --- a/src/accessor/grib_accessor_class_uint32.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint32_h -#define eccodes_accessor_uint32_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint32_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint32 */ -}; - -class grib_accessor_class_uint32_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint32_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint32_h */ diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h.bak b/src/accessor/grib_accessor_class_uint32_little_endian.h.bak deleted file mode 100644 index 357791081..000000000 --- a/src/accessor/grib_accessor_class_uint32_little_endian.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint32_little_endian_h -#define eccodes_accessor_uint32_little_endian_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint32_little_endian */ -}; - -class grib_accessor_class_uint32_little_endian_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint32_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_little_endian_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint32_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint64.h.bak b/src/accessor/grib_accessor_class_uint64.h.bak deleted file mode 100644 index 55215c77f..000000000 --- a/src/accessor/grib_accessor_class_uint64.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint64_h -#define eccodes_accessor_uint64_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint64_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint64 */ -}; - -class grib_accessor_class_uint64_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint64_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint64_h */ diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h.bak b/src/accessor/grib_accessor_class_uint64_little_endian.h.bak deleted file mode 100644 index 8c04a5398..000000000 --- a/src/accessor/grib_accessor_class_uint64_little_endian.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint64_little_endian_h -#define eccodes_accessor_uint64_little_endian_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint64_little_endian */ -}; - -class grib_accessor_class_uint64_little_endian_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint64_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_little_endian_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint64_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint8.h.bak b/src/accessor/grib_accessor_class_uint8.h.bak deleted file mode 100644 index 04dcb1075..000000000 --- a/src/accessor/grib_accessor_class_uint8.h.bak +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_uint8_h -#define eccodes_accessor_uint8_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_uint8_t : public grib_accessor_gen_t -{ -public: - /* Members defined in uint8 */ -}; - -class grib_accessor_class_uint8_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_uint8_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_uint8_t{}; } - int get_native_type(grib_accessor*) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; -}; -#endif /* eccodes_accessor_uint8_h */ diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak b/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak deleted file mode 100644 index 2db5b51b3..000000000 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_unexpanded_descriptors_h -#define eccodes_accessor_unexpanded_descriptors_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t -{ -public: - /* Members defined in unexpanded_descriptors */ - grib_accessor* unexpandedDescriptorsEncoded; - const char* createNewData; -}; - -class grib_accessor_class_unexpanded_descriptors_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_unexpanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_unexpanded_descriptors_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; -}; -#endif /* eccodes_accessor_unexpanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak b/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak deleted file mode 100644 index 0eea70de4..000000000 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.h.bak +++ /dev/null @@ -1,42 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_unpack_bufr_values_h -#define eccodes_accessor_unpack_bufr_values_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t -{ -public: - /* Members defined in unpack_bufr_values */ - grib_accessor* data_accessor; -}; - -class grib_accessor_class_unpack_bufr_values_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_unpack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_unpack_bufr_values_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - int unpack_string_array(grib_accessor*, char**, size_t* len) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_unpack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_unsigned.h.bak b/src/accessor/grib_accessor_class_unsigned.h.bak deleted file mode 100644 index 0523974ca..000000000 --- a/src/accessor/grib_accessor_class_unsigned.h.bak +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (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. - */ - -#pragma once - -#include "grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_unsigned_t : public grib_accessor_long_t -{ -public: - long nbytes; - grib_arguments* arg; -}; - - -class grib_accessor_class_unsigned_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_unsigned_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_t{}; } - void init(grib_accessor* a, const long len, grib_arguments* arg) override; - void dump(grib_accessor* a, grib_dumper* dumper) override; - int unpack_long(grib_accessor* a, long* val, size_t* len) override; - int pack_long(grib_accessor* a, const long* val, size_t* len) override; - long byte_count(grib_accessor* a) override; - int value_count(grib_accessor* a, long* len) override; - long byte_offset(grib_accessor* a) override; - void update_size(grib_accessor* a, size_t s) override; - long next_offset(grib_accessor* a) override; - int is_missing(grib_accessor* a) override; - void destroy(grib_context* context, grib_accessor* a) override; -}; diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h.bak b/src/accessor/grib_accessor_class_unsigned_bits.h.bak deleted file mode 100644 index 62ae48e60..000000000 --- a/src/accessor/grib_accessor_class_unsigned_bits.h.bak +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_unsigned_bits_h -#define eccodes_accessor_unsigned_bits_h - -#include "../grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_unsigned_bits_t : public grib_accessor_long_t -{ -public: - /* Members defined in unsigned_bits */ - const char* numberOfBits; - const char* numberOfElements; -}; - -class grib_accessor_class_unsigned_bits_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_unsigned_bits_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_bits_t{}; } - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; -}; -#endif /* eccodes_accessor_unsigned_bits_h */ diff --git a/src/accessor/grib_accessor_class_validity_date.h.bak b/src/accessor/grib_accessor_class_validity_date.h.bak deleted file mode 100644 index dfd8eb320..000000000 --- a/src/accessor/grib_accessor_class_validity_date.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_validity_date_h -#define eccodes_accessor_validity_date_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_validity_date_t : public grib_accessor_long_t -{ -public: - /* Members defined in validity_date */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* year; - const char* month; - const char* day; -}; - -class grib_accessor_class_validity_date_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_validity_date_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_date_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_validity_date_h */ diff --git a/src/accessor/grib_accessor_class_validity_time.h.bak b/src/accessor/grib_accessor_class_validity_time.h.bak deleted file mode 100644 index 3f7c27f7b..000000000 --- a/src/accessor/grib_accessor_class_validity_time.h.bak +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_validity_time_h -#define eccodes_accessor_validity_time_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_long.h" - -class grib_accessor_validity_time_t : public grib_accessor_long_t -{ -public: - /* Members defined in validity_time */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* hours; - const char* minutes; -}; - -class grib_accessor_class_validity_time_t : public grib_accessor_class_long_t -{ -public: - grib_accessor_class_validity_time_t(const char* name) : grib_accessor_class_long_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_time_t{}; } - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_validity_time_h */ diff --git a/src/accessor/grib_accessor_class_values.h.bak b/src/accessor/grib_accessor_class_values.h.bak deleted file mode 100644 index c7cbf54e7..000000000 --- a/src/accessor/grib_accessor_class_values.h.bak +++ /dev/null @@ -1,41 +0,0 @@ -/* - * (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. - */ - -#ifndef eccodes_accessor_values_h -#define eccodes_accessor_values_h - -#include "grib_accessor_class_gen.h" - -class grib_accessor_values_t : public grib_accessor_gen_t -{ -public: - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; -}; - -class grib_accessor_class_values_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_values_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_values_t{}; } - int get_native_type(grib_accessor*) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - long byte_count(grib_accessor*) override; - long byte_offset(grib_accessor*) override; - long next_offset(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - void update_size(grib_accessor*, size_t) override; - int compare(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_values_h */ diff --git a/src/accessor/grib_accessor_class_variable.h.bak b/src/accessor/grib_accessor_class_variable.h.bak deleted file mode 100644 index 90ff71238..000000000 --- a/src/accessor/grib_accessor_class_variable.h.bak +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (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. - */ - -#pragma once - -#include "grib_accessor.h" -#include "grib_accessor_class_gen.h" - - -class grib_accessor_variable_t : public grib_accessor_gen_t -{ -public: - double dval; - float fval; - char* cval; - char* cname; - int type; -}; - -class grib_accessor_class_variable_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_variable_t(const char* name) : grib_accessor_class_gen_t(name) {}; - grib_accessor* create_empty_accessor() override { return new grib_accessor_variable_t{}; } - int get_native_type(grib_accessor*) override; - int pack_double(grib_accessor*, const double* val, size_t* len) override; - int pack_float(grib_accessor*, const float* val, size_t* len) override; - int pack_long(grib_accessor*, const long* val, size_t* len) override; - int pack_string(grib_accessor*, const char*, size_t* len) override; - int unpack_double(grib_accessor*, double* val, size_t* len) override; - int unpack_float(grib_accessor*, float* val, size_t* len) override; - int unpack_long(grib_accessor*, long* val, size_t* len) override; - int unpack_string(grib_accessor*, char*, size_t* len) override; - size_t string_length(grib_accessor*) override; - long byte_count(grib_accessor*) override; - int value_count(grib_accessor*, long*) override; - void destroy(grib_context*, grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int compare(grib_accessor*, grib_accessor*) override; - grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; -}; diff --git a/src/accessor/grib_accessor_class_vector.h.bak b/src/accessor/grib_accessor_class_vector.h.bak deleted file mode 100644 index 671441001..000000000 --- a/src/accessor/grib_accessor_class_vector.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_vector_h -#define eccodes_accessor_vector_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_abstract_vector.h" - -class grib_accessor_vector_t : public grib_accessor_abstract_vector_t -{ -public: - /* Members defined in vector */ - const char* vector; - int index; -}; - -class grib_accessor_class_vector_t : public grib_accessor_class_abstract_vector_t -{ -public: - grib_accessor_class_vector_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_vector_t{}; } - int unpack_double(grib_accessor*, double* val, size_t* len) override; - void init(grib_accessor*, const long, grib_arguments*) override; -}; -#endif /* eccodes_accessor_vector_h */ diff --git a/src/accessor/grib_accessor_class_when.h.bak b/src/accessor/grib_accessor_class_when.h.bak deleted file mode 100644 index b2ddcc0b0..000000000 --- a/src/accessor/grib_accessor_class_when.h.bak +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * (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. - */ - -#ifndef eccodes_accessor_when_h -#define eccodes_accessor_when_h - -#include "grib_api_internal.h" -#include "grib_accessor_class_gen.h" - -class grib_accessor_when_t : public grib_accessor_gen_t -{ -public: - /* Members defined in when */ -}; - -class grib_accessor_class_when_t : public grib_accessor_class_gen_t -{ -public: - grib_accessor_class_when_t(const char* name) : grib_accessor_class_gen_t(name) {} - grib_accessor* create_empty_accessor() override { return new grib_accessor_when_t{}; } - int get_native_type(grib_accessor*) override; - void dump(grib_accessor*, grib_dumper*) override; - void init(grib_accessor*, const long, grib_arguments*) override; - int notify_change(grib_accessor*, grib_accessor*) override; -}; -#endif /* eccodes_accessor_when_h */ diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc index 935516964..3ff166e42 100644 --- a/src/accessor/grib_accessors_list.cc +++ b/src/accessor/grib_accessors_list.cc @@ -1,3 +1,12 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ #include "grib_accessors_list.h" diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h index 0ec5798a4..3c5cc2ebe 100644 --- a/src/accessor/grib_accessors_list.h +++ b/src/accessor/grib_accessors_list.h @@ -1,3 +1,13 @@ +/* + * (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. + */ + #pragma once #include "grib_accessor.h" From 78578782f7892f1945a7159eeada78a10066c26f Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 14:27:04 +0100 Subject: [PATCH 30/90] Remove unnecessary header files --- ...rib_accessor_class_abstract_long_vector.cc | 2 - .../grib_accessor_class_abstract_vector.cc | 2 - src/accessor/grib_accessor_class_ascii.cc | 1 - src/accessor/grib_accessor_class_bit.cc | 22 ++-- src/accessor/grib_accessor_class_bitmap.cc | 1 - src/accessor/grib_accessor_class_bits.cc | 1 - .../grib_accessor_class_bits_per_value.cc | 1 - src/accessor/grib_accessor_class_blob.cc | 1 - src/accessor/grib_accessor_class_budgdate.cc | 1 - .../grib_accessor_class_bufr_data_array.cc | 1 - ...grib_accessor_class_bufr_elements_table.cc | 2 - ...ccessor_class_bufr_extract_area_subsets.cc | 1 - ...sor_class_bufr_extract_datetime_subsets.cc | 1 - ...rib_accessor_class_bufr_extract_subsets.cc | 1 - .../grib_accessor_class_bufr_group.cc | 1 - ...rib_accessor_class_bufr_simple_thinning.cc | 1 - .../grib_accessor_class_bufr_string_values.cc | 1 - ...essor_class_bufrdc_expanded_descriptors.cc | 1 - src/accessor/grib_accessor_class_bytes.cc | 1 - ...r_class_change_alternative_row_scanning.cc | 1 - ...ccessor_class_change_scanning_direction.cc | 1 - ...b_accessor_class_check_internal_version.cc | 1 - .../grib_accessor_class_closest_date.cc | 1 - src/accessor/grib_accessor_class_codeflag.cc | 1 - src/accessor/grib_accessor_class_codetable.cc | 4 - .../grib_accessor_class_codetable_title.cc | 1 - .../grib_accessor_class_codetable_units.cc | 1 - src/accessor/grib_accessor_class_concept.cc | 1 - .../grib_accessor_class_count_file.cc | 1 - .../grib_accessor_class_count_missing.cc | 1 - .../grib_accessor_class_count_total.cc | 1 - .../grib_accessor_class_data_apply_bitmap.cc | 1 - ...cessor_class_data_apply_boustrophedonic.cc | 1 - ...class_data_apply_boustrophedonic_bitmap.cc | 1 - .../grib_accessor_class_data_dummy_field.cc | 1 - ...b_accessor_class_data_g1complex_packing.cc | 1 - ...a_g1second_order_constant_width_packing.cc | 1 - ...g1second_order_general_extended_packing.cc | 1 - ..._accessor_class_data_g1secondary_bitmap.cc | 1 - ..._accessor_class_data_g1shsimple_packing.cc | 1 - ...ib_accessor_class_data_g1simple_packing.cc | 1 - ...accessor_class_data_g2bifourier_packing.cc | 1 - ...b_accessor_class_data_g2complex_packing.cc | 1 - ..._accessor_class_data_g2secondary_bitmap.cc | 1 - ..._accessor_class_data_g2shsimple_packing.cc | 1 - ...ib_accessor_class_data_g2simple_packing.cc | 1 - ...ata_g2simple_packing_with_preprocessing.cc | 1 - ...ib_accessor_class_data_jpeg2000_packing.cc | 1 - .../grib_accessor_class_data_raw_packing.cc | 1 - ..._accessor_class_data_run_length_packing.cc | 1 - ...ib_accessor_class_data_secondary_bitmap.cc | 1 - .../grib_accessor_class_data_sh_packed.cc | 1 - .../grib_accessor_class_data_sh_unpacked.cc | 1 - ...ib_accessor_class_data_shsimple_packing.cc | 1 - .../grib_accessor_class_decimal_precision.cc | 1 - .../grib_accessor_class_dictionary.cc | 1 - src/accessor/grib_accessor_class_dirty.cc | 1 - src/accessor/grib_accessor_class_divdouble.cc | 1 - src/accessor/grib_accessor_class_double.cc | 1 - src/accessor/grib_accessor_class_element.cc | 1 - src/accessor/grib_accessor_class_evaluate.cc | 1 - ...rib_accessor_class_expanded_descriptors.cc | 1 - ...or_class_from_scale_factor_scaled_value.cc | 1 - ...ib_accessor_class_g1_half_byte_codeflag.cc | 1 - .../grib_accessor_class_g1_message_length.cc | 1 - .../grib_accessor_class_g1_section4_length.cc | 1 - src/accessor/grib_accessor_class_g1bitmap.cc | 1 - src/accessor/grib_accessor_class_g1date.cc | 1 - ...b_accessor_class_g1day_of_the_year_date.cc | 1 - ...ccessor_class_g1end_of_interval_monthly.cc | 1 - .../grib_accessor_class_g1fcperiod.cc | 1 - .../grib_accessor_class_g1forecastmonth.cc | 1 - .../grib_accessor_class_g1monthlydate.cc | 1 - ...ass_g1number_of_coded_values_sh_complex.cc | 1 - ...lass_g1number_of_coded_values_sh_simple.cc | 1 - .../grib_accessor_class_g1step_range.cc | 1 - .../grib_accessor_class_g1verificationdate.cc | 1 - .../grib_accessor_class_g2_aerosol.cc | 1 - .../grib_accessor_class_g2_chemical.cc | 1 - src/accessor/grib_accessor_class_g2_eps.cc | 1 - .../grib_accessor_class_g2_mars_labeling.cc | 1 - src/accessor/grib_accessor_class_g2bitmap.cc | 1 - .../grib_accessor_class_g2bitmap_present.cc | 1 - src/accessor/grib_accessor_class_g2date.cc | 1 - .../grib_accessor_class_g2end_step.cc | 1 - src/accessor/grib_accessor_class_g2grid.cc | 40 ++++--- src/accessor/grib_accessor_class_g2latlon.cc | 34 +++--- src/accessor/grib_accessor_class_g2level.cc | 104 ++++++++++-------- src/accessor/grib_accessor_class_g2lon.cc | 16 +-- .../grib_accessor_class_gaussian_grid_name.cc | 17 +-- .../grib_accessor_class_gds_is_present.cc | 40 +++---- ...b_accessor_class_gds_not_present_bitmap.cc | 5 +- .../grib_accessor_class_global_gaussian.cc | 1 - src/accessor/grib_accessor_class_group.cc | 1 - .../grib_accessor_class_gts_header.cc | 1 - .../grib_accessor_class_hash_array.cc | 1 - .../grib_accessor_class_headers_only.cc | 1 - src/accessor/grib_accessor_class_ibmfloat.cc | 1 - src/accessor/grib_accessor_class_ieeefloat.cc | 1 - src/accessor/grib_accessor_class_ifs_param.cc | 1 - src/accessor/grib_accessor_class_iterator.cc | 5 - .../grib_accessor_class_julian_date.cc | 1 - .../grib_accessor_class_julian_day.cc | 1 - .../grib_accessor_class_ksec1expver.cc | 1 - src/accessor/grib_accessor_class_label.cc | 1 - src/accessor/grib_accessor_class_latitudes.cc | 54 ++++----- .../grib_accessor_class_latlon_increment.cc | 1 - .../grib_accessor_class_latlonvalues.cc | 1 - .../grib_accessor_class_library_version.cc | 1 - .../grib_accessor_class_local_definition.cc | 1 - .../grib_accessor_class_long_vector.cc | 1 - .../grib_accessor_class_longitudes.cc | 1 - src/accessor/grib_accessor_class_lookup.cc | 1 - .../grib_accessor_class_mars_param.cc | 1 - src/accessor/grib_accessor_class_mars_step.cc | 1 - src/accessor/grib_accessor_class_md5.cc | 31 ++++-- src/accessor/grib_accessor_class_message.cc | 1 - .../grib_accessor_class_message_copy.cc | 1 - .../grib_accessor_class_multdouble.cc | 1 - src/accessor/grib_accessor_class_non_alpha.cc | 1 - ...b_accessor_class_number_of_coded_values.cc | 1 - .../grib_accessor_class_number_of_points.cc | 1 - ...ccessor_class_number_of_points_gaussian.cc | 1 - .../grib_accessor_class_number_of_values.cc | 1 - ...class_number_of_values_data_raw_packing.cc | 1 - ...grib_accessor_class_octahedral_gaussian.cc | 1 - .../grib_accessor_class_octet_number.cc | 1 - .../grib_accessor_class_offset_file.cc | 1 - .../grib_accessor_class_offset_values.cc | 1 - .../grib_accessor_class_optimal_step_units.cc | 1 - .../grib_accessor_class_pack_bufr_values.cc | 1 - .../grib_accessor_class_packing_type.cc | 1 - src/accessor/grib_accessor_class_pad.cc | 1 - src/accessor/grib_accessor_class_padding.cc | 1 - src/accessor/grib_accessor_class_padto.cc | 1 - src/accessor/grib_accessor_class_padtoeven.cc | 1 - .../grib_accessor_class_padtomultiple.cc | 1 - src/accessor/grib_accessor_class_position.cc | 1 - .../grib_accessor_class_proj_string.cc | 1 - src/accessor/grib_accessor_class_raw.cc | 1 - .../grib_accessor_class_rdbtime_guess_date.cc | 1 - ...ib_accessor_class_reference_value_error.cc | 1 - src/accessor/grib_accessor_class_round.cc | 1 - src/accessor/grib_accessor_class_scale.cc | 1 - .../grib_accessor_class_scale_values.cc | 1 - ...essor_class_second_order_bits_per_value.cc | 1 - .../grib_accessor_class_section_length.cc | 1 - .../grib_accessor_class_section_padding.cc | 1 - .../grib_accessor_class_section_pointer.cc | 1 - ...rib_accessor_class_select_step_template.cc | 1 - ...grib_accessor_class_sexagesimal2decimal.cc | 1 - src/accessor/grib_accessor_class_signed.cc | 1 - .../grib_accessor_class_signed_bits.cc | 1 - ...rib_accessor_class_simple_packing_error.cc | 1 - src/accessor/grib_accessor_class_size.cc | 1 - .../grib_accessor_class_smart_table.cc | 4 - .../grib_accessor_class_smart_table_column.cc | 1 - src/accessor/grib_accessor_class_spd.cc | 1 - ...grib_accessor_class_spectral_truncation.cc | 1 - src/accessor/grib_accessor_class_sprintf.cc | 1 - .../grib_accessor_class_statistics.cc | 1 - ...grib_accessor_class_statistics_spectral.cc | 1 - ...grib_accessor_class_step_human_readable.cc | 1 - .../grib_accessor_class_step_in_units.cc | 1 - src/accessor/grib_accessor_class_sum.cc | 1 - .../grib_accessor_class_suppressed.cc | 1 - src/accessor/grib_accessor_class_time.cc | 1 - src/accessor/grib_accessor_class_to_double.cc | 1 - .../grib_accessor_class_to_integer.cc | 1 - src/accessor/grib_accessor_class_to_string.cc | 1 - .../grib_accessor_class_transient_darray.cc | 1 - src/accessor/grib_accessor_class_trim.cc | 1 - src/accessor/grib_accessor_class_uint16.cc | 1 - src/accessor/grib_accessor_class_uint32.cc | 1 - ...rib_accessor_class_uint32_little_endian.cc | 1 - src/accessor/grib_accessor_class_uint64.cc | 1 - ...rib_accessor_class_uint64_little_endian.cc | 1 - src/accessor/grib_accessor_class_uint8.cc | 1 - ...b_accessor_class_unexpanded_descriptors.cc | 1 - .../grib_accessor_class_unpack_bufr_values.cc | 4 - .../grib_accessor_class_unsigned_bits.cc | 1 - .../grib_accessor_class_validity_date.cc | 1 - .../grib_accessor_class_validity_time.cc | 1 - src/accessor/grib_accessor_class_values.cc | 1 - src/accessor/grib_accessor_class_vector.cc | 1 - src/accessor/grib_accessor_class_when.cc | 1 - 186 files changed, 201 insertions(+), 354 deletions(-) diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.cc b/src/accessor/grib_accessor_class_abstract_long_vector.cc index ad0740841..0f4514aa1 100644 --- a/src/accessor/grib_accessor_class_abstract_long_vector.cc +++ b/src/accessor/grib_accessor_class_abstract_long_vector.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_long_vector.h" grib_accessor_class_abstract_long_vector_t _grib_accessor_class_abstract_long_vector{"abstract_long_vector"}; grib_accessor_class* grib_accessor_class_abstract_long_vector = &_grib_accessor_class_abstract_long_vector; - diff --git a/src/accessor/grib_accessor_class_abstract_vector.cc b/src/accessor/grib_accessor_class_abstract_vector.cc index 692e9c404..2ee141e8f 100644 --- a/src/accessor/grib_accessor_class_abstract_vector.cc +++ b/src/accessor/grib_accessor_class_abstract_vector.cc @@ -9,9 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" grib_accessor_class_abstract_vector_t _grib_accessor_class_abstract_vector{"abstract_vector"}; grib_accessor_class* grib_accessor_class_abstract_vector = &_grib_accessor_class_abstract_vector; - diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc index 2c824fe29..f45053267 100644 --- a/src/accessor/grib_accessor_class_ascii.cc +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" grib_accessor_class_ascii_t _grib_accessor_class_ascii{"ascii"}; diff --git a/src/accessor/grib_accessor_class_bit.cc b/src/accessor/grib_accessor_class_bit.cc index ef30efe24..c1efac202 100644 --- a/src/accessor/grib_accessor_class_bit.cc +++ b/src/accessor/grib_accessor_class_bit.cc @@ -9,25 +9,26 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bit.h" -grib_accessor_class_bit_t _grib_accessor_class_bit{"bit"}; +grib_accessor_class_bit_t _grib_accessor_class_bit{ "bit" }; grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; -void grib_accessor_class_bit_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_bit_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_long_t::init(a, len, arg); grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; - a->length = 0; + a->length = 0; self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); } -int grib_accessor_class_bit_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_bit_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; - int ret = 0; - long data = 0; + int ret = 0; + long data = 0; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: unpack_long: Wrong size for %s, it contains %d values ", a->name, 1); @@ -49,7 +50,8 @@ int grib_accessor_class_bit_t::unpack_long(grib_accessor* a, long* val, size_t* return GRIB_SUCCESS; } -int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; if (*len < 1) { @@ -61,7 +63,7 @@ int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size grib_accessor* owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner); if (!owner) { grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: Cannot get the owner %s for computing the bit value of %s", - self->owner, a->name); + self->owner, a->name); *len = 0; return GRIB_NOT_FOUND; } @@ -71,7 +73,7 @@ int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size /* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */ if (a->context->debug) { /* Print bit positions from 1 (MSB) */ - fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0) ); + fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0)); } grib_set_bit(mdata, 7 - self->bit_index, *val > 0); diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index a2d659f65..e507d021b 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bitmap.h" grib_accessor_class_bitmap_t _grib_accessor_class_bitmap{"bitmap"}; diff --git a/src/accessor/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc index d5d1f248c..e0a9e7d8d 100644 --- a/src/accessor/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bits.h" grib_accessor_class_bits_t _grib_accessor_class_bits{"bits"}; diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc index 51403f855..590c48d89 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bits_per_value.h" grib_accessor_class_bits_per_value_t _grib_accessor_class_bits_per_value{"bits_per_value"}; diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index 93c7095bb..ca7b21f24 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_blob.h" grib_accessor_class_blob_t _grib_accessor_class_blob{"blob"}; diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc index e496488e2..4c58c20f2 100644 --- a/src/accessor/grib_accessor_class_budgdate.cc +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_budgdate.h" grib_accessor_class_budgdate_t _grib_accessor_class_budgdate{"budgdate"}; diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index e89d096b1..0314effa0 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -10,7 +10,6 @@ */ #include "grib_scaling.h" -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_data_array.h" grib_accessor_class_bufr_data_array_t _grib_accessor_class_bufr_data_array{"bufr_data_array"}; diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc index 9a34353de..42e7a1324 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -9,11 +9,9 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_elements_table.h" #include "grib_scaling.h" - #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index cbd6b5c5f..9a2310635 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_extract_area_subsets.h" grib_accessor_class_bufr_extract_area_subsets_t _grib_accessor_class_bufr_extract_area_subsets{"bufr_extract_area_subsets"}; diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index 400473180..368f49f0c 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_extract_datetime_subsets.h" grib_accessor_class_bufr_extract_datetime_subsets_t _grib_accessor_class_bufr_extract_datetime_subsets{"bufr_extract_datetime_subsets"}; diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc index 75f0618b8..7d5a23652 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_extract_subsets.h" grib_accessor_class_bufr_extract_subsets_t _grib_accessor_class_bufr_extract_subsets{"bufr_extract_subsets"}; diff --git a/src/accessor/grib_accessor_class_bufr_group.cc b/src/accessor/grib_accessor_class_bufr_group.cc index 2aae5e583..71249f70d 100644 --- a/src/accessor/grib_accessor_class_bufr_group.cc +++ b/src/accessor/grib_accessor_class_bufr_group.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_group.h" grib_accessor_class_bufr_group_t _grib_accessor_class_bufr_group{"bufr_group"}; diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc index c2621e52c..2c66d4585 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_simple_thinning.h" grib_accessor_class_bufr_simple_thinning_t _grib_accessor_class_bufr_simple_thinning{"bufr_simple_thinning"}; diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index f6b7d561a..eb76f6fb9 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufr_string_values.h" #include "grib_accessor_class_bufr_data_array.h" diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc index 9aa38faa4..bd411d510 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bufrdc_expanded_descriptors.h" grib_accessor_class_bufrdc_expanded_descriptors_t _grib_accessor_class_bufrdc_expanded_descriptors{"bufrdc_expanded_descriptors"}; diff --git a/src/accessor/grib_accessor_class_bytes.cc b/src/accessor/grib_accessor_class_bytes.cc index b7719e232..47c8713ae 100644 --- a/src/accessor/grib_accessor_class_bytes.cc +++ b/src/accessor/grib_accessor_class_bytes.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" grib_accessor_class_bytes_t _grib_accessor_class_bytes{"bytes"}; diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc index f9d740206..50475b6a6 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_change_alternative_row_scanning.h" grib_accessor_class_change_alternative_row_scanning_t _grib_accessor_class_change_alternative_row_scanning{"change_alternative_row_scanning"}; diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc index cfa45c592..e3b6144c9 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_change_scanning_direction.h" grib_accessor_class_change_scanning_direction_t _grib_accessor_class_change_scanning_direction{"change_scanning_direction"}; diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc index 987a512f5..f8ceb1896 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.cc +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_check_internal_version.h" grib_accessor_class_check_internal_version_t _grib_accessor_class_check_internal_version{"check_internal_version"}; diff --git a/src/accessor/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc index ace5bdf71..b0b3bb512 100644 --- a/src/accessor/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_closest_date.h" #include diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index d81c031a9..75b73aca4 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_codeflag.h" grib_accessor_class_codeflag_t _grib_accessor_class_codeflag{"codeflag"}; diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index 54f51929b..552274e75 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -8,10 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - #include "grib_accessor_class_codetable.h" #include diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc index 52d8b8b32..d124ee75f 100644 --- a/src/accessor/grib_accessor_class_codetable_title.cc +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_codetable_title.h" #include "grib_accessor_class_codetable.h" diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc index cb72847e0..2e7ccda61 100644 --- a/src/accessor/grib_accessor_class_codetable_units.cc +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_codetable_units.h" #include "grib_accessor_class_codetable.h" diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 32e612546..f67391af6 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_concept.h" grib_accessor_class_concept_t _grib_accessor_class_concept{"concept"}; diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc index b3317e515..a347e49ff 100644 --- a/src/accessor/grib_accessor_class_count_file.cc +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_count_file.h" grib_accessor_class_count_file_t _grib_accessor_class_count_file{"count_file"}; diff --git a/src/accessor/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc index a14c6d6c0..c381be043 100644 --- a/src/accessor/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_count_missing.h" grib_accessor_class_count_missing_t _grib_accessor_class_count_missing{"count_missing"}; diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc index 604981a56..561a8743d 100644 --- a/src/accessor/grib_accessor_class_count_total.cc +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_count_total.h" grib_accessor_class_count_total_t _grib_accessor_class_count_total{"count_total"}; diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index 5529ab36f..86e54ff63 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_apply_bitmap.h" grib_accessor_class_data_apply_bitmap_t _grib_accessor_class_data_apply_bitmap{"data_apply_bitmap"}; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index a4b020276..2569a05cb 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_apply_boustrophedonic.h" grib_accessor_class_data_apply_boustrophedonic_t _grib_accessor_class_data_apply_boustrophedonic{ "data_apply_boustrophedonic" }; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index d7e07a561..f796cfb02 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_apply_boustrophedonic_bitmap.h" grib_accessor_class_data_apply_boustrophedonic_bitmap_t _grib_accessor_class_data_apply_boustrophedonic_bitmap{"data_apply_boustrophedonic_bitmap"}; diff --git a/src/accessor/grib_accessor_class_data_dummy_field.cc b/src/accessor/grib_accessor_class_data_dummy_field.cc index 23bc83c9c..eddadcc08 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.cc +++ b/src/accessor/grib_accessor_class_data_dummy_field.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_dummy_field.h" grib_accessor_class_data_dummy_field_t _grib_accessor_class_data_dummy_field{"data_dummy_field"}; diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc index b1fc4fa4b..5ac11346e 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1complex_packing.h" grib_accessor_class_data_g1complex_packing_t _grib_accessor_class_data_g1complex_packing{"data_g1complex_packing"}; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc index 44452957e..579fbd8cb 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1second_order_constant_width_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 48b5081df..a5c1084ac 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1second_order_general_extended_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc index 639512a57..3697f6f75 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1secondary_bitmap.h" grib_accessor_class_data_g1secondary_bitmap_t _grib_accessor_class_data_g1secondary_bitmap{"data_g1secondary_bitmap"}; diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc index d6a8a6562..f1f06d654 100644 --- a/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1shsimple_packing.h" grib_accessor_class_data_g1shsimple_packing_t _grib_accessor_class_data_g1shsimple_packing{"data_g1shsimple_packing"}; diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc index 2346e33dd..a19132f1a 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1simple_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index 06121f9aa..60cf8e0f9 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2bifourier_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/grib_accessor_class_data_g2complex_packing.cc index 7ccd19117..c1e5e7aad 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2complex_packing.h" grib_accessor_class_data_g2complex_packing_t _grib_accessor_class_data_g2complex_packing{"data_g2complex_packing"}; diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc index f16ccf74f..a6fd7bd46 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2secondary_bitmap.h" grib_accessor_class_data_g2secondary_bitmap_t _grib_accessor_class_data_g2secondary_bitmap{"data_g2secondary_bitmap"}; diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc index ad204da06..7e2b5cd54 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2shsimple_packing.h" grib_accessor_class_data_g2shsimple_packing_t _grib_accessor_class_data_g2shsimple_packing{"data_g2shsimple_packing"}; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing.cc index 849c4647a..7f3ef141a 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2simple_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index ad877ca82..8eac09789 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2simple_packing_with_preprocessing.h" #define DIRECT 0 #define INVERSE 1 diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index 73ad0ea64..a68a3eae7 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_jpeg2000_packing.h" grib_accessor_class_data_jpeg2000_packing_t _grib_accessor_class_data_jpeg2000_packing{"data_jpeg2000_packing"}; diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc index e9de19af0..499b46bec 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_raw_packing.h" #include "grib_ieeefloat.h" diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.cc b/src/accessor/grib_accessor_class_data_run_length_packing.cc index 849652127..35792c503 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.cc +++ b/src/accessor/grib_accessor_class_data_run_length_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_run_length_packing.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc index b453aa5b1..f79098f84 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_secondary_bitmap.h" grib_accessor_class_data_secondary_bitmap_t _grib_accessor_class_data_secondary_bitmap{"data_secondary_bitmap"}; diff --git a/src/accessor/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc index f7febe225..80bc7648f 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_sh_packed.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc index 9573bd732..efa738c65 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_sh_unpacked.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/grib_accessor_class_data_shsimple_packing.cc index 6fd8d9f6b..0de921d06 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_data_shsimple_packing.h" grib_accessor_class_data_shsimple_packing_t _grib_accessor_class_data_shsimple_packing{"data_shsimple_packing"}; diff --git a/src/accessor/grib_accessor_class_decimal_precision.cc b/src/accessor/grib_accessor_class_decimal_precision.cc index c063512c0..6149de763 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.cc +++ b/src/accessor/grib_accessor_class_decimal_precision.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_decimal_precision.h" grib_accessor_class_decimal_precision_t _grib_accessor_class_decimal_precision{"decimal_precision"}; diff --git a/src/accessor/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc index 59ed89b32..9a0b3307d 100644 --- a/src/accessor/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_dictionary.h" grib_accessor_class_dictionary_t _grib_accessor_class_dictionary{"dictionary"}; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc index 89a05806b..39df7e450 100644 --- a/src/accessor/grib_accessor_class_dirty.cc +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_dirty.h" grib_accessor_class_dirty_t _grib_accessor_class_dirty{"dirty"}; diff --git a/src/accessor/grib_accessor_class_divdouble.cc b/src/accessor/grib_accessor_class_divdouble.cc index cf79b434d..a652752fa 100644 --- a/src/accessor/grib_accessor_class_divdouble.cc +++ b/src/accessor/grib_accessor_class_divdouble.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_divdouble.h" grib_accessor_class_divdouble_t _grib_accessor_class_divdouble{"divdouble"}; diff --git a/src/accessor/grib_accessor_class_double.cc b/src/accessor/grib_accessor_class_double.cc index 0e3b0ea00..a0e3a49b5 100644 --- a/src/accessor/grib_accessor_class_double.cc +++ b/src/accessor/grib_accessor_class_double.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" grib_accessor_class_double_t _grib_accessor_class_double{"double"}; diff --git a/src/accessor/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc index a058d3dea..eb2a874f2 100644 --- a/src/accessor/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_element.h" grib_accessor_class_element_t _grib_accessor_class_element{"element"}; diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc index 25f4f5ba5..efed99598 100644 --- a/src/accessor/grib_accessor_class_evaluate.cc +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_evaluate.h" grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{"evaluate"}; diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index d885ad1d8..ff91dbc6f 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_expanded_descriptors.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc index 9ba8aa65e..4168e1476 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_from_scale_factor_scaled_value.h" grib_accessor_class_from_scale_factor_scaled_value_t _grib_accessor_class_from_scale_factor_scaled_value{"from_scale_factor_scaled_value"}; diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc index f2d309d06..2f757addc 100644 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1_half_byte_codeflag.h" grib_accessor_class_g1_half_byte_codeflag_t _grib_accessor_class_g1_half_byte_codeflag{"g1_half_byte_codeflag"}; diff --git a/src/accessor/grib_accessor_class_g1_message_length.cc b/src/accessor/grib_accessor_class_g1_message_length.cc index de8145a53..89ce742c5 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.cc +++ b/src/accessor/grib_accessor_class_g1_message_length.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1_message_length.h" grib_accessor_class_g1_message_length_t _grib_accessor_class_g1_message_length{"g1_message_length"}; diff --git a/src/accessor/grib_accessor_class_g1_section4_length.cc b/src/accessor/grib_accessor_class_g1_section4_length.cc index 1c4f9ccf1..8eea656b0 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.cc +++ b/src/accessor/grib_accessor_class_g1_section4_length.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1_section4_length.h" grib_accessor_class_g1_section4_length_t _grib_accessor_class_g1_section4_length{"g1_section4_length"}; diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc index 1a7a7bb9e..e8c0645ad 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.cc +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1bitmap.h" #include "shared_functions.h" diff --git a/src/accessor/grib_accessor_class_g1date.cc b/src/accessor/grib_accessor_class_g1date.cc index 938628031..64631a1ea 100644 --- a/src/accessor/grib_accessor_class_g1date.cc +++ b/src/accessor/grib_accessor_class_g1date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1date.h" grib_accessor_class_g1date_t _grib_accessor_class_g1date{"g1date"}; diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc index a75e043c9..83d23ea92 100644 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1day_of_the_year_date.h" grib_accessor_class_g1day_of_the_year_date_t _grib_accessor_class_g1day_of_the_year_date{"g1day_of_the_year_date"}; diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc index c280f26b3..ea48fc6cb 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1end_of_interval_monthly.h" grib_accessor_class_g1end_of_interval_monthly_t _grib_accessor_class_g1end_of_interval_monthly{"g1end_of_interval_monthly"}; diff --git a/src/accessor/grib_accessor_class_g1fcperiod.cc b/src/accessor/grib_accessor_class_g1fcperiod.cc index 143a381e7..fcf98d78d 100644 --- a/src/accessor/grib_accessor_class_g1fcperiod.cc +++ b/src/accessor/grib_accessor_class_g1fcperiod.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1fcperiod.h" grib_accessor_class_g1fcperiod_t _grib_accessor_class_g1fcperiod{"g1fcperiod"}; diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc index a849125f9..7da455773 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1forecastmonth.h" grib_accessor_class_g1forecastmonth_t _grib_accessor_class_g1forecastmonth{"g1forecastmonth"}; diff --git a/src/accessor/grib_accessor_class_g1monthlydate.cc b/src/accessor/grib_accessor_class_g1monthlydate.cc index 79aba52ed..420f96ef3 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.cc +++ b/src/accessor/grib_accessor_class_g1monthlydate.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1monthlydate.h" grib_accessor_class_g1monthlydate_t _grib_accessor_class_g1monthlydate{"g1monthlydate"}; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc index 0623a32d7..9976ad812 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1number_of_coded_values_sh_complex.h" grib_accessor_class_g1number_of_coded_values_sh_complex_t _grib_accessor_class_g1number_of_coded_values_sh_complex{"g1number_of_coded_values_sh_complex"}; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc index 50fe992c9..802e6ceb7 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1number_of_coded_values_sh_simple.h" grib_accessor_class_g1number_of_coded_values_sh_simple_t _grib_accessor_class_g1number_of_coded_values_sh_simple{"g1number_of_coded_values_sh_simple"}; diff --git a/src/accessor/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc index 8ad1b3e12..a2920a1cf 100644 --- a/src/accessor/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1step_range.h" grib_accessor_class_g1step_range_t _grib_accessor_class_g1step_range{"g1step_range"}; diff --git a/src/accessor/grib_accessor_class_g1verificationdate.cc b/src/accessor/grib_accessor_class_g1verificationdate.cc index b77267427..63a1f1356 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.cc +++ b/src/accessor/grib_accessor_class_g1verificationdate.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g1verificationdate.h" grib_accessor_class_g1verificationdate_t _grib_accessor_class_g1verificationdate{"g1verificationdate"}; diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc index 4d20e0d9a..464563187 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.cc +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2_aerosol.h" grib_accessor_class_g2_aerosol_t _grib_accessor_class_g2_aerosol{"g2_aerosol"}; diff --git a/src/accessor/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc index d00e90feb..3d05886a5 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2_chemical.h" grib_accessor_class_g2_chemical_t _grib_accessor_class_g2_chemical{"g2_chemical"}; diff --git a/src/accessor/grib_accessor_class_g2_eps.cc b/src/accessor/grib_accessor_class_g2_eps.cc index afdea42bf..6b6c42fd7 100644 --- a/src/accessor/grib_accessor_class_g2_eps.cc +++ b/src/accessor/grib_accessor_class_g2_eps.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2_eps.h" grib_accessor_class_g2_eps_t _grib_accessor_class_g2_eps{"g2_eps"}; diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index 8fcc03141..4ea0f5e7c 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2_mars_labeling.h" grib_accessor_class_g2_mars_labeling_t _grib_accessor_class_g2_mars_labeling{"g2_mars_labeling"}; diff --git a/src/accessor/grib_accessor_class_g2bitmap.cc b/src/accessor/grib_accessor_class_g2bitmap.cc index 3996e0c7f..d5af880b3 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.cc +++ b/src/accessor/grib_accessor_class_g2bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2bitmap.h" #include "shared_functions.h" diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.cc b/src/accessor/grib_accessor_class_g2bitmap_present.cc index 4e31cb3ba..1444783fe 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.cc +++ b/src/accessor/grib_accessor_class_g2bitmap_present.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2bitmap_present.h" grib_accessor_class_g2bitmap_present_t _grib_accessor_class_g2bitmap_present{"g2bitmap_present"}; diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc index b4ea04eda..238da76f7 100644 --- a/src/accessor/grib_accessor_class_g2date.cc +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2date.h" grib_accessor_class_g2date_t _grib_accessor_class_g2date{"g2date"}; diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index 1e0f77c03..20bf71e59 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2end_step.h" #include "step.h" #include "step_utilities.h" diff --git a/src/accessor/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc index c28351a29..b5d33a39d 100644 --- a/src/accessor/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -9,18 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2grid.h" -grib_accessor_class_g2grid_t _grib_accessor_class_g2grid{"g2grid"}; +grib_accessor_class_g2grid_t _grib_accessor_class_g2grid{ "g2grid" }; grib_accessor_class* grib_accessor_class_g2grid = &_grib_accessor_class_g2grid; -void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->latitude_first = grib_arguments_get_name(hand, c, n++); self->longitude_first = grib_arguments_get_name(hand, c, n++); @@ -36,7 +36,8 @@ void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arg GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_g2grid_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_g2grid_t::value_count(grib_accessor* a, long* count) +{ *count = 6; return 0; } @@ -44,10 +45,11 @@ int grib_accessor_class_g2grid_t::value_count(grib_accessor* a, long* count){ // GRIB edition 2 uses microdegrees #define ANGLE_SUBDIVISIONS (1000 * 1000) -int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; long basic_angle = 0; long sub_division = 0; @@ -93,7 +95,8 @@ int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, s if (!self->j_increment) { v[n++] = GRIB_MISSING_LONG; - } else { + } + else { if ((ret = grib_get_long_internal(hand, self->j_increment, &v[n++])) != GRIB_SUCCESS) return ret; } @@ -106,7 +109,8 @@ int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, s return GRIB_SUCCESS; } -long gcd(long a, long b){ +long gcd(long a, long b) +{ if (b > a) return gcd(b, a); if (b == 0) @@ -114,11 +118,13 @@ long gcd(long a, long b){ return gcd(b, a % b); } -long lcm(long a, long b){ +long lcm(long a, long b) +{ return a * b / gcd(a, b); } -int is_ok(const double* val, long v[6], double basic_angle, double sub_division){ +int is_ok(const double* val, long v[6], double basic_angle, double sub_division) +{ int i; int ok = 1; @@ -142,7 +148,8 @@ int is_ok(const double* val, long v[6], double basic_angle, double sub_division) return ok; } -int trial(const double* val, long v[6], long* basic_angle, long* sub_division){ +int trial(const double* val, long v[6], long* basic_angle, long* sub_division) +{ int i = 0; long ni, nj; @@ -172,9 +179,10 @@ int trial(const double* val, long v[6], long* basic_angle, long* sub_division){ return is_ok(val, v, *basic_angle, *sub_division); } -int grib_accessor_class_g2grid_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_g2grid_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_handle* hand = grib_handle_of_accessor(a); int ret; long v[6]; int n; diff --git a/src/accessor/grib_accessor_class_g2latlon.cc b/src/accessor/grib_accessor_class_g2latlon.cc index 35bb09e7e..afb3a2f7a 100644 --- a/src/accessor/grib_accessor_class_g2latlon.cc +++ b/src/accessor/grib_accessor_class_g2latlon.cc @@ -9,26 +9,27 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2latlon.h" -grib_accessor_class_g2latlon_t _grib_accessor_class_g2latlon{"g2latlon"}; +grib_accessor_class_g2latlon_t _grib_accessor_class_g2latlon{ "g2latlon" }; grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latlon; -void grib_accessor_class_g2latlon_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2latlon_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; - int n = 0; + int n = 0; self->grid = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); self->given = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_g2latlon_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_g2latlon_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; - int ret = 0; + int ret = 0; long given = 1; double grid[6]; @@ -56,12 +57,13 @@ int grib_accessor_class_g2latlon_t::unpack_double(grib_accessor* a, double* val, return GRIB_SUCCESS; } -int grib_accessor_class_g2latlon_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_g2latlon_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; - int ret = 0; + int ret = 0; double grid[6]; - size_t size = 6; - double new_val = *val; + size_t size = 6; + double new_val = *val; grib_handle* hand = grib_handle_of_accessor(a); if (*len < 1) { @@ -94,10 +96,11 @@ int grib_accessor_class_g2latlon_t::pack_double(grib_accessor* a, const double* return grib_set_double_array_internal(hand, self->grid, grid, size); } -int grib_accessor_class_g2latlon_t::pack_missing(grib_accessor* a){ +int grib_accessor_class_g2latlon_t::pack_missing(grib_accessor* a) +{ grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; - double missing = GRIB_MISSING_DOUBLE; - size_t size = 1; + double missing = GRIB_MISSING_DOUBLE; + size_t size = 1; if (!self->given) return GRIB_NOT_IMPLEMENTED; @@ -105,9 +108,10 @@ int grib_accessor_class_g2latlon_t::pack_missing(grib_accessor* a){ return pack_double(a, &missing, &size); } -int grib_accessor_class_g2latlon_t::is_missing(grib_accessor* a){ +int grib_accessor_class_g2latlon_t::is_missing(grib_accessor* a) +{ grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; - long given = 1; + long given = 1; if (self->given) grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); diff --git a/src/accessor/grib_accessor_class_g2level.cc b/src/accessor/grib_accessor_class_g2level.cc index 37e3c01d6..8da0be27f 100644 --- a/src/accessor/grib_accessor_class_g2level.cc +++ b/src/accessor/grib_accessor_class_g2level.cc @@ -9,18 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2level.h" -grib_accessor_class_g2level_t _grib_accessor_class_g2level{"g2level"}; +grib_accessor_class_g2level_t _grib_accessor_class_g2level{ "g2level" }; grib_accessor_class* grib_accessor_class_g2level = &_grib_accessor_class_g2level; -void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->type_first = grib_arguments_get_name(hand, c, n++); self->scale_first = grib_arguments_get_name(hand, c, n++); @@ -31,24 +31,26 @@ void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_ar a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION; } -bool is_tigge(grib_handle* h){ +bool is_tigge(grib_handle* h) +{ long productionStatus = 0; - int err = grib_get_long(h, "productionStatusOfProcessedData", &productionStatus); + int err = grib_get_long(h, "productionStatusOfProcessedData", &productionStatus); if (err) return false; return (productionStatus == 4 || productionStatus == 5); } -int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, size_t* len){ - int ret = 0; +int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + int ret = 0; grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_handle* hand = grib_handle_of_accessor(a); long type_first = 0; long scale_first = 0; long value_first = 0; char pressure_units[10] = {0,}; size_t pressure_units_len = 10; - bool tigge = is_tigge(hand); + bool tigge = is_tigge(hand); double v; @@ -76,8 +78,9 @@ int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, // GRIB-637, ECC-1081: Potential vorticity surface if (type_first == 109) { if (tigge) { - scale_first -= 6; // TIGGE data follows different rules - } else { + scale_first -= 6; // TIGGE data follows different rules + } + else { scale_first -= 9; } } @@ -93,9 +96,9 @@ int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, } switch (type_first) { - case 100: // Isobaric surface (Pa) + case 100: // Isobaric surface (Pa) if (!strcmp(pressure_units, "hPa")) { - long x = v / 100.0; // 1 hPa = 100 Pa + long x = v / 100.0; // 1 hPa = 100 Pa if (scale_first == 0 && x == 0) { // Switch to Pa instead of hPa as the value is less than a hectoPascal char pa[] = "Pa"; @@ -115,27 +118,29 @@ int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, return GRIB_SUCCESS; } -int grib_accessor_class_g2level_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_g2level_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ double dval = 0; int ret = unpack_double(a, &dval, len); if (ret == GRIB_SUCCESS) { - *val = (long)(dval + 0.5); // round up + *val = (long)(dval + 0.5); // round up } return ret; } -int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - double value_first = *val; - //long scale_first = 0; - long type_first = 0; - char pressure_units[10] = {0,}; - size_t pressure_units_len = 10; - const long lval = (long)value_first; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + double value_first = *val; + // long scale_first = 0; + long type_first = 0; + char pressure_units[10] = {0,}; + size_t pressure_units_len = 10; + const long lval = (long)value_first; - if (value_first == lval) { // input is a whole number; process it as an integer + if (value_first == lval) { // input is a whole number; process it as an integer return pack_long(a, &lval, len); } @@ -149,7 +154,7 @@ int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* v return ret; switch (type_first) { - case 100: // Pa + case 100: // Pa if (!strcmp(pressure_units, "hPa")) value_first *= 100; break; @@ -160,14 +165,14 @@ int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* v // final = scaled_value * 10 ^ -scale_factor - //scale_first = 2; - //value_first *= 100; - //value_first = value_first + 0.5; //round up + // scale_first = 2; + // value_first *= 100; + // value_first = value_first + 0.5; //round up // TODO(masn): These maxima should come from the respective accessors - const int64_t scaled_value_max = (1ULL << 32) - 1; // scaledValueOf*FixedSurface is 4 octets - const int64_t scale_factor_max = (1ULL << 8) - 1; // scaleFactorOf*FixedSurface is 1 octet - int64_t lscaled_value=0, lscale_factor=0; + const int64_t scaled_value_max = (1ULL << 32) - 1; // scaledValueOf*FixedSurface is 4 octets + const int64_t scale_factor_max = (1ULL << 8) - 1; // scaleFactorOf*FixedSurface is 1 octet + int64_t lscaled_value = 0, lscale_factor = 0; ret = compute_scaled_value_and_scale_factor(value_first, scaled_value_max, scale_factor_max, &lscaled_value, &lscale_factor); if (ret) { @@ -186,7 +191,8 @@ int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* v return GRIB_SUCCESS; } -int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ int ret = 0; long value_first = *val; long scale_first = 0; @@ -195,9 +201,9 @@ int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, size_t pressure_units_len = 10; grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int change_scale_and_value = 1; - bool tigge = is_tigge(hand); + grib_handle* hand = grib_handle_of_accessor(a); + int change_scale_and_value = 1; + bool tigge = is_tigge(hand); if (*len != 1) return GRIB_WRONG_ARRAY_SIZE; @@ -218,16 +224,17 @@ int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, return ret; switch (type_first) { - case 100: // Pa + case 100: // Pa scale_first = 0; if (!strcmp(pressure_units, "hPa")) value_first *= 100; break; - case 109: // Potential vorticity surface (See ECC-1081) + case 109: // Potential vorticity surface (See ECC-1081) if (!tigge) { scale_first = 9; - } else { - scale_first = 6; // TIGGE data follows different rules + } + else { + scale_first = 6; // TIGGE data follows different rules } break; @@ -260,12 +267,13 @@ int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, return GRIB_SUCCESS; } -int grib_accessor_class_g2level_t::is_missing(grib_accessor* a){ +int grib_accessor_class_g2level_t::is_missing(grib_accessor* a) +{ grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int err = 0; - int ret = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int err = 0; - ret = grib_is_missing(hand, self->scale_first, &err) + - grib_is_missing(hand, self->value_first, &err); return ret; + int ret = grib_is_missing(hand, self->scale_first, &err) + + grib_is_missing(hand, self->value_first, &err); + return ret; } diff --git a/src/accessor/grib_accessor_class_g2lon.cc b/src/accessor/grib_accessor_class_g2lon.cc index e5b25640f..b7cb43d03 100644 --- a/src/accessor/grib_accessor_class_g2lon.cc +++ b/src/accessor/grib_accessor_class_g2lon.cc @@ -9,24 +9,25 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_g2lon.h" -grib_accessor_class_g2lon_t _grib_accessor_class_g2lon{"g2lon"}; +grib_accessor_class_g2lon_t _grib_accessor_class_g2lon{ "g2lon" }; grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; -void grib_accessor_class_g2lon_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2lon_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; - int n = 0; + int n = 0; self->longitude = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_g2lon_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_g2lon_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; - int ret = 0; + int ret = 0; long longitude; if ((ret = grib_get_long(grib_handle_of_accessor(a), self->longitude, &longitude)) != GRIB_SUCCESS) @@ -42,7 +43,8 @@ int grib_accessor_class_g2lon_t::unpack_double(grib_accessor* a, double* val, si return GRIB_SUCCESS; } -int grib_accessor_class_g2lon_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_g2lon_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; long longitude; double value = *val; diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/grib_accessor_class_gaussian_grid_name.cc index b77970ae9..f6b79e794 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.cc +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.cc @@ -9,17 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_gaussian_grid_name.h" -grib_accessor_class_gaussian_grid_name_t _grib_accessor_class_gaussian_grid_name{"gaussian_grid_name"}; +grib_accessor_class_gaussian_grid_name_t _grib_accessor_class_gaussian_grid_name{ "gaussian_grid_name" }; grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_class_gaussian_grid_name; -void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; - int n = 0; + int n = 0; self->N = grib_arguments_get_name(a->parent->h, arg, n++); self->Ni = grib_arguments_get_name(a->parent->h, arg, n++); @@ -29,13 +29,15 @@ void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -int grib_accessor_class_gaussian_grid_name_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_gaussian_grid_name_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } #define MAX_GRIDNAME_LEN 16 -int grib_accessor_class_gaussian_grid_name_t::unpack_string(grib_accessor* a, char* v, size_t* len){ +int grib_accessor_class_gaussian_grid_name_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; long N = 0, Ni = 0; @@ -80,6 +82,7 @@ int grib_accessor_class_gaussian_grid_name_t::unpack_string(grib_accessor* a, ch return GRIB_SUCCESS; } -size_t grib_accessor_class_gaussian_grid_name_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_gaussian_grid_name_t::string_length(grib_accessor* a) +{ return MAX_GRIDNAME_LEN; } diff --git a/src/accessor/grib_accessor_class_gds_is_present.cc b/src/accessor/grib_accessor_class_gds_is_present.cc index b2685ee3a..b568b9bdd 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.cc +++ b/src/accessor/grib_accessor_class_gds_is_present.cc @@ -9,36 +9,37 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_gds_is_present.h" -grib_accessor_class_gds_is_present_t _grib_accessor_class_gds_is_present{"gds_is_present"}; +grib_accessor_class_gds_is_present_t _grib_accessor_class_gds_is_present{ "gds_is_present" }; grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_gds_is_present; -void grib_accessor_class_gds_is_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_gds_is_present_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); - int n = 0; + int n = 0; grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - self->gds_present = grib_arguments_get_name(h, c, n++); - self->grid_definition = grib_arguments_get_name(h, c, n++); - self->bitmap_present = grib_arguments_get_name(h, c, n++); - self->values = grib_arguments_get_name(h, c, n++); + grib_handle* h = grib_handle_of_accessor(a); + self->gds_present = grib_arguments_get_name(h, c, n++); + self->grid_definition = grib_arguments_get_name(h, c, n++); + self->bitmap_present = grib_arguments_get_name(h, c, n++); + self->values = grib_arguments_get_name(h, c, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->length = 0; } -int grib_accessor_class_gds_is_present_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_gds_is_present_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; - long missing = 255; - int ret = 0; - size_t size = 0; - double* values = NULL; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + long missing = 255; + int ret = 0; + size_t size = 0; + double* values = NULL; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); if (*val != 1) return GRIB_NOT_IMPLEMENTED; @@ -73,9 +74,10 @@ int grib_accessor_class_gds_is_present_t::pack_long(grib_accessor* a, const long return GRIB_SUCCESS; } -int grib_accessor_class_gds_is_present_t::unpack_long(grib_accessor* a, long* val, size_t* len){ - int ret = 0; - grib_handle* h = grib_handle_of_accessor(a); +int grib_accessor_class_gds_is_present_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; if ((ret = grib_get_long_internal(h, self->gds_present, val)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc index 0fd8c9e01..6691e2fea 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_gds_not_present_bitmap.h" grib_accessor_class_gds_not_present_bitmap_t _grib_accessor_class_gds_not_present_bitmap{"gds_not_present_bitmap"}; @@ -47,9 +46,9 @@ int grib_accessor_class_gds_not_present_bitmap_t::unpack_double(grib_accessor* a long nn = 0; long missing_value; - int err = 0; double* coded_vals = NULL; - err = a->value_count(&nn); n_vals = nn; + int err = a->value_count(&nn); + n_vals = nn; if (err) return err; diff --git a/src/accessor/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc index 1a86afd55..34ac67881 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_global_gaussian.h" grib_accessor_class_global_gaussian_t _grib_accessor_class_global_gaussian{"global_gaussian"}; diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc index d540c927c..aef185022 100644 --- a/src/accessor/grib_accessor_class_group.cc +++ b/src/accessor/grib_accessor_class_group.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_group.h" grib_accessor_class_group_t _grib_accessor_class_group{"group"}; diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc index 493cbf0f8..62a63bb8f 100644 --- a/src/accessor/grib_accessor_class_gts_header.cc +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_gts_header.h" grib_accessor_class_gts_header_t _grib_accessor_class_gts_header{"gts_header"}; diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc index d4f005710..1955dc07f 100644 --- a/src/accessor/grib_accessor_class_hash_array.cc +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_hash_array.h" grib_accessor_class_hash_array_t _grib_accessor_class_hash_array{"hash_array"}; diff --git a/src/accessor/grib_accessor_class_headers_only.cc b/src/accessor/grib_accessor_class_headers_only.cc index 802fd3f67..9b053112d 100644 --- a/src/accessor/grib_accessor_class_headers_only.cc +++ b/src/accessor/grib_accessor_class_headers_only.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_headers_only.h" grib_accessor_class_headers_only_t _grib_accessor_class_headers_only{"headers_only"}; diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index 65c59ba0f..f3b0f8b98 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_ibmfloat.h" grib_accessor_class_ibmfloat_t _grib_accessor_class_ibmfloat{"ibmfloat"}; diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index e15091925..53894a8a6 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_ieeefloat.h" grib_accessor_class_ieeefloat_t _grib_accessor_class_ieeefloat{"ieeefloat"}; diff --git a/src/accessor/grib_accessor_class_ifs_param.cc b/src/accessor/grib_accessor_class_ifs_param.cc index 419eeff91..32a972c7c 100644 --- a/src/accessor/grib_accessor_class_ifs_param.cc +++ b/src/accessor/grib_accessor_class_ifs_param.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_ifs_param.h" grib_accessor_class_ifs_param_t _grib_accessor_class_ifs_param{"ifs_param"}; diff --git a/src/accessor/grib_accessor_class_iterator.cc b/src/accessor/grib_accessor_class_iterator.cc index 138146747..4cdfd6670 100644 --- a/src/accessor/grib_accessor_class_iterator.cc +++ b/src/accessor/grib_accessor_class_iterator.cc @@ -8,11 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************** - * Enrico Fucile - *************************/ - -#include "grib_api_internal.h" #include "grib_accessor_class_iterator.h" grib_accessor_class_iterator_t _grib_accessor_class_iterator{"iterator"}; diff --git a/src/accessor/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc index 8e3f1e1c4..e633b42e4 100644 --- a/src/accessor/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_julian_date.h" grib_accessor_class_julian_date_t _grib_accessor_class_julian_date{"julian_date"}; diff --git a/src/accessor/grib_accessor_class_julian_day.cc b/src/accessor/grib_accessor_class_julian_day.cc index f96213a0e..e46751181 100644 --- a/src/accessor/grib_accessor_class_julian_day.cc +++ b/src/accessor/grib_accessor_class_julian_day.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_julian_day.h" grib_accessor_class_julian_day_t _grib_accessor_class_julian_day{"julian_day"}; diff --git a/src/accessor/grib_accessor_class_ksec1expver.cc b/src/accessor/grib_accessor_class_ksec1expver.cc index 0b6d94754..0eb0af2c1 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.cc +++ b/src/accessor/grib_accessor_class_ksec1expver.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_ksec1expver.h" grib_accessor_class_ksec1expver_t _grib_accessor_class_ksec1expver{"ksec1expver"}; diff --git a/src/accessor/grib_accessor_class_label.cc b/src/accessor/grib_accessor_class_label.cc index dfcecd887..5b9448399 100644 --- a/src/accessor/grib_accessor_class_label.cc +++ b/src/accessor/grib_accessor_class_label.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_label.h" grib_accessor_class_label_t _grib_accessor_class_label{"label"}; diff --git a/src/accessor/grib_accessor_class_latitudes.cc b/src/accessor/grib_accessor_class_latitudes.cc index c290c9f8e..ae2f718bd 100644 --- a/src/accessor/grib_accessor_class_latitudes.cc +++ b/src/accessor/grib_accessor_class_latitudes.cc @@ -9,16 +9,14 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_latitudes.h" -grib_accessor_class_latitudes_t _grib_accessor_class_latitudes{"latitudes"}; +grib_accessor_class_latitudes_t _grib_accessor_class_latitudes{ "latitudes" }; grib_accessor_class* grib_accessor_class_latitudes = &_grib_accessor_class_latitudes; - - static int get_distinct(grib_accessor* a, double** val, long* len); -int compare_doubles(const void* a, const void* b, int ascending){ +int compare_doubles(const void* a, const void* b, int ascending) +{ /* ascending is a boolean: 0 or 1 */ double* arg1 = (double*)a; double* arg2 = (double*)b; @@ -35,17 +33,20 @@ int compare_doubles(const void* a, const void* b, int ascending){ else return 1; } -int compare_doubles_ascending(const void* a, const void* b){ +int compare_doubles_ascending(const void* a, const void* b) +{ return compare_doubles(a, b, 1); } -int compare_doubles_descending(const void* a, const void* b){ +int compare_doubles_descending(const void* a, const void* b) +{ return compare_doubles(a, b, 0); } -void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; - int n = 0; + int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->distinct = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); @@ -54,18 +55,19 @@ void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_ a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_latitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len){ - grib_context* c = a->context; +int grib_accessor_class_latitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_context* c = a->context; grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; - int ret = 0; - double* v = val; - double dummyLon = 0; - size_t size = 0; - long count = 0; - grib_iterator* iter = NULL; + int ret = 0; + double* v = val; + double dummyLon = 0; + size_t size = 0; + long count = 0; + grib_iterator* iter = NULL; self->save = 1; - ret = value_count(a, &count); + ret = value_count(a, &count); if (ret) return ret; size = count; if (*len < size) { @@ -107,11 +109,12 @@ int grib_accessor_class_latitudes_t::unpack_double(grib_accessor* a, double* val return ret; } -int grib_accessor_class_latitudes_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_latitudes_t::value_count(grib_accessor* a, long* len) +{ grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = a->context; - double* val = NULL; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = a->context; + double* val = NULL; int ret; size_t size; @@ -138,20 +141,21 @@ int grib_accessor_class_latitudes_t::value_count(grib_accessor* a, long* len){ return ret; } -static int get_distinct(grib_accessor* a, double** val, long* len){ +static int get_distinct(grib_accessor* a, double** val, long* len) +{ long count = 0; double prev; double* v = NULL; double* v1 = NULL; double dummyLon = 0; - int ret = 0; + int ret = 0; int i; long jScansPositively = 0; /* default: north to south */ size_t size = *len; grib_context* c = a->context; // Performance: We do not need the values to be decoded - grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); + grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); if (ret != GRIB_SUCCESS) { if (iter) grib_iterator_delete(iter); diff --git a/src/accessor/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc index 66e0944ac..885a4cd61 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_latlon_increment.h" grib_accessor_class_latlon_increment_t _grib_accessor_class_latlon_increment{"latlon_increment"}; diff --git a/src/accessor/grib_accessor_class_latlonvalues.cc b/src/accessor/grib_accessor_class_latlonvalues.cc index 42a2b8c31..5d43d6be9 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.cc +++ b/src/accessor/grib_accessor_class_latlonvalues.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_latlonvalues.h" grib_accessor_class_latlonvalues_t _grib_accessor_class_latlonvalues{"latlonvalues"}; diff --git a/src/accessor/grib_accessor_class_library_version.cc b/src/accessor/grib_accessor_class_library_version.cc index 61fafe279..527b4809a 100644 --- a/src/accessor/grib_accessor_class_library_version.cc +++ b/src/accessor/grib_accessor_class_library_version.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_library_version.h" grib_accessor_class_library_version_t _grib_accessor_class_library_version{"library_version"}; diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index b0633c698..0964a3005 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_local_definition.h" grib_accessor_class_local_definition_t _grib_accessor_class_local_definition{"local_definition"}; diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc index 2ca32aa48..0aee8c8c9 100644 --- a/src/accessor/grib_accessor_class_long_vector.cc +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_long_vector.h" #include "grib_accessor_class_abstract_long_vector.h" diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index 68b89dc23..e25654c94 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_longitudes.h" grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{"longitudes"}; diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc index 3275b9d4e..17ccd4d61 100644 --- a/src/accessor/grib_accessor_class_lookup.cc +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_lookup.h" grib_accessor_class_lookup_t _grib_accessor_class_lookup{"lookup"}; diff --git a/src/accessor/grib_accessor_class_mars_param.cc b/src/accessor/grib_accessor_class_mars_param.cc index 99012ca4f..feb5fc905 100644 --- a/src/accessor/grib_accessor_class_mars_param.cc +++ b/src/accessor/grib_accessor_class_mars_param.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_mars_param.h" grib_accessor_class_mars_param_t _grib_accessor_class_mars_param{"mars_param"}; diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc index 40e198ba3..34d245998 100644 --- a/src/accessor/grib_accessor_class_mars_step.cc +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_mars_step.h" grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{"mars_step"}; diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index 4cc9beaf0..40cbae672 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -9,17 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_md5.h" #include "md5.h" -grib_accessor_class_md5_t _grib_accessor_class_md5{"md5"}; +grib_accessor_class_md5_t _grib_accessor_class_md5{ "md5" }; grib_accessor_class* grib_accessor_class_md5 = &_grib_accessor_class_md5; -void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); - grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; char* b = 0; int n = 0; grib_string_list* current = 0; @@ -48,11 +48,13 @@ void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_argu a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -int grib_accessor_class_md5_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_md5_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = GRIB_SUCCESS; size_t alen = 0; @@ -60,11 +62,13 @@ int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b){ int err = 0; long count = 0; - err = a->value_count(&count); if (err) + err = a->value_count(&count); + if (err) return err; alen = count; - err = b->value_count(&count); if (err) + err = b->value_count(&count); + if (err) return err; blen = count; @@ -74,7 +78,8 @@ int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b){ return retval; } -int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* len){ +int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; unsigned mess_len; unsigned char* mess; @@ -82,7 +87,7 @@ int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* long offset = 0, length = 0; grib_string_list* blocklist = NULL; int ret = GRIB_SUCCESS; - long i = 0; + long i = 0; struct grib_md5_state md5c; if (*len < 32) { @@ -131,7 +136,8 @@ int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* return ret; } -void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; if (self->blocklist) { grib_string_list* next = self->blocklist; @@ -146,7 +152,8 @@ void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a){ grib_accessor_class_gen_t::destroy(c, a); } -int grib_accessor_class_md5_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_md5_t::value_count(grib_accessor* a, long* count) +{ *count = 1; /* ECC-1475 */ return 0; } diff --git a/src/accessor/grib_accessor_class_message.cc b/src/accessor/grib_accessor_class_message.cc index c855e067e..be704b1a1 100644 --- a/src/accessor/grib_accessor_class_message.cc +++ b/src/accessor/grib_accessor_class_message.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_message.h" grib_accessor_class_message_t _grib_accessor_class_message{"message"}; diff --git a/src/accessor/grib_accessor_class_message_copy.cc b/src/accessor/grib_accessor_class_message_copy.cc index 36490fb89..7927b6c60 100644 --- a/src/accessor/grib_accessor_class_message_copy.cc +++ b/src/accessor/grib_accessor_class_message_copy.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_message_copy.h" grib_accessor_class_message_copy_t _grib_accessor_class_message_copy{"message_copy"}; diff --git a/src/accessor/grib_accessor_class_multdouble.cc b/src/accessor/grib_accessor_class_multdouble.cc index ea5068291..cbe5b42da 100644 --- a/src/accessor/grib_accessor_class_multdouble.cc +++ b/src/accessor/grib_accessor_class_multdouble.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_multdouble.h" grib_accessor_class_multdouble_t _grib_accessor_class_multdouble{"multdouble"}; diff --git a/src/accessor/grib_accessor_class_non_alpha.cc b/src/accessor/grib_accessor_class_non_alpha.cc index 26401d764..68aaffdd7 100644 --- a/src/accessor/grib_accessor_class_non_alpha.cc +++ b/src/accessor/grib_accessor_class_non_alpha.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_non_alpha.h" grib_accessor_class_non_alpha_t _grib_accessor_class_non_alpha{"non_alpha"}; diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.cc b/src/accessor/grib_accessor_class_number_of_coded_values.cc index 3cbcf7324..f1023dd2e 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.cc +++ b/src/accessor/grib_accessor_class_number_of_coded_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_number_of_coded_values.h" grib_accessor_class_number_of_coded_values_t _grib_accessor_class_number_of_coded_values{"number_of_coded_values"}; diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc index d1c164fac..c1b63f2a2 100644 --- a/src/accessor/grib_accessor_class_number_of_points.cc +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_number_of_points.h" grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{"number_of_points"}; diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 909aa1b3d..9cabea10c 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_number_of_points_gaussian.h" grib_accessor_class_number_of_points_gaussian_t _grib_accessor_class_number_of_points_gaussian{"number_of_points_gaussian"}; diff --git a/src/accessor/grib_accessor_class_number_of_values.cc b/src/accessor/grib_accessor_class_number_of_values.cc index 1b8e9fd65..414cf5e05 100644 --- a/src/accessor/grib_accessor_class_number_of_values.cc +++ b/src/accessor/grib_accessor_class_number_of_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_number_of_values.h" grib_accessor_class_number_of_values_t _grib_accessor_class_number_of_values{"number_of_values"}; diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc index 1605faa21..b8f1d667b 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_number_of_values_data_raw_packing.h" grib_accessor_class_number_of_values_data_raw_packing_t _grib_accessor_class_number_of_values_data_raw_packing{"number_of_values_data_raw_packing"}; diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index a5e4c7a76..ca106dd4a 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_octahedral_gaussian.h" grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussian{"octahedral_gaussian"}; diff --git a/src/accessor/grib_accessor_class_octet_number.cc b/src/accessor/grib_accessor_class_octet_number.cc index bb30500a4..4b270f257 100644 --- a/src/accessor/grib_accessor_class_octet_number.cc +++ b/src/accessor/grib_accessor_class_octet_number.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_octet_number.h" grib_accessor_class_octet_number_t _grib_accessor_class_octet_number{"octet_number"}; diff --git a/src/accessor/grib_accessor_class_offset_file.cc b/src/accessor/grib_accessor_class_offset_file.cc index 9bcb55f99..b52e8eb41 100644 --- a/src/accessor/grib_accessor_class_offset_file.cc +++ b/src/accessor/grib_accessor_class_offset_file.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_offset_file.h" grib_accessor_class_offset_file_t _grib_accessor_class_offset_file{"offset_file"}; diff --git a/src/accessor/grib_accessor_class_offset_values.cc b/src/accessor/grib_accessor_class_offset_values.cc index 700bdb0f4..26f78b5c3 100644 --- a/src/accessor/grib_accessor_class_offset_values.cc +++ b/src/accessor/grib_accessor_class_offset_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_offset_values.h" grib_accessor_class_offset_values_t _grib_accessor_class_offset_values{"offset_values"}; diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc index 8df1db80e..3c725ec87 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_optimal_step_units.h" #include "step.h" #include "step_utilities.h" diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc index 4c276ed42..08b80d607 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_pack_bufr_values.h" grib_accessor_class_pack_bufr_values_t _grib_accessor_class_pack_bufr_values{"pack_bufr_values"}; diff --git a/src/accessor/grib_accessor_class_packing_type.cc b/src/accessor/grib_accessor_class_packing_type.cc index 8be8c02aa..5dd862a07 100644 --- a/src/accessor/grib_accessor_class_packing_type.cc +++ b/src/accessor/grib_accessor_class_packing_type.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_packing_type.h" grib_accessor_class_packing_type_t _grib_accessor_class_packing_type{"packing_type"}; diff --git a/src/accessor/grib_accessor_class_pad.cc b/src/accessor/grib_accessor_class_pad.cc index aa6ff538f..345b510fb 100644 --- a/src/accessor/grib_accessor_class_pad.cc +++ b/src/accessor/grib_accessor_class_pad.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_pad.h" grib_accessor_class_pad_t _grib_accessor_class_pad{"pad"}; diff --git a/src/accessor/grib_accessor_class_padding.cc b/src/accessor/grib_accessor_class_padding.cc index 2dd0c6265..499c77f2b 100644 --- a/src/accessor/grib_accessor_class_padding.cc +++ b/src/accessor/grib_accessor_class_padding.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" grib_accessor_class_padding_t _grib_accessor_class_padding{"padding"}; diff --git a/src/accessor/grib_accessor_class_padto.cc b/src/accessor/grib_accessor_class_padto.cc index d162403ed..110d8d858 100644 --- a/src/accessor/grib_accessor_class_padto.cc +++ b/src/accessor/grib_accessor_class_padto.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_padto.h" grib_accessor_class_padto_t _grib_accessor_class_padto{"padto"}; diff --git a/src/accessor/grib_accessor_class_padtoeven.cc b/src/accessor/grib_accessor_class_padtoeven.cc index ff6aef055..adf8b0d84 100644 --- a/src/accessor/grib_accessor_class_padtoeven.cc +++ b/src/accessor/grib_accessor_class_padtoeven.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_padtoeven.h" grib_accessor_class_padtoeven_t _grib_accessor_class_padtoeven{"padtoeven"}; diff --git a/src/accessor/grib_accessor_class_padtomultiple.cc b/src/accessor/grib_accessor_class_padtomultiple.cc index 88e4c6591..d4e463578 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.cc +++ b/src/accessor/grib_accessor_class_padtomultiple.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_padtomultiple.h" grib_accessor_class_padtomultiple_t _grib_accessor_class_padtomultiple{"padtomultiple"}; diff --git a/src/accessor/grib_accessor_class_position.cc b/src/accessor/grib_accessor_class_position.cc index a8d6201d4..f1a429270 100644 --- a/src/accessor/grib_accessor_class_position.cc +++ b/src/accessor/grib_accessor_class_position.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_position.h" grib_accessor_class_position_t _grib_accessor_class_position{"position"}; diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index d55b277e0..f8c8e127f 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_proj_string.h" grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{"proj_string"}; diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc index 1473325a3..4a80b772a 100644 --- a/src/accessor/grib_accessor_class_raw.cc +++ b/src/accessor/grib_accessor_class_raw.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_raw.h" grib_accessor_class_raw_t _grib_accessor_class_raw{"raw"}; diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc index 77d917757..173e0a3dc 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_rdbtime_guess_date.h" grib_accessor_class_rdbtime_guess_date_t _grib_accessor_class_rdbtime_guess_date{"rdbtime_guess_date"}; diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc index 7329acaee..9a1dba20b 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.cc +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_reference_value_error.h" grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{"reference_value_error"}; diff --git a/src/accessor/grib_accessor_class_round.cc b/src/accessor/grib_accessor_class_round.cc index b1a114d0e..f56fa4a1c 100644 --- a/src/accessor/grib_accessor_class_round.cc +++ b/src/accessor/grib_accessor_class_round.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_round.h" grib_accessor_class_round_t _grib_accessor_class_round{"round"}; diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc index 76deb2dc5..eb01412d2 100644 --- a/src/accessor/grib_accessor_class_scale.cc +++ b/src/accessor/grib_accessor_class_scale.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_scale.h" grib_accessor_class_scale_t _grib_accessor_class_scale{"scale"}; diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc index dcb3e8a1a..03c5e0de2 100644 --- a/src/accessor/grib_accessor_class_scale_values.cc +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_scale_values.h" grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{"scale_values"}; diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc index 5d0075ad3..1c253764a 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_second_order_bits_per_value.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_section_length.cc b/src/accessor/grib_accessor_class_section_length.cc index 3378d60c8..bcc75cc2b 100644 --- a/src/accessor/grib_accessor_class_section_length.cc +++ b/src/accessor/grib_accessor_class_section_length.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_section_length.h" grib_accessor_class_section_length_t _grib_accessor_class_section_length{"section_length"}; diff --git a/src/accessor/grib_accessor_class_section_padding.cc b/src/accessor/grib_accessor_class_section_padding.cc index d05abcd25..c3457898f 100644 --- a/src/accessor/grib_accessor_class_section_padding.cc +++ b/src/accessor/grib_accessor_class_section_padding.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_section_padding.h" grib_accessor_class_section_padding_t _grib_accessor_class_section_padding{"section_padding"}; diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc index 93344acfc..72eb78d6d 100644 --- a/src/accessor/grib_accessor_class_section_pointer.cc +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_section_pointer.h" grib_accessor_class_section_pointer_t _grib_accessor_class_section_pointer{"section_pointer"}; diff --git a/src/accessor/grib_accessor_class_select_step_template.cc b/src/accessor/grib_accessor_class_select_step_template.cc index 8de2bc24f..bc72a5220 100644 --- a/src/accessor/grib_accessor_class_select_step_template.cc +++ b/src/accessor/grib_accessor_class_select_step_template.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_select_step_template.h" grib_accessor_class_select_step_template_t _grib_accessor_class_select_step_template{"select_step_template"}; diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc index 275ce2ff0..e1920c1b9 100644 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_sexagesimal2decimal.h" grib_accessor_class_sexagesimal2decimal_t _grib_accessor_class_sexagesimal2decimal{"sexagesimal2decimal"}; diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index 84822b421..dea029231 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_signed.h" grib_accessor_class_signed_t _grib_accessor_class_signed{"signed"}; diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc index c43f2c064..3da4d03c2 100644 --- a/src/accessor/grib_accessor_class_signed_bits.cc +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_signed_bits.h" grib_accessor_class_signed_bits_t _grib_accessor_class_signed_bits{"signed_bits"}; diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc index 3675b7d15..5f713a950 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.cc +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_simple_packing_error.h" #include "grib_scaling.h" diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc index 363cafd28..a9aa37f06 100644 --- a/src/accessor/grib_accessor_class_size.cc +++ b/src/accessor/grib_accessor_class_size.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_size.h" grib_accessor_class_size_t _grib_accessor_class_size{"size"}; diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index e26169656..2d18ade06 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -8,10 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - #include "grib_accessor_class_smart_table.h" #include diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc index d04f63e5e..7d352471d 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.cc +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_smart_table_column.h" #include "grib_accessor_class_smart_table.h" diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc index 699ab6f9c..dd717ba3c 100644 --- a/src/accessor/grib_accessor_class_spd.cc +++ b/src/accessor/grib_accessor_class_spd.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_spd.h" grib_accessor_class_spd_t _grib_accessor_class_spd{"spd"}; diff --git a/src/accessor/grib_accessor_class_spectral_truncation.cc b/src/accessor/grib_accessor_class_spectral_truncation.cc index 5a51a416c..2fc45511f 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.cc +++ b/src/accessor/grib_accessor_class_spectral_truncation.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_spectral_truncation.h" grib_accessor_class_spectral_truncation_t _grib_accessor_class_spectral_truncation{"spectral_truncation"}; diff --git a/src/accessor/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc index 6c361604e..cc9e37e6a 100644 --- a/src/accessor/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_sprintf.h" grib_accessor_class_sprintf_t _grib_accessor_class_sprintf{"sprintf"}; diff --git a/src/accessor/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc index f84731e0e..2d5cfd756 100644 --- a/src/accessor/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_statistics.h" grib_accessor_class_statistics_t _grib_accessor_class_statistics{"statistics"}; diff --git a/src/accessor/grib_accessor_class_statistics_spectral.cc b/src/accessor/grib_accessor_class_statistics_spectral.cc index ea57cd2be..f2cfb6f35 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.cc +++ b/src/accessor/grib_accessor_class_statistics_spectral.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_statistics_spectral.h" grib_accessor_class_statistics_spectral_t _grib_accessor_class_statistics_spectral{"statistics_spectral"}; diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index ea6930f90..ea5280632 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_step_human_readable.h" grib_accessor_class_step_human_readable_t _grib_accessor_class_step_human_readable{"step_human_readable"}; diff --git a/src/accessor/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc index 1d6c0afb9..3bbdba009 100644 --- a/src/accessor/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_step_in_units.h" #include "step.h" #include "step_utilities.h" diff --git a/src/accessor/grib_accessor_class_sum.cc b/src/accessor/grib_accessor_class_sum.cc index 5001e6b52..39b96854f 100644 --- a/src/accessor/grib_accessor_class_sum.cc +++ b/src/accessor/grib_accessor_class_sum.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_sum.h" grib_accessor_class_sum_t _grib_accessor_class_sum{"sum"}; diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc index e205b782e..14d5932bc 100644 --- a/src/accessor/grib_accessor_class_suppressed.cc +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_suppressed.h" grib_accessor_class_suppressed_t _grib_accessor_class_suppressed{"suppressed"}; diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc index ead200ca3..debb1a2f4 100644 --- a/src/accessor/grib_accessor_class_time.cc +++ b/src/accessor/grib_accessor_class_time.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_time.h" grib_accessor_class_time_t _grib_accessor_class_time{"time"}; diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc index 51e6de3e1..854a32ffc 100644 --- a/src/accessor/grib_accessor_class_to_double.cc +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_to_double.h" grib_accessor_class_to_double_t _grib_accessor_class_to_double{"to_double"}; diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc index 9109ab603..bc58f31c6 100644 --- a/src/accessor/grib_accessor_class_to_integer.cc +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_to_integer.h" grib_accessor_class_to_integer_t _grib_accessor_class_to_integer{"to_integer"}; diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc index 65f7a3647..4f1150ffb 100644 --- a/src/accessor/grib_accessor_class_to_string.cc +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_to_string.h" grib_accessor_class_to_string_t _grib_accessor_class_to_string{"to_string"}; diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc index 5ed3333db..d45ec3478 100644 --- a/src/accessor/grib_accessor_class_transient_darray.cc +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_transient_darray.h" grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{"transient_darray"}; diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc index 8e0e45a6b..a7db4f3ff 100644 --- a/src/accessor/grib_accessor_class_trim.cc +++ b/src/accessor/grib_accessor_class_trim.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_trim.h" grib_accessor_class_trim_t _grib_accessor_class_trim{"trim"}; diff --git a/src/accessor/grib_accessor_class_uint16.cc b/src/accessor/grib_accessor_class_uint16.cc index b8476105c..1d9158ac0 100644 --- a/src/accessor/grib_accessor_class_uint16.cc +++ b/src/accessor/grib_accessor_class_uint16.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint16.h" grib_accessor_class_uint16_t _grib_accessor_class_uint16{"uint16"}; diff --git a/src/accessor/grib_accessor_class_uint32.cc b/src/accessor/grib_accessor_class_uint32.cc index 6465375b6..7518cb68c 100644 --- a/src/accessor/grib_accessor_class_uint32.cc +++ b/src/accessor/grib_accessor_class_uint32.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint32.h" grib_accessor_class_uint32_t _grib_accessor_class_uint32{"uint32"}; diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.cc b/src/accessor/grib_accessor_class_uint32_little_endian.cc index 7800d30c0..b8733bd0a 100644 --- a/src/accessor/grib_accessor_class_uint32_little_endian.cc +++ b/src/accessor/grib_accessor_class_uint32_little_endian.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint32_little_endian.h" grib_accessor_class_uint32_little_endian_t _grib_accessor_class_uint32_little_endian{"uint32_little_endian"}; diff --git a/src/accessor/grib_accessor_class_uint64.cc b/src/accessor/grib_accessor_class_uint64.cc index 302702dab..4c79f7bb4 100644 --- a/src/accessor/grib_accessor_class_uint64.cc +++ b/src/accessor/grib_accessor_class_uint64.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint64.h" grib_accessor_class_uint64_t _grib_accessor_class_uint64{"uint64"}; diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.cc b/src/accessor/grib_accessor_class_uint64_little_endian.cc index 80da3d903..81d0fed37 100644 --- a/src/accessor/grib_accessor_class_uint64_little_endian.cc +++ b/src/accessor/grib_accessor_class_uint64_little_endian.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint64_little_endian.h" grib_accessor_class_uint64_little_endian_t _grib_accessor_class_uint64_little_endian{"uint64_little_endian"}; diff --git a/src/accessor/grib_accessor_class_uint8.cc b/src/accessor/grib_accessor_class_uint8.cc index b86079a53..ce5d88f98 100644 --- a/src/accessor/grib_accessor_class_uint8.cc +++ b/src/accessor/grib_accessor_class_uint8.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_uint8.h" grib_accessor_class_uint8_t _grib_accessor_class_uint8{"uint8"}; diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index 4339691a9..f430b4864 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_unexpanded_descriptors.h" grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{"unexpanded_descriptors"}; diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index 4b3be3ad4..9942a64a8 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -9,16 +9,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_unpack_bufr_values.h" #include "grib_accessor_class_bufr_data_array.h" - - grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{"unpack_bufr_values"}; grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; - void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ grib_accessor_class_gen_t::init(a, len, params); char* key; diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index 14c22d309..40088c17d 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned_bits.h" grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{"unsigned_bits"}; diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc index 8a62f296b..19c26bf48 100644 --- a/src/accessor/grib_accessor_class_validity_date.cc +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_validity_date.h" #include "shared_functions.h" diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc index c74b44035..9cbc445cb 100644 --- a/src/accessor/grib_accessor_class_validity_time.cc +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_validity_time.h" #include "shared_functions.h" diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index 7def5b09e..5aa172a05 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_values.h" grib_accessor_class_values_t _grib_accessor_class_values{"values"}; diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index 36b252f95..bd0185d73 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_vector.h" #include "grib_accessor_class_abstract_vector.h" diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc index 68b7196c3..2ab2652f0 100644 --- a/src/accessor/grib_accessor_class_when.cc +++ b/src/accessor/grib_accessor_class_when.cc @@ -9,7 +9,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" #include "grib_accessor_class_when.h" grib_accessor_class_when_t _grib_accessor_class_when{"when"}; From f6d42954d24df648ee17e853c5533a6979231caf Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 27 Apr 2024 14:39:23 +0100 Subject: [PATCH 31/90] Initialize all data members --- src/accessor/grib_accessor.cc | 20 ++++++++++---------- src/accessor/grib_accessor.h | 14 ++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/accessor/grib_accessor.cc b/src/accessor/grib_accessor.cc index 08e50cb78..23c52c888 100644 --- a/src/accessor/grib_accessor.cc +++ b/src/accessor/grib_accessor.cc @@ -61,26 +61,26 @@ int grib_accessor::add_attribute(grib_accessor* attr, int nest_if_clash) { int id = 0; int idx = 0; - grib_accessor* same = NULL; - grib_accessor* aloc = this; + grib_accessor* pSame = NULL; + grib_accessor* pAloc = this; if (this->has_attributes()) { - same = this->get_attribute_index(attr->name, &id); + pSame = this->get_attribute_index(attr->name, &id); } - if (same) { + if (pSame) { if (nest_if_clash == 0) return GRIB_ATTRIBUTE_CLASH; - aloc = same; + pAloc = pSame; } for (id = 0; id < MAX_ACCESSOR_ATTRIBUTES; id++) { - if (aloc->attributes[id] == NULL) { + if (pAloc->attributes[id] == NULL) { // attr->parent=a->parent; - aloc->attributes[id] = attr; - attr->parent_as_attribute = aloc; - if (aloc->same) - attr->same = aloc->same->get_attribute_index(attr->name, &idx); + pAloc->attributes[id] = attr; + attr->parent_as_attribute = pAloc; + if (pAloc->same) + attr->same = pAloc->same->get_attribute_index(attr->name, &idx); grib_context_log(this->context, GRIB_LOG_DEBUG, "added attribute %s->%s", this->name, attr->name); return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor.h b/src/accessor/grib_accessor.h index c18a355d2..7fe8aad19 100644 --- a/src/accessor/grib_accessor.h +++ b/src/accessor/grib_accessor.h @@ -16,7 +16,11 @@ class grib_accessor { public: - grib_accessor() : name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), length(0), offset(0), parent(nullptr), next_(nullptr), previous_(nullptr), cclass(nullptr), flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), set(nullptr), parent_as_attribute(nullptr) {} + grib_accessor() : + name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), + length(0), offset(0), parent(nullptr), next_(nullptr), previous_(nullptr), cclass(nullptr), + flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), + set(nullptr), parent_as_attribute(nullptr) {} virtual ~grib_accessor() {} virtual void init_accessor(const long, grib_arguments*) = 0; @@ -78,15 +82,15 @@ public: unsigned long flags; /** < Various flags */ grib_section* sub_section; - const char* all_names[MAX_ACCESSOR_NAMES]; /** < name of the accessor */ - const char* all_name_spaces[MAX_ACCESSOR_NAMES]; /** < namespace to which the accessor belongs */ + const char* all_names[MAX_ACCESSOR_NAMES]= {0,}; /** < name of the accessor */ + const char* all_name_spaces[MAX_ACCESSOR_NAMES] = {0,}; /** < namespace to which the accessor belongs */ int dirty; grib_accessor* same; /** < accessors with the same name */ long loop; /** < used in lists */ grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ const char* set; - grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES]; /** < attributes are accessors */ + grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES] = {0,}; /** < attributes are accessors */ grib_accessor* parent_as_attribute; }; @@ -141,5 +145,3 @@ public: virtual int clear(grib_accessor*) = 0; virtual grib_accessor* make_clone(grib_accessor*, grib_section*, int*) = 0; }; - - From f55015ee1018b43a7ddb5b5e81cfa1aa7d3bf0fc Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 30 Apr 2024 08:40:44 +0100 Subject: [PATCH 32/90] Testing: Catch error messages (Setting integer values double array) --- tests/pseudo_budg.sh | 3 +++ tests/pseudo_diag.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/pseudo_budg.sh b/tests/pseudo_budg.sh index 4c50789d8..9c793a718 100755 --- a/tests/pseudo_budg.sh +++ b/tests/pseudo_budg.sh @@ -17,6 +17,9 @@ tempOut=temp.$label.txt tempRef=temp.$label.ref tempBud=temp.$label.bud +# Abort if any error messages are posted +export ECCODES_FAIL_IF_LOG_MESSAGE=1 + ${tools_dir}/grib_ls -j ${data_dir}/budg > $tempOut cat > $tempRef << EOF { "messages" : [ diff --git a/tests/pseudo_diag.sh b/tests/pseudo_diag.sh index 50208a45e..af45d6aea 100755 --- a/tests/pseudo_diag.sh +++ b/tests/pseudo_diag.sh @@ -20,6 +20,9 @@ REDIRECT=/dev/null sample=$ECCODES_SAMPLES_PATH/diag.tmpl +# Abort if any error messages are posted +export ECCODES_FAIL_IF_LOG_MESSAGE=1 + # Basic grib commands should not fail # ------------------------------------ ${tools_dir}/grib_ls $sample > $REDIRECT From 4735c01df5a30f1bbe052e8d0f6ede6f765c1873 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Thu, 2 May 2024 16:10:38 +0000 Subject: [PATCH 33/90] Simplify generic pack_double function --- src/accessor/grib_accessor_class_gen.cc | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 0c522cadd..a147996dd 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -539,33 +539,15 @@ int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, size_t* len) { - static int check_pack_long = 1; - if (check_pack_long) { - const long v_tmp = (long) (*v); - size_t l_tmp = 0; - pack_long(a, &v_tmp, &l_tmp); - check_pack_long = 0; - } - is_overridden_[PACK_DOUBLE] = 0; + grib_context* c = a->context; - int do_pack_as_long = 0; - grib_context* c = a->context; - if (is_overridden_[PACK_LONG]) { - do_pack_as_long = 1; - } - else { + if (strcmp(a->cclass->name, "codetable") == 0 || is_overridden_[PACK_LONG]) { /* ECC-648: Special case of codetable */ - if (strcmp(a->cclass->name, "codetable") == 0) { - do_pack_as_long = 1; - } - } - - if (do_pack_as_long) { return pack_double_array_as_long(a, v, len); } - grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); if (is_overridden_[PACK_STRING]) { grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); } From 33dbaa5db91dd51406f066502fc8f9ffae100655 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Thu, 2 May 2024 17:26:22 +0000 Subject: [PATCH 34/90] Fix reflection --- src/accessor/grib_accessor_class_gen.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index a147996dd..cba6e3ae0 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -586,10 +586,7 @@ int grib_accessor_class_gen_t::pack_string(grib_accessor* a, const char* v, size __func__, v, a->name); return GRIB_WRONG_TYPE; } - int err = a->pack_double(&val, &l); - if (is_overridden_[PACK_DOUBLE]) { - return err; - } + return a->pack_double(&val, &l); } if (is_overridden_[PACK_LONG]) { From ea6fca236eacf8037c214e114eb176545dfc80cf Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Fri, 3 May 2024 12:41:00 +0000 Subject: [PATCH 35/90] Initialisation of accessors lists --- src/accessor/grib_accessors_list.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h index 3c5cc2ebe..2bdd29de7 100644 --- a/src/accessor/grib_accessors_list.h +++ b/src/accessor/grib_accessors_list.h @@ -26,11 +26,11 @@ public: int unpack_float(float* val, size_t* buffer_len); int unpack_string(char** val, size_t* buffer_len); - grib_accessor* accessor; - int rank; - grib_accessors_list* next_; - grib_accessors_list* prev_; - grib_accessors_list* last_; + grib_accessor* accessor = nullptr; + int rank = 0; + grib_accessors_list* next_ = nullptr; + grib_accessors_list* prev_ = nullptr; + grib_accessors_list* last_ = nullptr; }; grib_accessors_list* grib_accessors_list_create(grib_context* c); From 7ddc88a430ae3caa06c36f7b6210c7b91ee64f28 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 7 May 2024 10:03:49 +0000 Subject: [PATCH 36/90] Fix py_bufr_ecc-869.py test --- src/accessor/grib_accessor_class_bufr_data_array.cc | 6 ++++-- src/accessor/grib_accessor_class_gen.cc | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index 0314effa0..14f13d966 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -2066,7 +2066,8 @@ int is_bitmap_start_descriptor(grib_accessors_list* al, int* err){ acode = al->accessor->get_attribute("code"); if (acode) - *err = acode->unpack_long(code, &l); else + *err = acode->unpack_long(code, &l); + else return 1; switch (code[0]) { @@ -2081,7 +2082,8 @@ int is_bitmap_start_descriptor(grib_accessors_list* al, int* err){ { //long index[1]; //grib_accessor* anindex=grib_accessor_get_attribute(al->accessor,"index"); - //anindex->unpack_long(index,&l); return 1; + //anindex->unpack_long(index,&l); + return 1; } } return 0; diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index cba6e3ae0..292c87c35 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -542,7 +542,7 @@ int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, si is_overridden_[PACK_DOUBLE] = 0; grib_context* c = a->context; - if (strcmp(a->cclass->name, "codetable") == 0 || is_overridden_[PACK_LONG]) { + if (is_overridden_[PACK_LONG] || strcmp(a->cclass->name, "codetable") == 0) { /* ECC-648: Special case of codetable */ return pack_double_array_as_long(a, v, len); } From 677f73f3c8695a50ab6cac399d81a586f9a30c87 Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 7 May 2024 15:51:08 +0100 Subject: [PATCH 37/90] ECC-1820: Fix Windows build --- .../grib_accessor_class_data_ccsds_packing.cc | 291 ++++++++++++++---- .../grib_accessor_class_data_ccsds_packing.h | 158 +--------- 2 files changed, 229 insertions(+), 220 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 1feed1323..e453a7b09 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -11,14 +11,24 @@ #include "grib_accessor_class_data_ccsds_packing.h" -grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{"data_ccsds_packing"}; +#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) + #include +#endif + +#ifndef LIBAEC_DLL_EXPORTED + #error Version of libaec appears to be too old. Please upgrade. +#endif + +grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{ "data_ccsds_packing" }; grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing; -void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* h = grib_handle_of_accessor(a); + + grib_handle* h = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(h, args, self->carg++); self->reference_value = grib_arguments_get_name(h, args, self->carg++); @@ -34,7 +44,8 @@ void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, count); @@ -42,47 +53,50 @@ int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long #if defined(HAVE_LIBAEC) || defined(HAVE_AEC) -bool grib_accessor_class_data_ccsds_packing_t::is_big_endian() +static bool is_big_endian() { - unsigned char is_big_endian = 0; + unsigned char is_big_endian = 0; unsigned short endianess_test = 1; return reinterpret_cast(&endianess_test)[0] == is_big_endian; } -void grib_accessor_class_data_ccsds_packing_t::modify_aec_flags(long* flags){ +static void modify_aec_flags(long* flags) +{ // ECC-1602: Performance improvement: enabled the use of native data types *flags &= ~AEC_DATA_3BYTE; // disable support for 3-bytes per value if (is_big_endian()) - *flags |= AEC_DATA_MSB; // enable big-endian + *flags |= AEC_DATA_MSB; // enable big-endian else *flags &= ~AEC_DATA_MSB; // enable little-endian } -const char* grib_accessor_class_data_ccsds_packing_t::aec_get_error_message(int code) +static const char* aec_get_error_message(int code) { - if (code == AEC_MEM_ERROR) return "AEC_MEM_ERROR"; - if (code == AEC_DATA_ERROR) return "AEC_DATA_ERROR"; + if (code == AEC_MEM_ERROR) return "AEC_MEM_ERROR"; + if (code == AEC_DATA_ERROR) return "AEC_DATA_ERROR"; if (code == AEC_STREAM_ERROR) return "AEC_STREAM_ERROR"; - if (code == AEC_CONF_ERROR) return "AEC_CONF_ERROR"; - if (code == AEC_OK) return "AEC_OK"; + if (code == AEC_CONF_ERROR) return "AEC_CONF_ERROR"; + if (code == AEC_OK) return "AEC_OK"; return "Unknown error code"; } -void grib_accessor_class_data_ccsds_packing_t::print_aec_stream_info(struct aec_stream* strm, const char* func){ - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); +static void print_aec_stream_info(struct aec_stream* strm, const char* func) +{ + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.bits_per_sample=%u\n", func, strm->bits_per_sample); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.rsi=%u\n", func, strm->rsi); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_out=%lu\n", func, strm->avail_out); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.rsi=%u\n", func, strm->rsi); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_out=%lu\n", func, strm->avail_out); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); } -int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_handle* hand = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; - int err = GRIB_SUCCESS; + int err = GRIB_SUCCESS; size_t buflen = 0, i = 0; bool is_constant_field = false; @@ -92,9 +106,9 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons long binary_scale_factor = 0; long decimal_scale_factor = 0; - //long optimize_scaling_factor = 0; - double reference_value = 0; - long bits_per_value = 0; + // long optimize_scaling_factor = 0; + double reference_value = 0; + long bits_per_value = 0; double max, min, d, divisor; long number_of_data_points; @@ -118,8 +132,8 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) return err; - //if ((err = grib_get_long_internal(gh, self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS) - // return err; + // if ((err = grib_get_long_internal(gh, self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS) + // return err; if ((err = grib_get_long_internal(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) return err; @@ -139,8 +153,10 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons max = val[0]; min = max; for (i = 1; i < n_vals; i++) { - if (val[i] > max) max = val[i]; - else if (val[i] < min) min = val[i]; + if (val[i] > max) + max = val[i]; + else if (val[i] < min) + min = val[i]; } if ((err = grib_check_data_values_minmax(hand, min, max)) != GRIB_SUCCESS) { @@ -149,10 +165,11 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons if (min == max) { is_constant_field = true; - } else { + } + else { if (bits_per_value == 0) { // ECC-1202: A non-constant field with bitsPerValue==0! - bits_per_value = 24; //Set sane value + bits_per_value = 24; // Set sane value } } @@ -172,7 +189,7 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons if ((err = grib_set_long_internal(hand, self->number_of_values, n_vals)) != GRIB_SUCCESS) return err; - bits_per_value = 0; // ECC-1387 + bits_per_value = 0; // ECC-1387 if ((err = grib_set_long_internal(hand, self->bits_per_value, bits_per_value)) != GRIB_SUCCESS) return err; @@ -191,25 +208,25 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons if (grib_get_nearest_smaller_value(hand, self->reference_value, min, &reference_value) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, - "%s %s: Unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value); + "%s %s: Unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value); return GRIB_INTERNAL_ERROR; } if (reference_value > min) { grib_context_log(a->context, GRIB_LOG_ERROR, - "%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min); + "%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min); DEBUG_ASSERT(reference_value <= min); return GRIB_INTERNAL_ERROR; } } else { - int last = 127; // last must be a parameter coming from the def file - double range = 0; + int last = 127; // last must be a parameter coming from the def file + double range = 0; double minrange = 0, maxrange = 0; double unscaled_max = 0; double unscaled_min = 0; - double f = 0; - double decimal = 1; + double f = 0; + double decimal = 1; decimal_scale_factor = 0; range = (max - min); @@ -292,17 +309,17 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons } break; default: - grib_context_log(a->context, GRIB_LOG_ERROR,"%s pack_double: packing %s, bits_per_value=%ld (max 32)", - cclass_name, a->name, bits_per_value); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s pack_double: packing %s, bits_per_value=%ld (max 32)", + cclass_name, a->name, bits_per_value); err = GRIB_INVALID_BPV; goto cleanup; } - grib_context_log(a->context, GRIB_LOG_DEBUG,"%s pack_double: packing %s, %zu values", cclass_name, a->name, n_vals); + grib_context_log(a->context, GRIB_LOG_DEBUG, "%s pack_double: packing %s, %zu values", cclass_name, a->name, n_vals); // ECC-1431: GRIB2: CCSDS encoding failure AEC_STREAM_ERROR buflen = (nbytes * n_vals) * 67 / 64 + 256; - buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); + buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); if (!buf) { err = GRIB_OUT_OF_MEMORY; @@ -317,7 +334,7 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons grib_get_double_internal(hand, self->reference_value, &ref); if (ref != reference_value) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: %s (ref=%.10e != reference_value=%.10e)", - cclass_name, __func__, self->reference_value, ref, reference_value); + cclass_name, __func__, self->reference_value, ref, reference_value); return GRIB_INTERNAL_ERROR; } } @@ -338,7 +355,6 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons strm.next_in = encoded; strm.avail_in = nbytes * n_vals; - // This does not support spherical harmonics, and treats 24 differently than: // see http://cdo.sourcearchive.com/documentation/1.5.1.dfsg.1-1/cgribexlib_8c_source.html @@ -346,7 +362,7 @@ int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, cons if ((err = aec_buffer_encode(&strm)) != AEC_OK) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_encode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); + cclass_name, __func__, err, aec_get_error_message(err)); err = GRIB_ENCODING_ERROR; goto cleanup; } @@ -367,23 +383,165 @@ cleanup: return err; } -int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + int err = GRIB_SUCCESS, i = 0; + size_t buflen = 0; + struct aec_stream strm; + double bscale = 0; + double dscale = 0; + unsigned char* buf = NULL; + size_t n_vals = 0; + size_t size = 0; + unsigned char* decoded = NULL; + // unsigned char* p = NULL; + long nn = 0; + + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + double reference_value = 0; + long bits_per_value = 0; + + long ccsds_flags; + long ccsds_block_size; + long ccsds_rsi; + size_t nbytes; + + self->dirty = 0; + + if ((err = a->value_count(&nn)) != GRIB_SUCCESS) + return err; + n_vals = nn; + + if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + // ECC-477: Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) + return err; + + modify_aec_flags(&ccsds_flags); + + // TODO(masn): This should be called upstream + if (*len < n_vals) + return GRIB_ARRAY_TOO_SMALL; + + // Special case + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + bscale = codes_power(binary_scale_factor, 2); + dscale = codes_power(-decimal_scale_factor, 10); + + buflen = a->byte_count(); + buf = (unsigned char*)hand->buffer->data; + buf += a->byte_offset(); + strm.flags = ccsds_flags; + strm.bits_per_sample = bits_per_value; + strm.block_size = ccsds_block_size; + strm.rsi = ccsds_rsi; + + strm.next_in = buf; + strm.avail_in = buflen; + + nbytes = (bits_per_value + 7) / 8; + if (nbytes == 3) + nbytes = 4; + + size = n_vals * nbytes; + decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); + if (!decoded) { + err = GRIB_OUT_OF_MEMORY; + goto cleanup; + } + strm.next_out = decoded; + strm.avail_out = size; + + if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); + + if ((err = aec_buffer_decode(&strm)) != AEC_OK) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", + cclass_name, __func__, err, aec_get_error_message(err)); + err = GRIB_DECODING_ERROR; + goto cleanup; + } + + // ECC-1427: Performance improvement (replaced by ECC-1602) + // grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); + + // ECC-1602: Performance improvement + switch (nbytes) { + case 1: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 2: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + case 4: + for (i = 0; i < n_vals; i++) { + val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; + } + break; + default: + grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", + cclass_name, __func__, a->name, bits_per_value); + err = GRIB_INVALID_BPV; + goto cleanup; + } + + *len = n_vals; + +cleanup: + grib_context_buffer_free(a->context, decoded); + return err; +} + +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ // The index idx relates to codedValues NOT values! const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int err = 0; - size_t size = 0; - long bits_per_value = 0; + + grib_handle* hand = grib_handle_of_accessor(a); + int err = 0; + size_t size = 0; + long bits_per_value = 0; double reference_value = 0; - double* values = NULL; + double* values = NULL; if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) return err; @@ -411,13 +569,14 @@ int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accesso return GRIB_SUCCESS; } -int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; - double* values = NULL; - int err = 0; - long bits_per_value = 0; + double* values = NULL; + int err = 0; + long bits_per_value = 0; double reference_value = 0; if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -458,28 +617,34 @@ int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_acc #else -static void print_error_feature_not_enabled(grib_context* c){ +static void print_error_feature_not_enabled(grib_context* c) +{ grib_context_log(c, GRIB_LOG_ERROR, "CCSDS support not enabled. " "Please rebuild with -DENABLE_AEC=ON (Adaptive Entropy Coding library)"); } -int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h index 19889e937..c93c0d24c 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.h +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -9,20 +9,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_ccsds_packing_h -#define eccodes_accessor_data_ccsds_packing_h +#pragma once #include "grib_accessor_class_values.h" #include "grib_scaling.h" -#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) -#include -#endif - -#ifndef LIBAEC_DLL_EXPORTED - #error Version of libaec appears to be too old. Please upgrade. -#endif - class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t { public: @@ -40,7 +31,6 @@ public: }; - // TODO(maee): if libaec is not available, this class should not be defined class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t { @@ -54,150 +44,4 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; - -private: - template int unpack(grib_accessor*, T*, size_t* ); - void print_aec_stream_info(struct aec_stream*, const char*); - void modify_aec_flags(long*); - const char* aec_get_error_message(int); - bool is_big_endian(); }; - - -template -int grib_accessor_class_data_ccsds_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - int err = GRIB_SUCCESS, i = 0; - size_t buflen = 0; - struct aec_stream strm; - double bscale = 0; - double dscale = 0; - unsigned char* buf = NULL; - size_t n_vals = 0; - size_t size = 0; - unsigned char* decoded = NULL; - // unsigned char* p = NULL; - long nn = 0; - - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - double reference_value = 0; - long bits_per_value = 0; - - long ccsds_flags; - long ccsds_block_size; - long ccsds_rsi; - size_t nbytes; - - self->dirty = 0; - - if ((err = a->value_count(&nn)) != GRIB_SUCCESS) - return err; - n_vals = nn; - - if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(hand, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - // ECC-477: Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(hand, self->ccsds_block_size, &ccsds_block_size)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(hand, self->ccsds_rsi, &ccsds_rsi)) != GRIB_SUCCESS) - return err; - - modify_aec_flags(&ccsds_flags); - - // TODO(masn): This should be called upstream - if (*len < n_vals) - return GRIB_ARRAY_TOO_SMALL; - - // Special case - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - bscale = codes_power(binary_scale_factor, 2); - dscale = codes_power(-decimal_scale_factor, 10); - - buflen = a->byte_count(); buf = (unsigned char*)hand->buffer->data; - buf += a->byte_offset(); - strm.flags = ccsds_flags; - strm.bits_per_sample = bits_per_value; - strm.block_size = ccsds_block_size; - strm.rsi = ccsds_rsi; - - strm.next_in = buf; - strm.avail_in = buflen; - - nbytes = (bits_per_value + 7) / 8; - if (nbytes == 3) - nbytes = 4; - - size = n_vals * nbytes; - decoded = (unsigned char*)grib_context_buffer_malloc_clear(a->context, size); - if (!decoded) { - err = GRIB_OUT_OF_MEMORY; - goto cleanup; - } - strm.next_out = decoded; - strm.avail_out = size; - - if (hand->context->debug) print_aec_stream_info(&strm, "unpack_*"); - - if ((err = aec_buffer_decode(&strm)) != AEC_OK) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); - err = GRIB_DECODING_ERROR; - goto cleanup; - } - - // ECC-1427: Performance improvement (replaced by ECC-1602) - //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); - - // ECC-1602: Performance improvement - switch (nbytes) { - case 1: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 2: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - case 4: - for (i = 0; i < n_vals; i++) { - val[i] = (reinterpret_cast(decoded)[i] * bscale + reference_value) * dscale; - } - break; - default: - grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", - cclass_name, __func__, a->name, bits_per_value); - err = GRIB_INVALID_BPV; - goto cleanup; - } - - *len = n_vals; - -cleanup: - grib_context_buffer_free(a->context, decoded); - return err; -} - -#endif /* eccodes_accessor_data_ccsds_packing_h */ From 481c78c22772d7c92f4446712e07f9decbc48645 Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 7 May 2024 16:03:20 +0100 Subject: [PATCH 38/90] ECC-1820: Fix CCSDS class when -DENABLE_AEC=OFF --- src/accessor/grib_accessor_class_data_ccsds_packing.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index e453a7b09..5b0813bfd 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -13,11 +13,11 @@ #if defined(HAVE_LIBAEC) || defined(HAVE_AEC) #include + #ifndef LIBAEC_DLL_EXPORTED + #error Version of libaec appears to be too old. Please upgrade. + #endif #endif -#ifndef LIBAEC_DLL_EXPORTED - #error Version of libaec appears to be too old. Please upgrade. -#endif grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{ "data_ccsds_packing" }; grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing; From 867da9928cbe1ff6f1a78f7e1d4af19dae982e56 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 7 May 2024 15:12:50 +0000 Subject: [PATCH 39/90] Cleanup --- ...essor_class_data_g2simple_packing_with_preprocessing.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index 8eac09789..fa653c0cb 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -127,10 +127,6 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_doubl return err; } - // TODO(maee): fix this - //Assert(super->super); - //super2 = *(super->super); - //err = super2->unpack_double(a, val, &n_vals); [> GRIB-364 <] err = grib_accessor_class_data_simple_packing_t::unpack_double(a, val, &n_vals); if (err != GRIB_SUCCESS) return err; @@ -146,7 +142,6 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_doubl int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; - //grib_accessor_class* super = *(a->cclass->super); size_t n_vals = *len; int err = 0; @@ -163,8 +158,6 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double( if (err != GRIB_SUCCESS) return err; - // TOOD(maee): fix this - //err = super->pack_double(a, val, len); err = grib_accessor_class_data_g2simple_packing_t::pack_double(a, val, len); if (err != GRIB_SUCCESS) return err; From 41c513e7d90b5826f24fdee410d8d665589da5bf Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 7 May 2024 16:47:42 +0100 Subject: [PATCH 40/90] ECC-1820: Remove duplicate entry --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 28e037c21..fce6d88d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -126,7 +126,6 @@ list( APPEND eccodes_src_files accessor/grib_accessor_class_g2lon.cc accessor/grib_accessor_class_global_gaussian.cc accessor/grib_accessor_class_gaussian_grid_name.cc - accessor/grib_accessor_class_gen.cc accessor/grib_accessor_class_getenv.cc accessor/grib_accessor_class_gts_header.cc accessor/grib_accessor_class_ifs_param.cc From 6b1dae3e5527b373189d8691683472337da0caca Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 7 May 2024 15:58:49 +0000 Subject: [PATCH 41/90] Cleanup --- .../grib_accessor_class_data_g2simple_packing.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing.cc index 7f3ef141a..08aa11699 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.cc @@ -104,20 +104,7 @@ int grib_accessor_class_data_g2simple_packing_t::pack_double(grib_accessor* a, c return grib_set_double_array(h, "values", val, *len); } - // ==== TODO(maee): Fix this ==== ret = grib_accessor_class_data_simple_packing_t::pack_double(a, cval, len); - //if (super != grib_accessor_class_data_g2simple_packing) { - // [> Normal case: parent not same as me! <] - // ret = super->pack_double(a, val, len); - //} - //else { - // [> GRIB-364: simple packing with logarithm pre-processing <] - // grib_accessor_class* super2 = NULL; - // Assert(super->super); - // super2 = *(super->super); - // ret = super2->pack_double(a, val, len); - //} - // ============================= switch (ret) { case GRIB_CONSTANT_FIELD: grib_buffer_replace(a, NULL, 0, 1, 1); From 1a3e11e67f0c644f3801182a592950a81e3bbf5c Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 7 May 2024 15:59:20 +0000 Subject: [PATCH 42/90] Better commment --- src/accessor/grib_accessor_class_gen.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 292c87c35..5618d95e2 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -229,7 +229,8 @@ void grib_accessor_class_gen_t::init(grib_accessor* a, const long len, grib_argu grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); switch (type) { - // TODO(maee): single-precision + // TODO(maee): add single-precision case + case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); a->pack_double(&d, &s_len); From 6aa4be2084fc91489c2adf24c741f8dd928a9f89 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 7 May 2024 16:35:10 +0000 Subject: [PATCH 43/90] Remove unnecessary includes --- src/grib_accessor_class.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index ceda43659..cfec4d21d 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -25,12 +25,10 @@ extern grib_accessor_class* grib_accessor_class_change_scanning_direction; extern grib_accessor_class* grib_accessor_class_check_internal_version; extern grib_accessor_class* grib_accessor_class_closest_date; extern grib_accessor_class* grib_accessor_class_codeflag; -#include "accessor/grib_accessor_class_codetable.h" extern grib_accessor_class* grib_accessor_class_codetable; extern grib_accessor_class* grib_accessor_class_codetable_title; extern grib_accessor_class* grib_accessor_class_codetable_units; extern grib_accessor_class* grib_accessor_class_concept; -#include "accessor/grib_accessor_class_constant.h" extern grib_accessor_class* grib_accessor_class_constant; extern grib_accessor_class* grib_accessor_class_count_file; extern grib_accessor_class* grib_accessor_class_count_missing; @@ -115,7 +113,6 @@ extern grib_accessor_class* grib_accessor_class_headers_only; extern grib_accessor_class* grib_accessor_class_ibmfloat; extern grib_accessor_class* grib_accessor_class_ieeefloat; extern grib_accessor_class* grib_accessor_class_ifs_param; -#include "accessor/grib_accessor_class_iterator.h" extern grib_accessor_class* grib_accessor_class_iterator; extern grib_accessor_class* grib_accessor_class_julian_date; extern grib_accessor_class* grib_accessor_class_julian_day; @@ -126,7 +123,6 @@ extern grib_accessor_class* grib_accessor_class_latlon_increment; extern grib_accessor_class* grib_accessor_class_latlonvalues; extern grib_accessor_class* grib_accessor_class_library_version; extern grib_accessor_class* grib_accessor_class_local_definition; -#include "accessor/grib_accessor_class_long.h" extern grib_accessor_class* grib_accessor_class_long; extern grib_accessor_class* grib_accessor_class_long_vector; extern grib_accessor_class* grib_accessor_class_longitudes; @@ -137,7 +133,6 @@ extern grib_accessor_class* grib_accessor_class_md5; extern grib_accessor_class* grib_accessor_class_message; extern grib_accessor_class* grib_accessor_class_message_copy; extern grib_accessor_class* grib_accessor_class_multdouble; -#include "accessor/grib_accessor_class_nearest.h" extern grib_accessor_class* grib_accessor_class_nearest; extern grib_accessor_class* grib_accessor_class_non_alpha; extern grib_accessor_class* grib_accessor_class_number_of_coded_values; @@ -176,7 +171,6 @@ extern grib_accessor_class* grib_accessor_class_signed; extern grib_accessor_class* grib_accessor_class_signed_bits; extern grib_accessor_class* grib_accessor_class_simple_packing_error; extern grib_accessor_class* grib_accessor_class_size; -#include "accessor/grib_accessor_class_smart_table.h" extern grib_accessor_class* grib_accessor_class_smart_table; extern grib_accessor_class* grib_accessor_class_smart_table_column; extern grib_accessor_class* grib_accessor_class_spd; @@ -192,7 +186,6 @@ extern grib_accessor_class* grib_accessor_class_time; extern grib_accessor_class* grib_accessor_class_to_double; extern grib_accessor_class* grib_accessor_class_to_integer; extern grib_accessor_class* grib_accessor_class_to_string; -#include "accessor/grib_accessor_class_transient.h" extern grib_accessor_class* grib_accessor_class_transient; extern grib_accessor_class* grib_accessor_class_transient_darray; extern grib_accessor_class* grib_accessor_class_trim; @@ -204,13 +197,11 @@ extern grib_accessor_class* grib_accessor_class_uint64_little_endian; extern grib_accessor_class* grib_accessor_class_uint8; extern grib_accessor_class* grib_accessor_class_unexpanded_descriptors; extern grib_accessor_class* grib_accessor_class_unpack_bufr_values; -#include "accessor/grib_accessor_class_unsigned.h" extern grib_accessor_class* grib_accessor_class_unsigned; extern grib_accessor_class* grib_accessor_class_unsigned_bits; extern grib_accessor_class* grib_accessor_class_validity_date; extern grib_accessor_class* grib_accessor_class_validity_time; extern grib_accessor_class* grib_accessor_class_values; -#include "accessor/grib_accessor_class_variable.h" extern grib_accessor_class* grib_accessor_class_variable; extern grib_accessor_class* grib_accessor_class_vector; extern grib_accessor_class* grib_accessor_class_when; From 57b2698cc3400aae6e34160ed3a564f4e0616f6c Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 10:15:10 +0100 Subject: [PATCH 44/90] Compiler warnings re sprintf --- fortran/grib_fortran.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fortran/grib_fortran.cc b/fortran/grib_fortran.cc index 34a061730..972118384 100644 --- a/fortran/grib_fortran.cc +++ b/fortran/grib_fortran.cc @@ -987,7 +987,7 @@ void grib_f_write_on_fail(int* gid) { file_count++; GRIB_MUTEX_UNLOCK(&handle_mutex) - sprintf(filename,"%ld_%d_error.grib",(long)pid,file_count); + snprintf(filename, sizeof(filename), "%ld_%d_error.grib",(long)pid,file_count); h=get_handle(*gid); if (h) grib_write_message(h,filename,"w"); @@ -1250,7 +1250,7 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) fort_char_clean(name, len); - sprintf(buf,"%s",grib_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s",grib_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; @@ -1322,7 +1322,7 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) fort_char_clean(name, len); - sprintf(buf, "%s", codes_bufr_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s", codes_bufr_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; From cf72dca9714ba8bd52c27895bde755799c4f1266 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 10:16:12 +0100 Subject: [PATCH 45/90] Move function from header to local static. Use pragma once --- .../grib_accessor_class_data_apply_bitmap.cc | 178 ++++++++--- .../grib_accessor_class_data_apply_bitmap.h | 90 +----- ...rib_accessor_class_data_complex_packing.cc | 279 ++++++++++++++++-- ...grib_accessor_class_data_complex_packing.h | 227 +------------- ...grib_accessor_class_data_simple_packing.cc | 258 ++++++++++++---- .../grib_accessor_class_data_simple_packing.h | 151 +--------- 6 files changed, 597 insertions(+), 586 deletions(-) diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index 86e54ff63..cf3d5f4a5 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -11,13 +11,14 @@ #include "grib_accessor_class_data_apply_bitmap.h" -grib_accessor_class_data_apply_bitmap_t _grib_accessor_class_data_apply_bitmap{"data_apply_bitmap"}; +grib_accessor_class_data_apply_bitmap_t _grib_accessor_class_data_apply_bitmap{ "data_apply_bitmap" }; grib_accessor_class* grib_accessor_class_data_apply_bitmap = &_grib_accessor_class_data_apply_bitmap; -void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_gen_t::init(a, v, args); - int n = 0; + int n = 0; grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -29,14 +30,16 @@ void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long a->length = 0; } -void grib_accessor_class_data_apply_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_data_apply_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_values(dumper, a); } -int grib_accessor_class_data_apply_bitmap_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_apply_bitmap_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - size_t len = 0; - int ret = 0; + size_t len = 0; + int ret = GRIB_SUCCESS; if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) ret = grib_get_size(grib_handle_of_accessor(a), self->bitmap, &len); @@ -48,17 +51,18 @@ int grib_accessor_class_data_apply_bitmap_t::value_count(grib_accessor* a, long* return ret; } -int grib_accessor_class_data_apply_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - int err = 0, i = 0; - size_t cidx = 0; + grib_handle* gh = grib_handle_of_accessor(a); + size_t i = 0, cidx = 0; double missing_value = 0; double* bvals = NULL; size_t n_vals = 0; long nn = 0; - err = a->value_count(&nn); n_vals = nn; + int err = a->value_count(&nn); + n_vals = nn; if (err) return err; @@ -93,19 +97,21 @@ int grib_accessor_class_data_apply_bitmap_t::unpack_double_element(grib_accessor return grib_get_double_element_internal(gh, self->coded_values, cidx, val); } -int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_handle* gh = grib_handle_of_accessor(a); int err = 0, all_missing = 1; - size_t cidx = 0; /* index into the coded_values array */ - size_t* cidx_array = NULL; /* array of indexes into the coded_values */ - double* cval_array = NULL; /* array of values of the coded_values */ + size_t cidx = 0; /* index into the coded_values array */ + size_t* cidx_array = NULL; /* array of indexes into the coded_values */ + double* cval_array = NULL; /* array of values of the coded_values */ double missing_value = 0; double* bvals = NULL; size_t n_vals = 0, i = 0, j = 0, idx = 0, count_1s = 0, ci = 0; long nn = 0; - err = a->value_count(&nn); n_vals = nn; + err = a->value_count(&nn); + n_vals = nn; if (err) return err; if (!grib_find_accessor(gh, self->bitmap)) @@ -119,7 +125,8 @@ int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_acce for (i = 0; i < len; i++) { if (val_array[i] == 0) { val_array[i] = missing_value; - } else { + } + else { all_missing = 0; count_1s++; } @@ -144,7 +151,7 @@ int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_acce ci = 0; for (i = 0; i < len; i++) { if (val_array[i] == 1) { - idx = index_array[i]; + idx = index_array[i]; cidx = 0; for (j = 0; j < idx; j++) { cidx += bvals[j]; @@ -171,17 +178,18 @@ int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_acce return GRIB_SUCCESS; } -int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - int err = 0; - size_t bmaplen = *len; - long coded_n_vals = 0; - double* coded_vals = NULL; - long i = 0; - long j = 0; - double missing_value = 0; - grib_handle* hand = grib_handle_of_accessor(a); - grib_context* ctxt = a->context; + int err = 0; + size_t bmaplen = *len; + long coded_n_vals = 0; + double* coded_vals = NULL; + long i = 0; + long j = 0; + double missing_value = 0; + grib_handle* hand = grib_handle_of_accessor(a); + grib_context* ctxt = a->context; if (*len == 0) return GRIB_NO_VALUES; @@ -231,22 +239,106 @@ int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const } -int grib_accessor_class_data_apply_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + + size_t i = 0; + size_t j = 0; + size_t n_vals = 0; + long nn = 0; + size_t coded_n_vals = 0; + T* coded_vals = NULL; + double missing_value = 0; + + int err = a->value_count(&nn); + n_vals = nn; + if (err) + return err; + + if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) + return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if (coded_n_vals == 0) { + for (i = 0; i < n_vals; i++) + val[i] = missing_value; + + *len = n_vals; + return GRIB_SUCCESS; + } + + if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) + return err; + + coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); + if (coded_vals == NULL) + return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { + grib_context_free(a->context, coded_vals); + return err; + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", + __func__, a->name, n_vals); + + for (i = 0; i < n_vals; i++) { + if (val[i] == 0) { + val[i] = missing_value; + } + else { + val[i] = coded_vals[j++]; + if (j > coded_n_vals) { + grib_context_free(a->context, coded_vals); + grib_context_log(a->context, GRIB_LOG_ERROR, + "grib_accessor_class_data_apply_bitmap [%s]:" + " %s : number of coded values does not match bitmap %ld %ld", + a->name, __func__, coded_n_vals, n_vals); + + return GRIB_ARRAY_TOO_SMALL; + } + } + } + + *len = n_vals; + + grib_context_free(a->context, coded_vals); + return err; +} + +int grib_accessor_class_data_apply_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_apply_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_apply_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_apply_bitmap_t::get_native_type(grib_accessor* a){ - //grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); - +int grib_accessor_class_data_apply_bitmap_t::get_native_type(grib_accessor* a) +{ + // grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + // return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); return GRIB_TYPE_DOUBLE; } -int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -256,11 +348,13 @@ int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_acce int err = 0; long count = 0; - err = a->value_count(&count); if (err) + err = a->value_count(&count); + if (err) return err; alen = count; - err = b->value_count(&count); if (err) + err = b->value_count(&count); + if (err) return err; blen = count; @@ -270,9 +364,10 @@ int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_acce aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; - for (size_t i=0; i int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_data_apply_bitmap_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; - - size_t i = 0; - size_t j = 0; - size_t n_vals = 0; - long nn = 0; - int err = 0; - size_t coded_n_vals = 0; - T* coded_vals = NULL; - double missing_value = 0; - - err = a->value_count(&nn); n_vals = nn; - if (err) - return err; - - if (!grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) - return grib_get_array(grib_handle_of_accessor(a), self->coded_values, val, len); - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if (coded_n_vals == 0) { - for (i = 0; i < n_vals; i++) - val[i] = missing_value; - - *len = n_vals; - return GRIB_SUCCESS; - } - - if ((err = grib_get_array_internal(grib_handle_of_accessor(a), self->bitmap, val, &n_vals)) != GRIB_SUCCESS) - return err; - - coded_vals = (T*)grib_context_malloc(a->context, coded_n_vals * sizeof(T)); - if (coded_vals == NULL) - return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_array(grib_handle_of_accessor(a), self->coded_values, coded_vals, &coded_n_vals)) != GRIB_SUCCESS) { - grib_context_free(a->context, coded_vals); - return err; - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", - __func__, - a->name, n_vals); - - for (i = 0; i < n_vals; i++) { - if (val[i] == 0) { - val[i] = missing_value; - } - else { - val[i] = coded_vals[j++]; - if (j > coded_n_vals) { - grib_context_free(a->context, coded_vals); - grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_class_data_apply_bitmap [%s]:" - " %s : number of coded values does not match bitmap %ld %ld", - a->name, __func__, coded_n_vals, n_vals); - - return GRIB_ARRAY_TOO_SMALL; - } - } - } - - *len = n_vals; - - grib_context_free(a->context, coded_vals); - return err; -} - -#endif /* eccodes_accessor_data_apply_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index 77a3ab822..81e402303 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -11,13 +11,14 @@ #include "grib_accessor_class_data_complex_packing.h" -grib_accessor_class_data_complex_packing_t _grib_accessor_class_data_complex_packing{"data_complex_packing"}; +grib_accessor_class_data_complex_packing_t _grib_accessor_class_data_complex_packing{ "data_complex_packing" }; grib_accessor_class* grib_accessor_class_data_complex_packing = &_grib_accessor_class_data_complex_packing; -void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_handle* gh = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(gh, args, self->carg++); self->ieee_floats = grib_arguments_get_name(gh, args, self->carg++); @@ -33,14 +34,16 @@ void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const lo a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_complex_packing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_complex_packing_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - int ret = 0; + + int ret = GRIB_SUCCESS; grib_handle* gh = grib_handle_of_accessor(a); - long pen_j = 0; - long pen_k = 0; - long pen_m = 0; - *count = 0; + long pen_j = 0; + long pen_k = 0; + long pen_m = 0; + *count = 0; if (a->length == 0) return 0; @@ -62,7 +65,8 @@ int grib_accessor_class_data_complex_packing_t::value_count(grib_accessor* a, lo return ret; } -double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation){ +double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation) +{ /*long n_vals = ((fieldTruncation+1)*(fieldTruncation+2));*/ long loop, index, m, n = 0; double pFactor, zeps = 1.0e-15; @@ -95,7 +99,6 @@ double calculate_pfactor(const grib_context* ctx, const double* spectralField, l /* * Form norms for the rows which contain part of the unscaled subset. */ - index = -2; for (m = 0; m < subsetTruncation; m++) { for (n = m; n <= fieldTruncation; n++) { @@ -110,7 +113,6 @@ double calculate_pfactor(const grib_context* ctx, const double* spectralField, l /* * Form norms for the rows which do not contain part of the unscaled subset. */ - for (m = subsetTruncation; m <= fieldTruncation; m++) { for (n = m; n <= fieldTruncation; n++) { index += 2; @@ -146,7 +148,6 @@ double calculate_pfactor(const grib_context* ctx, const double* spectralField, l /* * Perform a least square fit for the equation */ - for (loop = ismin; loop <= ismax; loop++) { x = log((double)(loop * (loop + 1))); y = log(norms[loop]); @@ -168,10 +169,11 @@ double calculate_pfactor(const grib_context* ctx, const double* spectralField, l return pFactor; } -int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; size_t i = 0; int ret = GRIB_SUCCESS; @@ -519,7 +521,7 @@ int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, co grib_get_double_internal(gh, self->reference_value, &ref); if (ref != reference_value) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: %s (ref=%.10e != reference_value=%.10e)", - cclass_name, __func__, self->reference_value, ref, reference_value); + cclass_name, __func__, self->reference_value, ref, reference_value); return GRIB_INTERNAL_ERROR; } } @@ -536,34 +538,253 @@ int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, co return ret; } +template +static int unpack_real(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + size_t i = 0; + int ret = GRIB_SUCCESS; + long hcount = 0; + long lcount = 0; + long hpos = 0; + long lup = 0; + long mmax = 0; + long n_vals = 0; + T* scals = NULL; + T *pscals = NULL, *pval = NULL; -int grib_accessor_class_data_complex_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ - return unpack(a, val, len); + T s = 0; + T d = 0; + T laplacianOperator = 0; + unsigned char* buf = NULL; + unsigned char* hres = NULL; + unsigned char* lres = NULL; + unsigned long packed_offset; + long lpos = 0; + + long maxv = 0; + long GRIBEX_sh_bug_present = 0; + long ieee_floats = 0; + + long offsetdata = 0; + long bits_per_value = 0; + T reference_value = 0; + long binary_scale_factor = 0; + long decimal_scale_factor = 0; + + long sub_j = 0; + long sub_k = 0; + long sub_m = 0; + long pen_j = 0; + long pen_k = 0; + long pen_m = 0; + + T operat = 0; + int bytes; + int err = 0; + double tmp; + + decode_float_proc decode_float = NULL; + + err = a->value_count(&n_vals); + if (err) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) + return ret; + reference_value = tmp; + if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) + return ret; + + /* ECC-774: don't use grib_get_long_internal */ + if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) + return ret; + laplacianOperator = tmp; + + if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) + return ret; + + self->dirty = 0; + + switch (ieee_floats) { + case 0: + decode_float = grib_long_to_ibm; + bytes = 4; + break; + case 1: + decode_float = grib_long_to_ieee; + bytes = 4; + break; + case 2: + decode_float = grib_long_to_ieee64; + bytes = 8; + break; + default: + return GRIB_NOT_IMPLEMENTED; + } + + if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); + return GRIB_DECODING_ERROR; + } + + buf = (unsigned char*)gh->buffer->data; + + maxv = pen_j + 1; + + buf += a->byte_offset(); + hres = buf; + lres = buf; + + if (pen_j == sub_j) { + n_vals = (pen_j + 1) * (pen_j + 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); + if (d) { + for (i = 0; i < n_vals; i++) + val[i] *= d; + } + return 0; + } + + packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); + lpos = 8 * (packed_offset - offsetdata); + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); + if (!scals) return GRIB_OUT_OF_MEMORY; + + scals[0] = 0; + for (i = 1; i < maxv; i++) { + operat = pow(i * (i + 1), laplacianOperator); + if (operat != 0) + scals[i] = (1.0 / operat); + else { + grib_context_log(a->context, GRIB_LOG_WARNING, + "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); + scals[i] = 0; + } + } + + /* + printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); + printf("packed offset=%ld\n",packed_offset); + for(i=0;i 0) { + lup = mmax; + if (sub_k >= 0) { + for (hcount = 0; hcount < sub_k + 1; hcount++) { + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); + + if (GRIBEX_sh_bug_present && hcount == sub_k) { + /* bug in ecmwf data, last row (K+1)is scaled but should not */ + val[i - 2] *= scals[lup]; + val[i - 1] *= scals[lup]; + } + lup++; + } + sub_k--; + } + + pscals = scals + lup; + pval = val + i; +#if FAST_BIG_ENDIAN + grib_decode_double_array_complex(lres, + &lpos, bits_per_value, + reference_value, s, pscals, (maxv - hcount) * 2, pval); + i += (maxv - hcount) * 2; +#else + (void)pscals; /* suppress gcc warning */ + (void)pval; /* suppress gcc warning */ + for (lcount = hcount; lcount < maxv; lcount++) { + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; + /* These values should always be zero, but as they are packed, + it is necessary to force them back to zero */ + if (mmax == 0) + val[i - 1] = 0; + lup++; + } +#endif + + maxv--; + hcount = 0; + mmax++; + } + + Assert(*len >= i); + *len = i; + + grib_context_free(a->context, scals); + + return ret; } -int grib_accessor_class_data_complex_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_complex_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + return unpack_real(a, val, len); +} + +int grib_accessor_class_data_complex_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ // TODO(maee): See ECC-1579 // Investigate why results are not bit-identical // return unpack(a, val, len); - int err = 0; - size_t i = 0; - size_t size = *len; - double* val8 = NULL; - val8 = (double*)grib_context_malloc(a->context, size*(sizeof(double))); + size_t size = *len; + double* val8 = (double*)grib_context_malloc(a->context, size * (sizeof(double))); if (!val8) return GRIB_OUT_OF_MEMORY; - err = unpack(a, val8, len); + int err = unpack_real(a, val8, len); if (err) { - grib_context_free(a->context,val8); + grib_context_free(a->context, val8); return err; } - for(i=0; icontext,val8); + grib_context_free(a->context, val8); return GRIB_SUCCESS; } diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h b/src/accessor/grib_accessor_class_data_complex_packing.h index d588eef38..a8276311a 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.h +++ b/src/accessor/grib_accessor_class_data_complex_packing.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_complex_packing_h -#define eccodes_accessor_data_complex_packing_h +#pragma once #include "grib_accessor_class_data_simple_packing.h" #include "grib_scaling.h" @@ -45,228 +44,4 @@ public: int unpack_float(grib_accessor*, float* val, size_t* len) override; int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - -template -int grib_accessor_class_data_complex_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - size_t i = 0; - int ret = GRIB_SUCCESS; - long hcount = 0; - long lcount = 0; - long hpos = 0; - long lup = 0; - long mmax = 0; - long n_vals = 0; - T* scals = NULL; - T* pscals = NULL, *pval = NULL; - - T s = 0; - T d = 0; - T laplacianOperator = 0; - unsigned char* buf = NULL; - unsigned char* hres = NULL; - unsigned char* lres = NULL; - unsigned long packed_offset; - long lpos = 0; - - long maxv = 0; - long GRIBEX_sh_bug_present = 0; - long ieee_floats = 0; - - long offsetdata = 0; - long bits_per_value = 0; - T reference_value = 0; - long binary_scale_factor = 0; - long decimal_scale_factor = 0; - - long sub_j = 0; - long sub_k = 0; - long sub_m = 0; - long pen_j = 0; - long pen_k = 0; - long pen_m = 0; - - T operat = 0; - int bytes; - int err = 0; - double tmp; - - decode_float_proc decode_float = NULL; - - err = a->value_count(&n_vals); if (err) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((ret = grib_get_long_internal(gh, self->offsetdata, &offsetdata)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_double_internal(gh, self->reference_value, &tmp)) != GRIB_SUCCESS) - return ret; - reference_value = tmp; - if ((ret = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(gh, self->GRIBEX_sh_bug_present, &GRIBEX_sh_bug_present)) != GRIB_SUCCESS) - return ret; - - /* ECC-774: don't use grib_get_long_internal */ - if ((ret = grib_get_long(gh, self->ieee_floats, &ieee_floats)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &tmp)) != GRIB_SUCCESS) - return ret; - laplacianOperator = tmp; - - if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->sub_m, &sub_m)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_j, &pen_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_k, &pen_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(gh, self->pen_m, &pen_m)) != GRIB_SUCCESS) - return ret; - - self->dirty = 0; - - switch (ieee_floats) { - case 0: - decode_float = grib_long_to_ibm; - bytes = 4; - break; - case 1: - decode_float = grib_long_to_ieee; - bytes = 4; - break; - case 2: - decode_float = grib_long_to_ieee64; - bytes = 8; - break; - default: - return GRIB_NOT_IMPLEMENTED; - } - - if (sub_j != sub_k || sub_j != sub_m || pen_j != pen_k || pen_j != pen_m) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid pentagonal resolution parameters", cclass_name); - return GRIB_DECODING_ERROR; - } - - buf = (unsigned char*)gh->buffer->data; - - maxv = pen_j + 1; - - buf += a->byte_offset(); hres = buf; - lres = buf; - - if (pen_j == sub_j) { - n_vals = (pen_j + 1) * (pen_j + 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_ieee_decode_array(a->context, buf, n_vals, bytes, val); - if (d) { - for (i = 0; i < n_vals; i++) - val[i] *= d; - } - return 0; - } - - packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); - lpos = 8 * (packed_offset - offsetdata); - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - scals = (T*)grib_context_malloc(a->context, maxv * sizeof(T)); - if (!scals) return GRIB_OUT_OF_MEMORY; - - scals[0] = 0; - for (i = 1; i < maxv; i++) { - operat = pow(i * (i + 1), laplacianOperator); - if (operat != 0) - scals[i] = (1.0 / operat); - else { - grib_context_log(a->context, GRIB_LOG_WARNING, - "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); - scals[i] = 0; - } - } - - /* - printf("UNPACKING LAPLACE=%.20f\n",laplacianOperator); - printf("packed offset=%ld\n",packed_offset); - for(i=0;i 0) { - lup = mmax; - if (sub_k >= 0) { - for (hcount = 0; hcount < sub_k + 1; hcount++) { - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - val[i++] = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes)); - - if (GRIBEX_sh_bug_present && hcount == sub_k) { - /* bug in ecmwf data, last row (K+1)is scaled but should not */ - val[i - 2] *= scals[lup]; - val[i - 1] *= scals[lup]; - } - lup++; - } - sub_k--; - } - - pscals = scals + lup; - pval = val + i; -#if FAST_BIG_ENDIAN - grib_decode_double_array_complex(lres, - &lpos, bits_per_value, - reference_value, s, pscals, (maxv - hcount) * 2, pval); - i += (maxv - hcount) * 2; -#else - (void)pscals; /* suppress gcc warning */ - (void)pval; /* suppress gcc warning */ - for (lcount = hcount; lcount < maxv; lcount++) { - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - val[i++] = d * (T)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value) * scals[lup]; - /* These values should always be zero, but as they are packed, - it is necessary to force them back to zero */ - if (mmax == 0) - val[i - 1] = 0; - lup++; - } -#endif - - maxv--; - hcount = 0; - mmax++; - } - - Assert(*len >= i); - *len = i; - - grib_context_free(a->context, scals); - - return ret; -} - -#endif /* eccodes_accessor_data_complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc index d1032808e..591e89526 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -11,26 +11,28 @@ #include "grib_accessor_class_data_simple_packing.h" #include "grib_optimize_decimal_factor.h" +#include "grib_bits_any_endian_simple.h" #include #include -grib_accessor_class_data_simple_packing_t _grib_accessor_class_data_simple_packing{"data_simple_packing"}; +grib_accessor_class_data_simple_packing_t _grib_accessor_class_data_simple_packing{ "data_simple_packing" }; grib_accessor_class* grib_accessor_class_data_simple_packing = &_grib_accessor_class_data_simple_packing; -void grib_accessor_class_data_simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_values_t::init(a, v, args); grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - self->units_factor = grib_arguments_get_name(gh, args, self->carg++); - self->units_bias = grib_arguments_get_name(gh, args, self->carg++); - self->changing_precision = grib_arguments_get_name(gh, args, self->carg++); - self->number_of_values = grib_arguments_get_name(gh, args, self->carg++); - self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); - self->reference_value = grib_arguments_get_name(gh, args, self->carg++); - self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->optimize_scaling_factor = grib_arguments_get_name(gh, args, self->carg++); + grib_handle* gh = grib_handle_of_accessor(a); + self->units_factor = grib_arguments_get_name(gh, args, self->carg++); + self->units_bias = grib_arguments_get_name(gh, args, self->carg++); + self->changing_precision = grib_arguments_get_name(gh, args, self->carg++); + self->number_of_values = grib_arguments_get_name(gh, args, self->carg++); + self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); + self->reference_value = grib_arguments_get_name(gh, args, self->carg++); + self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->optimize_scaling_factor = grib_arguments_get_name(gh, args, self->carg++); a->flags |= GRIB_ACCESSOR_FLAG_DATA; self->dirty = 1; } @@ -44,7 +46,8 @@ static const unsigned long nbits[32] = { 0x40000000, 0x80000000 }; -static int number_of_bits(unsigned long x, long* result){ +static int number_of_bits(unsigned long x, long* result) +{ const int count = sizeof(nbits) / sizeof(nbits[0]); const unsigned long* n = nbits; *result = 0; @@ -58,19 +61,21 @@ static int number_of_bits(unsigned long x, long* result){ return GRIB_SUCCESS; } -int grib_accessor_class_data_simple_packing_t::value_count(grib_accessor* a, long* number_of_values){ +int grib_accessor_class_data_simple_packing_t::value_count(grib_accessor* a, long* number_of_values) +{ grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - *number_of_values = 0; + *number_of_values = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - const char* cclass_name = a->cclass->name; + const char* cclass_name = a->cclass->name; - long n_vals; - int err = 0; + long n_vals = 0; + int err = 0; grib_handle* gh = grib_handle_of_accessor(a); double reference_value; @@ -78,12 +83,12 @@ int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_access long bits_per_value; long decimal_scale_factor; unsigned char* buf = (unsigned char*)gh->buffer->data; - double s = 0; - double d = 0; - long pos = 0; + double s = 0; + double d = 0; + long pos = 0; - n_vals = 0; - err = a->value_count(&n_vals); if (err) + err = a->value_count(&n_vals); + if (err) return err; if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -146,29 +151,176 @@ int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_access return err; } -int grib_accessor_class_data_simple_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ - int err = 0; +int grib_accessor_class_data_simple_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ + int err = 0; size_t i = 0; - for (i=0; i +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); -int grib_accessor_class_data_simple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + + size_t i = 0; + int err = 0; + size_t n_vals = 0; + long pos = 0; + long count = 0; + + double reference_value; + long binary_scale_factor; + long bits_per_value; + long decimal_scale_factor; + long offsetBeforeData; + double s = 0; + double d = 0; + double units_factor = 1.0; + double units_bias = 0.0; + + err = a->value_count(&count); + if (err) + return err; + n_vals = count; + + if (*len < n_vals) { + *len = (long)n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + + /* + * check we don't decode bpv > max(ulong) as it is + * not currently supported by the algorithm + */ + if (bits_per_value > (sizeof(long) * 8)) { + return GRIB_INVALID_BPV; + } + + if (self->units_factor && + (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_factor, 1.0); + } + + if (self->units_bias && + (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { + grib_set_double_internal(gh, self->units_bias, 0.0); + } + + if (n_vals == 0) { + *len = 0; + return GRIB_SUCCESS; + } + + self->dirty = 0; + + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + + /* Special case */ + + if (bits_per_value == 0) { + for (i = 0; i < n_vals; i++) + val[i] = reference_value; + *len = n_vals; + return GRIB_SUCCESS; + } + + s = codes_power(binary_scale_factor, 2); + d = codes_power(-decimal_scale_factor, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); + + offsetBeforeData = a->byte_offset(); + buf += offsetBeforeData; + + /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + + /* ECC-941 */ + if (!a->context->ieee_packing) { + /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ + long offsetAfterData = 0; + err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); + if (!err && offsetAfterData > offsetBeforeData) { + const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ + if (offsetBeforeData + valuesSize > offsetAfterData) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Data section size mismatch: " + "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", + cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); + return GRIB_DECODING_ERROR; + } + } + // if (offsetBeforeData == offsetAfterData) { + // /* Crazy case: Constant field with bitsPerValue > 0 */ + // for (i = 0; i < n_vals; i++) + // val[i] = reference_value; + // *len = n_vals; + // return GRIB_SUCCESS; + // } + } + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", + cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); + grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); + + *len = (long)n_vals; + + if (units_factor != 1.0) { + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] = val[i] * units_factor + units_bias; + } + } + else { + for (i = 0; i < n_vals; i++) { + val[i] *= units_factor; + } + } + } + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] += units_bias; + } + } + return err; +} + +int grib_accessor_class_data_simple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_data_simple_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_data_simple_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* buf, long pos, size_t n_vals){ +static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* buf, long pos, size_t n_vals) +{ grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; size_t i = 0; int err = 0; @@ -240,7 +392,8 @@ int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* bu grib_context_log(a->context, GRIB_LOG_DEBUG, "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; + offsetBeforeData = a->byte_offset(); + buf += offsetBeforeData; /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ @@ -290,14 +443,16 @@ int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* bu return err; } -int grib_accessor_class_data_simple_packing_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len){ +int grib_accessor_class_data_simple_packing_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) +{ grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - size_t nvals = len; - size_t* plen = &len; - long bits_per_value = 0; - long pos; - int err; + + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + size_t nvals = len; + size_t* plen = &len; + long bits_per_value = 0; + long pos = 0; + int err = GRIB_SUCCESS; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -308,14 +463,15 @@ int grib_accessor_class_data_simple_packing_t::unpack_double_subarray(grib_acces return _unpack_double(a, val, plen, buf, pos, nvals); } -int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; - size_t i = 0; - size_t n_vals = *len; - int err = 0; + size_t i = 0; + size_t n_vals = *len; + int err = 0; double reference_value = 0; long binary_scale_factor = 0; long bits_per_value = 0; @@ -360,8 +516,10 @@ int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, con max = val[0]; min = max; for (i = 1; i < n_vals; i++) { - if (val[i] > max) max = val[i]; - else if (val[i] < min) min = val[i]; + if (val[i] > max) + max = val[i]; + else if (val[i] < min) + min = val[i]; } if ((err = grib_check_data_values_minmax(gh, min, max)) != GRIB_SUCCESS) { @@ -460,7 +618,7 @@ int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, con /* divisor=1; */ } else { - int last = 127; /* 'last' should be a parameter coming from a definitions file */ + int last = 127; /* 'last' should be a parameter coming from a definitions file */ if (c->gribex_mode_on && self->edition == 1) last = 99; /* bits_per_value is given and decimal_scale_factor and binary_scale_factor are calcualated */ diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h b/src/accessor/grib_accessor_class_data_simple_packing.h index 92f355b3f..52761202d 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.h +++ b/src/accessor/grib_accessor_class_data_simple_packing.h @@ -9,11 +9,9 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_simple_packing_h -#define eccodes_accessor_data_simple_packing_h +#pragma once #include "grib_accessor_class_values.h" -#include "grib_bits_any_endian_simple.h" #include "grib_scaling.h" class grib_accessor_data_simple_packing_t : public grib_accessor_values_t @@ -45,151 +43,4 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_data_simple_packing_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - - grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - - size_t i = 0; - int err = 0; - size_t n_vals = 0; - long pos = 0; - long count = 0; - - double reference_value; - long binary_scale_factor; - long bits_per_value; - long decimal_scale_factor; - long offsetBeforeData; - double s = 0; - double d = 0; - double units_factor = 1.0; - double units_bias = 0.0; - - err = a->value_count(&count); if (err) - return err; - n_vals = count; - - if (*len < n_vals) { - *len = (long)n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - - /* - * check we don't decode bpv > max(ulong) as it is - * not currently supported by the algorithm - */ - if (bits_per_value > (sizeof(long) * 8)) { - return GRIB_INVALID_BPV; - } - - if (self->units_factor && - (grib_get_double_internal(gh, self->units_factor, &units_factor) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_factor, 1.0); - } - - if (self->units_bias && - (grib_get_double_internal(gh, self->units_bias, &units_bias) == GRIB_SUCCESS)) { - grib_set_double_internal(gh, self->units_bias, 0.0); - } - - if (n_vals == 0) { - *len = 0; - return GRIB_SUCCESS; - } - - self->dirty = 0; - - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - - /* Special case */ - - if (bits_per_value == 0) { - for (i = 0; i < n_vals; i++) - val[i] = reference_value; - *len = n_vals; - return GRIB_SUCCESS; - } - - s = codes_power(binary_scale_factor, 2); - d = codes_power(-decimal_scale_factor, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - - offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; - - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ - - /* ECC-941 */ - if (!a->context->ieee_packing) { - /* Must turn off this check when the environment variable ECCODES_GRIB_IEEE_PACKING is on */ - long offsetAfterData = 0; - err = grib_get_long(gh, "offsetAfterData", &offsetAfterData); - if (!err && offsetAfterData > offsetBeforeData) { - const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ - if (offsetBeforeData + valuesSize > offsetAfterData) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Data section size mismatch: " - "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", - cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); - return GRIB_DECODING_ERROR; - } - } - // if (offsetBeforeData == offsetAfterData) { - // /* Crazy case: Constant field with bitsPerValue > 0 */ - // for (i = 0; i < n_vals; i++) - // val[i] = reference_value; - // *len = n_vals; - // return GRIB_SUCCESS; - // } - } - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "%s %s: calling outline function: bpv: %ld, rv: %g, bsf: %ld, dsf: %ld", - cclass_name, __func__, bits_per_value, reference_value, binary_scale_factor, decimal_scale_factor); - grib_decode_array(buf, &pos, bits_per_value, reference_value, s, d, n_vals, val); - - *len = (long)n_vals; - - if (units_factor != 1.0) { - if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] = val[i] * units_factor + units_bias; - } - } else { - for (i = 0; i < n_vals; i++) { - val[i] *= units_factor; - } - } - } - else if (units_bias != 0.0) { - for (i = 0; i < n_vals; i++) { - val[i] += units_bias; - } - } - return err; -} - - -#endif /* eccodes_accessor_data_simple_packing_h */ From 0d802de270724b10706f6adae8495e91cc30c341 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Wed, 8 May 2024 09:35:23 +0000 Subject: [PATCH 46/90] Fix grib_accessor_class_gen definition --- src/accessor/grib_accessor_class_gen.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 5618d95e2..7223f39a9 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -208,7 +208,7 @@ void grib_accessor_gen_t::destroy(grib_context* ct) grib_accessor_class_gen_t _grib_accessor_class_gen = grib_accessor_class_gen_t("gen"); -grib_accessor_class_gen_t* grib_accessor_class_gen = &_grib_accessor_class_gen; +grib_accessor_class* grib_accessor_class_gen = &_grib_accessor_class_gen; void grib_accessor_class_gen_t::init(grib_accessor* a, const long len, grib_arguments* param) { From e0f2213627fb9c5b11483e304835cd1b1a96f9e0 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 12:12:18 +0100 Subject: [PATCH 47/90] ECC-1820: Remove unnecessary header files --- src/accessor/grib_accessor_class_abstract_long_vector.h | 1 - src/accessor/grib_accessor_class_abstract_vector.h | 1 - src/accessor/grib_accessor_class_ascii.h | 1 - src/accessor/grib_accessor_class_bit.h | 1 - src/accessor/grib_accessor_class_bitmap.h | 1 - src/accessor/grib_accessor_class_bits.h | 1 - src/accessor/grib_accessor_class_bits_per_value.h | 1 - src/accessor/grib_accessor_class_blob.h | 1 - src/accessor/grib_accessor_class_budgdate.h | 1 - src/accessor/grib_accessor_class_bufr_data_element.h | 1 - src/accessor/grib_accessor_class_bufr_elements_table.h | 1 - .../grib_accessor_class_bufr_extract_area_subsets.h | 1 - .../grib_accessor_class_bufr_extract_datetime_subsets.h | 1 - src/accessor/grib_accessor_class_bufr_extract_subsets.h | 1 - src/accessor/grib_accessor_class_bufr_group.h | 1 - src/accessor/grib_accessor_class_bufr_simple_thinning.h | 1 - src/accessor/grib_accessor_class_bufr_string_values.h | 1 - .../grib_accessor_class_bufrdc_expanded_descriptors.h | 1 - src/accessor/grib_accessor_class_bytes.h | 1 - .../grib_accessor_class_change_alternative_row_scanning.h | 1 - .../grib_accessor_class_change_scanning_direction.h | 1 - src/accessor/grib_accessor_class_check_internal_version.h | 1 - src/accessor/grib_accessor_class_closest_date.h | 1 - src/accessor/grib_accessor_class_codeflag.h | 1 - src/accessor/grib_accessor_class_codetable.h | 6 ------ src/accessor/grib_accessor_class_codetable_title.h | 1 - src/accessor/grib_accessor_class_codetable_units.h | 1 - src/accessor/grib_accessor_class_concept.h | 1 - src/accessor/grib_accessor_class_constant.h | 6 ------ src/accessor/grib_accessor_class_count_file.h | 1 - src/accessor/grib_accessor_class_count_missing.h | 1 - src/accessor/grib_accessor_class_count_total.h | 1 - src/accessor/grib_accessor_class_data_apply_bitmap.h | 1 - ...rib_accessor_class_data_apply_boustrophedonic_bitmap.h | 1 - src/accessor/grib_accessor_class_data_dummy_field.h | 1 - src/accessor/grib_accessor_class_data_g1complex_packing.h | 5 +---- ...sor_class_data_g1second_order_constant_width_packing.h | 5 +---- ...r_class_data_g1second_order_general_extended_packing.h | 5 +---- .../grib_accessor_class_data_g1secondary_bitmap.h | 5 +---- .../grib_accessor_class_data_g1shsimple_packing.h | 5 +---- src/accessor/grib_accessor_class_data_g1simple_packing.h | 5 +---- .../grib_accessor_class_data_g2bifourier_packing.h | 5 +---- src/accessor/grib_accessor_class_data_g2complex_packing.h | 5 +---- .../grib_accessor_class_data_g2secondary_bitmap.h | 5 +---- .../grib_accessor_class_data_g2shsimple_packing.h | 5 +---- ...essor_class_data_g2simple_packing_with_preprocessing.h | 5 +---- src/accessor/grib_accessor_class_data_jpeg2000_packing.h | 5 +---- src/accessor/grib_accessor_class_data_raw_packing.h | 5 +---- .../grib_accessor_class_data_run_length_packing.h | 5 +---- src/accessor/grib_accessor_class_data_secondary_bitmap.h | 5 +---- src/accessor/grib_accessor_class_data_sh_packed.h | 5 +---- src/accessor/grib_accessor_class_data_sh_unpacked.h | 5 +---- src/accessor/grib_accessor_class_data_shsimple_packing.h | 5 +---- src/accessor/grib_accessor_class_decimal_precision.h | 1 - src/accessor/grib_accessor_class_dictionary.h | 1 - src/accessor/grib_accessor_class_dirty.h | 1 - src/accessor/grib_accessor_class_divdouble.h | 1 - src/accessor/grib_accessor_class_element.h | 1 - src/accessor/grib_accessor_class_evaluate.h | 1 - src/accessor/grib_accessor_class_expanded_descriptors.h | 1 - .../grib_accessor_class_from_scale_factor_scaled_value.h | 1 - src/accessor/grib_accessor_class_g1_half_byte_codeflag.h | 1 - src/accessor/grib_accessor_class_g1_message_length.h | 1 - src/accessor/grib_accessor_class_g1_section4_length.h | 1 - src/accessor/grib_accessor_class_g1bitmap.h | 1 - src/accessor/grib_accessor_class_g1date.h | 1 - src/accessor/grib_accessor_class_g1day_of_the_year_date.h | 1 - .../grib_accessor_class_g1end_of_interval_monthly.h | 1 - src/accessor/grib_accessor_class_g1fcperiod.h | 1 - src/accessor/grib_accessor_class_g1forecastmonth.h | 1 - src/accessor/grib_accessor_class_g1monthlydate.h | 1 - ...b_accessor_class_g1number_of_coded_values_sh_complex.h | 1 - ...ib_accessor_class_g1number_of_coded_values_sh_simple.h | 1 - src/accessor/grib_accessor_class_g1step_range.h | 1 - src/accessor/grib_accessor_class_g1verificationdate.h | 1 - src/accessor/grib_accessor_class_g2_aerosol.h | 1 - src/accessor/grib_accessor_class_g2_chemical.h | 1 - src/accessor/grib_accessor_class_g2_eps.h | 1 - src/accessor/grib_accessor_class_g2_mars_labeling.h | 1 - src/accessor/grib_accessor_class_g2bitmap.h | 1 - src/accessor/grib_accessor_class_g2bitmap_present.h | 1 - src/accessor/grib_accessor_class_g2date.h | 1 - src/accessor/grib_accessor_class_g2end_step.h | 1 - src/accessor/grib_accessor_class_g2grid.h | 1 - src/accessor/grib_accessor_class_g2latlon.h | 1 - src/accessor/grib_accessor_class_g2level.h | 1 - src/accessor/grib_accessor_class_g2lon.h | 1 - src/accessor/grib_accessor_class_gaussian_grid_name.h | 1 - src/accessor/grib_accessor_class_gds_is_present.h | 1 - src/accessor/grib_accessor_class_gds_not_present_bitmap.h | 1 - src/accessor/grib_accessor_class_global_gaussian.h | 1 - src/accessor/grib_accessor_class_group.h | 1 - src/accessor/grib_accessor_class_gts_header.h | 1 - src/accessor/grib_accessor_class_hash_array.h | 1 - src/accessor/grib_accessor_class_headers_only.h | 1 - src/accessor/grib_accessor_class_ifs_param.h | 1 - src/accessor/grib_accessor_class_julian_date.h | 1 - src/accessor/grib_accessor_class_julian_day.h | 1 - src/accessor/grib_accessor_class_ksec1expver.h | 1 - src/accessor/grib_accessor_class_label.h | 1 - src/accessor/grib_accessor_class_latitudes.h | 1 - src/accessor/grib_accessor_class_latlon_increment.h | 1 - src/accessor/grib_accessor_class_latlonvalues.h | 1 - src/accessor/grib_accessor_class_library_version.h | 1 - src/accessor/grib_accessor_class_local_definition.h | 1 - src/accessor/grib_accessor_class_long.h | 1 - src/accessor/grib_accessor_class_long_vector.h | 1 - src/accessor/grib_accessor_class_longitudes.h | 1 - src/accessor/grib_accessor_class_mars_param.h | 1 - src/accessor/grib_accessor_class_mars_step.h | 1 - src/accessor/grib_accessor_class_md5.h | 1 - src/accessor/grib_accessor_class_message.h | 1 - src/accessor/grib_accessor_class_message_copy.h | 1 - src/accessor/grib_accessor_class_multdouble.h | 1 - src/accessor/grib_accessor_class_nearest.h | 1 - src/accessor/grib_accessor_class_non_alpha.h | 1 - src/accessor/grib_accessor_class_number_of_coded_values.h | 1 - src/accessor/grib_accessor_class_number_of_points.h | 1 - .../grib_accessor_class_number_of_points_gaussian.h | 1 - src/accessor/grib_accessor_class_number_of_values.h | 1 - ...rib_accessor_class_number_of_values_data_raw_packing.h | 1 - src/accessor/grib_accessor_class_octahedral_gaussian.h | 1 - src/accessor/grib_accessor_class_octet_number.h | 1 - src/accessor/grib_accessor_class_offset_file.h | 1 - src/accessor/grib_accessor_class_offset_values.h | 1 - src/accessor/grib_accessor_class_pack_bufr_values.h | 1 - src/accessor/grib_accessor_class_packing_type.h | 1 - src/accessor/grib_accessor_class_pad.h | 1 - src/accessor/grib_accessor_class_padding.h | 1 - src/accessor/grib_accessor_class_padto.h | 1 - src/accessor/grib_accessor_class_padtoeven.h | 1 - src/accessor/grib_accessor_class_padtomultiple.h | 1 - src/accessor/grib_accessor_class_position.h | 1 - src/accessor/grib_accessor_class_proj_string.h | 1 - src/accessor/grib_accessor_class_raw.h | 1 - src/accessor/grib_accessor_class_rdbtime_guess_date.h | 1 - src/accessor/grib_accessor_class_reference_value_error.h | 1 - src/accessor/grib_accessor_class_round.h | 1 - src/accessor/grib_accessor_class_scale.h | 1 - src/accessor/grib_accessor_class_scale_values.h | 1 - .../grib_accessor_class_second_order_bits_per_value.h | 1 - src/accessor/grib_accessor_class_section_length.h | 1 - src/accessor/grib_accessor_class_section_padding.h | 1 - src/accessor/grib_accessor_class_section_pointer.h | 1 - src/accessor/grib_accessor_class_select_step_template.h | 1 - src/accessor/grib_accessor_class_sexagesimal2decimal.h | 1 - src/accessor/grib_accessor_class_signed.h | 1 - src/accessor/grib_accessor_class_signed_bits.h | 1 - src/accessor/grib_accessor_class_simple_packing_error.h | 1 - src/accessor/grib_accessor_class_size.h | 1 - src/accessor/grib_accessor_class_smart_table.h | 8 -------- src/accessor/grib_accessor_class_spd.h | 1 - src/accessor/grib_accessor_class_spectral_truncation.h | 1 - src/accessor/grib_accessor_class_sprintf.h | 1 - src/accessor/grib_accessor_class_statistics.h | 1 - src/accessor/grib_accessor_class_statistics_spectral.h | 1 - src/accessor/grib_accessor_class_step_human_readable.h | 1 - src/accessor/grib_accessor_class_step_in_units.h | 1 - src/accessor/grib_accessor_class_sum.h | 1 - src/accessor/grib_accessor_class_suppressed.h | 1 - src/accessor/grib_accessor_class_time.h | 1 - src/accessor/grib_accessor_class_to_double.h | 1 - src/accessor/grib_accessor_class_to_integer.h | 1 - src/accessor/grib_accessor_class_to_string.h | 1 - src/accessor/grib_accessor_class_transient_darray.h | 1 - src/accessor/grib_accessor_class_trim.h | 1 - src/accessor/grib_accessor_class_uint16.h | 1 - src/accessor/grib_accessor_class_uint32.h | 1 - src/accessor/grib_accessor_class_uint32_little_endian.h | 1 - src/accessor/grib_accessor_class_uint64.h | 1 - src/accessor/grib_accessor_class_uint64_little_endian.h | 1 - src/accessor/grib_accessor_class_uint8.h | 1 - src/accessor/grib_accessor_class_unexpanded_descriptors.h | 1 - src/accessor/grib_accessor_class_unpack_bufr_values.h | 1 - src/accessor/grib_accessor_class_unsigned.h | 1 - src/accessor/grib_accessor_class_unsigned_bits.h | 1 - src/accessor/grib_accessor_class_validity_date.h | 1 - src/accessor/grib_accessor_class_validity_time.h | 1 - src/accessor/grib_accessor_class_values.h | 4 +--- src/accessor/grib_accessor_class_vector.h | 1 - src/accessor/grib_accessor_class_when.h | 1 - 181 files changed, 19 insertions(+), 254 deletions(-) diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h b/src/accessor/grib_accessor_class_abstract_long_vector.h index 5c3c6b5f9..0585a5819 100644 --- a/src/accessor/grib_accessor_class_abstract_long_vector.h +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_abstract_long_vector_h #define eccodes_accessor_abstract_long_vector_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_abstract_vector.h b/src/accessor/grib_accessor_class_abstract_vector.h index d1201ede7..7d5dd13df 100644 --- a/src/accessor/grib_accessor_class_abstract_vector.h +++ b/src/accessor/grib_accessor_class_abstract_vector.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_abstract_vector_h #define eccodes_accessor_abstract_vector_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_abstract_vector_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_ascii.h b/src/accessor/grib_accessor_class_ascii.h index ea00a247c..1fa848236 100644 --- a/src/accessor/grib_accessor_class_ascii.h +++ b/src/accessor/grib_accessor_class_ascii.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_ascii_h #define eccodes_accessor_ascii_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_ascii_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bit.h b/src/accessor/grib_accessor_class_bit.h index 28c001488..7ad258b03 100644 --- a/src/accessor/grib_accessor_class_bit.h +++ b/src/accessor/grib_accessor_class_bit.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bit_h #define eccodes_accessor_bit_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bit_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bitmap.h b/src/accessor/grib_accessor_class_bitmap.h index dd66d6256..599e8c7ab 100644 --- a/src/accessor/grib_accessor_class_bitmap.h +++ b/src/accessor/grib_accessor_class_bitmap.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bitmap_h #define eccodes_accessor_bitmap_h -#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_bitmap_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_bits.h b/src/accessor/grib_accessor_class_bits.h index dccc43486..2508e5ba0 100644 --- a/src/accessor/grib_accessor_class_bits.h +++ b/src/accessor/grib_accessor_class_bits.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bits_h #define eccodes_accessor_bits_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bits_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bits_per_value.h b/src/accessor/grib_accessor_class_bits_per_value.h index 3d83e07e6..dee7f76e3 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.h +++ b/src/accessor/grib_accessor_class_bits_per_value.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bits_per_value_h #define eccodes_accessor_bits_per_value_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bits_per_value_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_blob.h b/src/accessor/grib_accessor_class_blob.h index d0dc4b290..9743ca17b 100644 --- a/src/accessor/grib_accessor_class_blob.h +++ b/src/accessor/grib_accessor_class_blob.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_blob_h #define eccodes_accessor_blob_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_blob_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_budgdate.h b/src/accessor/grib_accessor_class_budgdate.h index d5a75ffe1..1b8103a03 100644 --- a/src/accessor/grib_accessor_class_budgdate.h +++ b/src/accessor/grib_accessor_class_budgdate.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_budgdate_h #define eccodes_accessor_budgdate_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_budgdate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h index a8766df47..4dd22a7d5 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.h +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_data_element_h #define eccodes_accessor_bufr_data_element_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h b/src/accessor/grib_accessor_class_bufr_elements_table.h index 1149b2ad3..d29bc9192 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.h +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_elements_table_h #define eccodes_accessor_bufr_elements_table_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h index f2e8b0ba2..b22452490 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_extract_area_subsets_h #define eccodes_accessor_bufr_extract_area_subsets_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h index 3f7c505e0..5f4bf9dd7 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_extract_datetime_subsets_h #define eccodes_accessor_bufr_extract_datetime_subsets_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_subsets.h index 736206c08..0d0f60fd7 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_extract_subsets_h #define eccodes_accessor_bufr_extract_subsets_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h index c225cfe2d..87f060282 100644 --- a/src/accessor/grib_accessor_class_bufr_group.h +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_group_h #define eccodes_accessor_bufr_group_h -#include "grib_api_internal.h" #include "grib_accessor_class_variable.h" class grib_accessor_bufr_group_t : public grib_accessor_variable_t diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h b/src/accessor/grib_accessor_class_bufr_simple_thinning.h index 6971e5edb..5cb9f6144 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.h +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_simple_thinning_h #define eccodes_accessor_bufr_simple_thinning_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h b/src/accessor/grib_accessor_class_bufr_string_values.h index 2262990a7..387bafd1e 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.h +++ b/src/accessor/grib_accessor_class_bufr_string_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufr_string_values_h #define eccodes_accessor_bufr_string_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h index 9d8f551b2..fcc08fc91 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bufrdc_expanded_descriptors_h #define eccodes_accessor_bufrdc_expanded_descriptors_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_bytes.h b/src/accessor/grib_accessor_class_bytes.h index ee72f13c3..558d52018 100644 --- a/src/accessor/grib_accessor_class_bytes.h +++ b/src/accessor/grib_accessor_class_bytes.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_bytes_h #define eccodes_accessor_bytes_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_bytes_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h index 3caca2a6b..e2ecc7994 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_change_alternative_row_scanning_h #define eccodes_accessor_change_alternative_row_scanning_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h b/src/accessor/grib_accessor_class_change_scanning_direction.h index 7d8ac8d6a..0dae34341 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.h +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_change_scanning_direction_h #define eccodes_accessor_change_scanning_direction_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_check_internal_version.h b/src/accessor/grib_accessor_class_check_internal_version.h index 222ec76ab..46f9a29d5 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.h +++ b/src/accessor/grib_accessor_class_check_internal_version.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_check_internal_version_h #define eccodes_accessor_check_internal_version_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_closest_date.h b/src/accessor/grib_accessor_class_closest_date.h index be6d3aa98..e5b65c683 100644 --- a/src/accessor/grib_accessor_class_closest_date.h +++ b/src/accessor/grib_accessor_class_closest_date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_closest_date_h #define eccodes_accessor_closest_date_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_closest_date_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_codeflag.h b/src/accessor/grib_accessor_class_codeflag.h index f74af599a..f9465f703 100644 --- a/src/accessor/grib_accessor_class_codeflag.h +++ b/src/accessor/grib_accessor_class_codeflag.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_codeflag_h #define eccodes_accessor_codeflag_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_codeflag_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_codetable.h b/src/accessor/grib_accessor_class_codetable.h index 48ae07502..8a16d9113 100644 --- a/src/accessor/grib_accessor_class_codetable.h +++ b/src/accessor/grib_accessor_class_codetable.h @@ -8,17 +8,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" #include - class grib_accessor_codetable_t : public grib_accessor_unsigned_t { public: diff --git a/src/accessor/grib_accessor_class_codetable_title.h b/src/accessor/grib_accessor_class_codetable_title.h index 873b3e0a1..4a2114579 100644 --- a/src/accessor/grib_accessor_class_codetable_title.h +++ b/src/accessor/grib_accessor_class_codetable_title.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_codetable_title_h #define eccodes_accessor_codetable_title_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_codetable_title_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_codetable_units.h b/src/accessor/grib_accessor_class_codetable_units.h index 913afb1d2..d5207f532 100644 --- a/src/accessor/grib_accessor_class_codetable_units.h +++ b/src/accessor/grib_accessor_class_codetable_units.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_codetable_units_h #define eccodes_accessor_codetable_units_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_codetable_units_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_concept.h b/src/accessor/grib_accessor_class_concept.h index 436e5b95e..e2d9b8474 100644 --- a/src/accessor/grib_accessor_class_concept.h +++ b/src/accessor/grib_accessor_class_concept.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_concept_h #define eccodes_accessor_concept_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_concept_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_constant.h b/src/accessor/grib_accessor_class_constant.h index 029c51e79..916df88e9 100644 --- a/src/accessor/grib_accessor_class_constant.h +++ b/src/accessor/grib_accessor_class_constant.h @@ -8,12 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ - -/************************************* - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" #include "grib_accessor_class_variable.h" class grib_accessor_constant_t : public grib_accessor_variable_t {}; diff --git a/src/accessor/grib_accessor_class_count_file.h b/src/accessor/grib_accessor_class_count_file.h index fd2251045..727df09c2 100644 --- a/src/accessor/grib_accessor_class_count_file.h +++ b/src/accessor/grib_accessor_class_count_file.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_count_file_h #define eccodes_accessor_count_file_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_file_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_count_missing.h b/src/accessor/grib_accessor_class_count_missing.h index d43c6f22e..405456843 100644 --- a/src/accessor/grib_accessor_class_count_missing.h +++ b/src/accessor/grib_accessor_class_count_missing.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_count_missing_h #define eccodes_accessor_count_missing_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_missing_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_count_total.h b/src/accessor/grib_accessor_class_count_total.h index 9c242b5c6..4518f9703 100644 --- a/src/accessor/grib_accessor_class_count_total.h +++ b/src/accessor/grib_accessor_class_count_total.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_count_total_h #define eccodes_accessor_count_total_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_count_total_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h b/src/accessor/grib_accessor_class_data_apply_bitmap.h index 18b7802a9..a2d724ed7 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.h @@ -11,7 +11,6 @@ #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_apply_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h index c03416060..5b26b3a4f 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h #define eccodes_accessor_data_apply_boustrophedonic_bitmap_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h b/src/accessor/grib_accessor_class_data_dummy_field.h index 31d6d27b8..2fac95235 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.h +++ b/src/accessor/grib_accessor_class_data_dummy_field.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_data_dummy_field_h #define eccodes_accessor_data_dummy_field_h -#include "grib_api_internal.h" #include "grib_accessor_class_data_g1simple_packing.h" class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h b/src/accessor/grib_accessor_class_data_g1complex_packing.h index a3c916606..75ad18d66 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1complex_packing_h -#define eccodes_accessor_data_g1complex_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_complex_packing.h" class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t @@ -34,4 +32,3 @@ public: int pack_double(grib_accessor*, const double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g1complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h index 8c190bd12..0da32c286 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1second_order_constant_width_packing_h -#define eccodes_accessor_data_g1second_order_constant_width_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t @@ -50,4 +48,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_data_g1second_order_constant_width_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h index fb2356a4f..4bb6c061c 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1second_order_general_extended_packing_h -#define eccodes_accessor_data_g1second_order_general_extended_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t @@ -65,4 +63,3 @@ public: private: int unpack(grib_accessor* a, double*, float*, size_t*); }; -#endif /* eccodes_accessor_data_g1second_order_general_extended_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h index d0eaedb55..562108986 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1secondary_bitmap_h -#define eccodes_accessor_data_g1secondary_bitmap_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_secondary_bitmap.h" class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t @@ -31,4 +29,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g1secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h index 8a212b5df..56e1ee47b 100644 --- a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1shsimple_packing_h -#define eccodes_accessor_data_g1shsimple_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_shsimple_packing.h" class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t @@ -29,4 +27,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; int value_count(grib_accessor*, long*) override; }; -#endif /* eccodes_accessor_data_g1shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h b/src/accessor/grib_accessor_class_data_g1simple_packing.h index 9d210ab63..2dfedd6c9 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g1simple_packing_h -#define eccodes_accessor_data_g1simple_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t @@ -34,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g1simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h index 1d2838414..b3ca0176a 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2bifourier_packing_h -#define eccodes_accessor_data_g2bifourier_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t @@ -44,4 +42,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2bifourier_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h b/src/accessor/grib_accessor_class_data_g2complex_packing.h index ec7ab213e..cfa0f8116 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2complex_packing_h -#define eccodes_accessor_data_g2complex_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_complex_packing.h" class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t @@ -31,4 +29,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2complex_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h index abc550a97..64428a4ce 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2secondary_bitmap_h -#define eccodes_accessor_data_g2secondary_bitmap_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_secondary_bitmap.h" class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t @@ -31,4 +29,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h index 30899788b..c0189ae66 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2shsimple_packing_h -#define eccodes_accessor_data_g2shsimple_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_shsimple_packing.h" class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t @@ -33,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h index 797815bd3..5825b9d16 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2simple_packing_with_preprocessing_h -#define eccodes_accessor_data_g2simple_packing_with_preprocessing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_g2simple_packing.h" class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t @@ -33,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2simple_packing_with_preprocessing_h */ diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h index 4802dd2ac..6fc01b977 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_jpeg2000_packing_h -#define eccodes_accessor_data_jpeg2000_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t @@ -43,4 +41,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_data_jpeg2000_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_raw_packing.h b/src/accessor/grib_accessor_class_data_raw_packing.h index 075cc470e..8012c1f51 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_data_raw_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_raw_packing_h -#define eccodes_accessor_data_raw_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_values.h" class grib_accessor_data_raw_packing_t : public grib_accessor_values_t @@ -35,4 +33,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h b/src/accessor/grib_accessor_class_data_run_length_packing.h index f57d69c39..c35689abf 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.h +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_run_length_packing_h -#define eccodes_accessor_data_run_length_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_values.h" class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t @@ -37,4 +35,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_run_length_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h b/src/accessor/grib_accessor_class_data_secondary_bitmap.h index 06a2ab576..8bc156ef5 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_secondary_bitmap_h -#define eccodes_accessor_data_secondary_bitmap_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t @@ -35,4 +33,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_secondary_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h b/src/accessor/grib_accessor_class_data_sh_packed.h index 109534010..377db9ab4 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.h +++ b/src/accessor/grib_accessor_class_data_sh_packed.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_sh_packed_h -#define eccodes_accessor_data_sh_packed_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t @@ -40,4 +38,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_sh_packed_h */ diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h b/src/accessor/grib_accessor_class_data_sh_unpacked.h index 3f9c57dc8..b201e3dd3 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.h +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_sh_unpacked_h -#define eccodes_accessor_data_sh_unpacked_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_data_simple_packing.h" class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t @@ -40,4 +38,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_sh_unpacked_h */ diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h b/src/accessor/grib_accessor_class_data_shsimple_packing.h index b4c388902..e77612ddd 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h @@ -9,10 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_shsimple_packing_h -#define eccodes_accessor_data_shsimple_packing_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t @@ -34,4 +32,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_shsimple_packing_h */ diff --git a/src/accessor/grib_accessor_class_decimal_precision.h b/src/accessor/grib_accessor_class_decimal_precision.h index a3e3e3024..741e32e83 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.h +++ b/src/accessor/grib_accessor_class_decimal_precision.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_decimal_precision_h #define eccodes_accessor_decimal_precision_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_decimal_precision_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_dictionary.h b/src/accessor/grib_accessor_class_dictionary.h index 353cb9efa..327c6fc72 100644 --- a/src/accessor/grib_accessor_class_dictionary.h +++ b/src/accessor/grib_accessor_class_dictionary.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_dictionary_h #define eccodes_accessor_dictionary_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_dictionary_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_dirty.h b/src/accessor/grib_accessor_class_dirty.h index 78d4fcb64..1e49bf0a4 100644 --- a/src/accessor/grib_accessor_class_dirty.h +++ b/src/accessor/grib_accessor_class_dirty.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_dirty_h #define eccodes_accessor_dirty_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_dirty_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_divdouble.h b/src/accessor/grib_accessor_class_divdouble.h index eb2357a3e..bc61e4012 100644 --- a/src/accessor/grib_accessor_class_divdouble.h +++ b/src/accessor/grib_accessor_class_divdouble.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_divdouble_h #define eccodes_accessor_divdouble_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_divdouble_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_element.h b/src/accessor/grib_accessor_class_element.h index fe1d58ecd..20fa07fcc 100644 --- a/src/accessor/grib_accessor_class_element.h +++ b/src/accessor/grib_accessor_class_element.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_element_h #define eccodes_accessor_element_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_element_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_evaluate.h b/src/accessor/grib_accessor_class_evaluate.h index cfaf92c00..d3a856881 100644 --- a/src/accessor/grib_accessor_class_evaluate.h +++ b/src/accessor/grib_accessor_class_evaluate.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_evaluate_h #define eccodes_accessor_evaluate_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_evaluate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h b/src/accessor/grib_accessor_class_expanded_descriptors.h index 419b28c61..b359a829f 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_expanded_descriptors_h #define eccodes_accessor_expanded_descriptors_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h index d14cb9c56..d73bffe02 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_from_scale_factor_scaled_value_h #define eccodes_accessor_from_scale_factor_scaled_value_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h index bf6ae7372..765ddeb0b 100644 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1_half_byte_codeflag_h #define eccodes_accessor_g1_half_byte_codeflag_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g1_message_length.h b/src/accessor/grib_accessor_class_g1_message_length.h index 65d1983a9..38e85365e 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.h +++ b/src/accessor/grib_accessor_class_g1_message_length.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1_message_length_h #define eccodes_accessor_g1_message_length_h -#include "grib_api_internal.h" #include "grib_accessor_class_section_length.h" class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h b/src/accessor/grib_accessor_class_g1_section4_length.h index 0cb88362a..100f69157 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.h +++ b/src/accessor/grib_accessor_class_g1_section4_length.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1_section4_length_h #define eccodes_accessor_g1_section4_length_h -#include "grib_api_internal.h" #include "grib_accessor_class_section_length.h" class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t diff --git a/src/accessor/grib_accessor_class_g1bitmap.h b/src/accessor/grib_accessor_class_g1bitmap.h index d27f6b4eb..005114620 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.h +++ b/src/accessor/grib_accessor_class_g1bitmap.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1bitmap_h #define eccodes_accessor_g1bitmap_h -#include "grib_api_internal.h" #include "grib_accessor_class_bitmap.h" class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t diff --git a/src/accessor/grib_accessor_class_g1date.h b/src/accessor/grib_accessor_class_g1date.h index 734b2a3b5..6119ca99e 100644 --- a/src/accessor/grib_accessor_class_g1date.h +++ b/src/accessor/grib_accessor_class_g1date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1date_h #define eccodes_accessor_g1date_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h index bc12f541e..a5564f968 100644 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1day_of_the_year_date_h #define eccodes_accessor_g1day_of_the_year_date_h -#include "grib_api_internal.h" #include "grib_accessor_class_g1date.h" class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h index 7e6ac3563..a37edfbcf 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1end_of_interval_monthly_h #define eccodes_accessor_g1end_of_interval_monthly_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h b/src/accessor/grib_accessor_class_g1fcperiod.h index b2862cb78..40810cb86 100644 --- a/src/accessor/grib_accessor_class_g1fcperiod.h +++ b/src/accessor/grib_accessor_class_g1fcperiod.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1fcperiod_h #define eccodes_accessor_g1fcperiod_h -#include "grib_api_internal.h" #include "grib_accessor_class_g1step_range.h" class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h b/src/accessor/grib_accessor_class_g1forecastmonth.h index 3a5fbb89b..ff268febc 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.h +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1forecastmonth_h #define eccodes_accessor_g1forecastmonth_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h b/src/accessor/grib_accessor_class_g1monthlydate.h index b279e56c3..6148e4307 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.h +++ b/src/accessor/grib_accessor_class_g1monthlydate.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1monthlydate_h #define eccodes_accessor_g1monthlydate_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1monthlydate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h index 75b21875b..e8cdb50ca 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h #define eccodes_accessor_g1number_of_coded_values_sh_complex_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h index d59e4999c..f5cc84b02 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h #define eccodes_accessor_g1number_of_coded_values_sh_simple_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g1step_range.h b/src/accessor/grib_accessor_class_g1step_range.h index 26d7116e8..252a214ae 100644 --- a/src/accessor/grib_accessor_class_g1step_range.h +++ b/src/accessor/grib_accessor_class_g1step_range.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1step_range_h #define eccodes_accessor_g1step_range_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_long_vector.h" class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h b/src/accessor/grib_accessor_class_g1verificationdate.h index 70edcf7d8..1a97bf3c6 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.h +++ b/src/accessor/grib_accessor_class_g1verificationdate.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g1verificationdate_h #define eccodes_accessor_g1verificationdate_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g1verificationdate_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h b/src/accessor/grib_accessor_class_g2_aerosol.h index f9feaa5e8..96c1b4b9e 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.h +++ b/src/accessor/grib_accessor_class_g2_aerosol.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2_aerosol_h #define eccodes_accessor_g2_aerosol_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_chemical.h b/src/accessor/grib_accessor_class_g2_chemical.h index 01a159008..59df76928 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.h +++ b/src/accessor/grib_accessor_class_g2_chemical.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2_chemical_h #define eccodes_accessor_g2_chemical_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_eps.h b/src/accessor/grib_accessor_class_g2_eps.h index a29e975ea..b651985b1 100644 --- a/src/accessor/grib_accessor_class_g2_eps.h +++ b/src/accessor/grib_accessor_class_g2_eps.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2_eps_h #define eccodes_accessor_g2_eps_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h b/src/accessor/grib_accessor_class_g2_mars_labeling.h index a73962542..b3f7969bb 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.h +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2_mars_labeling_h #define eccodes_accessor_g2_mars_labeling_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_g2bitmap.h b/src/accessor/grib_accessor_class_g2bitmap.h index 3f1b85d23..3c6f3e39c 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.h +++ b/src/accessor/grib_accessor_class_g2bitmap.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2bitmap_h #define eccodes_accessor_g2bitmap_h -#include "grib_api_internal.h" #include "grib_accessor_class_bitmap.h" class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h b/src/accessor/grib_accessor_class_g2bitmap_present.h index 18c7ac3f7..8ac86bbb4 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.h +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2bitmap_present_h #define eccodes_accessor_g2bitmap_present_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2date.h b/src/accessor/grib_accessor_class_g2date.h index 1c7a8a02d..da4e6b379 100644 --- a/src/accessor/grib_accessor_class_g2date.h +++ b/src/accessor/grib_accessor_class_g2date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2date_h #define eccodes_accessor_g2date_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2end_step.h b/src/accessor/grib_accessor_class_g2end_step.h index b408681a0..756079631 100644 --- a/src/accessor/grib_accessor_class_g2end_step.h +++ b/src/accessor/grib_accessor_class_g2end_step.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2end_step_h #define eccodes_accessor_g2end_step_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2end_step_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2grid.h b/src/accessor/grib_accessor_class_g2grid.h index 25a527b69..ca1ef3e6c 100644 --- a/src/accessor/grib_accessor_class_g2grid.h +++ b/src/accessor/grib_accessor_class_g2grid.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2grid_h #define eccodes_accessor_g2grid_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2grid_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g2latlon.h b/src/accessor/grib_accessor_class_g2latlon.h index c179bdd60..519b63b57 100644 --- a/src/accessor/grib_accessor_class_g2latlon.h +++ b/src/accessor/grib_accessor_class_g2latlon.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2latlon_h #define eccodes_accessor_g2latlon_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2latlon_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_g2level.h b/src/accessor/grib_accessor_class_g2level.h index a0163be8b..f0abf7e6e 100644 --- a/src/accessor/grib_accessor_class_g2level.h +++ b/src/accessor/grib_accessor_class_g2level.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2level_h #define eccodes_accessor_g2level_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_g2level_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_g2lon.h b/src/accessor/grib_accessor_class_g2lon.h index dd631adf4..409cc1297 100644 --- a/src/accessor/grib_accessor_class_g2lon.h +++ b/src/accessor/grib_accessor_class_g2lon.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_g2lon_h #define eccodes_accessor_g2lon_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_g2lon_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h b/src/accessor/grib_accessor_class_gaussian_grid_name.h index a6be9dc33..abb505cb5 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.h +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_gaussian_grid_name_h #define eccodes_accessor_gaussian_grid_name_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_gds_is_present.h b/src/accessor/grib_accessor_class_gds_is_present.h index 8dad7dd21..b7617a64d 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.h +++ b/src/accessor/grib_accessor_class_gds_is_present.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_gds_is_present_h #define eccodes_accessor_gds_is_present_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_gds_is_present_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h index 377fac8b4..03750bb03 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_gds_not_present_bitmap_h #define eccodes_accessor_gds_not_present_bitmap_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_global_gaussian.h b/src/accessor/grib_accessor_class_global_gaussian.h index 5bd73dd8f..8c9d37f13 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.h +++ b/src/accessor/grib_accessor_class_global_gaussian.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_global_gaussian_h #define eccodes_accessor_global_gaussian_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_global_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_group.h b/src/accessor/grib_accessor_class_group.h index ab56f174e..3d718fdfa 100644 --- a/src/accessor/grib_accessor_class_group.h +++ b/src/accessor/grib_accessor_class_group.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_group_h #define eccodes_accessor_group_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_group_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_gts_header.h b/src/accessor/grib_accessor_class_gts_header.h index 15f2bfd9e..3027def40 100644 --- a/src/accessor/grib_accessor_class_gts_header.h +++ b/src/accessor/grib_accessor_class_gts_header.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_gts_header_h #define eccodes_accessor_gts_header_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_gts_header_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_hash_array.h b/src/accessor/grib_accessor_class_hash_array.h index 7ebd98929..f3791d91f 100644 --- a/src/accessor/grib_accessor_class_hash_array.h +++ b/src/accessor/grib_accessor_class_hash_array.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_hash_array_h #define eccodes_accessor_hash_array_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_hash_array_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_headers_only.h b/src/accessor/grib_accessor_class_headers_only.h index d5743cf90..d972319c5 100644 --- a/src/accessor/grib_accessor_class_headers_only.h +++ b/src/accessor/grib_accessor_class_headers_only.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_headers_only_h #define eccodes_accessor_headers_only_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_headers_only_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_ifs_param.h b/src/accessor/grib_accessor_class_ifs_param.h index b9fe2bd33..1c86b8561 100644 --- a/src/accessor/grib_accessor_class_ifs_param.h +++ b/src/accessor/grib_accessor_class_ifs_param.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_ifs_param_h #define eccodes_accessor_ifs_param_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_ifs_param_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_julian_date.h b/src/accessor/grib_accessor_class_julian_date.h index 944e85996..b555ee9dc 100644 --- a/src/accessor/grib_accessor_class_julian_date.h +++ b/src/accessor/grib_accessor_class_julian_date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_julian_date_h #define eccodes_accessor_julian_date_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_julian_date_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_julian_day.h b/src/accessor/grib_accessor_class_julian_day.h index b31f3b0dd..6bb48344f 100644 --- a/src/accessor/grib_accessor_class_julian_day.h +++ b/src/accessor/grib_accessor_class_julian_day.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_julian_day_h #define eccodes_accessor_julian_day_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_julian_day_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_ksec1expver.h b/src/accessor/grib_accessor_class_ksec1expver.h index ca0a18695..7225613a5 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.h +++ b/src/accessor/grib_accessor_class_ksec1expver.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_ksec1expver_h #define eccodes_accessor_ksec1expver_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_label.h b/src/accessor/grib_accessor_class_label.h index 01b7ac392..058ce9a11 100644 --- a/src/accessor/grib_accessor_class_label.h +++ b/src/accessor/grib_accessor_class_label.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_label_h #define eccodes_accessor_label_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_label_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_latitudes.h b/src/accessor/grib_accessor_class_latitudes.h index e89db49e4..1b55b5210 100644 --- a/src/accessor/grib_accessor_class_latitudes.h +++ b/src/accessor/grib_accessor_class_latitudes.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_latitudes_h #define eccodes_accessor_latitudes_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latitudes_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_latlon_increment.h b/src/accessor/grib_accessor_class_latlon_increment.h index e85d1ec91..3c189450d 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.h +++ b/src/accessor/grib_accessor_class_latlon_increment.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_latlon_increment_h #define eccodes_accessor_latlon_increment_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latlon_increment_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_latlonvalues.h b/src/accessor/grib_accessor_class_latlonvalues.h index 56faec4d9..0109e7e86 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.h +++ b/src/accessor/grib_accessor_class_latlonvalues.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_latlonvalues_h #define eccodes_accessor_latlonvalues_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_latlonvalues_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_library_version.h b/src/accessor/grib_accessor_class_library_version.h index 66099c2c0..d4c56b52c 100644 --- a/src/accessor/grib_accessor_class_library_version.h +++ b/src/accessor/grib_accessor_class_library_version.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_library_version_h #define eccodes_accessor_library_version_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_library_version_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_local_definition.h b/src/accessor/grib_accessor_class_local_definition.h index 9be7d7e9a..6ca10add6 100644 --- a/src/accessor/grib_accessor_class_local_definition.h +++ b/src/accessor/grib_accessor_class_local_definition.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_local_definition_h #define eccodes_accessor_local_definition_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_local_definition_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_long.h b/src/accessor/grib_accessor_class_long.h index fea39235e..72a67a8e5 100644 --- a/src/accessor/grib_accessor_class_long.h +++ b/src/accessor/grib_accessor_class_long.h @@ -10,7 +10,6 @@ #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_long_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_long_vector.h b/src/accessor/grib_accessor_class_long_vector.h index b2d3a4a67..aacd5e06e 100644 --- a/src/accessor/grib_accessor_class_long_vector.h +++ b/src/accessor/grib_accessor_class_long_vector.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_long_vector_h #define eccodes_accessor_long_vector_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_long_vector.h" class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t diff --git a/src/accessor/grib_accessor_class_longitudes.h b/src/accessor/grib_accessor_class_longitudes.h index 0825f5a90..a1964ea51 100644 --- a/src/accessor/grib_accessor_class_longitudes.h +++ b/src/accessor/grib_accessor_class_longitudes.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_longitudes_h #define eccodes_accessor_longitudes_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_longitudes_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_mars_param.h b/src/accessor/grib_accessor_class_mars_param.h index 87400a5f7..d56488c0a 100644 --- a/src/accessor/grib_accessor_class_mars_param.h +++ b/src/accessor/grib_accessor_class_mars_param.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_mars_param_h #define eccodes_accessor_mars_param_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_mars_param_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_mars_step.h b/src/accessor/grib_accessor_class_mars_step.h index 67d95ef9a..5a570203f 100644 --- a/src/accessor/grib_accessor_class_mars_step.h +++ b/src/accessor/grib_accessor_class_mars_step.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_mars_step_h #define eccodes_accessor_mars_step_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_mars_step_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h index 7b265f797..fdfc70718 100644 --- a/src/accessor/grib_accessor_class_md5.h +++ b/src/accessor/grib_accessor_class_md5.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_md5_h #define eccodes_accessor_md5_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_md5_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_message.h b/src/accessor/grib_accessor_class_message.h index c81e23750..478c01964 100644 --- a/src/accessor/grib_accessor_class_message.h +++ b/src/accessor/grib_accessor_class_message.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_message_h #define eccodes_accessor_message_h -#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_message_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_message_copy.h b/src/accessor/grib_accessor_class_message_copy.h index 53002c968..fa4110a1c 100644 --- a/src/accessor/grib_accessor_class_message_copy.h +++ b/src/accessor/grib_accessor_class_message_copy.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_message_copy_h #define eccodes_accessor_message_copy_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_message_copy_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_multdouble.h b/src/accessor/grib_accessor_class_multdouble.h index c9847dde1..5cc218aac 100644 --- a/src/accessor/grib_accessor_class_multdouble.h +++ b/src/accessor/grib_accessor_class_multdouble.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_multdouble_h #define eccodes_accessor_multdouble_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_multdouble_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_nearest.h b/src/accessor/grib_accessor_class_nearest.h index 098eb69a8..efc7ebfc4 100644 --- a/src/accessor/grib_accessor_class_nearest.h +++ b/src/accessor/grib_accessor_class_nearest.h @@ -10,7 +10,6 @@ #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_nearest_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_non_alpha.h b/src/accessor/grib_accessor_class_non_alpha.h index e9f910723..72674ac5d 100644 --- a/src/accessor/grib_accessor_class_non_alpha.h +++ b/src/accessor/grib_accessor_class_non_alpha.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_non_alpha_h #define eccodes_accessor_non_alpha_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_non_alpha_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h b/src/accessor/grib_accessor_class_number_of_coded_values.h index 7cb74d1c2..1d46cdd6b 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.h +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_number_of_coded_values_h #define eccodes_accessor_number_of_coded_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_points.h b/src/accessor/grib_accessor_class_number_of_points.h index 3ca18b6e9..4adaddaa2 100644 --- a/src/accessor/grib_accessor_class_number_of_points.h +++ b/src/accessor/grib_accessor_class_number_of_points.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_number_of_points_h #define eccodes_accessor_number_of_points_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_points_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h b/src/accessor/grib_accessor_class_number_of_points_gaussian.h index 70ba3d6d4..48e63d28c 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.h +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_number_of_points_gaussian_h #define eccodes_accessor_number_of_points_gaussian_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_values.h b/src/accessor/grib_accessor_class_number_of_values.h index 246c29cbd..8b6418a9c 100644 --- a/src/accessor/grib_accessor_class_number_of_values.h +++ b/src/accessor/grib_accessor_class_number_of_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_number_of_values_h #define eccodes_accessor_number_of_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_number_of_values_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h index ff57531d2..0a4601852 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_number_of_values_data_raw_packing_h #define eccodes_accessor_number_of_values_data_raw_packing_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h b/src/accessor/grib_accessor_class_octahedral_gaussian.h index f9aee3d78..f9c540018 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.h +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_octahedral_gaussian_h #define eccodes_accessor_octahedral_gaussian_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_octet_number.h b/src/accessor/grib_accessor_class_octet_number.h index 6be9134af..35f536214 100644 --- a/src/accessor/grib_accessor_class_octet_number.h +++ b/src/accessor/grib_accessor_class_octet_number.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_octet_number_h #define eccodes_accessor_octet_number_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_octet_number_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_offset_file.h b/src/accessor/grib_accessor_class_offset_file.h index 8806590f7..326559d81 100644 --- a/src/accessor/grib_accessor_class_offset_file.h +++ b/src/accessor/grib_accessor_class_offset_file.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_offset_file_h #define eccodes_accessor_offset_file_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_offset_file_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_offset_values.h b/src/accessor/grib_accessor_class_offset_values.h index 17d31a91a..4fe2fc779 100644 --- a/src/accessor/grib_accessor_class_offset_values.h +++ b/src/accessor/grib_accessor_class_offset_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_offset_values_h #define eccodes_accessor_offset_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_offset_values_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h b/src/accessor/grib_accessor_class_pack_bufr_values.h index feef9ef37..8cb218129 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.h +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_pack_bufr_values_h #define eccodes_accessor_pack_bufr_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_packing_type.h b/src/accessor/grib_accessor_class_packing_type.h index 69c52f866..2a454c1f4 100644 --- a/src/accessor/grib_accessor_class_packing_type.h +++ b/src/accessor/grib_accessor_class_packing_type.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_packing_type_h #define eccodes_accessor_packing_type_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_packing_type_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_pad.h b/src/accessor/grib_accessor_class_pad.h index 28fefc891..08bf09727 100644 --- a/src/accessor/grib_accessor_class_pad.h +++ b/src/accessor/grib_accessor_class_pad.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_pad_h #define eccodes_accessor_pad_h -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_pad_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padding.h b/src/accessor/grib_accessor_class_padding.h index 2d53ed7c8..7544987e0 100644 --- a/src/accessor/grib_accessor_class_padding.h +++ b/src/accessor/grib_accessor_class_padding.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_padding_h #define eccodes_accessor_padding_h -#include "grib_api_internal.h" #include "grib_accessor_class_bytes.h" class grib_accessor_padding_t : public grib_accessor_bytes_t diff --git a/src/accessor/grib_accessor_class_padto.h b/src/accessor/grib_accessor_class_padto.h index 5b7867019..fde8ebbef 100644 --- a/src/accessor/grib_accessor_class_padto.h +++ b/src/accessor/grib_accessor_class_padto.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_padto_h #define eccodes_accessor_padto_h -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padto_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padtoeven.h b/src/accessor/grib_accessor_class_padtoeven.h index 2f9ccc1ff..5dff5ba39 100644 --- a/src/accessor/grib_accessor_class_padtoeven.h +++ b/src/accessor/grib_accessor_class_padtoeven.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_padtoeven_h #define eccodes_accessor_padtoeven_h -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padtoeven_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_padtomultiple.h b/src/accessor/grib_accessor_class_padtomultiple.h index f391fbe58..5bcb0ea71 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.h +++ b/src/accessor/grib_accessor_class_padtomultiple.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_padtomultiple_h #define eccodes_accessor_padtomultiple_h -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_padtomultiple_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_position.h b/src/accessor/grib_accessor_class_position.h index 05564e503..5597940b4 100644 --- a/src/accessor/grib_accessor_class_position.h +++ b/src/accessor/grib_accessor_class_position.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_position_h #define eccodes_accessor_position_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_position_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_proj_string.h b/src/accessor/grib_accessor_class_proj_string.h index bb4fa76a7..7205a8942 100644 --- a/src/accessor/grib_accessor_class_proj_string.h +++ b/src/accessor/grib_accessor_class_proj_string.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_proj_string_h #define eccodes_accessor_proj_string_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_proj_string_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_raw.h b/src/accessor/grib_accessor_class_raw.h index d754deb63..5f4cc36ef 100644 --- a/src/accessor/grib_accessor_class_raw.h +++ b/src/accessor/grib_accessor_class_raw.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_raw_h #define eccodes_accessor_raw_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_raw_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h b/src/accessor/grib_accessor_class_rdbtime_guess_date.h index 1c75f1556..9cef89877 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.h +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_rdbtime_guess_date_h #define eccodes_accessor_rdbtime_guess_date_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_reference_value_error.h b/src/accessor/grib_accessor_class_reference_value_error.h index aea5e95e5..bac786ca6 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.h +++ b/src/accessor/grib_accessor_class_reference_value_error.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_reference_value_error_h #define eccodes_accessor_reference_value_error_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_reference_value_error_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_round.h b/src/accessor/grib_accessor_class_round.h index ed94f9804..e235dfd85 100644 --- a/src/accessor/grib_accessor_class_round.h +++ b/src/accessor/grib_accessor_class_round.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_round_h #define eccodes_accessor_round_h -#include "grib_api_internal.h" #include "grib_accessor_class_evaluate.h" class grib_accessor_round_t : public grib_accessor_evaluate_t diff --git a/src/accessor/grib_accessor_class_scale.h b/src/accessor/grib_accessor_class_scale.h index 5a44f8013..e75fdb021 100644 --- a/src/accessor/grib_accessor_class_scale.h +++ b/src/accessor/grib_accessor_class_scale.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_scale_h #define eccodes_accessor_scale_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_scale_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_scale_values.h b/src/accessor/grib_accessor_class_scale_values.h index ab644956b..4c807f696 100644 --- a/src/accessor/grib_accessor_class_scale_values.h +++ b/src/accessor/grib_accessor_class_scale_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_scale_values_h #define eccodes_accessor_scale_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_scale_values_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h b/src/accessor/grib_accessor_class_second_order_bits_per_value.h index 5c30e9e19..b5a38b417 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.h +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_second_order_bits_per_value_h #define eccodes_accessor_second_order_bits_per_value_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_section_length.h b/src/accessor/grib_accessor_class_section_length.h index 5c9b810d0..0c56b4cb0 100644 --- a/src/accessor/grib_accessor_class_section_length.h +++ b/src/accessor/grib_accessor_class_section_length.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_section_length_h #define eccodes_accessor_section_length_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_section_length_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_section_padding.h b/src/accessor/grib_accessor_class_section_padding.h index b039ed838..f3ea9c821 100644 --- a/src/accessor/grib_accessor_class_section_padding.h +++ b/src/accessor/grib_accessor_class_section_padding.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_section_padding_h #define eccodes_accessor_section_padding_h -#include "grib_api_internal.h" #include "grib_accessor_class_padding.h" class grib_accessor_section_padding_t : public grib_accessor_padding_t diff --git a/src/accessor/grib_accessor_class_section_pointer.h b/src/accessor/grib_accessor_class_section_pointer.h index 0f92439a4..e34125800 100644 --- a/src/accessor/grib_accessor_class_section_pointer.h +++ b/src/accessor/grib_accessor_class_section_pointer.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_section_pointer_h #define eccodes_accessor_section_pointer_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_section_pointer_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_select_step_template.h b/src/accessor/grib_accessor_class_select_step_template.h index ad6548aa4..d2e58c757 100644 --- a/src/accessor/grib_accessor_class_select_step_template.h +++ b/src/accessor/grib_accessor_class_select_step_template.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_select_step_template_h #define eccodes_accessor_select_step_template_h -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h b/src/accessor/grib_accessor_class_sexagesimal2decimal.h index 32fa3498d..0dec18f2c 100644 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.h +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_sexagesimal2decimal_h #define eccodes_accessor_sexagesimal2decimal_h -#include "grib_api_internal.h" #include "grib_accessor_class_to_double.h" class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t diff --git a/src/accessor/grib_accessor_class_signed.h b/src/accessor/grib_accessor_class_signed.h index c25fc1752..72d3c6657 100644 --- a/src/accessor/grib_accessor_class_signed.h +++ b/src/accessor/grib_accessor_class_signed.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_signed_h #define eccodes_accessor_signed_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_signed_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_signed_bits.h b/src/accessor/grib_accessor_class_signed_bits.h index 05cf524aa..d70a9a27a 100644 --- a/src/accessor/grib_accessor_class_signed_bits.h +++ b/src/accessor/grib_accessor_class_signed_bits.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_signed_bits_h #define eccodes_accessor_signed_bits_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_signed_bits_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h b/src/accessor/grib_accessor_class_simple_packing_error.h index 950716638..55f720b78 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.h +++ b/src/accessor/grib_accessor_class_simple_packing_error.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_simple_packing_error_h #define eccodes_accessor_simple_packing_error_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_simple_packing_error_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_size.h b/src/accessor/grib_accessor_class_size.h index 7cfb325f5..12914616e 100644 --- a/src/accessor/grib_accessor_class_size.h +++ b/src/accessor/grib_accessor_class_size.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_size_h #define eccodes_accessor_size_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_size_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_smart_table.h b/src/accessor/grib_accessor_class_smart_table.h index 93a6ea682..c7aaf0827 100644 --- a/src/accessor/grib_accessor_class_smart_table.h +++ b/src/accessor/grib_accessor_class_smart_table.h @@ -8,18 +8,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - - #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_unsigned.h" #include - class grib_accessor_smart_table_t : public grib_accessor_unsigned_t { public: @@ -36,7 +29,6 @@ public: int dirty; }; - class grib_accessor_class_smart_table_t : public grib_accessor_class_unsigned_t { public: diff --git a/src/accessor/grib_accessor_class_spd.h b/src/accessor/grib_accessor_class_spd.h index 3c47458d3..17ebb9b15 100644 --- a/src/accessor/grib_accessor_class_spd.h +++ b/src/accessor/grib_accessor_class_spd.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_spd_h #define eccodes_accessor_spd_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_spd_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h b/src/accessor/grib_accessor_class_spectral_truncation.h index 329c59155..fb43b42d1 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.h +++ b/src/accessor/grib_accessor_class_spectral_truncation.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_spectral_truncation_h #define eccodes_accessor_spectral_truncation_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_spectral_truncation_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_sprintf.h b/src/accessor/grib_accessor_class_sprintf.h index 360cd3b1b..c183db830 100644 --- a/src/accessor/grib_accessor_class_sprintf.h +++ b/src/accessor/grib_accessor_class_sprintf.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_sprintf_h #define eccodes_accessor_sprintf_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_sprintf_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_statistics.h b/src/accessor/grib_accessor_class_statistics.h index e4ffed90d..fcc866ca8 100644 --- a/src/accessor/grib_accessor_class_statistics.h +++ b/src/accessor/grib_accessor_class_statistics.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_statistics_h #define eccodes_accessor_statistics_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_statistics_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h b/src/accessor/grib_accessor_class_statistics_spectral.h index c47f2385a..1451a0d2e 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.h +++ b/src/accessor/grib_accessor_class_statistics_spectral.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_statistics_spectral_h #define eccodes_accessor_statistics_spectral_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_step_human_readable.h b/src/accessor/grib_accessor_class_step_human_readable.h index 9d902f324..4100f6008 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.h +++ b/src/accessor/grib_accessor_class_step_human_readable.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_step_human_readable_h #define eccodes_accessor_step_human_readable_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_step_human_readable_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_step_in_units.h b/src/accessor/grib_accessor_class_step_in_units.h index e6fe8a6f6..0f8036d13 100644 --- a/src/accessor/grib_accessor_class_step_in_units.h +++ b/src/accessor/grib_accessor_class_step_in_units.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_step_in_units_h #define eccodes_accessor_step_in_units_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_step_in_units_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_sum.h b/src/accessor/grib_accessor_class_sum.h index c05c7c6d1..5ee44d7a0 100644 --- a/src/accessor/grib_accessor_class_sum.h +++ b/src/accessor/grib_accessor_class_sum.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_sum_h #define eccodes_accessor_sum_h -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_sum_t : public grib_accessor_double_t diff --git a/src/accessor/grib_accessor_class_suppressed.h b/src/accessor/grib_accessor_class_suppressed.h index 844c1fb6b..5de58f430 100644 --- a/src/accessor/grib_accessor_class_suppressed.h +++ b/src/accessor/grib_accessor_class_suppressed.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_suppressed_h #define eccodes_accessor_suppressed_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_suppressed_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_time.h b/src/accessor/grib_accessor_class_time.h index 247e4a08d..c343872b8 100644 --- a/src/accessor/grib_accessor_class_time.h +++ b/src/accessor/grib_accessor_class_time.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_time_h #define eccodes_accessor_time_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_time_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_to_double.h b/src/accessor/grib_accessor_class_to_double.h index 639cc98f5..8b3d861e0 100644 --- a/src/accessor/grib_accessor_class_to_double.h +++ b/src/accessor/grib_accessor_class_to_double.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_to_double_h #define eccodes_accessor_to_double_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_double_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_to_integer.h b/src/accessor/grib_accessor_class_to_integer.h index ec3505c75..38f909248 100644 --- a/src/accessor/grib_accessor_class_to_integer.h +++ b/src/accessor/grib_accessor_class_to_integer.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_to_integer_h #define eccodes_accessor_to_integer_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_integer_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_to_string.h b/src/accessor/grib_accessor_class_to_string.h index 6dd1e4de8..0a5077eb0 100644 --- a/src/accessor/grib_accessor_class_to_string.h +++ b/src/accessor/grib_accessor_class_to_string.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_to_string_h #define eccodes_accessor_to_string_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_to_string_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_transient_darray.h b/src/accessor/grib_accessor_class_transient_darray.h index 6aeff1491..a1142dbe3 100644 --- a/src/accessor/grib_accessor_class_transient_darray.h +++ b/src/accessor/grib_accessor_class_transient_darray.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_transient_darray_h #define eccodes_accessor_transient_darray_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_transient_darray_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_trim.h b/src/accessor/grib_accessor_class_trim.h index 664ccc528..df06a277f 100644 --- a/src/accessor/grib_accessor_class_trim.h +++ b/src/accessor/grib_accessor_class_trim.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_trim_h #define eccodes_accessor_trim_h -#include "grib_api_internal.h" #include "grib_accessor_class_ascii.h" class grib_accessor_trim_t : public grib_accessor_ascii_t diff --git a/src/accessor/grib_accessor_class_uint16.h b/src/accessor/grib_accessor_class_uint16.h index 0952e2d57..d77d2b6f6 100644 --- a/src/accessor/grib_accessor_class_uint16.h +++ b/src/accessor/grib_accessor_class_uint16.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint16_h #define eccodes_accessor_uint16_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint16_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint32.h b/src/accessor/grib_accessor_class_uint32.h index 0cf8a0bd9..e327b275e 100644 --- a/src/accessor/grib_accessor_class_uint32.h +++ b/src/accessor/grib_accessor_class_uint32.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint32_h #define eccodes_accessor_uint32_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint32_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h b/src/accessor/grib_accessor_class_uint32_little_endian.h index 357791081..554ea6a93 100644 --- a/src/accessor/grib_accessor_class_uint32_little_endian.h +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint32_little_endian_h #define eccodes_accessor_uint32_little_endian_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint64.h b/src/accessor/grib_accessor_class_uint64.h index 55215c77f..3e7779fa3 100644 --- a/src/accessor/grib_accessor_class_uint64.h +++ b/src/accessor/grib_accessor_class_uint64.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint64_h #define eccodes_accessor_uint64_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint64_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h b/src/accessor/grib_accessor_class_uint64_little_endian.h index 8c04a5398..e2e1774b1 100644 --- a/src/accessor/grib_accessor_class_uint64_little_endian.h +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint64_little_endian_h #define eccodes_accessor_uint64_little_endian_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_uint8.h b/src/accessor/grib_accessor_class_uint8.h index 04dcb1075..fb18550e6 100644 --- a/src/accessor/grib_accessor_class_uint8.h +++ b/src/accessor/grib_accessor_class_uint8.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_uint8_h #define eccodes_accessor_uint8_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_uint8_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h b/src/accessor/grib_accessor_class_unexpanded_descriptors.h index 2db5b51b3..eac0dbf6a 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.h +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_unexpanded_descriptors_h #define eccodes_accessor_unexpanded_descriptors_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h b/src/accessor/grib_accessor_class_unpack_bufr_values.h index 0eea70de4..dde08dc9b 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.h +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_unpack_bufr_values_h #define eccodes_accessor_unpack_bufr_values_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t diff --git a/src/accessor/grib_accessor_class_unsigned.h b/src/accessor/grib_accessor_class_unsigned.h index 0523974ca..50f3cfb16 100644 --- a/src/accessor/grib_accessor_class_unsigned.h +++ b/src/accessor/grib_accessor_class_unsigned.h @@ -10,7 +10,6 @@ #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unsigned_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h b/src/accessor/grib_accessor_class_unsigned_bits.h index ae20b0a5a..3042ea3fa 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.h +++ b/src/accessor/grib_accessor_class_unsigned_bits.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_unsigned_bits_h #define eccodes_accessor_unsigned_bits_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_unsigned_bits_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_validity_date.h b/src/accessor/grib_accessor_class_validity_date.h index dfd8eb320..ca2efb7c4 100644 --- a/src/accessor/grib_accessor_class_validity_date.h +++ b/src/accessor/grib_accessor_class_validity_date.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_validity_date_h #define eccodes_accessor_validity_date_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_validity_date_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_validity_time.h b/src/accessor/grib_accessor_class_validity_time.h index 3f7c27f7b..7b998e595 100644 --- a/src/accessor/grib_accessor_class_validity_time.h +++ b/src/accessor/grib_accessor_class_validity_time.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_validity_time_h #define eccodes_accessor_validity_time_h -#include "grib_api_internal.h" #include "grib_accessor_class_long.h" class grib_accessor_validity_time_t : public grib_accessor_long_t diff --git a/src/accessor/grib_accessor_class_values.h b/src/accessor/grib_accessor_class_values.h index c7cbf54e7..5de50f2bd 100644 --- a/src/accessor/grib_accessor_class_values.h +++ b/src/accessor/grib_accessor_class_values.h @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_values_h -#define eccodes_accessor_values_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: void update_size(grib_accessor*, size_t) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_values_h */ diff --git a/src/accessor/grib_accessor_class_vector.h b/src/accessor/grib_accessor_class_vector.h index 671441001..12871fcc9 100644 --- a/src/accessor/grib_accessor_class_vector.h +++ b/src/accessor/grib_accessor_class_vector.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_vector_h #define eccodes_accessor_vector_h -#include "grib_api_internal.h" #include "grib_accessor_class_abstract_vector.h" class grib_accessor_vector_t : public grib_accessor_abstract_vector_t diff --git a/src/accessor/grib_accessor_class_when.h b/src/accessor/grib_accessor_class_when.h index b2ddcc0b0..22c5bee97 100644 --- a/src/accessor/grib_accessor_class_when.h +++ b/src/accessor/grib_accessor_class_when.h @@ -12,7 +12,6 @@ #ifndef eccodes_accessor_when_h #define eccodes_accessor_when_h -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_when_t : public grib_accessor_gen_t From f0b68e4b157da02e4fcbda6ddd6634bfac32d847 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 13:05:36 +0100 Subject: [PATCH 48/90] ECC-1820: Accessor hash --- src/grib_accessor_classes_hash.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index 178ed937b..5617c9456 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -51,8 +51,7 @@ struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; #endif #endif -static unsigned int -grib_accessor_classes_get_id (const char *str, size_t len) +static unsigned int grib_accessor_classes_get_id (const char *str, size_t len) { static const unsigned short asso_values[] = { @@ -622,20 +621,19 @@ static const struct accessor_class_hash classes[] = {"g1verificationdate", &grib_accessor_class_g1verificationdate} }; -const struct accessor_class_hash * -grib_accessor_classes_hash (const char *str, size_t len) -{ - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) +static const struct accessor_class_hash* grib_accessor_classes_hash(const char *str, size_t len) { unsigned int key = grib_accessor_classes_get_id (str, len); - if (key <= MAX_HASH_VALUE) +#ifdef DEBUG { - const char *s = classes[key].name; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return &classes[key]; - } + const char *s; + Assert( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH ); + Assert( key <= MAX_HASH_VALUE ); + s = classes[key].name; + Assert( *str == *s && strcmp(str + 1, s + 1)==0 ); } - return 0; +#endif + + return &classes[key]; } From 915935d512c8622d22001746c72409a42e272c4e Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 13:11:39 +0100 Subject: [PATCH 49/90] ECC-1820: Remove unused files --- src/grib_accessor_class_bitmap.cc | 297 -------------- ...ib_accessor_class_g1_half_byte_codeflag.cc | 147 ------- src/grib_accessor_class_g2step_range.cc | 375 ------------------ src/grib_accessor_class_transient_darray.cc | 216 ---------- 4 files changed, 1035 deletions(-) delete mode 100644 src/grib_accessor_class_bitmap.cc delete mode 100644 src/grib_accessor_class_g1_half_byte_codeflag.cc delete mode 100644 src/grib_accessor_class_g2step_range.cc delete mode 100644 src/grib_accessor_class_transient_darray.cc diff --git a/src/grib_accessor_class_bitmap.cc b/src/grib_accessor_class_bitmap.cc deleted file mode 100644 index c5be0ebbb..000000000 --- a/src/grib_accessor_class_bitmap.cc +++ /dev/null @@ -1,297 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = next_offset - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = string_length - IMPLEMENTS = init;dump;update_size - MEMBERS=const char* tableReference - MEMBERS=const char* missing_value - MEMBERS=const char* offsetbsec - MEMBERS=const char* sLength - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; -} grib_accessor_bitmap; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_bitmap = { - &grib_accessor_class_bytes, /* super */ - "bitmap", /* name */ - sizeof(grib_accessor_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; - -/* END_CLASS_IMP */ - - -static void compute_size(grib_accessor* a) -{ - long slen = 0; - long off = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_get_long_internal(hand, self->offsetbsec, &off); - grib_get_long_internal(hand, self->sLength, &slen); - - if (slen == 0) { - grib_accessor* seclen; - size_t size; - /* Assume reparsing */ - Assert(hand->loader != 0); - if (hand->loader != 0) { - seclen = grib_find_accessor(hand, self->sLength); - Assert(seclen); - grib_get_block_length(seclen->parent, &size); - slen = size; - } - } - - // printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset); - - a->length = off + (slen - a->offset); - - if (a->length < 0) { - /* Assume reparsing */ - /*Assert(hand->loader != 0);*/ - a->length = 0; - } - - Assert(a->length >= 0); -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->tableReference = grib_arguments_get_name(hand, arg, n++); - self->missing_value = grib_arguments_get_name(hand, arg, n++); - self->offsetbsec = grib_arguments_get_name(hand, arg, n++); - self->sLength = grib_arguments_get_name(hand, arg, n++); - - compute_size(a); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - long len = 0; - char label[1024]; - - grib_value_count(a, &len); - - snprintf(label, 1024, "Bitmap of %ld values", len); - grib_dump_bytes(dumper, a, label); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long pos = a->offset * 8; - long tlen = 0; - const grib_handle* hand = grib_handle_of_accessor(a); - - int err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = tlen; - return GRIB_ARRAY_TOO_SMALL; - } - - for (long i = 0; i < tlen; i++) { - val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long pos = a->offset * 8; - long tlen; - grib_handle* hand = grib_handle_of_accessor(a); - - int err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = tlen; - return GRIB_ARRAY_TOO_SMALL; - } - - for (long i = 0; i < tlen; i++) { - val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - long pos = a->offset * 8; - - pos += idx; - *val = (double)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, 1); - - return GRIB_SUCCESS; -} -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - for (size_t i=0; ilength = s; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_handle* hand = grib_handle_of_accessor(a); - const size_t l = a->length; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - for (long i = 0; i < a->length; i++) { - val[i] = hand->buffer->data[a->offset + i]; - } - - *len = a->length; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g1_half_byte_codeflag.cc b/src/grib_accessor_class_g1_half_byte_codeflag.cc deleted file mode 100644 index c7d9828e0..000000000 --- a/src/grib_accessor_class_g1_half_byte_codeflag.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_half_byte_codeflag -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g1_half_byte_codeflag */ -} grib_accessor_g1_half_byte_codeflag; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g1_half_byte_codeflag = { - &grib_accessor_class_gen, /* super */ - "g1_half_byte_codeflag", /* name */ - sizeof(grib_accessor_g1_half_byte_codeflag), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor_class_g1_half_byte_codeflag; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - if (*len < 1) { - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - unsigned char dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; - - *val = dat; - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - if (*len < 1) { - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - // printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]); - grib_handle_of_accessor(a)->buffer->data[a->offset] = (a->parent->h->buffer->data[a->offset] & 0xf0) | (*val & 0x0f); - // printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]); - - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_g2step_range.cc b/src/grib_accessor_class_g2step_range.cc deleted file mode 100644 index e1dd9494b..000000000 --- a/src/grib_accessor_class_g2step_range.cc +++ /dev/null @@ -1,375 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include "step.h" -#include "step_utilities.h" -#include -#include -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = get_native_type;string_length - IMPLEMENTS = init - MEMBERS = const char* start_step - MEMBERS = const char* end_step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2step_range -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g2step_range */ - const char* start_step; - const char* end_step; -} grib_accessor_g2step_range; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g2step_range = { - &grib_accessor_class_gen, /* super */ - "g2step_range", /* name */ - sizeof(grib_accessor_g2step_range), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2step_range; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - - int n = 0; - - self->start_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->end_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -//static void dump(grib_accessor* a, grib_dumper* dumper) -//{ - //grib_dump_string(dumper, a, NULL); -//} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - size_t size = 0; - double start_step_value = 0; - double end_step_value = 0; - long step_units; - - int show_hours = a->context->grib_hourly_steps_with_units; - - if ((ret = grib_get_double_internal(h, self->start_step, &start_step_value)) != GRIB_SUCCESS) - return ret; - if ((ret= grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - char fp_format[128] = "%g"; - size_t fp_format_len = sizeof(fp_format); - if ((ret = grib_get_string_internal(h, "formatForDoubles", fp_format, &fp_format_len)) != GRIB_SUCCESS) - return ret; - std::stringstream ss; - - eccodes::Step start_step{start_step_value, step_units}; - if (self->end_step == NULL) { - ss << start_step.value(fp_format, show_hours); - } - else { - if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - - eccodes::Step end_step{end_step_value, step_units}; - - if (start_step_value == end_step_value) { - ss << end_step.value(fp_format, show_hours); - } - else { - ss << start_step.value(fp_format, show_hours) << "-" << end_step.value(fp_format, show_hours); - } - } - - size = ss.str().size() + 1; - - if (*len < size) - return GRIB_ARRAY_TOO_SMALL; - - *len = size; - - memcpy(val, ss.str().c_str(), size); - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g2step_range::unpack_string: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -// Step range format: [-] -// and can be in different units -// stepRange="X" in instantaneous field is equivalent to set step=X -// stepRange="X" in accumulated field is equivalent to startStep=X, endStep=startStep -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - - long force_step_units; - if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) - return ret; - - // Note: - // forceStepUnits is a special key that is used to identify the origin of the defined units - // i.e., whether they have been defined by the user. - // If this key is defined (!= 255), it indicates that the stepUnits have been defined by the user. - // Once this key is set, it has the highest priority: it automatically overrides certain units and the default value in stepUnits - - if (h->loader) { // h->loader is set only when rebuilding or reparsing - force_step_units = 255; // See ECC-1768 and ECC-1800 - } - - try { - std::vector steps = parse_range(val, eccodes::Unit{force_step_units}); - if (steps.size() == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Could not parse step range: %s", val); - return GRIB_INVALID_ARGUMENT; - } - - eccodes::Step step_0; - eccodes::Step step_1; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if (steps.size() > 1) - std::tie(step_0, step_1) = find_common_units(steps[0].optimize_unit(), steps[1].optimize_unit()); - else - step_0 = steps[0].optimize_unit(); - } - else { - step_0 = eccodes::Step{steps[0].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - if (steps.size() > 1) { - step_1 = eccodes::Step{steps[1].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - } - } - - if ((ret = grib_set_long_internal(h, "startStepUnit", step_0.unit().value()))) - return ret; - if ((ret = set_step(h, "forecastTime" , "indicatorOfUnitOfTimeRange", step_0)) != GRIB_SUCCESS) - return ret; - - if (self->end_step != NULL) { - if (steps.size() > 1) { - if ((ret = grib_set_long_internal(h, "endStepUnit", step_1.unit().value()))) - return ret; - if ((ret = grib_set_long_internal(h, self->end_step, step_1.value()))) - return ret; - } else { - if ((ret = grib_set_long_internal(h, "endStepUnit", step_0.unit().value()))) - return ret; - if ((ret = grib_set_long_internal(h, self->end_step, step_0.value()))) - return ret; - } - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_g2step_range::pack_string: %s", e.what()); - return GRIB_INVALID_ARGUMENT; - } - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char buff[100]; - size_t bufflen = 100; - - snprintf(buff, sizeof(buff), "%ld", *val); - return pack_string(a, buff, &bufflen); -} - - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - long end_start_value = 0; - long end_step_value = 0; - long step_units = 0; - - if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) - return ret; - try { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - throw std::runtime_error("Failed to get stepUnits"); - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - eccodes::Step start_step{end_start_value, step_units}; - if (self->end_step == NULL) { - *val = start_step.value(); - } - else { - if ((ret = grib_get_long_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - eccodes::Step end_step{end_step_value, step_units}; - *val = end_step.value(); - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Failed to unpack step range: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - double end_start_value = 0; - double end_step_value = 0; - long step_units = 0; - - if ((ret = grib_get_double_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - throw std::runtime_error("Failed to get stepUnits"); - - try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - eccodes::Step start_step{end_start_value, step_units}; - if (self->end_step == NULL) { - *val = start_step.value(); - } - else { - if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - eccodes::Step end_step{end_step_value, step_units}; - *val = end_step.value(); - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grid_accessor_g2step_range::unpack_double: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/grib_accessor_class_transient_darray.cc b/src/grib_accessor_class_transient_darray.cc deleted file mode 100644 index 51dbc2433..000000000 --- a/src/grib_accessor_class_transient_darray.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count - IMPLEMENTS = get_native_type - MEMBERS=grib_darray* arr - MEMBERS=int type; - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_transient_darray -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in transient_darray */ - grib_darray* arr; - int type; -} grib_accessor_transient_darray; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_transient_darray = { - &grib_accessor_class_gen, /* super */ - "transient_darray", /* name */ - sizeof(grib_accessor_transient_darray), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - self->arr = NULL; - self->type = GRIB_TYPE_DOUBLE; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_double(dumper, a, NULL); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, val[i]); - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, (double)val[i]); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %zu, required %ld)", a->name, *len, count); - *len = count; - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %zu, required %ld)", a->name, *len, count); - *len = count; - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = (long)self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - grib_darray_delete(a->context, self->arr); -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - *count = grib_darray_used_size(self->arr); - else - *count = 0; - - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - const grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - return self->type; -} From d397f5867aa17eb9525989edcb07c3c9269cfce9 Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 8 May 2024 15:54:40 +0100 Subject: [PATCH 50/90] ECC-1820: Local static functions --- src/accessor/grib_accessor_class_ascii.cc | 63 ++++--- src/accessor/grib_accessor_class_bitmap.cc | 58 +++--- .../grib_accessor_class_bits_per_value.cc | 33 ++-- .../grib_accessor_class_bufr_data_array.cc | 128 ++++++++----- ...grib_accessor_class_bufr_elements_table.cc | 58 +++--- ...ccessor_class_bufr_extract_area_subsets.cc | 31 ++-- ...sor_class_bufr_extract_datetime_subsets.cc | 59 +++--- ...rib_accessor_class_bufr_simple_thinning.cc | 18 +- src/accessor/grib_accessor_class_codeflag.cc | 23 ++- src/accessor/grib_accessor_class_codetable.cc | 8 +- src/accessor/grib_accessor_class_concept.cc | 134 ++++++++------ .../grib_accessor_class_count_missing.cc | 36 ++-- ...g1second_order_general_extended_packing.cc | 79 ++++---- ...ib_accessor_class_data_g22order_packing.cc | 20 +- ...accessor_class_data_g2bifourier_packing.cc | 21 ++- ...ata_g2simple_packing_with_preprocessing.cc | 21 ++- ...ib_accessor_class_data_jpeg2000_packing.cc | 2 +- .../grib_accessor_class_data_png_packing.cc | 12 +- src/accessor/grib_accessor_class_element.cc | 15 +- ...rib_accessor_class_expanded_descriptors.cc | 30 ++- .../grib_accessor_class_g1forecastmonth.cc | 53 +++--- .../grib_accessor_class_g2_mars_labeling.cc | 59 +++--- .../grib_accessor_class_g2end_step.cc | 174 ++++++++++-------- src/accessor/grib_accessor_class_g2grid.cc | 12 +- .../grib_accessor_class_longitudes.cc | 1 - ...ccessor_class_number_of_points_gaussian.cc | 78 ++++---- ...grib_accessor_class_octahedral_gaussian.cc | 2 +- ...essor_class_second_order_bits_per_value.cc | 2 +- .../grib_accessor_class_smart_table.cc | 6 +- ...grib_accessor_class_step_human_readable.cc | 41 +++-- .../grib_accessor_class_suppressed.cc | 29 +-- 31 files changed, 772 insertions(+), 534 deletions(-) diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc index f45053267..b3e9f6a8a 100644 --- a/src/accessor/grib_accessor_class_ascii.cc +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -11,35 +11,40 @@ #include "grib_accessor_class_ascii.h" -grib_accessor_class_ascii_t _grib_accessor_class_ascii{"ascii"}; +grib_accessor_class_ascii_t _grib_accessor_class_ascii{ "ascii" }; grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; -void grib_accessor_class_ascii_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_ascii_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); a->length = len; Assert(a->length >= 0); } -int grib_accessor_class_ascii_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_ascii_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -size_t grib_accessor_class_ascii_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_ascii_t::string_length(grib_accessor* a) +{ return a->length; } -void grib_accessor_class_ascii_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_ascii_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string(dumper, a, NULL); } -int grib_accessor_class_ascii_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_ascii_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_ascii_t::unpack_string(grib_accessor* a, char* val, size_t* len){ - size_t i = 0; +int grib_accessor_class_ascii_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_handle* hand = grib_handle_of_accessor(a); const size_t alen = a->length; @@ -47,30 +52,32 @@ int grib_accessor_class_ascii_t::unpack_string(grib_accessor* a, char* val, size const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, alen+1, *len); + cclass_name, a->name, alen + 1, *len); *len = alen + 1; return GRIB_BUFFER_TOO_SMALL; } + size_t i = 0; for (i = 0; i < alen; i++) val[i] = hand->buffer->data[a->offset + i]; val[i] = 0; - *len = i; + *len = i; return GRIB_SUCCESS; } -int grib_accessor_class_ascii_t::pack_string(grib_accessor* a, const char* val, size_t* len){ - size_t i = 0; +int grib_accessor_class_ascii_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_handle* hand = grib_handle_of_accessor(a); const size_t alen = a->length; if (len[0] > (alen + 1)) { grib_context_log(a->context, GRIB_LOG_ERROR, - "pack_string: Wrong size (%zu) for %s, it contains %ld values", len[0], a->name, a->length + 1); + "pack_string: Wrong size (%zu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); len[0] = 0; return GRIB_BUFFER_TOO_SMALL; } - for (i = 0; i < alen; i++) { + for (size_t i = 0; i < alen; i++) { if (i < len[0]) hand->buffer->data[a->offset + i] = val[i]; else @@ -80,17 +87,20 @@ int grib_accessor_class_ascii_t::pack_string(grib_accessor* a, const char* val, return GRIB_SUCCESS; } -int grib_accessor_class_ascii_t::pack_long(grib_accessor* a, const long* v, size_t* len){ +int grib_accessor_class_ascii_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as long (It's a string)", a->name); return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_ascii_t::pack_double(grib_accessor* a, const double* v, size_t* len){ +int grib_accessor_class_ascii_t::pack_double(grib_accessor* a, const double* v, size_t* len) +{ grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as double (It's a string)", a->name); return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_ascii_t::unpack_long(grib_accessor* a, long* v, size_t* len){ +int grib_accessor_class_ascii_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ char val[1024] = {0,}; size_t l = sizeof(val); size_t i = 0; @@ -116,12 +126,14 @@ int grib_accessor_class_ascii_t::unpack_long(grib_accessor* a, long* v, size_t* return GRIB_SUCCESS; } -int grib_accessor_class_ascii_t::unpack_double(grib_accessor* a, double* v, size_t* len){ +int grib_accessor_class_ascii_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ char val[1024]; size_t l = sizeof(val); char* last = NULL; - int err = a->unpack_string(val, &l); if (err) return err; + int err = a->unpack_string(val, &l); + if (err) return err; *v = strtod(val, &last); @@ -135,14 +147,15 @@ int grib_accessor_class_ascii_t::unpack_double(grib_accessor* a, double* v, size return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_ascii_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_ascii_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = 0; char* aval = 0; char* bval = 0; int err = 0; - size_t alen = a->length+1; - size_t blen = b->length+1; + size_t alen = a->length + 1; + size_t blen = b->length + 1; if (alen != blen) return GRIB_COUNT_MISMATCH; @@ -150,8 +163,10 @@ int grib_accessor_class_ascii_t::compare(grib_accessor* a, grib_accessor* b){ aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - err = a->unpack_string(aval, &alen); if (err) return err; - err = b->unpack_string(bval, &blen); if (err) return err; + err = a->unpack_string(aval, &alen); + if (err) return err; + err = b->unpack_string(bval, &blen); + if (err) return err; retval = GRIB_SUCCESS; if (!STR_EQUAL(aval, bval)) diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index e507d021b..505871a3a 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -11,12 +11,11 @@ #include "grib_accessor_class_bitmap.h" -grib_accessor_class_bitmap_t _grib_accessor_class_bitmap{"bitmap"}; +grib_accessor_class_bitmap_t _grib_accessor_class_bitmap{ "bitmap" }; grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; - - -void compute_size(grib_accessor* a){ +static void compute_size(grib_accessor* a) +{ long slen = 0; long off = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -51,7 +50,8 @@ void compute_size(grib_accessor* a){ Assert(a->length >= 0); } -void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_bytes_t::init(a, len, arg); grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; grib_handle* hand = grib_handle_of_accessor(a); @@ -65,24 +65,29 @@ void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_a compute_size(a); } -long grib_accessor_class_bitmap_t::next_offset(grib_accessor* a){ - return a->byte_offset() + a->byte_count();} +long grib_accessor_class_bitmap_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} -void grib_accessor_class_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper) +{ long len = 0; char label[1024]; a->value_count(&len); - snprintf(label, 1024, "Bitmap of %ld values", len); + snprintf(label, sizeof(label), "Bitmap of %ld values", len); grib_dump_bytes(dumper, a, label); } -int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ long pos = a->offset * 8; long tlen = 0; const grib_handle* hand = grib_handle_of_accessor(a); - int err = a->value_count(&tlen); if (err) + int err = a->value_count(&tlen); + if (err) return err; if (*len < tlen) { @@ -99,13 +104,15 @@ int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_ } template -int unpack(grib_accessor* a, T* val, size_t* len){ +int unpack(grib_accessor* a, T* val, size_t* len) +{ static_assert(std::is_floating_point::value, "Requires floating points numbers"); long pos = a->offset * 8; long tlen; grib_handle* hand = grib_handle_of_accessor(a); - int err = a->value_count(&tlen); if (err) + int err = a->value_count(&tlen); + if (err) return err; if (*len < tlen) { @@ -121,15 +128,18 @@ int unpack(grib_accessor* a, T* val, size_t* len){ return GRIB_SUCCESS; } -int grib_accessor_class_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ long pos = a->offset * 8; pos += idx; @@ -137,24 +147,28 @@ int grib_accessor_class_bitmap_t::unpack_double_element(grib_accessor* a, size_t return GRIB_SUCCESS; } -int grib_accessor_class_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ - for (size_t i=0; ilength = s; } -size_t grib_accessor_class_bitmap_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_bitmap_t::string_length(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_bitmap_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_bitmap_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_handle* hand = grib_handle_of_accessor(a); - const size_t l = a->length; + const size_t l = a->length; if (*len < l) { const char* cclass_name = a->cclass->name; diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc index 590c48d89..dbdef54cb 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -11,24 +11,27 @@ #include "grib_accessor_class_bits_per_value.h" -grib_accessor_class_bits_per_value_t _grib_accessor_class_bits_per_value{"bits_per_value"}; +grib_accessor_class_bits_per_value_t _grib_accessor_class_bits_per_value{ "bits_per_value" }; grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_bits_per_value; -void grib_accessor_class_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* args){ +void grib_accessor_class_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, l, args); - int n = 0; + int n = 0; grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; } -int grib_accessor_class_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len){ - int ret = 0; +int grib_accessor_class_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; - grib_handle* h = grib_handle_of_accessor(a); + + int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); if ((ret = grib_get_long_internal(h, self->bits_per_value, val)) != GRIB_SUCCESS) return ret; @@ -37,13 +40,15 @@ int grib_accessor_class_bits_per_value_t::unpack_long(grib_accessor* a, long* va return ret; } -int grib_accessor_class_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len){ - double* values = NULL; - size_t size = 0; - int ret = 0; +int grib_accessor_class_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + + double* values = NULL; + size_t size = 0; + int ret = 0; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index 14f13d966..e0c998950 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -34,28 +34,32 @@ grib_accessor_class* grib_accessor_class_bufr_data_array = &_grib_accessor_class return retval; \ } -int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset); +static int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset); typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); +static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); -int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); -void restart_bitmap(grib_accessor_bufr_data_array_t* self){ +static void restart_bitmap(grib_accessor_bufr_data_array_t* self) +{ self->bitmapCurrent = -1; self->bitmapCurrentElementsDescriptorsIndex = self->bitmapStartElementsDescriptorsIndex - 1; } -void cancel_bitmap(grib_accessor_bufr_data_array_t* self){ +static void cancel_bitmap(grib_accessor_bufr_data_array_t* self) +{ self->bitmapCurrent = -1; self->bitmapStart = -1; } -int is_bitmap_start_defined(grib_accessor_bufr_data_array_t* self){ +static int is_bitmap_start_defined(grib_accessor_bufr_data_array_t* self) +{ return self->bitmapStart == -1 ? 0 : 1; } -size_t get_length(grib_accessor* a){ +size_t get_length(grib_accessor* a) +{ grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; - size_t len = 0; + size_t len = 0; const grib_handle* h = grib_handle_of_accessor(a); @@ -65,7 +69,8 @@ size_t get_length(grib_accessor* a){ } /* Operator 203YYY: Store the TableB code and changed reference value in linked list */ -void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array_t* self, int code, long new_ref_val){ +static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array_t* self, int code, long new_ref_val) +{ bufr_tableb_override* tb = (bufr_tableb_override*)grib_context_malloc_clear(c, sizeof(bufr_tableb_override)); tb->code = code; tb->new_ref_val = new_ref_val; @@ -82,7 +87,8 @@ void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_arra } /* Operator 203YYY: Retrieve changed reference value from linked list */ -int tableB_override_get_ref_val(grib_accessor_bufr_data_array_t* self, int code, long* out_ref_val){ +static int tableB_override_get_ref_val(grib_accessor_bufr_data_array_t* self, int code, long* out_ref_val) +{ bufr_tableb_override* p = self->tableb_override; while (p) { if (p->code == code) { @@ -95,7 +101,8 @@ int tableB_override_get_ref_val(grib_accessor_bufr_data_array_t* self, int code, } /* Operator 203YYY: Clear and free linked list */ -void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array_t* self){ +void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array_t* self) +{ bufr_tableb_override* tb = self->tableb_override; while (tb) { bufr_tableb_override* n = tb->next; @@ -106,7 +113,8 @@ void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array_t* sel } /* Operator 203YYY: Copy contents of linked list to the transient array key */ -int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array_t* self){ +int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array_t* self) +{ int err = GRIB_SUCCESS; size_t size = 0; long* refVals = NULL; @@ -126,7 +134,8 @@ int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array_t* sel return err; } /* Check numBits is sufficient for entries in the overridden reference values list*/ -int check_overridden_reference_values(const grib_context* c, long* refValList, size_t refValListSize, int numBits){ +static int check_overridden_reference_values(const grib_context* c, long* refValList, size_t refValListSize, int numBits) +{ const long maxval = (1 << (numBits - 1)) - 1; const long minval = -(1 << (numBits - 1)); size_t i = 0; @@ -205,7 +214,8 @@ void grib_accessor_class_bufr_data_array_t::init(grib_accessor* a, const long v, // } // } -int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, int size){ +static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, int size) +{ const int saved_bitsToEndData = self->bitsToEndData; if (c->debug == 1) grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data decoding: \tbitsToEndData=%d elementSize=%d", self->bitsToEndData, size); @@ -302,7 +312,8 @@ void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode) self->unpackMode = unpackMode; } -int get_descriptors(grib_accessor* a){ +static int get_descriptors(grib_accessor* a) +{ grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int ret = 0, i, numberOfDescriptors; grib_handle* h = grib_handle_of_accessor(a); @@ -328,7 +339,7 @@ int get_descriptors(grib_accessor* a){ return ret; } -int decode_string_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, +static int decode_string_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self) { int ret = 0; @@ -469,7 +480,7 @@ grib_darray* decode_double_array(grib_context* c, unsigned char* data, long* pos return ret; } -int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, +static int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, grib_sarray* stringValues) { int err = 0, n, ival; @@ -535,7 +546,7 @@ void set_missing_long_to_double(grib_darray* dvalues){ } /* ECC-750: The 'factor' argument is 10^-scale */ -int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor, +static int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, double factor, double* minAllowed, double* maxAllowed) { /* Maximum value is allowed to be the largest number (all bits 1) which means it's MISSING */ @@ -551,7 +562,7 @@ int descriptor_get_min_max(bufr_descriptor* bd, long width, long reference, doub return GRIB_SUCCESS; } -int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, +static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, grib_darray* dvalues) { int err = 0; @@ -769,7 +780,7 @@ int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_desc return err; } -int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, +static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, double value) { size_t lval; @@ -816,7 +827,7 @@ int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_desc return err; } -int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, +static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, char* sval) { int err = 0; @@ -832,7 +843,7 @@ int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_desc return err; } -char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, +static char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, int* err) { char* sval = 0; @@ -855,7 +866,7 @@ char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_ return sval; } -double decode_double_value(grib_context* c, unsigned char* data, long* pos, +static double decode_double_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, int canBeMissing, grib_accessor_bufr_data_array_t* self, int* err) { @@ -886,7 +897,7 @@ double decode_double_value(grib_context* c, unsigned char* data, long* pos, return dval; } -int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -968,7 +979,7 @@ int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s return err; } -int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int ret = 0; @@ -1033,7 +1044,8 @@ int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, i return ret; } -int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array_t* self){ +static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array_t* self) +{ grib_darray* doubleValues = NULL; int err = 0; double cdval = 0; @@ -1055,7 +1067,7 @@ int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, gr } /* Operator 203YYY: Change Reference Values: Encoding definition phase */ -int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array_t* self, +static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array_t* self, grib_buffer* buff, long* pos, bufr_descriptor* bd) { int err = 0; @@ -1094,7 +1106,7 @@ int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_a return err; } -int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1154,7 +1166,7 @@ int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, i return err; } -int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int err = 0; @@ -1217,7 +1229,7 @@ int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array_t* sel return err; } -int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1288,7 +1300,7 @@ int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s return err; } -int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, +static int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { @@ -1304,7 +1316,7 @@ int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, i return encode_element(c, self, subsetIndex, buff, data, pos, i, 0, elementIndex, dval, 0); } -int build_bitmap(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, +static int build_bitmap(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; @@ -1402,7 +1414,8 @@ int build_bitmap(grib_accessor_bufr_data_array_t* self, unsigned char* data, lon return GRIB_SUCCESS; } -int consume_bitmap(grib_accessor_bufr_data_array_t* self, int iBitmapOperator){ +static int consume_bitmap(grib_accessor_bufr_data_array_t* self, int iBitmapOperator) +{ int bitmapSize = 0, iDelayedReplication; int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1432,7 +1445,7 @@ int consume_bitmap(grib_accessor_bufr_data_array_t* self, int iBitmapOperator){ return GRIB_SUCCESS; } -int build_bitmap_new_data(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, +static int build_bitmap_new_data(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; @@ -1519,7 +1532,8 @@ int build_bitmap_new_data(grib_accessor_bufr_data_array_t* self, unsigned char* } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, int compressedData){ +static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, int compressedData) +{ int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1556,7 +1570,8 @@ int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array_t* } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues){ +static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues) +{ int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1597,7 +1612,8 @@ int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array_t* self, grib return elementsDescriptorsIndex->v[self->bitmapCurrentElementsDescriptorsIndex]; } -void push_zero_element(grib_accessor_bufr_data_array_t* self, grib_darray* dval){ +static void push_zero_element(grib_accessor_bufr_data_array_t* self, grib_darray* dval) +{ grib_darray* d = 0; grib_accessor* a = (grib_accessor*)self; grib_context* c = a->context; @@ -1611,7 +1627,7 @@ void push_zero_element(grib_accessor_bufr_data_array_t* self, grib_darray* dval) } } -grib_accessor* create_attribute_variable(const char* name, grib_section* section, int type, char* sval, double dval, long lval, unsigned long flags) +static grib_accessor* create_attribute_variable(const char* name, grib_section* section, int type, char* sval, double dval, long lval, unsigned long flags) { grib_accessor* a = NULL; grib_action creator = {0,}; @@ -1644,7 +1660,8 @@ grib_accessor* create_attribute_variable(const char* name, grib_section* section return a; } -void set_creator_name(grib_action* creator, int code){ +static void set_creator_name(grib_action* creator, int code) +{ switch (code) { case 222000: creator->name = (char*)"qualityInformationFollows"; @@ -1716,7 +1733,8 @@ void set_creator_name(grib_action* creator, int code){ } /* See ECC-741 */ -int adding_extra_key_attributes(grib_handle* h){ +static int adding_extra_key_attributes(grib_handle* h) +{ long skip = 0; /* default is to add */ int err = 0; err = grib_get_long(h, "skipExtraKeyAttributes", &skip); @@ -1725,7 +1743,7 @@ int adding_extra_key_attributes(grib_handle* h){ return (!skip); } -grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, grib_accessor* attribute, grib_section* section, +static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, grib_accessor* attribute, grib_section* section, long ide, long subset, int add_dump_flag, int add_coord_flag, int count, int add_extra_attributes) { @@ -1978,7 +1996,8 @@ static grib_accessor* get_element_from_bitmap(const grib_accessor* a, bitmap_s* // significanceQualifierGroup[i]=0; // } -void grib_convert_to_attribute(grib_accessor* a){ +static void grib_convert_to_attribute(grib_accessor* a) +{ if (a->h == NULL && a->parent != NULL) { a->h = grib_handle_of_accessor(a); a->parent = NULL; @@ -2025,7 +2044,8 @@ static grib_iarray* set_subset_list( return list; } -int bitmap_ref_skip(grib_accessors_list* al, int* err){ +static int bitmap_ref_skip(grib_accessors_list* al, int* err) +{ grib_accessor* acode = NULL; long code[1]; size_t l = 1; @@ -2057,7 +2077,8 @@ int bitmap_ref_skip(grib_accessors_list* al, int* err){ } /* Return 1 if the descriptor is an operator marking the start of a bitmap */ -int is_bitmap_start_descriptor(grib_accessors_list* al, int* err){ +static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err) +{ grib_accessor* acode = NULL; long code[1]; size_t l = 1; @@ -2089,7 +2110,8 @@ int is_bitmap_start_descriptor(grib_accessors_list* al, int* err){ return 0; } -void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize){ +static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize) +{ int i = 0, ret = 0; fprintf(stderr, "ECCODES DEBUG: bitmap_init: bitmapSize=%d\n", bitmapSize); bitmap->cursor = bitmapStart->next_; @@ -2180,11 +2202,13 @@ static grib_accessor* accessor_or_attribute_with_same_name(grib_accessor* a, con // return *r; // } -int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a){ +int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a) +{ return grib_trie_with_rank_insert(accessorsTrie, a->name, a); } -int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset){ +static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset) +{ grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int err = 0; int rank; @@ -2509,7 +2533,8 @@ int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long return err; } -void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array_t* self){ +static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array_t* self) +{ size_t nInputReplications; size_t nInputExtendedReplications; size_t nInputShortReplications; @@ -2554,7 +2579,8 @@ void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array_t* sel } } -void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array_t* self){ +static void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array_t* self) +{ size_t nInputBitmap; self->nInputBitmap = -1; self->iInputBitmap = 0; @@ -2571,7 +2597,8 @@ void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array_t* self){ } } -int set_to_missing_if_out_of_range(grib_handle* h){ +static int set_to_missing_if_out_of_range(grib_handle* h) +{ /* First check if the transient key is set */ long setToMissingIfOutOfRange = 0; if (grib_get_long(h, "setToMissingIfOutOfRange", &setToMissingIfOutOfRange) == GRIB_SUCCESS && @@ -2582,7 +2609,8 @@ int set_to_missing_if_out_of_range(grib_handle* h){ return h->context->bufr_set_to_missing_if_out_of_range; } -int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset){ +static int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset) +{ int err = 0; long inr, innr, ir, ip; long n[MAX_NESTED_REPLICATIONS] = {0,}; diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc index 42e7a1324..ddd055544 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -41,13 +41,14 @@ void thread_init() #endif -grib_accessor_class_bufr_elements_table_t _grib_accessor_class_bufr_elements_table{"bufr_elements_table"}; +grib_accessor_class_bufr_elements_table_t _grib_accessor_class_bufr_elements_table{ "bufr_elements_table" }; grib_accessor_class* grib_accessor_class_bufr_elements_table = &_grib_accessor_class_bufr_elements_table; -void grib_accessor_class_bufr_elements_table_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_bufr_elements_table_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); - int n = 0; + int n = 0; grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; self->dictionary = grib_arguments_get_string(grib_handle_of_accessor(a), params, n++); @@ -68,7 +69,9 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) char localDir[1024] = {0,}; char dictName[1024] = {0,}; char masterRecomposed[1024] = {0,}; /*e.g. bufr/tables/0/wmo/36/element.table */ - char localRecomposed[1024] = {0,}; /*e.g. bufr/tables/0/local/0/98/0/element.table */ + char localRecomposed[1024] = { + 0, + }; /*e.g. bufr/tables/0/local/0/98/0/element.table */ char* localFilename = 0; char** list = 0; char** cached_list = 0; @@ -113,9 +116,9 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) if (!filename) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to find definition file %s", self->dictionary); - if (strlen(masterRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG,"master path=%s", masterRecomposed); + if (strlen(masterRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG, "master path=%s", masterRecomposed); if (strlen(localRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG, "local path=%s", localRecomposed); - *err = GRIB_FILE_NOT_FOUND; + *err = GRIB_FILE_NOT_FOUND; dictionary = NULL; goto the_end; } @@ -139,7 +142,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) dictionary = grib_trie_new(c); while (fgets(line, sizeof(line) - 1, f)) { - DEBUG_ASSERT( strlen(line) > 0 ); + DEBUG_ASSERT(strlen(line) > 0); if (line[0] == '#') continue; /* Ignore first line with column titles */ list = string_split(line, "|"); grib_trie_insert(dictionary, list[0], list); @@ -156,14 +159,15 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) } while (fgets(line, sizeof(line) - 1, f)) { - DEBUG_ASSERT( strlen(line) > 0 ); - if (line[0] == '#') continue; /* Ignore first line with column titles */ + DEBUG_ASSERT(strlen(line) > 0); + if (line[0] == '#') continue; /* Ignore first line with column titles */ list = string_split(line, "|"); /* Look for the descriptor code in the trie. It might be there from before */ cached_list = (char**)grib_trie_get(dictionary, list[0]); if (cached_list) { /* If found, we are about to overwrite it. So free memory */ int i; - for (i = 0; cached_list[i] != NULL; ++i) free(cached_list[i]); + for (i = 0; cached_list[i] != NULL; ++i) + free(cached_list[i]); free(cached_list); } grib_trie_insert(dictionary, list[0], list); @@ -178,7 +182,8 @@ the_end: return dictionary; } -int convert_type(const char* stype){ +static int convert_type(const char* stype) +{ int ret = BUFR_DESCRIPTOR_TYPE_UNKNOWN; switch (stype[0]) { case 's': @@ -208,16 +213,18 @@ int convert_type(const char* stype){ return ret; } -long atol_fast(const char* input){ +long atol_fast(const char* input) +{ if (strcmp(input, "0") == 0) return 0; return atol(input); } -int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v){ - int ret = 0; - char** list = 0; - char code[7] = { 0 }; +int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) +{ + int ret = 0; + char** list = 0; + char code[7] = { 0 }; const size_t codeLen = sizeof(code); grib_trie* table = load_bufr_elements_table(a, &ret); @@ -235,8 +242,8 @@ int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v){ /* ECC-1137: check descriptor key name and unit lengths */ const size_t maxlen_shortName = sizeof(v->shortName); const size_t maxlen_units = sizeof(v->units); - Assert( strlen(list[1]) < maxlen_shortName ); - Assert( strlen(list[4]) < maxlen_units ); + Assert(strlen(list[1]) < maxlen_shortName); + Assert(strlen(list[4]) < maxlen_units); } #endif @@ -310,23 +317,28 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i return v; } -int grib_accessor_class_bufr_elements_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_bufr_elements_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_bufr_elements_table_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_bufr_elements_table_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -int grib_accessor_class_bufr_elements_table_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_elements_table_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_bufr_elements_table_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_bufr_elements_table_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_bufr_elements_table_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_bufr_elements_table_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index 9a2310635..91a34c72c 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -11,15 +11,16 @@ #include "grib_accessor_class_bufr_extract_area_subsets.h" -grib_accessor_class_bufr_extract_area_subsets_t _grib_accessor_class_bufr_extract_area_subsets{"bufr_extract_area_subsets"}; +grib_accessor_class_bufr_extract_area_subsets_t _grib_accessor_class_bufr_extract_area_subsets{ "bufr_extract_area_subsets" }; grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets = &_grib_accessor_class_bufr_extract_area_subsets; -void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; a->length = 0; self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); @@ -36,23 +37,26 @@ void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, con a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -int grib_accessor_class_bufr_extract_area_subsets_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_extract_area_subsets_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } /* Copy first element of array into all others */ -void fill_in(double a[], long length){ +static void fill_in(double a[], long length) +{ long i; for (i = 1; i < length; ++i) a[i] = a[0]; } -int select_area(grib_accessor* a){ +static int select_area(grib_accessor* a) +{ grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; - int ret = 0; + int ret = 0; long compressed = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); grib_context* c = h->context; double* lat = NULL; @@ -61,8 +65,8 @@ int select_area(grib_accessor* a){ double lonWest, lonEast, latNorth, latSouth; long numberOfSubsets, i, latRank, lonRank; grib_iarray* subsets = NULL; - size_t nsubsets = 0; - char latstr[32] = {0,}; + size_t nsubsets = 0; + char latstr[32] = {0,}; char lonstr[32] = {0,}; ret = grib_get_long(h, "compressedData", &compressed); @@ -160,7 +164,7 @@ int select_area(grib_accessor* a){ if (nsubsets != 0) { long* subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); grib_context_free(c, subsets_ar); if (ret) return ret; @@ -176,7 +180,8 @@ int select_area(grib_accessor* a){ return ret; } -int grib_accessor_class_bufr_extract_area_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bufr_extract_area_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ /*grib_accessor_bufr_extract_area_subsets_t *self =(grib_accessor_bufr_extract_area_subsets_t*)a;*/ if (*len == 0) diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index 368f49f0c..d47652984 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -11,13 +11,14 @@ #include "grib_accessor_class_bufr_extract_datetime_subsets.h" -grib_accessor_class_bufr_extract_datetime_subsets_t _grib_accessor_class_bufr_extract_datetime_subsets{"bufr_extract_datetime_subsets"}; +grib_accessor_class_bufr_extract_datetime_subsets_t _grib_accessor_class_bufr_extract_datetime_subsets{ "bufr_extract_datetime_subsets" }; grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets = &_grib_accessor_class_bufr_extract_datetime_subsets; -void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); - int n = 0; + int n = 0; grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; a->length = 0; @@ -28,12 +29,14 @@ void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -int grib_accessor_class_bufr_extract_datetime_subsets_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_extract_datetime_subsets_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } /* Convert input date to Julian number. If date is invalid, return -1 */ -double date_to_julian(long year, long month, long day, long hour, long minute, double second){ +double date_to_julian(long year, long month, long day, long hour, long minute, double second) +{ double result = 0; /* Julian number in units of days */ /* For validating the date/time, we specify seconds as an integer */ @@ -85,7 +88,9 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, } else { /* uncompressed */ - char keystr[32] = {0,}; + char keystr[32] = { + 0, + }; size_t values_len = 0; for (i = 0; i < numberOfSubsets; ++i) { long lVal = 0; @@ -104,15 +109,24 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, return err; } -int select_datetime(grib_accessor* a){ - int ret = 0; - long compressed = 0; +static int select_datetime(grib_accessor* a) +{ + int ret = 0; + long compressed = 0; grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = h->context; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = h->context; size_t n; double julianStart = 0, julianEnd = 0, julianDT = 0; - char start_str[80] = {0,}, end_str[80] = {0,}, datetime_str[80] = {0,}; + char start_str[80] = { + 0, + }, + end_str[80] = { + 0, + }, + datetime_str[80] = { + 0, + }; long yearRank, monthRank, dayRank, hourRank, minuteRank, secondRank; long yearStart, monthStart, dayStart, hourStart, minuteStart, secondStart; long yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd; @@ -120,13 +134,13 @@ int select_datetime(grib_accessor* a){ double* second = NULL; long numberOfSubsets, i; grib_iarray* subsets = NULL; - size_t nsubsets = 0; - char yearstr[32] = "year"; - char monthstr[32] = "month"; - char daystr[32] = "day"; - char hourstr[32] = "hour"; - char minutestr[32] = "minute"; - char secondstr[32] = "second"; + size_t nsubsets = 0; + char yearstr[32] = "year"; + char monthstr[32] = "month"; + char daystr[32] = "day"; + char hourstr[32] = "hour"; + char minutestr[32] = "minute"; + char secondstr[32] = "second"; ret = grib_get_long(h, "compressedData", &compressed); if (ret) return ret; @@ -265,7 +279,7 @@ int select_datetime(grib_accessor* a){ if (ret) secondEnd = 0; snprintf(end_str, sizeof(end_str), "%04ld/%02ld/%02ld %02ld:%02ld:%02ld", - yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); + yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); if (c->debug) fprintf(stderr, "ECCODES DEBUG bufr_extract_datetime_subsets: end =%s\n", end_str); julianEnd = date_to_julian(yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); if (julianEnd == -1) { @@ -311,7 +325,7 @@ int select_datetime(grib_accessor* a){ if (nsubsets != 0) { long* subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); grib_context_free(c, subsets_ar); if (ret) return ret; @@ -332,7 +346,8 @@ cleanup: return ret; } -int grib_accessor_class_bufr_extract_datetime_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bufr_extract_datetime_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ /*grib_accessor_bufr_extract_datetime_subsets_t *self =(grib_accessor_bufr_extract_datetime_subsets_t*)a;*/ if (*len == 0) diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc index 2c66d4585..a74d7a74c 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -11,15 +11,16 @@ #include "grib_accessor_class_bufr_simple_thinning.h" -grib_accessor_class_bufr_simple_thinning_t _grib_accessor_class_bufr_simple_thinning{"bufr_simple_thinning"}; +grib_accessor_class_bufr_simple_thinning_t _grib_accessor_class_bufr_simple_thinning{ "bufr_simple_thinning" }; grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_class_bufr_simple_thinning; -void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; a->length = 0; self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); @@ -32,11 +33,13 @@ void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const lo a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -int grib_accessor_class_bufr_simple_thinning_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_simple_thinning_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } -int apply_thinning(grib_accessor* a){ +static int apply_thinning(grib_accessor* a) +{ const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; long skip; @@ -101,7 +104,8 @@ int apply_thinning(grib_accessor* a){ return ret; } -int grib_accessor_class_bufr_simple_thinning_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bufr_simple_thinning_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; if (*len == 0) diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 75b73aca4..6cfda6942 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_codeflag.h" -grib_accessor_class_codeflag_t _grib_accessor_class_codeflag{"codeflag"}; +grib_accessor_class_codeflag_t _grib_accessor_class_codeflag{ "codeflag" }; grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codeflag; -void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* param){ +void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* param) +{ grib_accessor_class_unsigned_t::init(a, len, param); grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; a->length = len; @@ -23,12 +24,14 @@ void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib Assert(a->length >= 0); } -int test_bit(long a, long b){ - DEBUG_ASSERT(b>=0); +static int test_bit(long a, long b) +{ + DEBUG_ASSERT(b >= 0); return a & (1 << b); } -int grib_get_codeflag(grib_accessor* a, long code, char* codename){ +static int grib_get_codeflag(grib_accessor* a, long code, char* codename) +{ const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; FILE* f = NULL; char fname[1024]; @@ -42,8 +45,8 @@ int grib_get_codeflag(grib_accessor* a, long code, char* codename){ err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); if (err) { - strncpy(fname, self->tablename, sizeof(fname)-1); - fname[sizeof(fname)-1] = '\0'; + strncpy(fname, self->tablename, sizeof(fname) - 1); + fname[sizeof(fname) - 1] = '\0'; } if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) { @@ -98,12 +101,14 @@ int grib_get_codeflag(grib_accessor* a, long code, char* codename){ return GRIB_SUCCESS; } -int grib_accessor_class_codeflag_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_codeflag_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -void grib_accessor_class_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper) +{ const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; long v = 0; char flagname[1024] = {0,}; diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index 552274e75..f21ef0f86 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -44,10 +44,7 @@ void thread_init() } #endif - - - -int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t); +static int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t); void grib_accessor_class_codetable_t::init(grib_accessor* a, const long len, grib_arguments* params) { @@ -145,6 +142,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } +// Cater for parameters being NULL static int str_eq(const char* a, const char* b) { if (a && b && (grib_inline_strcmp(a, b) == 0)) @@ -267,7 +265,7 @@ the_end: return t; } -int grib_load_codetable(grib_context* c, const char* filename, +static int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t) { char line[1024]; diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index a4261f8ee..98f0fb35c 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -11,7 +11,7 @@ #include "grib_accessor_class_concept.h" -grib_accessor_class_concept_t _grib_accessor_class_concept{"concept"}; +grib_accessor_class_concept_t _grib_accessor_class_concept{ "concept" }; grib_accessor_class* grib_accessor_class_concept = &_grib_accessor_class_concept; @@ -33,17 +33,20 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } -void grib_accessor_class_concept_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_concept_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_gen_t::init(a, len, args); a->length = 0; } -void grib_accessor_class_concept_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_concept_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string(dumper, a, NULL); } /* Return 1 (=True) or 0 (=False) */ -int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c){ +static int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c) +{ long lval; long lres = 0; int ok = FALSE; /* Boolean */ @@ -87,8 +90,9 @@ int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c) } /* Return 1 (=True) or 0 (=False) */ -int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c){ - long* val = NULL; +static int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c) +{ + long* val = NULL; size_t size = 0, i; int ret; /* Boolean */ int err = 0; @@ -117,7 +121,8 @@ int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c){ } /* Return 1 (=True) or 0 (=False) */ -int concept_condition_true(grib_handle* h, grib_concept_condition* c){ +static int concept_condition_true(grib_handle* h, grib_concept_condition* c) +{ if (c->expression == NULL) return concept_condition_iarray_true(h, c); else @@ -158,8 +163,8 @@ static const char* concept_evaluate(grib_accessor* a) } #define MAX_NUM_CONCEPT_VALUES 40 - -int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* e, grib_values* values, grib_sarray* sa, int* n){ +static int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* e, grib_values* values, grib_sarray* sa, int* n) +{ long lres = 0; double dres = 0.0; int count = *n; @@ -190,27 +195,31 @@ int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* return err; } -int concept_conditions_iarray_apply(grib_handle* h, grib_concept_condition* c){ +static int concept_conditions_iarray_apply(grib_handle* h, grib_concept_condition* c) +{ size_t size = grib_iarray_used_size(c->iarray); return grib_set_long_array(h, c->name, c->iarray->v, size); } -int concept_conditions_apply(grib_handle* h, grib_concept_condition* c, grib_values* values, grib_sarray* sa, int* n){ +static int concept_conditions_apply(grib_handle* h, grib_concept_condition* c, grib_values* values, grib_sarray* sa, int* n) +{ if (c->expression == NULL) return concept_conditions_iarray_apply(h, c); else return concept_conditions_expression_apply(h, c, values, sa, n); } -int cmpstringp(const void* p1, const void* p2){ +static int cmpstringp(const void* p1, const void* p2) +{ /* The actual arguments to this function are "pointers to pointers to char", but strcmp(3) arguments are "pointers to char", hence the following cast plus dereference */ return strcmp(*(char* const*)p1, *(char* const*)p2); } -bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value){ - if ( strcmp(concept_name, "packingType")==0 ) { +bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value) +{ + if (strcmp(concept_name, "packingType") == 0) { char input_packing_type[100]; size_t len = sizeof(input_packing_type); if (strstr(concept_value, "SPD")) { @@ -226,17 +235,18 @@ bool blacklisted(grib_handle* h, long edition, const char* concept_name, const c return true; } grib_get_string(h, "packingType", input_packing_type, &len); - if (strstr(input_packing_type,"grid_") && !strstr(concept_value,"grid_")) { + if (strstr(input_packing_type, "grid_") && !strstr(concept_value, "grid_")) { return true; } - if (strstr(input_packing_type,"spectral_") && !strstr(concept_value,"spectral_")) { + if (strstr(input_packing_type, "spectral_") && !strstr(concept_value, "spectral_")) { return true; } } return false; } -int grib_concept_apply(grib_accessor* a, const char* name){ +static int grib_concept_apply(grib_accessor* a, const char* name) +{ int err = 0; int count = 0; grib_concept_condition* e = NULL; @@ -261,8 +271,10 @@ int grib_concept_apply(grib_accessor* a, const char* name){ size_t i = 0, concept_count = 0; long dummy = 0, editionNumber = 0; char centre_s[32] = {0,}; - size_t centre_len = sizeof(centre_s); - char* all_concept_vals[MAX_NUM_CONCEPT_VALUES] = {NULL,}; /* sorted array containing concept values */ + size_t centre_len = sizeof(centre_s); + char* all_concept_vals[MAX_NUM_CONCEPT_VALUES] = { + NULL, + }; /* sorted array containing concept values */ grib_concept_value* pCon = concepts; grib_context_log(h->context, GRIB_LOG_ERROR, "concept: no match for %s=%s", act->name, name); @@ -279,11 +291,12 @@ int grib_concept_apply(grib_accessor* a, const char* name){ if (string_to_long(name, &dummy, 1) == GRIB_SUCCESS) { // The paramId value is an integer. Show them the param DB grib_context_log(h->context, GRIB_LOG_ERROR, - "Please check the Parameter Database 'https://codes.ecmwf.int/grib/param-db/?id=%s'", name); - } else { + "Please check the Parameter Database 'https://codes.ecmwf.int/grib/param-db/?id=%s'", name); + } + else { // paramId being set to a non-integer grib_context_log(h->context, GRIB_LOG_ERROR, - "The paramId value should be an integer. Are you trying to set the shortName?"); + "The paramId value should be an integer. Are you trying to set the shortName?"); } } if (strcmp(act->name, "shortName") == 0) { @@ -335,29 +348,31 @@ int grib_concept_apply(grib_accessor* a, const char* name){ return err; } -int grib_accessor_class_concept_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_concept_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_concept_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_concept_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ char buf[80]; size_t s; snprintf(buf, sizeof(buf), "%ld", *val); - //if(*len > 1) - // return GRIB_NOT_IMPLEMENTED; + // if(*len > 1) + // return GRIB_NOT_IMPLEMENTED; // ECC-1806: GRIB: Change of paramId in conversion from GRIB1 to GRIB2 if (STR_EQUAL(a->name, "paramId")) { grib_handle* h = grib_handle_of_accessor(a); - long edition = 0; + long edition = 0; if (grib_get_long(h, "edition", &edition) == GRIB_SUCCESS && edition == 2) { long newParamId = 0; if (grib_get_long(h, "paramIdForConversion", &newParamId) == GRIB_SUCCESS && newParamId > 0) { if (a->context->debug) { const char* cclass_name = a->cclass->name; fprintf(stderr, "ECCODES DEBUG %s::%s: Changing %s from %ld to %ld\n", - cclass_name, __func__, a->name, *val, newParamId); + cclass_name, __func__, a->name, *val, newParamId); } snprintf(buf, sizeof(buf), "%ld", newParamId); } @@ -368,7 +383,8 @@ int grib_accessor_class_concept_t::pack_long(grib_accessor* a, const long* val, return pack_string(a, buf, &s); } -int grib_accessor_class_concept_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_concept_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ /* * If we want to have a condition which contains tests for paramId as well * as a floating point key, then need to be able to evaluate paramId as a @@ -400,7 +416,8 @@ int grib_accessor_class_concept_t::unpack_double(grib_accessor* a, double* val, return ret; } -int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ const char* p = concept_evaluate(a); if (!p) { @@ -419,14 +436,14 @@ int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size * Keep this check in DEBUG mode only */ { - char *endptr; + char* endptr; *val = strtol(p, &endptr, 10); if (endptr == p || *endptr != '\0') { /* Failed to convert string into integer */ int type = GRIB_TYPE_UNDEFINED; - grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as long",a->name); + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack %s as long", a->name); if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context,GRIB_LOG_ERROR,"Hint: Try unpacking as %s", grib_get_type_name(type)); + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); } return GRIB_DECODING_ERROR; } @@ -435,7 +452,8 @@ int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size return GRIB_SUCCESS; } -int grib_accessor_class_concept_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_concept_t::get_native_type(grib_accessor* a) +{ int type = GRIB_TYPE_STRING; if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) type = GRIB_TYPE_LONG; @@ -443,13 +461,15 @@ int grib_accessor_class_concept_t::get_native_type(grib_accessor* a){ return type; } -void grib_accessor_class_concept_t::destroy(grib_context* c, grib_accessor* a){ - //grib_accessor_concept_t *self = (grib_accessor_concept_t*)a; - //grib_context_free(c,self->cval); +void grib_accessor_class_concept_t::destroy(grib_context* c, grib_accessor* a) +{ + // grib_accessor_concept_t *self = (grib_accessor_concept_t*)a; + // grib_context_free(c,self->cval); grib_accessor_class_gen_t::destroy(c, a); } -int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ size_t slen; const char* p = concept_evaluate(a); @@ -464,7 +484,7 @@ int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, si slen = strlen(p) + 1; if (*len < slen) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Concept unpack_string. Buffer too small for %s, value='%s' which requires %lu bytes (len=%lu)", + "Concept unpack_string. Buffer too small for %s, value='%s' which requires %lu bytes (len=%lu)", a->name, p, slen, *len); *len = slen; return GRIB_BUFFER_TOO_SMALL; @@ -472,30 +492,34 @@ int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, si strcpy(val, p); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ *len = slen; -// if (a->context->debug==1) { -// int err = 0; -// char result[1024] = {0,}; -// err = get_concept_condition_string(grib_handle_of_accessor(a), a->name, val, result); -// if (!err) fprintf(stderr, "ECCODES DEBUG concept name=%s, value=%s, conditions=%s\n", a->name, val, result); -// } + // if (a->context->debug==1) { + // int err = 0; + // char result[1024] = {0,}; + // err = get_concept_condition_string(grib_handle_of_accessor(a), a->name, val, result); + // if (!err) fprintf(stderr, "ECCODES DEBUG concept name=%s, value=%s, conditions=%s\n", a->name, val, result); + // } return GRIB_SUCCESS; } -int grib_accessor_class_concept_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_concept_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ return grib_concept_apply(a, val); } -size_t grib_accessor_class_concept_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_concept_t::string_length(grib_accessor* a) +{ return MAX_CONCEPT_STRING_LENGTH; } -int grib_accessor_class_concept_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_concept_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = 0; char* aval = 0; char* bval = 0; @@ -505,10 +529,12 @@ int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b){ int err = 0; long count = 0; - err = a->value_count(&count); if (err) return err; + err = a->value_count(&count); + if (err) return err; alen = count; - err = b->value_count(&count); if (err) return err; + err = b->value_count(&count); + if (err) return err; blen = count; if (alen != blen) @@ -519,8 +545,10 @@ int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b){ aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - err = a->unpack_string(aval, &alen); if (err) return err; - err = b->unpack_string(bval, &blen); if (err) return err; + err = a->unpack_string(aval, &alen); + if (err) return err; + err = b->unpack_string(bval, &blen); + if (err) return err; retval = GRIB_SUCCESS; if (!aval || !bval || grib_inline_strcmp(aval, bval)) diff --git a/src/accessor/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc index c381be043..7a3232175 100644 --- a/src/accessor/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -11,7 +11,7 @@ #include "grib_accessor_class_count_missing.h" -grib_accessor_class_count_missing_t _grib_accessor_class_count_missing{"count_missing"}; +grib_accessor_class_count_missing_t _grib_accessor_class_count_missing{ "count_missing" }; grib_accessor_class* grib_accessor_class_count_missing = &_grib_accessor_class_count_missing; @@ -34,22 +34,24 @@ static const unsigned char bitsoff[] = { 0 }; -void grib_accessor_class_count_missing_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_count_missing_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_long_t::init(a, len, arg); - int n = 0; + int n = 0; grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - a->length = 0; + grib_handle* h = grib_handle_of_accessor(a); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - self->bitmap = grib_arguments_get_name(h, arg, n++); - self->unusedBitsInBitmap = grib_arguments_get_name(h, arg, n++); - self->numberOfDataPoints = grib_arguments_get_name(h, arg, n++); + self->bitmap = grib_arguments_get_name(h, arg, n++); + self->unusedBitsInBitmap = grib_arguments_get_name(h, arg, n++); + self->numberOfDataPoints = grib_arguments_get_name(h, arg, n++); self->missingValueManagementUsed = grib_arguments_get_name(h, arg, n++); /* Can be NULL */ } static const int used[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; -int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing){ +static int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing) +{ int err = 0; long count_of_missing = 0; size_t vsize = 0, ii = 0; @@ -72,7 +74,8 @@ int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing){ return GRIB_SUCCESS; } -int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; unsigned char* p; int i; @@ -88,11 +91,10 @@ int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val if (!bitmap) { long mvmu = 0; if (self->missingValueManagementUsed && - grib_get_long(h, self->missingValueManagementUsed, &mvmu) == GRIB_SUCCESS && mvmu != 0) - { + grib_get_long(h, self->missingValueManagementUsed, &mvmu) == GRIB_SUCCESS && mvmu != 0) { /* ECC-523: No bitmap. Missing values are encoded in the Data Section. * So we must decode all the data values and count how many are missing - */ + */ long count_of_missing = 0; if (get_count_of_missing_values(h, &count_of_missing) == GRIB_SUCCESS) { *val = count_of_missing; @@ -101,7 +103,8 @@ int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } - size = bitmap->byte_count(); offset = bitmap->byte_offset(); + size = bitmap->byte_count(); + offset = bitmap->byte_offset(); if (grib_get_long(h, self->unusedBitsInBitmap, &unusedBitsInBitmap) != GRIB_SUCCESS) { if (grib_get_long(h, self->numberOfDataPoints, &numberOfDataPoints) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to count missing values"); @@ -110,7 +113,7 @@ int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val unusedBitsInBitmap = size * 8 - numberOfDataPoints; if (unusedBitsInBitmap < 0) { grib_context_log(a->context, GRIB_LOG_ERROR, "Inconsistent number of bitmap points: Check the bitmap and data sections!"); - grib_context_log(a->context, GRIB_LOG_ERROR, "Bitmap size=%ld, numberOfDataPoints=%ld", size*8, numberOfDataPoints); + grib_context_log(a->context, GRIB_LOG_ERROR, "Bitmap size=%ld, numberOfDataPoints=%ld", size * 8, numberOfDataPoints); return GRIB_DECODING_ERROR; } } @@ -128,7 +131,8 @@ int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_count_missing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_count_missing_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index a5c1084ac..f78bb1806 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -12,12 +12,12 @@ #include "grib_accessor_class_data_g1second_order_general_extended_packing.h" #include "grib_scaling.h" -grib_accessor_class_data_g1second_order_general_extended_packing_t _grib_accessor_class_data_g1second_order_general_extended_packing{"data_g1second_order_general_extended_packing"}; +grib_accessor_class_data_g1second_order_general_extended_packing_t _grib_accessor_class_data_g1second_order_general_extended_packing{ "data_g1second_order_general_extended_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing = &_grib_accessor_class_data_g1second_order_general_extended_packing; #define MAX_NUMBER_OF_GROUPS 65534 -#define EFDEBUG 0 +#define EFDEBUG 0 static const unsigned long nbits[64] = { 0x1, 0x2, 0x4, 0x8, @@ -38,7 +38,8 @@ static const unsigned long nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -long number_of_bits(grib_handle* h, unsigned long x){ +long number_of_bits(grib_handle* h, unsigned long x) +{ const unsigned long* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); long i = 0; @@ -54,10 +55,11 @@ long number_of_bits(grib_handle* h, unsigned long x){ return i; } -void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_data_simple_packing_t::init(a, v, args); grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; - grib_handle* handle = grib_handle_of_accessor(a); + grib_handle* handle = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(handle, args, self->carg++); self->packingType = grib_arguments_get_name(handle, args, self->carg++); @@ -83,17 +85,18 @@ void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(gr self->dataFlag = grib_arguments_get_name(handle, args, self->carg++); self->edition = 1; self->dirty = 1; - self->dvalues = NULL; - self->fvalues = NULL; + self->dvalues = NULL; + self->fvalues = NULL; self->double_dirty = self->float_dirty = 1; - self->size = 0; + self->size = 0; a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; - long numberOfCodedValues = 0; - long numberOfGroups = 0; + long numberOfCodedValues = 0; + long numberOfGroups = 0; size_t ngroups; long* groupLengths; long orderOfSPD = 0; @@ -126,7 +129,8 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::value_co return err; } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ size_t size; double* values; int err = 0; @@ -149,7 +153,8 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_d return GRIB_SUCCESS; } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ size_t size = 0, i = 0; double* values; int err = 0; @@ -176,9 +181,10 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_d return GRIB_SUCCESS; } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len) +{ grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; - int ret = 0; + int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* firstOrderValues = 0; long* X = 0; @@ -292,14 +298,13 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(g n++; } -// for (j=0;jdvalues) { if (numberOfValues != self->size) { grib_context_free(a->context, self->dvalues); @@ -396,11 +401,13 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(g return ret; } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) +{ return unpack(a, NULL, values, len); } -int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) +{ return unpack(a, values, NULL, len); } @@ -513,7 +520,8 @@ static void grib_split_long_groups(grib_handle* hand, grib_context* c, long* num grib_context_free(c, localFirstOrderValues); } -int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bits_per_value){ +static int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bits_per_value) +{ int err = 0; if ((err = grib_get_long_internal(h, bits_per_value_str, bits_per_value)) != GRIB_SUCCESS) return err; @@ -526,7 +534,8 @@ int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bit /* Note: on a 32bit system, the most significant bit is for signedness, so we have to drop one bit */ if (sizeof(long) == 4) { *bits_per_value = 31; - } else { + } + else { *bits_per_value = 32; } } @@ -536,10 +545,11 @@ int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, long* bit // For the old implementation of pack_double, see // src/deprecated/grib_accessor_class_data_g1second_order_general_extended_packing.pack_double.cc // See ECC-441 and ECC-261 -int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; - int ret = 0; - int grib2 = 0; + int ret = 0; + int grib2 = 0; long bits_per_value, orderOfSPD, binary_scale_factor; long numberOfValues; double max, min; @@ -1130,7 +1140,9 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_dou pos = 0; if (orderOfSPD) { - long SPD[4] = {0,}; + long SPD[4] = { + 0, + }; size_t nSPD = orderOfSPD + 1; Assert(orderOfSPD <= 3); for (i = 0; i < orderOfSPD; i++) @@ -1192,7 +1204,8 @@ int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_dou return GRIB_SUCCESS; } -void grib_accessor_class_data_g1second_order_general_extended_packing_t::destroy(grib_context* context, grib_accessor* a){ +void grib_accessor_class_data_g1second_order_general_extended_packing_t::destroy(grib_context* context, grib_accessor* a) +{ grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; if (self->dvalues != NULL) { grib_context_free(context, self->dvalues); diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index 43fbce6ba..bbc698100 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -130,7 +130,7 @@ void add_bitstream(bitstream_context* ctx, grib_accessor* a, int t, int n_bits) // find min/max of an integer array // return 0: if min max found // return 1: if min max not found, min = max = 0 -int int_min_max_array(int* data, unsigned int n, int* min, int* max) +static int int_min_max_array(int* data, unsigned int n, int* min, int* max) { unsigned int first; int mn, mx; @@ -172,7 +172,7 @@ int int_min_max_array(int* data, unsigned int n, int* min, int* max) return 0; } -double Int_Power(double x, int y) +static double Int_Power(double x, int y) { double value; @@ -192,7 +192,7 @@ double Int_Power(double x, int y) return value; } -int min_max_array(double* data, unsigned int n, double* min, double* max) +static int min_max_array(double* data, unsigned int n, double* min, double* max) { unsigned int first; double mn, mx; @@ -366,7 +366,7 @@ static int post_process(grib_context* c, long* vals, long len, long order, long return GRIB_SUCCESS; } -int find_nbits(unsigned int i) +static int find_nbits(unsigned int i) { #if !defined __GNUC__ || __GNUC__ < 4 int j; @@ -405,7 +405,7 @@ struct section struct section *head, *tail; }; -int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef) +static int sizeofsection(struct section* s, int ref_bits, int width_bits, int has_undef) { if (s->mn == INT_MAX) { // all undef return ref_bits + width_bits; @@ -434,7 +434,7 @@ static int sizeofsection2(int mn, int mx, int n, int ref_bits, int width_bits, return find_nbits(mx - mn + has_undef) * n + ref_bits + width_bits; } -int size_all(struct section* s, int ref_bits, int width_bits, int has_undef) +static int size_all(struct section* s, int ref_bits, int width_bits, int has_undef) { int bits; @@ -446,7 +446,7 @@ int size_all(struct section* s, int ref_bits, int width_bits, int has_undef) return (bits + 7) / 8; } -void move_one_left(struct section* s, int* v) +static void move_one_left(struct section* s, int* v) { struct section* t; int val, i, j, k; @@ -512,7 +512,7 @@ void move_one_left(struct section* s, int* v) } } -void move_one_right(struct section* s, int* v) +static void move_one_right(struct section* s, int* v) { struct section* t; int val, i, j, k; @@ -594,7 +594,7 @@ void move_one_right(struct section* s, int* v) return; } -void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) +static void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) { struct section* t; int val0, val1, nbit_s, nbit_t; @@ -670,7 +670,7 @@ void exchange(struct section* s, int* v, int has_undef, int LEN_SEC_MAX) } } -void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX) +static void merge_j(struct section* h, int ref_bits, int width_bits, int has_undef, int param, int LEN_SEC_MAX) { struct section *t, *m; int size_head, size_mid, size_tail, saving_mt, saving_hm; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index 60cf8e0f9..a014ef3c2 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -50,7 +50,8 @@ int grib_accessor_class_data_g2bifourier_packing_t::value_count(grib_accessor* a return grib_get_long_internal(gh, self->number_of_values, numberOfValues); } -void ellipse(long ni, long nj, long itrunc[], long jtrunc[]){ +static void ellipse(long ni, long nj, long itrunc[], long jtrunc[]) +{ const double zeps = 1.E-10; const double zauxil = 0.; int i, j; @@ -91,7 +92,8 @@ void ellipse(long ni, long nj, long itrunc[], long jtrunc[]){ } } -void rectangle(long ni, long nj, long itrunc[], long jtrunc[]){ +static void rectangle(long ni, long nj, long itrunc[], long jtrunc[]) +{ int i, j; /* @@ -109,7 +111,8 @@ void rectangle(long ni, long nj, long itrunc[], long jtrunc[]){ jtrunc[i] = nj; } -void diamond(long ni, long nj, long itrunc[], long jtrunc[]){ +static void diamond(long ni, long nj, long itrunc[], long jtrunc[]) +{ int i, j; if (nj == 0) @@ -171,7 +174,8 @@ typedef struct bif_trunc_t /* * Total number of coefficients */ -size_t size_bif(bif_trunc_t* bt){ +static size_t size_bif(bif_trunc_t* bt) +{ size_t n_vals = 0; int j; for (j = 0; j <= bt->bif_j; j++) @@ -182,7 +186,8 @@ size_t size_bif(bif_trunc_t* bt){ /* * Number of unpacked coefficients */ -size_t size_sub(bif_trunc_t* bt){ +static size_t size_sub(bif_trunc_t* bt) +{ size_t n_vals = 0; int i, j; for_ij() @@ -197,7 +202,8 @@ size_t size_sub(bif_trunc_t* bt){ return n_vals; } -double laplam(bif_trunc_t* bt, const double val[]){ +static double laplam(bif_trunc_t* bt, const double val[]) +{ /* * For bi-Fourier spectral fields, the Laplacian operator is a multiplication by (i*i+j*j) */ @@ -333,7 +339,8 @@ double laplam(bif_trunc_t* bt, const double val[]){ return zp; } -void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a){ +static void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a) +{ grib_handle* gh = grib_handle_of_accessor(a); if (bt == NULL) return; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index fa653c0cb..fc87df231 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -13,11 +13,12 @@ #define DIRECT 0 #define INVERSE 1 -grib_accessor_class_data_g2simple_packing_with_preprocessing_t _grib_accessor_class_data_g2simple_packing_with_preprocessing{"data_g2simple_packing_with_preprocessing"}; +grib_accessor_class_data_g2simple_packing_with_preprocessing_t _grib_accessor_class_data_g2simple_packing_with_preprocessing{ "data_g2simple_packing_with_preprocessing" }; grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing = &_grib_accessor_class_data_g2simple_packing_with_preprocessing; -void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_accessor* a, const long v, grib_arguments* args){ +void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ grib_accessor_class_data_g2simple_packing_t::init(a, v, args); grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); @@ -25,7 +26,8 @@ void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_a a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::value_count(grib_accessor* a, long* n_vals){ +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::value_count(grib_accessor* a, long* n_vals) +{ grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; *n_vals = 0; @@ -35,7 +37,7 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::value_count( static int pre_processing_func(double* values, long length, long pre_processing, double* pre_processing_parameter, int mode) { - int i = 0, ret = 0; + int i = 0, ret = 0; double min = values[0]; double next_min = values[0]; Assert(length > 0); @@ -96,10 +98,9 @@ static int pre_processing_func(double* values, long length, long pre_processing, return ret; } -int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; - //grib_accessor_class* super = *(a->cclass->super); - //grib_accessor_class* super2 = NULL; size_t n_vals = 0; long nn = 0; @@ -108,7 +109,8 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_doubl long pre_processing; double pre_processing_parameter; - err = a->value_count(&nn); n_vals = nn; + err = a->value_count(&nn); + n_vals = nn; if (err) return err; @@ -140,7 +142,8 @@ int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_doubl return err; } -int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; size_t n_vals = *len; diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index a68a3eae7..5ce5ae154 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -428,7 +428,7 @@ cleanup: } #else -void print_error_feature_not_enabled(grib_context* c){ +static void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "JPEG support not enabled. Please rebuild with -DENABLE_JPG=ON"); } diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 8db2e5b3b..690070214 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -53,14 +53,16 @@ typedef struct png_read_callback_data size_t offset; } png_read_callback_data; -void png_read_callback(png_structp png, png_bytep data, png_size_t length){ +static void png_read_callback(png_structp png, png_bytep data, png_size_t length) +{ png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); Assert(p->offset + length <= p->length); memcpy(data, p->buffer + p->offset, length); p->offset += length; } -void png_write_callback(png_structp png, png_bytep data, png_size_t length){ +static void png_write_callback(png_structp png, png_bytep data, png_size_t length) +{ png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); /* printf("p.offset=%zu len=%zu p.len=%zu\n", p->offset, length, p->length); */ /* Assert(p->offset + length <= p->length); */ @@ -73,7 +75,8 @@ void png_write_callback(png_structp png, png_bytep data, png_size_t length){ p->offset += length; } -void png_flush_callback(png_structp png){ +static void png_flush_callback(png_structp png) +{ /* Empty */ } @@ -218,7 +221,8 @@ cleanup: return err; } -bool is_constant(const double* values, size_t n_vals){ +static bool is_constant(const double* values, size_t n_vals) +{ bool isConstant = true; double v = 0; size_t i; diff --git a/src/accessor/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc index eb2a874f2..3d150d79e 100644 --- a/src/accessor/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -15,7 +15,8 @@ grib_accessor_class_element_t _grib_accessor_class_element{"element"}; grib_accessor_class* grib_accessor_class_element = &_grib_accessor_class_element; -void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_element_t* self = (grib_accessor_element_t*)a; grib_handle* hand = grib_handle_of_accessor(a); @@ -25,7 +26,8 @@ void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_ar self->element = grib_arguments_get_long(hand, c, n++); } -int check_element_index(const char* func, const char* array_name, long index, size_t size){ +static int check_element_index(const char* func, const char* array_name, long index, size_t size) +{ const grib_context* c = grib_context_get_default(); if (index < 0 || index >= size) { grib_context_log(c, GRIB_LOG_ERROR, "%s: Invalid element index %ld for array '%s'. Value must be between 0 and %zu", @@ -35,7 +37,8 @@ int check_element_index(const char* func, const char* array_name, long index, si return GRIB_SUCCESS; } -int grib_accessor_class_element_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_element_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; @@ -77,7 +80,8 @@ the_end: return ret; } -int grib_accessor_class_element_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_element_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; @@ -124,7 +128,8 @@ the_end: return ret; } -int grib_accessor_class_element_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_element_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index ff91dbc6f..b30e745a9 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -41,7 +41,8 @@ typedef struct change_coding_params result = grib_bufr_descriptors_array_pop_front(array); \ } -void grib_accessor_class_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, len, args); grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int n = 0; @@ -88,7 +89,8 @@ static char* descriptor_type_name(int dtype) } #endif -void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded, change_coding_params* ccp, int* err){ +static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded, change_coding_params* ccp, int* err) +{ int k, j, i; grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; size_t size = 0; @@ -463,7 +465,8 @@ static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_arra return expanded; } -int expand(grib_accessor* a){ +static int expand(grib_accessor* a) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int err = 0; size_t unexpandedSize = 0; @@ -599,7 +602,8 @@ bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(gr return self->expanded; } -int grib_accessor_class_expanded_descriptors_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_expanded_descriptors_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int ret = 0; size_t i = 0; @@ -633,7 +637,8 @@ int grib_accessor_class_expanded_descriptors_t::unpack_double(grib_accessor* a, return ret; } -int grib_accessor_class_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int ret = 0; size_t rlen = 0; @@ -678,7 +683,8 @@ int grib_accessor_class_expanded_descriptors_t::unpack_long(grib_accessor* a, lo return GRIB_SUCCESS; } -int grib_accessor_class_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ int err = 0; long* v = NULL; char buf[25] = {0,}; @@ -702,13 +708,15 @@ int grib_accessor_class_expanded_descriptors_t::unpack_string_array(grib_accesso return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_expanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_expanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; self->do_expand = 1; return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen){ +int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int err = 0; *rlen = 0; @@ -723,14 +731,16 @@ int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, lo return err; } -void grib_accessor_class_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_class_long_t::destroy(c, a); // grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; // if (self->rank==0 && self->expanded) // grib_bufr_descriptors_array_delete(self->expanded); } -int grib_accessor_class_expanded_descriptors_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_expanded_descriptors_t::get_native_type(grib_accessor* a) +{ grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; if (self->rank == 2) return GRIB_TYPE_DOUBLE; diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc index 7da455773..7ec448cf6 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_g1forecastmonth.h" -grib_accessor_class_g1forecastmonth_t _grib_accessor_class_g1forecastmonth{"g1forecastmonth"}; +grib_accessor_class_g1forecastmonth_t _grib_accessor_class_g1forecastmonth{ "g1forecastmonth" }; grib_accessor_class* grib_accessor_class_g1forecastmonth = &_grib_accessor_class_g1forecastmonth; -void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; grib_handle* h = grib_handle_of_accessor(a); @@ -31,17 +32,19 @@ void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, } } -void grib_accessor_class_g1forecastmonth_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_g1forecastmonth_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_long(dumper, a, NULL); } -int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result){ +static int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result) +{ long base_yearmonth = 0; - long vyear = 0; - long vmonth = 0; - long byear = 0; - long bmonth = 0; - long fcmonth = 0; + long vyear = 0; + long vmonth = 0; + long byear = 0; + long bmonth = 0; + long fcmonth = 0; base_yearmonth = base_date / 100; @@ -58,7 +61,8 @@ int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_d return GRIB_SUCCESS; } -int unpack_long_edition2(grib_accessor* a, long* val, size_t* len){ +static int unpack_long_edition2(grib_accessor* a, long* val, size_t* len) +{ int err = 0; grib_handle* h = grib_handle_of_accessor(a); long dataDate, verification_yearmonth; @@ -67,10 +71,10 @@ int unpack_long_edition2(grib_accessor* a, long* val, size_t* len){ long forecastTime, indicatorOfUnitOfTimeRange; double jul_base, jul2, dstep; - if ((err = grib_get_long(h, "year", &year)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "year", &year)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "month", &month)) != GRIB_SUCCESS) return err; - if ((err = grib_get_long(h, "day", &day)) != GRIB_SUCCESS) return err; - if ((err = grib_get_long(h, "hour", &hour)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "day", &day)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "hour", &hour)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "minute", &minute)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "second", &second)) != GRIB_SUCCESS) return err; @@ -90,19 +94,20 @@ int unpack_long_edition2(grib_accessor* a, long* val, size_t* len){ return err; dstep = (((double)forecastTime) * 3600) / 86400; /* as a fraction of a day */ - jul2 = jul_base + dstep; + jul2 = jul_base + dstep; if ((err = grib_julian_to_datetime(jul2, &year2, &month2, &day2, &hour2, &minute2, &second2)) != GRIB_SUCCESS) return err; - verification_yearmonth = year2*100 + month2; + verification_yearmonth = year2 * 100 + month2; if ((err = calculate_fcmonth(a, verification_yearmonth, dataDate, day, hour, val)) != GRIB_SUCCESS) return err; return GRIB_SUCCESS; } -int unpack_long_edition1(grib_accessor* a, long* val, size_t* len){ +int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) +{ int err = 0; grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; @@ -110,9 +115,9 @@ int unpack_long_edition1(grib_accessor* a, long* val, size_t* len){ long base_date = 0; long day = 0; long hour = 0; - long gribForecastMonth = 0; - long check = 0; - long fcmonth = 0; + long gribForecastMonth = 0; + long check = 0; + long fcmonth = 0; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->verification_yearmonth, &verification_yearmonth)) != GRIB_SUCCESS) @@ -148,10 +153,11 @@ int unpack_long_edition1(grib_accessor* a, long* val, size_t* len){ return GRIB_SUCCESS; } -int grib_accessor_class_g1forecastmonth_t::unpack_long(grib_accessor* a, long* val, size_t* len){ - int err = 0; +int grib_accessor_class_g1forecastmonth_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + int err = 0; grib_handle* hand = grib_handle_of_accessor(a); - long edition = 0; + long edition = 0; if ((err = grib_get_long(hand, "edition", &edition)) != GRIB_SUCCESS) return err; @@ -165,7 +171,8 @@ int grib_accessor_class_g1forecastmonth_t::unpack_long(grib_accessor* a, long* v } /* TODO: Check for a valid date */ -int grib_accessor_class_g1forecastmonth_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g1forecastmonth_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; return grib_set_long_internal(grib_handle_of_accessor(a), self->fcmonth, *val); } diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index 4ea0f5e7c..b9059220f 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -11,15 +11,16 @@ #include "grib_accessor_class_g2_mars_labeling.h" -grib_accessor_class_g2_mars_labeling_t _grib_accessor_class_g2_mars_labeling{"g2_mars_labeling"}; +grib_accessor_class_g2_mars_labeling_t _grib_accessor_class_g2_mars_labeling{ "g2_mars_labeling" }; grib_accessor_class* grib_accessor_class_g2_mars_labeling = &_grib_accessor_class_g2_mars_labeling; -void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_gen_t::init(a, l, c); grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); self->index = grib_arguments_get_long(hand, c, n++); self->the_class = grib_arguments_get_name(hand, c, n++); @@ -33,9 +34,10 @@ void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l self->typeOfGeneratingProcess = grib_arguments_get_name(hand, c, n++); } -int grib_accessor_class_g2_mars_labeling_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_g2_mars_labeling_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - char* key = NULL; + char* key = NULL; switch (self->index) { case 0: @@ -56,9 +58,10 @@ int grib_accessor_class_g2_mars_labeling_t::unpack_long(grib_accessor* a, long* return grib_get_long(grib_handle_of_accessor(a), key, val); } -int grib_accessor_class_g2_mars_labeling_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_g2_mars_labeling_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - char* key = NULL; + char* key = NULL; switch (self->index) { case 0: @@ -79,11 +82,12 @@ int grib_accessor_class_g2_mars_labeling_t::unpack_string(grib_accessor* a, char return grib_get_string(grib_handle_of_accessor(a), key, val, len); } -int extra_set(grib_accessor* a, long val){ - int ret = 0; +static int extra_set(grib_accessor* a, long val) +{ + int ret = 0; grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - char stepType[30] = {0,}; + grib_handle* hand = grib_handle_of_accessor(a); + char stepType[30] = {0,}; size_t stepTypelen = 30; long derivedForecast = -1; long productDefinitionTemplateNumberNew = -1; @@ -301,11 +305,12 @@ int extra_set(grib_accessor* a, long val){ return ret; } -int grib_accessor_class_g2_mars_labeling_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_g2_mars_labeling_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - char* key = NULL; - int ret = 0; - long lval = 0; + char* key = NULL; + int ret = 0; + long lval = 0; switch (self->index) { case 0: @@ -334,10 +339,11 @@ int grib_accessor_class_g2_mars_labeling_t::pack_string(grib_accessor* a, const return extra_set(a, lval); } -int grib_accessor_class_g2_mars_labeling_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g2_mars_labeling_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - char* key = NULL; - int ret = 0; + char* key = NULL; + int ret = 0; switch (self->index) { case 0: @@ -362,16 +368,18 @@ int grib_accessor_class_g2_mars_labeling_t::pack_long(grib_accessor* a, const lo return extra_set(a, *val); } -int grib_accessor_class_g2_mars_labeling_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_g2_mars_labeling_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -int grib_accessor_class_g2_mars_labeling_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_g2_mars_labeling_t::get_native_type(grib_accessor* a) +{ grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; - char* key = NULL; - int ret = 0; - int type = 0; + char* key = NULL; + int ret = 0; + int type = 0; switch (self->index) { case 0: @@ -389,7 +397,8 @@ int grib_accessor_class_g2_mars_labeling_t::get_native_type(grib_accessor* a){ return GRIB_INTERNAL_ERROR; } - ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); if (ret) + ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); + if (ret) grib_context_log(a->context, GRIB_LOG_ERROR, "unable to get native type for %s", key); return type; diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index 70fb9451c..6e8cfcda3 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -14,15 +14,16 @@ #include "step_utilities.h" #include -grib_accessor_class_g2end_step_t _grib_accessor_class_g2end_step{"g2end_step"}; +grib_accessor_class_g2end_step_t _grib_accessor_class_g2end_step{ "g2end_step" }; grib_accessor_class* grib_accessor_class_g2end_step = &_grib_accessor_class_g2end_step; -void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); self->start_step_value = grib_arguments_get_name(h, c, n++); self->step_units = grib_arguments_get_name(h, c, n++); @@ -41,29 +42,31 @@ void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib self->minute_of_end_of_interval = grib_arguments_get_name(h, c, n++); self->second_of_end_of_interval = grib_arguments_get_name(h, c, n++); - self->time_range_unit = grib_arguments_get_name(h, c, n++); + self->time_range_unit = grib_arguments_get_name(h, c, n++); self->time_range_value = grib_arguments_get_name(h, c, n++); self->typeOfTimeIncrement = grib_arguments_get_name(h, c, n++); self->numberOfTimeRange = grib_arguments_get_name(h, c, n++); } -void grib_accessor_class_g2end_step_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_g2end_step_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_double(dumper, a, NULL); } // See GRIB-488 -bool is_special_expver(const grib_handle* h){ - int ret = 0; +bool is_special_expver(const grib_handle* h) +{ + int ret = 0; char strMarsExpVer[50] = {0,}; char strMarsClass[50] = {0,}; size_t slen = 50; - ret = grib_get_string(h, "mars.class", strMarsClass, &slen); + ret = grib_get_string(h, "mars.class", strMarsClass, &slen); if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsClass, "em")) { // em = ERA-CLIM model integration for the 20th-century (ERA-20CM) slen = 50; - ret = grib_get_string(h, "experimentVersionNumber", strMarsExpVer, &slen); + ret = grib_get_string(h, "experimentVersionNumber", strMarsExpVer, &slen); if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsExpVer, "1605")) { - return true; // Special case of expVer 1605 in class "em" + return true; // Special case of expVer 1605 in class "em" } } @@ -80,8 +83,8 @@ static int convert_time_range_long_( Assert(lengthOfTimeRange != NULL); if (indicatorOfUnitForTimeRange != stepUnits) { - eccodes::Step time_range{*lengthOfTimeRange, indicatorOfUnitForTimeRange}; - time_range.set_unit(eccodes::Unit{stepUnits}); + eccodes::Step time_range{ *lengthOfTimeRange, indicatorOfUnitForTimeRange }; + time_range.set_unit(eccodes::Unit{ stepUnits }); if (time_range.value() != time_range.value()) { return GRIB_DECODING_ERROR; } @@ -91,9 +94,10 @@ static int convert_time_range_long_( return GRIB_SUCCESS; } -int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len){ +static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - int err = 0; + int err = 0; long start_step_value; long step_units; long time_range_unit; @@ -139,9 +143,10 @@ int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len){ return GRIB_SUCCESS; } -int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len){ +static int unpack_one_time_range_double_(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - int err = 0; + int err = 0; double start_step_value; long start_step_unit; long step_units; @@ -165,8 +170,8 @@ int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len){ if ((err = grib_get_long_internal(h, self->typeOfTimeIncrement, &typeOfTimeIncrement))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; - eccodes::Step time_range{time_range_value, time_range_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; + eccodes::Step time_range{ time_range_value, time_range_unit }; if (typeOfTimeIncrement == 1) { /* See GRIB-488 */ @@ -191,16 +196,23 @@ int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len){ } #define MAX_NUM_TIME_RANGES 16 /* maximum number of time range specifications */ -int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len){ +static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0, step_units = 0, start_step_value = 0; - size_t count = 0; - long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = {0,}; - long arr_coded_unit[MAX_NUM_TIME_RANGES] = {0,}; - long arr_coded_time_range[MAX_NUM_TIME_RANGES] = {0,}; + size_t count = 0; + long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_unit[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_time_range[MAX_NUM_TIME_RANGES] = { + 0, + }; if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return err; @@ -243,30 +255,37 @@ int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len){ return GRIB_DECODING_ERROR; } -int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* len){ +static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0; - long step_units = 0; - long start_step_value = 0; - long start_step_unit = 0; + long step_units = 0; + long start_step_value = 0; + long start_step_unit = 0; - size_t count = 0; - long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = {0, }; - long arr_coded_unit[MAX_NUM_TIME_RANGES] = {0, }; - long arr_coded_time_range[MAX_NUM_TIME_RANGES] = {0, }; + size_t count = 0; + long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_unit[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_time_range[MAX_NUM_TIME_RANGES] = { + 0, + }; if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return err; if ((err = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; if ((err = grib_get_long_internal(h, self->step_units, &step_units))) return err; - + if ((err = grib_get_long_internal(h, self->numberOfTimeRange, &numberOfTimeRange))) return err; if (numberOfTimeRange > MAX_NUM_TIME_RANGES) { @@ -290,7 +309,7 @@ int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* l long the_coded_unit = arr_coded_unit[i]; long the_coded_time_range = arr_coded_time_range[i]; - eccodes::Step time_range{the_coded_unit, the_coded_time_range}; + eccodes::Step time_range{ the_coded_unit, the_coded_time_range }; *val = (start_step + time_range).value(eccodes::Unit(step_units)); return GRIB_SUCCESS; @@ -305,10 +324,11 @@ int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* l // For the old implementation of unpack_long, see // src/deprecated/grib_accessor_class_g2end_step.unpack_long.cc // -int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; long start_step_value; long start_step_unit; long numberOfTimeRange; @@ -333,7 +353,7 @@ int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, s try { if (numberOfTimeRange == 1) { - ret = unpack_one_time_range_long_(a, val, len); + ret = unpack_one_time_range_long_(a, val, len); } else { ret = unpack_multiple_time_ranges_long_(a, val, len); @@ -347,10 +367,11 @@ int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, s return ret; } -int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; long start_step_value; long start_step_unit; long numberOfTimeRange; @@ -375,7 +396,7 @@ int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* va try { if (numberOfTimeRange == 1) { - ret = unpack_one_time_range_double_(a, val, len); + ret = unpack_one_time_range_double_(a, val, len); } else { ret = unpack_multiple_time_ranges_double_(a, val, len); @@ -389,10 +410,11 @@ int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* va return ret; } -int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit){ +static int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int err = 0; + grib_handle* h = grib_handle_of_accessor(a); + int err = 0; long year; long month; @@ -415,7 +437,7 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ double dend, dstep; const int show_units_for_hours = a->context->grib_hourly_steps_with_units; - eccodes::Step end_step{end_step_value, end_step_unit}; + eccodes::Step end_step{ end_step_value, end_step_unit }; /*point in time */ if (self->year == NULL) { @@ -446,10 +468,10 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ return err; long force_step_units; - if ((err= grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) + if ((err = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) return err; - if (eccodes::Unit{start_step_unit} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ start_step_unit } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { grib_context_log(h->context, GRIB_LOG_ERROR, "missing start step unit"); return GRIB_WRONG_STEP_UNIT; @@ -458,7 +480,7 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ if ((err = grib_get_long_internal(h, self->typeOfTimeIncrement, &typeOfTimeIncrement))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; eccodes::Step time_range = end_step - start_step; if (time_range.value() < 0) { @@ -473,7 +495,7 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ if (err != GRIB_SUCCESS) return err; - dstep = end_step.value(eccodes::Unit{eccodes::Unit::Value::DAY}); + dstep = end_step.value(eccodes::Unit{ eccodes::Unit::Value::DAY }); dend += dstep; err = grib_julian_to_datetime(dend, &year_of_end_of_interval, &month_of_end_of_interval, @@ -496,15 +518,15 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ return err; const char* forecast_time_value_key = "forecastTime"; - const char* forecast_time_unit_key = "indicatorOfUnitOfTimeRange"; + const char* forecast_time_unit_key = "indicatorOfUnitOfTimeRange"; eccodes::Step forecast_time_opt; eccodes::Step time_range_opt; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { std::tie(forecast_time_opt, time_range_opt) = find_common_units(start_step.optimize_unit(), time_range.optimize_unit()); } else { - forecast_time_opt = eccodes::Step{start_step.value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - time_range_opt = eccodes::Step{time_range.value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; + forecast_time_opt = eccodes::Step{ start_step.value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; + time_range_opt = eccodes::Step{ time_range.value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; } if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->time_range_value, time_range_opt.value())) != GRIB_SUCCESS) @@ -519,13 +541,14 @@ int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_ return GRIB_SUCCESS; } -int grib_accessor_class_g2end_step_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_g2end_step_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - char fp_format[128] = "%g"; - size_t fp_format_len = sizeof(fp_format); - size_t step_len = 0; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + char fp_format[128] = "%g"; + size_t fp_format_len = sizeof(fp_format); + size_t step_len = 0; long step_value; long step_units; const int show_units_for_hours = a->context->grib_hourly_steps_with_units; @@ -562,7 +585,8 @@ int grib_accessor_class_g2end_step_t::unpack_string(grib_accessor* a, char* val, return GRIB_SUCCESS; } -int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); int ret; @@ -572,12 +596,12 @@ int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* va try { long end_step_unit; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if ((ret = grib_get_long_internal(h, "endStepUnit", &end_step_unit)) != GRIB_SUCCESS) return ret; - if (eccodes::Unit{end_step_unit} == eccodes::Unit{eccodes::Unit::Value::MISSING}) - end_step_unit = eccodes::Unit{eccodes::Unit::Value::HOUR}.value(); + if (eccodes::Unit{ end_step_unit } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) + end_step_unit = eccodes::Unit{ eccodes::Unit::Value::HOUR }.value(); } else { end_step_unit = force_step_units; @@ -591,15 +615,16 @@ int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* va return ret; } -int grib_accessor_class_g2end_step_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_g2end_step_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + int ret = 0; long force_step_units; if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) return ret; try { - eccodes::Step end_step = step_from_string(val, eccodes::Unit{force_step_units}); + eccodes::Step end_step = step_from_string(val, eccodes::Unit{ force_step_units }); end_step.optimize_unit(); if ((ret = grib_set_long_internal(h, "endStepUnit", end_step.unit().value())) != GRIB_SUCCESS) @@ -615,15 +640,16 @@ int grib_accessor_class_g2end_step_t::pack_string(grib_accessor* a, const char* return GRIB_SUCCESS; } -int grib_accessor_class_g2end_step_t::get_native_type(grib_accessor* a){ - grib_handle* h = grib_handle_of_accessor(a); +int grib_accessor_class_g2end_step_t::get_native_type(grib_accessor* a) +{ + grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; if (!show_units_for_hours) { long step_units = 0; if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) { - if (eccodes::Unit{step_units} == eccodes::Unit::Value::HOUR) { - return GRIB_TYPE_LONG; // For backward compatibility + if (eccodes::Unit{ step_units } == eccodes::Unit::Value::HOUR) { + return GRIB_TYPE_LONG; // For backward compatibility } } } diff --git a/src/accessor/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc index 8f0bee1e5..3bc0a9a22 100644 --- a/src/accessor/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -19,8 +19,8 @@ void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arg { grib_accessor_class_double_t::init(a, l, c); grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->latitude_first = grib_arguments_get_name(hand, c, n++); self->longitude_first = grib_arguments_get_name(hand, c, n++); @@ -108,7 +108,7 @@ int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, s return GRIB_SUCCESS; } -long gcd(long a, long b) +static long gcd(long a, long b) { if (b > a) return gcd(b, a); @@ -117,12 +117,12 @@ long gcd(long a, long b) return gcd(b, a % b); } -long lcm(long a, long b) +static long lcm(long a, long b) { return a * b / gcd(a, b); } -int is_ok(const double* val, long v[6], double basic_angle, double sub_division) +static int is_ok(const double* val, long v[6], double basic_angle, double sub_division) { int i; int ok = 1; @@ -147,7 +147,7 @@ int is_ok(const double* val, long v[6], double basic_angle, double sub_division) return ok; } -int trial(const double* val, long v[6], long* basic_angle, long* sub_division) +static int trial(const double* val, long v[6], long* basic_angle, long* sub_division) { int i = 0; long ni, nj; diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index 72b96aaf9..a9ae31309 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -15,7 +15,6 @@ grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{"longitudes"}; grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_longitudes; - static int get_distinct(grib_accessor* a, double** val, long* len); int compare_doubles(const void* a, const void* b); void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 9cabea10c..39324fbd3 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -11,27 +11,29 @@ #include "grib_accessor_class_number_of_points_gaussian.h" -grib_accessor_class_number_of_points_gaussian_t _grib_accessor_class_number_of_points_gaussian{"number_of_points_gaussian"}; +grib_accessor_class_number_of_points_gaussian_t _grib_accessor_class_number_of_points_gaussian{ "number_of_points_gaussian" }; grib_accessor_class* grib_accessor_class_number_of_points_gaussian = &_grib_accessor_class_number_of_points_gaussian; #define EFDEBUG 0 -void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; - self->ni = grib_arguments_get_name(h, c, n++); - self->nj = grib_arguments_get_name(h, c, n++); - self->plpresent = grib_arguments_get_name(h, c, n++); - self->pl = grib_arguments_get_name(h, c, n++); - self->order = grib_arguments_get_name(h, c, n++); - self->lat_first = grib_arguments_get_name(h, c, n++); - self->lon_first = grib_arguments_get_name(h, c, n++); - self->lat_last = grib_arguments_get_name(h, c, n++); - self->lon_last = grib_arguments_get_name(h, c, n++); - self->support_legacy = grib_arguments_get_name(h, c, n++); + + self->ni = grib_arguments_get_name(h, c, n++); + self->nj = grib_arguments_get_name(h, c, n++); + self->plpresent = grib_arguments_get_name(h, c, n++); + self->pl = grib_arguments_get_name(h, c, n++); + self->order = grib_arguments_get_name(h, c, n++); + self->lat_first = grib_arguments_get_name(h, c, n++); + self->lon_first = grib_arguments_get_name(h, c, n++); + self->lat_last = grib_arguments_get_name(h, c, n++); + self->lon_last = grib_arguments_get_name(h, c, n++); + self->support_legacy = grib_arguments_get_name(h, c, n++); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; @@ -40,12 +42,13 @@ void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, con // Old implementation of num_points_reduced_gauss_old // See src/deprecated/grib_accessor_class_number_of_points_gaussian.cc // - -int angleApproximatelyEqual(double A, double B, double angular_precision){ +static int angleApproximatelyEqual(double A, double B, double angular_precision) +{ return angular_precision > 0 ? (fabs(A - B) <= angular_precision) : (A == B); } -double longitude_normalise(double lon, double minimum){ +static double longitude_normalise(double lon, double minimum) +{ while (lon < minimum) { lon += 360; } @@ -55,7 +58,8 @@ double longitude_normalise(double lon, double minimum){ return lon; } -void correctWestEast(long max_pl, double angular_precision, double* pWest, double* pEast){ +static void correctWestEast(long max_pl, double angular_precision, double* pWest, double* pEast) +{ double w, e; const double inc = 360.0 / max_pl; /*smallest increment*/ if (*pWest > *pEast) @@ -76,7 +80,8 @@ void correctWestEast(long max_pl, double angular_precision, double* pWest, doubl } } -int get_number_of_data_values(grib_handle* h, size_t* numDataValues){ +static int get_number_of_data_values(grib_handle* h, size_t* numDataValues) +{ int err = 0; long bpv = 0, bitmapPresent = 0; size_t bitmapLength = 0; @@ -110,11 +115,12 @@ int get_number_of_data_values(grib_handle* h, size_t* numDataValues){ int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len); int unpack_long_new(grib_accessor* a, long* val, size_t* len); -int grib_accessor_class_number_of_points_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ - int err = GRIB_SUCCESS; - long support_legacy = 1; +int grib_accessor_class_number_of_points_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + int err = GRIB_SUCCESS; + long support_legacy = 1; grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); if ((err = grib_get_long_internal(h, self->support_legacy, &support_legacy)) != GRIB_SUCCESS) return err; @@ -126,7 +132,8 @@ int grib_accessor_class_number_of_points_gaussian_t::unpack_long(grib_accessor* } /* New algorithm */ -int unpack_long_new(grib_accessor* a, long* val, size_t* len){ +int unpack_long_new(grib_accessor* a, long* val, size_t* len) +{ int err = GRIB_SUCCESS; int is_global = 0; long ni = 0, nj = 0, plpresent = 0, order = 0; @@ -141,7 +148,7 @@ int unpack_long_new(grib_accessor* a, long* val, size_t* len){ grib_handle* h = grib_handle_of_accessor(a); grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; - grib_context* c = a->context; + grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) return err; @@ -161,8 +168,8 @@ int unpack_long_new(grib_accessor* a, long* val, size_t* len){ } if (plpresent) { - long max_pl = 0; - int j = 0; + long max_pl = 0; + int j = 0; // double lon_first_row = 0, lon_last_row = 0; /*reduced*/ @@ -211,8 +218,8 @@ int unpack_long_new(grib_accessor* a, long* val, size_t* len){ return GRIB_GEOCALCULUS_PROBLEM; } grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last); - //lon_first_row = ((ilon_first)*360.0) / pl[j]; - //lon_last_row = ((ilon_last)*360.0) / pl[j]; + // lon_first_row = ((ilon_first)*360.0) / pl[j]; + // lon_last_row = ((ilon_last)*360.0) / pl[j]; *val += row_count; } } @@ -234,7 +241,8 @@ int unpack_long_new(grib_accessor* a, long* val, size_t* len){ } /* With Legacy support */ -int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len){ +int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len) +{ int err = GRIB_SUCCESS; int is_global = 0; long ni = 0, nj = 0, plpresent = 0, order = 0; @@ -250,7 +258,7 @@ int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len){ size_t numDataValues = 0; grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; - grib_context* c = a->context; + grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) return err; @@ -271,7 +279,7 @@ int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len){ if (plpresent) { long max_pl = 0; - int j = 0; + int j = 0; // double lon_first_row = 0, lon_last_row = 0; /*reduced*/ @@ -333,9 +341,9 @@ int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len){ } grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last); -// if ( row_count != pl[j] ) { -// printf("oops...... rc=%ld but pl[%d]=%ld\n", row_count, j,pl[j]); -// } + // if ( row_count != pl[j] ) { + // printf("oops...... rc=%ld but pl[%d]=%ld\n", row_count, j,pl[j]); + // } // lon_first_row = ((ilon_first)*360.0) / pl[j]; // lon_last_row = ((ilon_last)*360.0) / pl[j]; *val += row_count; diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index ca106dd4a..8c556e84a 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -36,7 +36,7 @@ void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const lon * -4 ..-4 All below equator * Anything else is considered not octahedral */ -int is_pl_octahedral(const long pl[], size_t size){ +static int is_pl_octahedral(const long pl[], size_t size){ long i; long prev_diff = -1; for (i = 1; i < size; ++i) { diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc index 1c253764a..ea7c4c931 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -35,7 +35,7 @@ static const size_t nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -int number_of_bits(size_t x, long* result){ +static int number_of_bits(size_t x, long* result){ const size_t* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); *result = 0; diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index b08e8b13b..1c49f2ab0 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -42,7 +42,7 @@ void thread_init() } #endif -int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t); +static int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t); void grib_accessor_class_smart_table_t::init(grib_accessor* a, const long len, grib_arguments* params) { @@ -162,7 +162,7 @@ grib_smart_table* load_table(grib_accessor* a) return t; } -int grib_load_smart_table(grib_context* c, const char* filename, +static int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t) { char line[1024] = {0,}; @@ -324,7 +324,7 @@ int grib_accessor_class_smart_table_t::unpack_string(grib_accessor* a, char* buf return GRIB_SUCCESS; } -int get_table_codes(grib_accessor* a) +static int get_table_codes(grib_accessor* a) { grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; size_t size = 0; diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index ea5280632..929733705 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -11,28 +11,31 @@ #include "grib_accessor_class_step_human_readable.h" -grib_accessor_class_step_human_readable_t _grib_accessor_class_step_human_readable{"step_human_readable"}; +grib_accessor_class_step_human_readable_t _grib_accessor_class_step_human_readable{ "step_human_readable" }; grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_class_step_human_readable; -void grib_accessor_class_step_human_readable_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_step_human_readable_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; - int n = 0; + int n = 0; grib_handle* h = grib_handle_of_accessor(a); - self->stepUnits = grib_arguments_get_name(h, params, n++); - self->step = grib_arguments_get_name(h, params, n++); - a->length = 0; + self->stepUnits = grib_arguments_get_name(h, params, n++); + self->step = grib_arguments_get_name(h, params, n++); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_step_human_readable_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_step_human_readable_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int get_step_human_readable(grib_handle* h, char* result, size_t* length){ - int err = 0; +static int get_step_human_readable(grib_handle* h, char* result, size_t* length) +{ + int err = 0; size_t slen = 2; long step, hour, minute, second; @@ -41,29 +44,33 @@ int get_step_human_readable(grib_handle* h, char* result, size_t* length){ */ if ((err = grib_set_string(h, "stepUnits", "s", &slen)) != GRIB_SUCCESS) return err; - if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) + if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) return err; - hour = step/3600; - minute = step/60 % 60; + hour = step / 3600; + minute = step / 60 % 60; second = step % 60; /* sprintf(result, "%ld:%ld:%ld", hour, minute, second); */ if (second) { snprintf(result, 1024, "%ldh %ldm %lds", hour, minute, second); - } else { - if (minute) snprintf(result, 1024, "%ldh %ldm", hour, minute); - else snprintf(result, 1024, "%ldh", hour); + } + else { + if (minute) + snprintf(result, 1024, "%ldh %ldm", hour, minute); + else + snprintf(result, 1024, "%ldh", hour); } *length = strlen(result); return GRIB_SUCCESS; } -int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; grib_handle* h = grib_handle_of_accessor(a); - long stepUnits; + long stepUnits = 0; int err = 0; /* Save the current value of stepUnits */ diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc index 14d5932bc..10a99ee64 100644 --- a/src/accessor/grib_accessor_class_suppressed.cc +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -11,23 +11,25 @@ #include "grib_accessor_class_suppressed.h" -grib_accessor_class_suppressed_t _grib_accessor_class_suppressed{"suppressed"}; +grib_accessor_class_suppressed_t _grib_accessor_class_suppressed{ "suppressed" }; grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_suppressed; -void grib_accessor_class_suppressed_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_suppressed_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; - self->args = c; + self->args = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; } -void log_message(grib_accessor* a){ +static void log_message(grib_accessor* a) +{ grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; - int i = 0; - grib_handle* hand = grib_handle_of_accessor(a); + int i = 0; + grib_handle* hand = grib_handle_of_accessor(a); grib_context_log(a->context, GRIB_LOG_ERROR, "key '%s' is unavailable in this version.", a->name); @@ -40,26 +42,31 @@ void log_message(grib_accessor* a){ } } -int grib_accessor_class_suppressed_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_suppressed_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ log_message(a); return GRIB_NOT_FOUND; } -int grib_accessor_class_suppressed_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_suppressed_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ log_message(a); return GRIB_NOT_FOUND; } -int grib_accessor_class_suppressed_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_suppressed_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ log_message(a); return GRIB_NOT_FOUND; } -int grib_accessor_class_suppressed_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_suppressed_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -int grib_accessor_class_suppressed_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_suppressed_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } From d6562ddcd6a29f5bcc0d945e10893be622d65b34 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 8 May 2024 15:55:54 +0000 Subject: [PATCH 51/90] ECC-1823: GRIB2: Add climatological albedo local ECMWF parameter to pseudocentre ERA6 --- definitions/grib2/localConcepts/era6/cfName.def | 8 ++++++++ definitions/grib2/localConcepts/era6/name.def | 8 ++++++++ definitions/grib2/localConcepts/era6/paramId.def | 8 ++++++++ definitions/grib2/localConcepts/era6/shortName.def | 8 ++++++++ definitions/grib2/localConcepts/era6/units.def | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/definitions/grib2/localConcepts/era6/cfName.def b/definitions/grib2/localConcepts/era6/cfName.def index b4593411b..04675741a 100644 --- a/definitions/grib2/localConcepts/era6/cfName.def +++ b/definitions/grib2/localConcepts/era6/cfName.def @@ -42,6 +42,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'surface_albedo' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'lwe_thickness_of_water_evaporation_amount' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/name.def b/definitions/grib2/localConcepts/era6/name.def index a716f4abd..b5c4fefb8 100644 --- a/definitions/grib2/localConcepts/era6/name.def +++ b/definitions/grib2/localConcepts/era6/name.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'Albedo (climatological)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'Evaporation' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/paramId.def b/definitions/grib2/localConcepts/era6/paramId.def index 48ebc11f2..85dc31997 100644 --- a/definitions/grib2/localConcepts/era6/paramId.def +++ b/definitions/grib2/localConcepts/era6/paramId.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'174' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation '182' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/shortName.def b/definitions/grib2/localConcepts/era6/shortName.def index 02efcff3c..0b9c836b9 100644 --- a/definitions/grib2/localConcepts/era6/shortName.def +++ b/definitions/grib2/localConcepts/era6/shortName.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'al' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'e' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/units.def b/definitions/grib2/localConcepts/era6/units.def index 828da275e..699b0c19a 100644 --- a/definitions/grib2/localConcepts/era6/units.def +++ b/definitions/grib2/localConcepts/era6/units.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'm of water equivalent' = { localTablesVersion = 1 ; From e47f0922f42e4eb328782c5ceaa3df69dcc79849 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 9 May 2024 12:51:25 +0100 Subject: [PATCH 52/90] Move functions from header to local static. Use 'pragma once' --- src/accessor/grib_accessor_class_ibmfloat.cc | 91 ++++++++++++++----- src/accessor/grib_accessor_class_ibmfloat.h | 36 +------- src/accessor/grib_accessor_class_ieeefloat.cc | 74 +++++++++++---- src/accessor/grib_accessor_class_ieeefloat.h | 34 +------ 4 files changed, 124 insertions(+), 111 deletions(-) diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index f3b0f8b98..c5766db01 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -11,37 +11,72 @@ #include "grib_accessor_class_ibmfloat.h" -grib_accessor_class_ibmfloat_t _grib_accessor_class_ibmfloat{"ibmfloat"}; +grib_accessor_class_ibmfloat_t _grib_accessor_class_ibmfloat{ "ibmfloat" }; grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmfloat; -void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_double_t::init(a, len, arg); grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; - long count = 0; + long count = 0; self->arg = arg; - a->value_count(&count); a->length = 4 * count; + a->value_count(&count); + a->length = 4 * count; Assert(a->length >= 0); } -int grib_accessor_class_ibmfloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + unsigned long rlen = 0; + long count = 0; + int err = 0; + unsigned long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&count); + if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ibmfloat_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_ibmfloat_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_ibmfloat_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = *len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; + + int ret = 0; + unsigned long i = 0; + unsigned long rlen = *len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); @@ -50,11 +85,10 @@ int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* } if (rlen == 1) { - - //double x = 0; - //grib_nearest_smaller_ibm_float(val[0],&x); - //double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); - //printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); + // double x = 0; + // grib_nearest_smaller_ibm_float(val[0],&x); + // double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); + // printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); off = a->byte_offset() * 8; ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); @@ -87,11 +121,13 @@ int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* return ret; } -long grib_accessor_class_ibmfloat_t::byte_count(grib_accessor* a){ +long grib_accessor_class_ibmfloat_t::byte_count(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_ibmfloat_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_ibmfloat_t::value_count(grib_accessor* a, long* len) +{ grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; *len = 0; if (!self->arg) { @@ -101,19 +137,24 @@ int grib_accessor_class_ibmfloat_t::value_count(grib_accessor* a, long* len){ return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -long grib_accessor_class_ibmfloat_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_ibmfloat_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_ibmfloat_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_ibmfloat_t::update_size(grib_accessor* a, size_t s) +{ a->length = (long)s; Assert(a->length >= 0); } -long grib_accessor_class_ibmfloat_t::next_offset(grib_accessor* a){ - return a->byte_offset() + a->byte_count();} +long grib_accessor_class_ibmfloat_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} -int grib_accessor_class_ibmfloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest){ +int grib_accessor_class_ibmfloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest) +{ int ret = 0; if (grib_nearest_smaller_ibm_float(val, nearest) == GRIB_INTERNAL_ERROR) { grib_context_log(a->context, GRIB_LOG_ERROR, "ibm_float:nearest_smaller_value overflow value=%g", val); diff --git a/src/accessor/grib_accessor_class_ibmfloat.h b/src/accessor/grib_accessor_class_ibmfloat.h index 9291d30a3..66bd01132 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.h +++ b/src/accessor/grib_accessor_class_ibmfloat.h @@ -8,10 +8,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_ibmfloat_h -#define eccodes_accessor_ibmfloat_h +#pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_double.h" class grib_accessor_ibmfloat_t : public grib_accessor_double_t @@ -36,36 +34,4 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; int nearest_smaller_value(grib_accessor*, double, double*) override; -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_ibmfloat_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - unsigned long rlen = 0; - long count = 0; - int err = 0; - unsigned long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&count); if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -#endif /* eccodes_accessor_ibmfloat_h */ diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index 53894a8a6..64b08fe50 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -11,20 +11,23 @@ #include "grib_accessor_class_ieeefloat.h" -grib_accessor_class_ieeefloat_t _grib_accessor_class_ieeefloat{"ieeefloat"}; +grib_accessor_class_ieeefloat_t _grib_accessor_class_ieeefloat{ "ieeefloat" }; grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeefloat; -void grib_accessor_class_ieeefloat_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_ieeefloat_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_double_t::init(a, len, arg); grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; - long count = 0; - self->arg = arg; - a->value_count(&count); a->length = 4 * count; + long count = 0; + self->arg = arg; + a->value_count(&count); + a->length = 4 * count; Assert(a->length >= 0); } -int grib_accessor_class_ieeefloat_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_ieeefloat_t::value_count(grib_accessor* a, long* len) +{ grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; *len = 0; @@ -35,14 +38,16 @@ int grib_accessor_class_ieeefloat_t::value_count(grib_accessor* a, long* len){ return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = (unsigned long)*len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; + + int ret = 0; + unsigned long i = 0; + unsigned long rlen = (unsigned long)*len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; if (*len < 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); @@ -55,7 +60,7 @@ int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ieee_to_long(val[0]), &off, 32); if (*len > 1) grib_context_log(a->context, GRIB_LOG_WARNING, "ieeefloat: Trying to pack %zu values in a scalar %s, packing first value", - *len, a->name); + *len, a->name); if (ret == GRIB_SUCCESS) len[0] = 1; return ret; @@ -80,19 +85,52 @@ int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* return ret; } -int grib_accessor_class_ieeefloat_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + + long rlen = 0; + int err = 0; + long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&rlen); + if (err) + return err; + + if (*len < (size_t)rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ieeefloat_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ return unpack(a, val, len); } -int grib_accessor_class_ieeefloat_t::unpack_float(grib_accessor* a, float* val, size_t* len){ +int grib_accessor_class_ieeefloat_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ return unpack(a, val, len); } -void grib_accessor_class_ieeefloat_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_ieeefloat_t::update_size(grib_accessor* a, size_t s) +{ a->length = (long)s; Assert(a->length >= 0); } -int grib_accessor_class_ieeefloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest){ +int grib_accessor_class_ieeefloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest) +{ return grib_nearest_smaller_ieee_float(val, nearest); } diff --git a/src/accessor/grib_accessor_class_ieeefloat.h b/src/accessor/grib_accessor_class_ieeefloat.h index 100b2ad6a..27536169f 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.h +++ b/src/accessor/grib_accessor_class_ieeefloat.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_ieeefloat_h -#define eccodes_accessor_ieeefloat_h +#pragma once #include "grib_accessor_class_double.h" @@ -32,35 +31,4 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; - -private: - template int unpack(grib_accessor*, T*, size_t*); }; - - -template -int grib_accessor_class_ieeefloat_t::unpack(grib_accessor* a, T* val, size_t* len){ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long rlen = 0; - int err = 0; - long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = a->value_count(&rlen); if (err) - return err; - - if (*len < (size_t)rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -#endif /* eccodes_accessor_ieeefloat_h */ From afb4271f49de142e6659a6be07a7d88bd0298c37 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 9 May 2024 13:23:08 +0100 Subject: [PATCH 53/90] Cosmetics --- src/accessor/grib_accessor_class_data_ccsds_packing.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h index c93c0d24c..d4d97bede 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.h +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -31,7 +31,6 @@ public: }; -// TODO(maee): if libaec is not available, this class should not be defined class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t { public: From 56617003675e6ba6b5e10bc5853c6f289e714792 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 10 May 2024 11:05:29 +0000 Subject: [PATCH 54/90] ECC-1820: Use 'pragma once' in all header files --- src/accessor/grib_accessor_class_abstract_long_vector.h | 4 +--- src/accessor/grib_accessor_class_abstract_vector.h | 4 +--- src/accessor/grib_accessor_class_ascii.h | 4 +--- src/accessor/grib_accessor_class_bit.h | 4 +--- src/accessor/grib_accessor_class_bitmap.h | 4 +--- src/accessor/grib_accessor_class_bits.h | 4 +--- src/accessor/grib_accessor_class_bits_per_value.h | 4 +--- src/accessor/grib_accessor_class_blob.h | 4 +--- src/accessor/grib_accessor_class_budgdate.h | 4 +--- src/accessor/grib_accessor_class_bufr_data_array.h | 5 +---- src/accessor/grib_accessor_class_bufr_data_element.h | 4 +--- src/accessor/grib_accessor_class_bufr_elements_table.h | 4 +--- src/accessor/grib_accessor_class_bufr_extract_area_subsets.h | 4 +--- .../grib_accessor_class_bufr_extract_datetime_subsets.h | 4 +--- src/accessor/grib_accessor_class_bufr_extract_subsets.h | 4 +--- src/accessor/grib_accessor_class_bufr_group.h | 4 +--- src/accessor/grib_accessor_class_bufr_simple_thinning.h | 4 +--- src/accessor/grib_accessor_class_bufr_string_values.h | 4 +--- .../grib_accessor_class_bufrdc_expanded_descriptors.h | 4 +--- src/accessor/grib_accessor_class_bytes.h | 4 +--- .../grib_accessor_class_change_alternative_row_scanning.h | 4 +--- src/accessor/grib_accessor_class_change_scanning_direction.h | 4 +--- src/accessor/grib_accessor_class_check_internal_version.h | 4 +--- src/accessor/grib_accessor_class_closest_date.h | 4 +--- src/accessor/grib_accessor_class_codeflag.h | 4 +--- src/accessor/grib_accessor_class_codetable_title.h | 4 +--- src/accessor/grib_accessor_class_codetable_units.h | 4 +--- src/accessor/grib_accessor_class_concept.h | 4 +--- src/accessor/grib_accessor_class_count_file.h | 4 +--- src/accessor/grib_accessor_class_count_missing.h | 4 +--- src/accessor/grib_accessor_class_count_total.h | 4 +--- src/accessor/grib_accessor_class_data_apply_bitmap.h | 1 - .../grib_accessor_class_data_apply_boustrophedonic.h | 1 - .../grib_accessor_class_data_apply_boustrophedonic_bitmap.h | 5 +---- src/accessor/grib_accessor_class_data_ccsds_packing.h | 1 - src/accessor/grib_accessor_class_data_complex_packing.h | 1 - src/accessor/grib_accessor_class_data_dummy_field.h | 5 +---- src/accessor/grib_accessor_class_data_g1complex_packing.h | 1 - ...cessor_class_data_g1second_order_constant_width_packing.h | 1 - ...ssor_class_data_g1second_order_general_extended_packing.h | 1 - ...grib_accessor_class_data_g1second_order_general_packing.h | 1 - ...b_accessor_class_data_g1second_order_row_by_row_packing.h | 1 - src/accessor/grib_accessor_class_data_g1secondary_bitmap.h | 1 - src/accessor/grib_accessor_class_data_g1shsimple_packing.h | 1 - src/accessor/grib_accessor_class_data_g1simple_packing.h | 1 - src/accessor/grib_accessor_class_data_g22order_packing.h | 1 - src/accessor/grib_accessor_class_data_g2bifourier_packing.h | 1 - src/accessor/grib_accessor_class_data_g2complex_packing.h | 1 - src/accessor/grib_accessor_class_data_g2secondary_bitmap.h | 1 - src/accessor/grib_accessor_class_data_g2shsimple_packing.h | 1 - src/accessor/grib_accessor_class_data_g2simple_packing.h | 4 +--- ...accessor_class_data_g2simple_packing_with_preprocessing.h | 1 - src/accessor/grib_accessor_class_data_jpeg2000_packing.h | 1 - src/accessor/grib_accessor_class_data_raw_packing.h | 1 - src/accessor/grib_accessor_class_data_run_length_packing.h | 1 - src/accessor/grib_accessor_class_data_secondary_bitmap.h | 1 - src/accessor/grib_accessor_class_data_sh_packed.h | 1 - src/accessor/grib_accessor_class_data_sh_unpacked.h | 1 - src/accessor/grib_accessor_class_data_shsimple_packing.h | 1 - src/accessor/grib_accessor_class_data_simple_packing.h | 1 - src/accessor/grib_accessor_class_decimal_precision.h | 5 +---- src/accessor/grib_accessor_class_dictionary.h | 5 +---- src/accessor/grib_accessor_class_dirty.h | 5 +---- src/accessor/grib_accessor_class_divdouble.h | 5 +---- src/accessor/grib_accessor_class_double.h | 5 +---- src/accessor/grib_accessor_class_element.h | 5 +---- src/accessor/grib_accessor_class_evaluate.h | 5 +---- src/accessor/grib_accessor_class_expanded_descriptors.h | 5 +---- .../grib_accessor_class_from_scale_factor_scaled_value.h | 4 +--- src/accessor/grib_accessor_class_g1_half_byte_codeflag.h | 4 +--- src/accessor/grib_accessor_class_g1_message_length.h | 4 +--- src/accessor/grib_accessor_class_g1_section4_length.h | 4 +--- src/accessor/grib_accessor_class_g1bitmap.h | 4 +--- src/accessor/grib_accessor_class_g1date.h | 4 +--- src/accessor/grib_accessor_class_g1day_of_the_year_date.h | 4 +--- src/accessor/grib_accessor_class_g1end_of_interval_monthly.h | 4 +--- src/accessor/grib_accessor_class_g1fcperiod.h | 4 +--- src/accessor/grib_accessor_class_g1forecastmonth.h | 4 +--- src/accessor/grib_accessor_class_g1monthlydate.h | 4 +--- ...grib_accessor_class_g1number_of_coded_values_sh_complex.h | 4 +--- .../grib_accessor_class_g1number_of_coded_values_sh_simple.h | 4 +--- src/accessor/grib_accessor_class_g1step_range.h | 4 +--- src/accessor/grib_accessor_class_g1verificationdate.h | 4 +--- src/accessor/grib_accessor_class_g2_aerosol.h | 4 +--- src/accessor/grib_accessor_class_g2_chemical.h | 4 +--- src/accessor/grib_accessor_class_g2_eps.h | 4 +--- src/accessor/grib_accessor_class_g2_mars_labeling.h | 4 +--- src/accessor/grib_accessor_class_g2bitmap.h | 4 +--- src/accessor/grib_accessor_class_g2bitmap_present.h | 4 +--- src/accessor/grib_accessor_class_g2date.h | 4 +--- src/accessor/grib_accessor_class_g2end_step.h | 4 +--- src/accessor/grib_accessor_class_g2grid.h | 4 +--- src/accessor/grib_accessor_class_g2latlon.h | 4 +--- src/accessor/grib_accessor_class_g2level.h | 4 +--- src/accessor/grib_accessor_class_g2lon.h | 4 +--- src/accessor/grib_accessor_class_g2step_range.h | 4 +--- src/accessor/grib_accessor_class_gaussian_grid_name.h | 4 +--- src/accessor/grib_accessor_class_gds_is_present.h | 4 +--- src/accessor/grib_accessor_class_gds_not_present_bitmap.h | 4 +--- src/accessor/grib_accessor_class_getenv.h | 4 +--- src/accessor/grib_accessor_class_global_gaussian.h | 4 +--- src/accessor/grib_accessor_class_group.h | 4 +--- src/accessor/grib_accessor_class_gts_header.h | 4 +--- src/accessor/grib_accessor_class_hash_array.h | 4 +--- src/accessor/grib_accessor_class_headers_only.h | 4 +--- src/accessor/grib_accessor_class_ifs_param.h | 4 +--- src/accessor/grib_accessor_class_julian_date.h | 4 +--- src/accessor/grib_accessor_class_julian_day.h | 4 +--- src/accessor/grib_accessor_class_ksec1expver.h | 4 +--- src/accessor/grib_accessor_class_label.h | 4 +--- src/accessor/grib_accessor_class_latitudes.h | 4 +--- src/accessor/grib_accessor_class_latlon_increment.h | 4 +--- src/accessor/grib_accessor_class_latlonvalues.h | 4 +--- src/accessor/grib_accessor_class_library_version.h | 4 +--- src/accessor/grib_accessor_class_local_definition.h | 4 +--- src/accessor/grib_accessor_class_long_vector.h | 4 +--- src/accessor/grib_accessor_class_longitudes.h | 4 +--- src/accessor/grib_accessor_class_lookup.h | 4 +--- src/accessor/grib_accessor_class_mars_param.h | 4 +--- src/accessor/grib_accessor_class_mars_step.h | 4 +--- src/accessor/grib_accessor_class_md5.h | 4 +--- src/accessor/grib_accessor_class_message.h | 4 +--- src/accessor/grib_accessor_class_message_copy.h | 4 +--- src/accessor/grib_accessor_class_multdouble.h | 4 +--- src/accessor/grib_accessor_class_non_alpha.h | 4 +--- src/accessor/grib_accessor_class_number_of_coded_values.h | 4 +--- src/accessor/grib_accessor_class_number_of_points.h | 4 +--- src/accessor/grib_accessor_class_number_of_points_gaussian.h | 4 +--- src/accessor/grib_accessor_class_number_of_values.h | 4 +--- .../grib_accessor_class_number_of_values_data_raw_packing.h | 4 +--- src/accessor/grib_accessor_class_octahedral_gaussian.h | 4 +--- src/accessor/grib_accessor_class_octet_number.h | 4 +--- src/accessor/grib_accessor_class_offset_file.h | 4 +--- src/accessor/grib_accessor_class_offset_values.h | 4 +--- src/accessor/grib_accessor_class_optimal_step_units.h | 4 +--- src/accessor/grib_accessor_class_pack_bufr_values.h | 4 +--- src/accessor/grib_accessor_class_packing_type.h | 4 +--- src/accessor/grib_accessor_class_pad.h | 4 +--- src/accessor/grib_accessor_class_padding.h | 4 +--- src/accessor/grib_accessor_class_padto.h | 4 +--- src/accessor/grib_accessor_class_padtoeven.h | 4 +--- src/accessor/grib_accessor_class_padtomultiple.h | 4 +--- src/accessor/grib_accessor_class_position.h | 4 +--- src/accessor/grib_accessor_class_proj_string.h | 4 +--- src/accessor/grib_accessor_class_raw.h | 4 +--- src/accessor/grib_accessor_class_rdbtime_guess_date.h | 4 +--- src/accessor/grib_accessor_class_reference_value_error.h | 4 +--- src/accessor/grib_accessor_class_round.h | 4 +--- src/accessor/grib_accessor_class_scale.h | 4 +--- src/accessor/grib_accessor_class_scale_values.h | 4 +--- .../grib_accessor_class_second_order_bits_per_value.h | 4 +--- src/accessor/grib_accessor_class_section.h | 4 +--- src/accessor/grib_accessor_class_section_length.h | 4 +--- src/accessor/grib_accessor_class_section_padding.h | 4 +--- src/accessor/grib_accessor_class_section_pointer.h | 4 +--- src/accessor/grib_accessor_class_select_step_template.h | 4 +--- src/accessor/grib_accessor_class_sexagesimal2decimal.h | 4 +--- src/accessor/grib_accessor_class_signed.h | 4 +--- src/accessor/grib_accessor_class_signed_bits.h | 4 +--- src/accessor/grib_accessor_class_simple_packing_error.h | 4 +--- src/accessor/grib_accessor_class_size.h | 4 +--- src/accessor/grib_accessor_class_smart_table_column.h | 4 +--- src/accessor/grib_accessor_class_spd.h | 4 +--- src/accessor/grib_accessor_class_spectral_truncation.h | 4 +--- src/accessor/grib_accessor_class_sprintf.h | 4 +--- src/accessor/grib_accessor_class_statistics.h | 4 +--- src/accessor/grib_accessor_class_statistics_spectral.h | 4 +--- src/accessor/grib_accessor_class_step_human_readable.h | 4 +--- src/accessor/grib_accessor_class_step_in_units.h | 4 +--- src/accessor/grib_accessor_class_sum.h | 4 +--- src/accessor/grib_accessor_class_suppressed.h | 4 +--- src/accessor/grib_accessor_class_time.h | 4 +--- src/accessor/grib_accessor_class_to_double.h | 4 +--- src/accessor/grib_accessor_class_to_integer.h | 4 +--- src/accessor/grib_accessor_class_to_string.h | 4 +--- src/accessor/grib_accessor_class_transient_darray.h | 4 +--- src/accessor/grib_accessor_class_trim.h | 4 +--- src/accessor/grib_accessor_class_uint16.h | 4 +--- src/accessor/grib_accessor_class_uint32.h | 4 +--- src/accessor/grib_accessor_class_uint32_little_endian.h | 4 +--- src/accessor/grib_accessor_class_uint64.h | 4 +--- src/accessor/grib_accessor_class_uint64_little_endian.h | 4 +--- src/accessor/grib_accessor_class_uint8.h | 4 +--- src/accessor/grib_accessor_class_unexpanded_descriptors.h | 4 +--- src/accessor/grib_accessor_class_unpack_bufr_values.h | 4 +--- src/accessor/grib_accessor_class_unsigned_bits.h | 4 +--- src/accessor/grib_accessor_class_validity_date.h | 4 +--- src/accessor/grib_accessor_class_validity_time.h | 4 +--- src/accessor/grib_accessor_class_vector.h | 4 +--- src/accessor/grib_accessor_class_when.h | 4 +--- 190 files changed, 164 insertions(+), 529 deletions(-) diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h b/src/accessor/grib_accessor_class_abstract_long_vector.h index 0585a5819..94ed9d636 100644 --- a/src/accessor/grib_accessor_class_abstract_long_vector.h +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_abstract_long_vector_h -#define eccodes_accessor_abstract_long_vector_h +#pragma once #include "grib_accessor_class_gen.h" @@ -29,4 +28,3 @@ public: grib_accessor_class_abstract_long_vector_t(const char* name) : grib_accessor_class_gen_t(name) {} grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; } }; -#endif /* eccodes_accessor_abstract_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_abstract_vector.h b/src/accessor/grib_accessor_class_abstract_vector.h index 7d5dd13df..b721a3adb 100644 --- a/src/accessor/grib_accessor_class_abstract_vector.h +++ b/src/accessor/grib_accessor_class_abstract_vector.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_abstract_vector_h -#define eccodes_accessor_abstract_vector_h +#pragma once #include "grib_accessor_class_double.h" @@ -28,4 +27,3 @@ public: grib_accessor_class_abstract_vector_t(const char* name) : grib_accessor_class_double_t(name) {} grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; } }; -#endif /* eccodes_accessor_abstract_vector_h */ diff --git a/src/accessor/grib_accessor_class_ascii.h b/src/accessor/grib_accessor_class_ascii.h index 1fa848236..8bef5eaac 100644 --- a/src/accessor/grib_accessor_class_ascii.h +++ b/src/accessor/grib_accessor_class_ascii.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_ascii_h -#define eccodes_accessor_ascii_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_ascii_h */ diff --git a/src/accessor/grib_accessor_class_bit.h b/src/accessor/grib_accessor_class_bit.h index 7ad258b03..188d5e370 100644 --- a/src/accessor/grib_accessor_class_bit.h +++ b/src/accessor/grib_accessor_class_bit.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bit_h -#define eccodes_accessor_bit_h +#pragma once #include "grib_accessor_class_long.h" @@ -31,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bit_h */ diff --git a/src/accessor/grib_accessor_class_bitmap.h b/src/accessor/grib_accessor_class_bitmap.h index 599e8c7ab..4f07f3a6c 100644 --- a/src/accessor/grib_accessor_class_bitmap.h +++ b/src/accessor/grib_accessor_class_bitmap.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bitmap_h -#define eccodes_accessor_bitmap_h +#pragma once #include "grib_accessor_class_bytes.h" @@ -41,4 +40,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_bits.h b/src/accessor/grib_accessor_class_bits.h index 2508e5ba0..19ec26b35 100644 --- a/src/accessor/grib_accessor_class_bits.h +++ b/src/accessor/grib_accessor_class_bits.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bits_h -#define eccodes_accessor_bits_h +#pragma once #include "grib_accessor_class_gen.h" @@ -41,4 +40,3 @@ public: long byte_count(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bits_h */ diff --git a/src/accessor/grib_accessor_class_bits_per_value.h b/src/accessor/grib_accessor_class_bits_per_value.h index dee7f76e3..741ecd0e5 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.h +++ b/src/accessor/grib_accessor_class_bits_per_value.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bits_per_value_h -#define eccodes_accessor_bits_per_value_h +#pragma once #include "grib_accessor_class_long.h" @@ -31,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_blob.h b/src/accessor/grib_accessor_class_blob.h index 9743ca17b..10dad4b7b 100644 --- a/src/accessor/grib_accessor_class_blob.h +++ b/src/accessor/grib_accessor_class_blob.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_blob_h -#define eccodes_accessor_blob_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_blob_h */ diff --git a/src/accessor/grib_accessor_class_budgdate.h b/src/accessor/grib_accessor_class_budgdate.h index 1b8103a03..ee18250e2 100644 --- a/src/accessor/grib_accessor_class_budgdate.h +++ b/src/accessor/grib_accessor_class_budgdate.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_budgdate_h -#define eccodes_accessor_budgdate_h +#pragma once #include "grib_accessor_class_long.h" @@ -32,4 +31,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_budgdate_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h b/src/accessor/grib_accessor_class_bufr_data_array.h index c6089fa63..75d02b9b4 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.h +++ b/src/accessor/grib_accessor_class_bufr_data_array.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_data_array_h -#define eccodes_accessor_bufr_data_array_h +#pragma once #include "grib_accessor_class_gen.h" @@ -89,4 +87,3 @@ grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); -#endif /* eccodes_accessor_bufr_data_array_h */ diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h index 4dd22a7d5..bbed1785b 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.h +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_data_element_h -#define eccodes_accessor_bufr_data_element_h +#pragma once #include "grib_accessor_class_gen.h" @@ -53,4 +52,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; }; -#endif /* eccodes_accessor_bufr_data_element_h */ diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h b/src/accessor/grib_accessor_class_bufr_elements_table.h index d29bc9192..4f133c9e4 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.h +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_elements_table_h -#define eccodes_accessor_bufr_elements_table_h +#pragma once #include "grib_accessor_class_gen.h" @@ -35,4 +34,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_elements_table_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h index b22452490..941f38ac0 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_extract_area_subsets_h -#define eccodes_accessor_bufr_extract_area_subsets_h +#pragma once #include "grib_accessor_class_gen.h" @@ -39,4 +38,3 @@ public: int pack_long(grib_accessor*, const long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_extract_area_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h index 5f4bf9dd7..765786cd2 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_extract_datetime_subsets_h -#define eccodes_accessor_bufr_extract_datetime_subsets_h +#pragma once #include "grib_accessor_class_gen.h" @@ -32,4 +31,3 @@ public: int pack_long(grib_accessor*, const long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_extract_datetime_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_subsets.h index 0d0f60fd7..3015d87ae 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.h +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_extract_subsets_h -#define eccodes_accessor_bufr_extract_subsets_h +#pragma once #include "grib_accessor_class_gen.h" @@ -33,4 +32,3 @@ public: int pack_long(grib_accessor*, const long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_extract_subsets_h */ diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h index 87f060282..758c5c772 100644 --- a/src/accessor/grib_accessor_class_bufr_group.h +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_group_h -#define eccodes_accessor_bufr_group_h +#pragma once #include "grib_accessor_class_variable.h" @@ -28,4 +27,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; grib_accessor* next(grib_accessor* a, int explore) override; }; -#endif /* eccodes_accessor_bufr_group_h */ diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h b/src/accessor/grib_accessor_class_bufr_simple_thinning.h index 5cb9f6144..9b7467914 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.h +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_simple_thinning_h -#define eccodes_accessor_bufr_simple_thinning_h +#pragma once #include "grib_accessor_class_gen.h" @@ -35,4 +34,3 @@ public: int pack_long(grib_accessor*, const long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_simple_thinning_h */ diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h b/src/accessor/grib_accessor_class_bufr_string_values.h index 387bafd1e..fe6c2acb7 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.h +++ b/src/accessor/grib_accessor_class_bufr_string_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufr_string_values_h -#define eccodes_accessor_bufr_string_values_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -34,4 +33,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufr_string_values_h */ diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h index fcc08fc91..92cf595ad 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bufrdc_expanded_descriptors_h -#define eccodes_accessor_bufrdc_expanded_descriptors_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: void destroy(grib_context*, grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_bufrdc_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_bytes.h b/src/accessor/grib_accessor_class_bytes.h index 558d52018..676cf55c4 100644 --- a/src/accessor/grib_accessor_class_bytes.h +++ b/src/accessor/grib_accessor_class_bytes.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_bytes_h -#define eccodes_accessor_bytes_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_bytes_h */ diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h index e2ecc7994..f889931a0 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_change_alternative_row_scanning_h -#define eccodes_accessor_change_alternative_row_scanning_h +#pragma once #include "grib_accessor_class_gen.h" @@ -34,4 +33,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_change_alternative_row_scanning_h */ diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h b/src/accessor/grib_accessor_class_change_scanning_direction.h index 0dae34341..ead274485 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.h +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_change_scanning_direction_h -#define eccodes_accessor_change_scanning_direction_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_change_scanning_direction_h */ diff --git a/src/accessor/grib_accessor_class_check_internal_version.h b/src/accessor/grib_accessor_class_check_internal_version.h index 46f9a29d5..d37b57282 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.h +++ b/src/accessor/grib_accessor_class_check_internal_version.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_check_internal_version_h -#define eccodes_accessor_check_internal_version_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -29,4 +28,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_check_internal_version_h */ diff --git a/src/accessor/grib_accessor_class_closest_date.h b/src/accessor/grib_accessor_class_closest_date.h index e5b65c683..ebd3cb6d4 100644 --- a/src/accessor/grib_accessor_class_closest_date.h +++ b/src/accessor/grib_accessor_class_closest_date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_closest_date_h -#define eccodes_accessor_closest_date_h +#pragma once #include "grib_accessor_class_double.h" @@ -39,4 +38,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_closest_date_h */ diff --git a/src/accessor/grib_accessor_class_codeflag.h b/src/accessor/grib_accessor_class_codeflag.h index f9465f703..82c8cc77b 100644 --- a/src/accessor/grib_accessor_class_codeflag.h +++ b/src/accessor/grib_accessor_class_codeflag.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_codeflag_h -#define eccodes_accessor_codeflag_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -30,4 +29,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_codetable_title.h b/src/accessor/grib_accessor_class_codetable_title.h index 4a2114579..f820c585c 100644 --- a/src/accessor/grib_accessor_class_codetable_title.h +++ b/src/accessor/grib_accessor_class_codetable_title.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_codetable_title_h -#define eccodes_accessor_codetable_title_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_codetable_title_h */ diff --git a/src/accessor/grib_accessor_class_codetable_units.h b/src/accessor/grib_accessor_class_codetable_units.h index d5207f532..0a8c9389d 100644 --- a/src/accessor/grib_accessor_class_codetable_units.h +++ b/src/accessor/grib_accessor_class_codetable_units.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_codetable_units_h -#define eccodes_accessor_codetable_units_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_codetable_units_h */ diff --git a/src/accessor/grib_accessor_class_concept.h b/src/accessor/grib_accessor_class_concept.h index e2d9b8474..7b9ea11d0 100644 --- a/src/accessor/grib_accessor_class_concept.h +++ b/src/accessor/grib_accessor_class_concept.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_concept_h -#define eccodes_accessor_concept_h +#pragma once #include "grib_accessor_class_gen.h" @@ -39,4 +38,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_concept_h */ diff --git a/src/accessor/grib_accessor_class_count_file.h b/src/accessor/grib_accessor_class_count_file.h index 727df09c2..25092b0a4 100644 --- a/src/accessor/grib_accessor_class_count_file.h +++ b/src/accessor/grib_accessor_class_count_file.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_count_file_h -#define eccodes_accessor_count_file_h +#pragma once #include "grib_accessor_class_long.h" @@ -28,4 +27,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_count_file_h */ diff --git a/src/accessor/grib_accessor_class_count_missing.h b/src/accessor/grib_accessor_class_count_missing.h index 405456843..3e2cf7330 100644 --- a/src/accessor/grib_accessor_class_count_missing.h +++ b/src/accessor/grib_accessor_class_count_missing.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_count_missing_h -#define eccodes_accessor_count_missing_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_count_missing_h */ diff --git a/src/accessor/grib_accessor_class_count_total.h b/src/accessor/grib_accessor_class_count_total.h index 4518f9703..6fa89df0e 100644 --- a/src/accessor/grib_accessor_class_count_total.h +++ b/src/accessor/grib_accessor_class_count_total.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_count_total_h -#define eccodes_accessor_count_total_h +#pragma once #include "grib_accessor_class_long.h" @@ -28,4 +27,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_count_total_h */ diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.h b/src/accessor/grib_accessor_class_data_apply_bitmap.h index a2d724ed7..f3bed1166 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h index 9b101e7ed..97987d217 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h index 5b26b3a4f..fee603876 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_apply_boustrophedonic_bitmap_h -#define eccodes_accessor_data_apply_boustrophedonic_bitmap_h +#pragma once #include "grib_accessor_class_gen.h" @@ -41,4 +39,3 @@ public: int unpack_double_element(grib_accessor*, size_t i, double* val) override; int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; }; -#endif /* eccodes_accessor_data_apply_boustrophedonic_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h index d4d97bede..0f9430232 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.h +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h b/src/accessor/grib_accessor_class_data_complex_packing.h index a8276311a..ee19b195c 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.h +++ b/src/accessor/grib_accessor_class_data_complex_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h b/src/accessor/grib_accessor_class_data_dummy_field.h index 2fac95235..c846abb98 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.h +++ b/src/accessor/grib_accessor_class_data_dummy_field.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_dummy_field_h -#define eccodes_accessor_data_dummy_field_h +#pragma once #include "grib_accessor_class_data_g1simple_packing.h" @@ -33,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_dummy_field_h */ diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h b/src/accessor/grib_accessor_class_data_g1complex_packing.h index 75ad18d66..51457e40e 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h index 0da32c286..8d2d53f0a 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h index 4bb6c061c..4bb50ae34 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h index 2e8bb3620..95295dae1 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h index 9b274a408..eca551669 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h index 562108986..63ee792ae 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h index 56e1ee47b..c852c7213 100644 --- a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h b/src/accessor/grib_accessor_class_data_g1simple_packing.h index 2dfedd6c9..c82532361 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.h +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h b/src/accessor/grib_accessor_class_data_g22order_packing.h index 39d01a70b..329823633 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.h +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h index b3ca0176a..2fd7378a5 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h b/src/accessor/grib_accessor_class_data_g2complex_packing.h index cfa0f8116..49f33a711 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.h +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h index 64428a4ce..f981e1e6c 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h index c0189ae66..02da8345e 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h b/src/accessor/grib_accessor_class_data_g2simple_packing.h index 4f27ab87c..a88cccac0 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing.h +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.h @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_data_g2simple_packing_h -#define eccodes_accessor_data_g2simple_packing_h +#pragma once #include "grib_accessor_class_data_simple_packing.h" @@ -25,4 +24,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_data_g2simple_packing_h */ diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h index 5825b9d16..4e2437e8b 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h index 6fc01b977..54dcc457c 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_raw_packing.h b/src/accessor/grib_accessor_class_data_raw_packing.h index 8012c1f51..b84650f28 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_data_raw_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h b/src/accessor/grib_accessor_class_data_run_length_packing.h index c35689abf..5a69a7ba0 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.h +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h b/src/accessor/grib_accessor_class_data_secondary_bitmap.h index 8bc156ef5..a24772be4 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.h +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h b/src/accessor/grib_accessor_class_data_sh_packed.h index 377db9ab4..bbe3caafe 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.h +++ b/src/accessor/grib_accessor_class_data_sh_packed.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h b/src/accessor/grib_accessor_class_data_sh_unpacked.h index b201e3dd3..7907b8c68 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.h +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h b/src/accessor/grib_accessor_class_data_shsimple_packing.h index e77612ddd..7b1620141 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.h +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h b/src/accessor/grib_accessor_class_data_simple_packing.h index 52761202d..3e50239a0 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.h +++ b/src/accessor/grib_accessor_class_data_simple_packing.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * diff --git a/src/accessor/grib_accessor_class_decimal_precision.h b/src/accessor/grib_accessor_class_decimal_precision.h index 741e32e83..a6b6d4839 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.h +++ b/src/accessor/grib_accessor_class_decimal_precision.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_decimal_precision_h -#define eccodes_accessor_decimal_precision_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +31,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_decimal_precision_h */ diff --git a/src/accessor/grib_accessor_class_dictionary.h b/src/accessor/grib_accessor_class_dictionary.h index 327c6fc72..8dc976e51 100644 --- a/src/accessor/grib_accessor_class_dictionary.h +++ b/src/accessor/grib_accessor_class_dictionary.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_dictionary_h -#define eccodes_accessor_dictionary_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +36,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_dictionary_h */ diff --git a/src/accessor/grib_accessor_class_dirty.h b/src/accessor/grib_accessor_class_dirty.h index 1e49bf0a4..b024b69f7 100644 --- a/src/accessor/grib_accessor_class_dirty.h +++ b/src/accessor/grib_accessor_class_dirty.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_dirty_h -#define eccodes_accessor_dirty_h +#pragma once #include "grib_accessor_class_long.h" @@ -30,4 +28,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_dirty_h */ diff --git a/src/accessor/grib_accessor_class_divdouble.h b/src/accessor/grib_accessor_class_divdouble.h index bc61e4012..9408b073a 100644 --- a/src/accessor/grib_accessor_class_divdouble.h +++ b/src/accessor/grib_accessor_class_divdouble.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_divdouble_h -#define eccodes_accessor_divdouble_h +#pragma once #include "grib_accessor_class_double.h" @@ -30,4 +28,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_divdouble_h */ diff --git a/src/accessor/grib_accessor_class_double.h b/src/accessor/grib_accessor_class_double.h index 1c1e2fb4f..7ad9771c2 100644 --- a/src/accessor/grib_accessor_class_double.h +++ b/src/accessor/grib_accessor_class_double.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_double_h -#define eccodes_accessor_double_h +#pragma once #include "grib_accessor_class_gen.h" @@ -27,4 +25,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_double_h */ diff --git a/src/accessor/grib_accessor_class_element.h b/src/accessor/grib_accessor_class_element.h index 20fa07fcc..220b8ff84 100644 --- a/src/accessor/grib_accessor_class_element.h +++ b/src/accessor/grib_accessor_class_element.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_element_h -#define eccodes_accessor_element_h +#pragma once #include "grib_accessor_class_long.h" @@ -32,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_element_h */ diff --git a/src/accessor/grib_accessor_class_evaluate.h b/src/accessor/grib_accessor_class_evaluate.h index d3a856881..0e40cf206 100644 --- a/src/accessor/grib_accessor_class_evaluate.h +++ b/src/accessor/grib_accessor_class_evaluate.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_evaluate_h -#define eccodes_accessor_evaluate_h +#pragma once #include "grib_accessor_class_long.h" @@ -29,4 +27,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_evaluate_h */ diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h b/src/accessor/grib_accessor_class_expanded_descriptors.h index b359a829f..7e42ad28c 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.h +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h @@ -1,4 +1,3 @@ - /* * (C) Copyright 2005- ECMWF. * @@ -9,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_expanded_descriptors_h -#define eccodes_accessor_expanded_descriptors_h +#pragma once #include "grib_accessor_class_long.h" @@ -43,4 +41,3 @@ public: void destroy(grib_context*, grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_expanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h index d73bffe02..d8dc1bcb8 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_from_scale_factor_scaled_value_h -#define eccodes_accessor_from_scale_factor_scaled_value_h +#pragma once #include "grib_accessor_class_double.h" @@ -33,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_from_scale_factor_scaled_value_h */ diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h index 765ddeb0b..662a75569 100644 --- a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1_half_byte_codeflag_h -#define eccodes_accessor_g1_half_byte_codeflag_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1_half_byte_codeflag_h */ diff --git a/src/accessor/grib_accessor_class_g1_message_length.h b/src/accessor/grib_accessor_class_g1_message_length.h index 38e85365e..9a24e3213 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.h +++ b/src/accessor/grib_accessor_class_g1_message_length.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1_message_length_h -#define eccodes_accessor_g1_message_length_h +#pragma once #include "grib_accessor_class_section_length.h" @@ -30,4 +29,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1_message_length_h */ diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h b/src/accessor/grib_accessor_class_g1_section4_length.h index 100f69157..9e805985c 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.h +++ b/src/accessor/grib_accessor_class_g1_section4_length.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1_section4_length_h -#define eccodes_accessor_g1_section4_length_h +#pragma once #include "grib_accessor_class_section_length.h" @@ -30,4 +29,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1_section4_length_h */ diff --git a/src/accessor/grib_accessor_class_g1bitmap.h b/src/accessor/grib_accessor_class_g1bitmap.h index 005114620..28914c591 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.h +++ b/src/accessor/grib_accessor_class_g1bitmap.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1bitmap_h -#define eccodes_accessor_g1bitmap_h +#pragma once #include "grib_accessor_class_bitmap.h" @@ -31,4 +30,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g1date.h b/src/accessor/grib_accessor_class_g1date.h index 6119ca99e..1195ac01c 100644 --- a/src/accessor/grib_accessor_class_g1date.h +++ b/src/accessor/grib_accessor_class_g1date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1date_h -#define eccodes_accessor_g1date_h +#pragma once #include "grib_accessor_class_long.h" @@ -35,4 +34,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1date_h */ diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h index a5564f968..5e484686c 100644 --- a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1day_of_the_year_date_h -#define eccodes_accessor_g1day_of_the_year_date_h +#pragma once #include "grib_accessor_class_g1date.h" @@ -29,4 +28,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1day_of_the_year_date_h */ diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h index a37edfbcf..baaea5320 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1end_of_interval_monthly_h -#define eccodes_accessor_g1end_of_interval_monthly_h +#pragma once #include "grib_accessor_class_abstract_vector.h" @@ -32,4 +31,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_g1end_of_interval_monthly_h */ diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h b/src/accessor/grib_accessor_class_g1fcperiod.h index 40810cb86..1b5b8dc7e 100644 --- a/src/accessor/grib_accessor_class_g1fcperiod.h +++ b/src/accessor/grib_accessor_class_g1fcperiod.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1fcperiod_h -#define eccodes_accessor_g1fcperiod_h +#pragma once #include "grib_accessor_class_g1step_range.h" @@ -27,4 +26,3 @@ public: grib_accessor* create_empty_accessor() override { return new grib_accessor_g1fcperiod_t{}; } int unpack_string(grib_accessor*, char*, size_t* len) override; }; -#endif /* eccodes_accessor_g1fcperiod_h */ diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h b/src/accessor/grib_accessor_class_g1forecastmonth.h index ff268febc..cd3a6d5f6 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.h +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1forecastmonth_h -#define eccodes_accessor_g1forecastmonth_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1forecastmonth_h */ diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h b/src/accessor/grib_accessor_class_g1monthlydate.h index 6148e4307..8503fa0af 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.h +++ b/src/accessor/grib_accessor_class_g1monthlydate.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1monthlydate_h -#define eccodes_accessor_g1monthlydate_h +#pragma once #include "grib_accessor_class_long.h" @@ -29,4 +28,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1monthlydate_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h index e8cdb50ca..97379631d 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1number_of_coded_values_sh_complex_h -#define eccodes_accessor_g1number_of_coded_values_sh_complex_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1number_of_coded_values_sh_complex_h */ diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h index f5cc84b02..4dafe6b15 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1number_of_coded_values_sh_simple_h -#define eccodes_accessor_g1number_of_coded_values_sh_simple_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1number_of_coded_values_sh_simple_h */ diff --git a/src/accessor/grib_accessor_class_g1step_range.h b/src/accessor/grib_accessor_class_g1step_range.h index 252a214ae..7ca19cb08 100644 --- a/src/accessor/grib_accessor_class_g1step_range.h +++ b/src/accessor/grib_accessor_class_g1step_range.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1step_range_h -#define eccodes_accessor_g1step_range_h +#pragma once #include "grib_accessor_class_abstract_long_vector.h" @@ -44,4 +43,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1step_range_h */ diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h b/src/accessor/grib_accessor_class_g1verificationdate.h index 1a97bf3c6..0e0469926 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.h +++ b/src/accessor/grib_accessor_class_g1verificationdate.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g1verificationdate_h -#define eccodes_accessor_g1verificationdate_h +#pragma once #include "grib_accessor_class_long.h" @@ -31,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g1verificationdate_h */ diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h b/src/accessor/grib_accessor_class_g2_aerosol.h index 96c1b4b9e..9fbd0c79b 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.h +++ b/src/accessor/grib_accessor_class_g2_aerosol.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2_aerosol_h -#define eccodes_accessor_g2_aerosol_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -33,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2_aerosol_h */ diff --git a/src/accessor/grib_accessor_class_g2_chemical.h b/src/accessor/grib_accessor_class_g2_chemical.h index 59df76928..66bf945aa 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.h +++ b/src/accessor/grib_accessor_class_g2_chemical.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2_chemical_h -#define eccodes_accessor_g2_chemical_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -33,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2_chemical_h */ diff --git a/src/accessor/grib_accessor_class_g2_eps.h b/src/accessor/grib_accessor_class_g2_eps.h index b651985b1..8453387fa 100644 --- a/src/accessor/grib_accessor_class_g2_eps.h +++ b/src/accessor/grib_accessor_class_g2_eps.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2_eps_h -#define eccodes_accessor_g2_eps_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -35,4 +34,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2_eps_h */ diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h b/src/accessor/grib_accessor_class_g2_mars_labeling.h index b3f7969bb..d47848565 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.h +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2_mars_labeling_h -#define eccodes_accessor_g2_mars_labeling_h +#pragma once #include "grib_accessor_class_gen.h" @@ -43,4 +42,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2_mars_labeling_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap.h b/src/accessor/grib_accessor_class_g2bitmap.h index 3c6f3e39c..2276b702c 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.h +++ b/src/accessor/grib_accessor_class_g2bitmap.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2bitmap_h -#define eccodes_accessor_g2bitmap_h +#pragma once #include "grib_accessor_class_bitmap.h" @@ -30,4 +29,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2bitmap_h */ diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h b/src/accessor/grib_accessor_class_g2bitmap_present.h index 8ac86bbb4..87d603f54 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.h +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2bitmap_present_h -#define eccodes_accessor_g2bitmap_present_h +#pragma once #include "grib_accessor_class_long.h" @@ -30,4 +29,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2bitmap_present_h */ diff --git a/src/accessor/grib_accessor_class_g2date.h b/src/accessor/grib_accessor_class_g2date.h index da4e6b379..e6981665c 100644 --- a/src/accessor/grib_accessor_class_g2date.h +++ b/src/accessor/grib_accessor_class_g2date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2date_h -#define eccodes_accessor_g2date_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2date_h */ diff --git a/src/accessor/grib_accessor_class_g2end_step.h b/src/accessor/grib_accessor_class_g2end_step.h index 756079631..d3a3b1433 100644 --- a/src/accessor/grib_accessor_class_g2end_step.h +++ b/src/accessor/grib_accessor_class_g2end_step.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2end_step_h -#define eccodes_accessor_g2end_step_h +#pragma once #include "grib_accessor_class_long.h" @@ -52,4 +51,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2end_step_h */ diff --git a/src/accessor/grib_accessor_class_g2grid.h b/src/accessor/grib_accessor_class_g2grid.h index ca1ef3e6c..07c9f9862 100644 --- a/src/accessor/grib_accessor_class_g2grid.h +++ b/src/accessor/grib_accessor_class_g2grid.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2grid_h -#define eccodes_accessor_g2grid_h +#pragma once #include "grib_accessor_class_double.h" @@ -38,4 +37,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2grid_h */ diff --git a/src/accessor/grib_accessor_class_g2latlon.h b/src/accessor/grib_accessor_class_g2latlon.h index 519b63b57..f4733757e 100644 --- a/src/accessor/grib_accessor_class_g2latlon.h +++ b/src/accessor/grib_accessor_class_g2latlon.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2latlon_h -#define eccodes_accessor_g2latlon_h +#pragma once #include "grib_accessor_class_double.h" @@ -34,4 +33,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2latlon_h */ diff --git a/src/accessor/grib_accessor_class_g2level.h b/src/accessor/grib_accessor_class_g2level.h index f0abf7e6e..55511b8f0 100644 --- a/src/accessor/grib_accessor_class_g2level.h +++ b/src/accessor/grib_accessor_class_g2level.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2level_h -#define eccodes_accessor_g2level_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2level_h */ diff --git a/src/accessor/grib_accessor_class_g2lon.h b/src/accessor/grib_accessor_class_g2lon.h index 409cc1297..d3f5bd8ff 100644 --- a/src/accessor/grib_accessor_class_g2lon.h +++ b/src/accessor/grib_accessor_class_g2lon.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2lon_h -#define eccodes_accessor_g2lon_h +#pragma once #include "grib_accessor_class_double.h" @@ -30,4 +29,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2lon_h */ diff --git a/src/accessor/grib_accessor_class_g2step_range.h b/src/accessor/grib_accessor_class_g2step_range.h index d15fa5e36..ec44546b3 100644 --- a/src/accessor/grib_accessor_class_g2step_range.h +++ b/src/accessor/grib_accessor_class_g2step_range.h @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_g2step_range_h -#define eccodes_accessor_g2step_range_h +#pragma once #include "grib_accessor_class_gen.h" @@ -36,4 +35,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_g2step_range_h */ diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h b/src/accessor/grib_accessor_class_gaussian_grid_name.h index abb505cb5..d67f80aa5 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.h +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_gaussian_grid_name_h -#define eccodes_accessor_gaussian_grid_name_h +#pragma once #include "grib_accessor_class_gen.h" @@ -33,4 +32,3 @@ public: size_t string_length(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_gaussian_grid_name_h */ diff --git a/src/accessor/grib_accessor_class_gds_is_present.h b/src/accessor/grib_accessor_class_gds_is_present.h index b7617a64d..d69619d44 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.h +++ b/src/accessor/grib_accessor_class_gds_is_present.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_gds_is_present_h -#define eccodes_accessor_gds_is_present_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_gds_is_present_h */ diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h index 03750bb03..bf9c0c012 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_gds_not_present_bitmap_h -#define eccodes_accessor_gds_not_present_bitmap_h +#pragma once #include "grib_accessor_class_gen.h" @@ -36,4 +35,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_gds_not_present_bitmap_h */ diff --git a/src/accessor/grib_accessor_class_getenv.h b/src/accessor/grib_accessor_class_getenv.h index 5068dad2c..b04c58a4d 100644 --- a/src/accessor/grib_accessor_class_getenv.h +++ b/src/accessor/grib_accessor_class_getenv.h @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_getenv_h -#define eccodes_accessor_getenv_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -33,4 +32,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_getenv_h */ diff --git a/src/accessor/grib_accessor_class_global_gaussian.h b/src/accessor/grib_accessor_class_global_gaussian.h index 8c9d37f13..1d49c0c32 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.h +++ b/src/accessor/grib_accessor_class_global_gaussian.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_global_gaussian_h -#define eccodes_accessor_global_gaussian_h +#pragma once #include "grib_accessor_class_long.h" @@ -40,4 +39,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_global_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_group.h b/src/accessor/grib_accessor_class_group.h index 3d718fdfa..9f1c31a81 100644 --- a/src/accessor/grib_accessor_class_group.h +++ b/src/accessor/grib_accessor_class_group.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_group_h -#define eccodes_accessor_group_h +#pragma once #include "grib_accessor_class_gen.h" @@ -37,4 +36,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_group_h */ diff --git a/src/accessor/grib_accessor_class_gts_header.h b/src/accessor/grib_accessor_class_gts_header.h index 3027def40..8072986a7 100644 --- a/src/accessor/grib_accessor_class_gts_header.h +++ b/src/accessor/grib_accessor_class_gts_header.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_gts_header_h -#define eccodes_accessor_gts_header_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -32,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_gts_header_h */ diff --git a/src/accessor/grib_accessor_class_hash_array.h b/src/accessor/grib_accessor_class_hash_array.h index f3791d91f..fa2732cac 100644 --- a/src/accessor/grib_accessor_class_hash_array.h +++ b/src/accessor/grib_accessor_class_hash_array.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_hash_array_h -#define eccodes_accessor_hash_array_h +#pragma once #include "grib_accessor_class_gen.h" @@ -41,4 +40,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_hash_array_h */ diff --git a/src/accessor/grib_accessor_class_headers_only.h b/src/accessor/grib_accessor_class_headers_only.h index d972319c5..a7dc81891 100644 --- a/src/accessor/grib_accessor_class_headers_only.h +++ b/src/accessor/grib_accessor_class_headers_only.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_headers_only_h -#define eccodes_accessor_headers_only_h +#pragma once #include "grib_accessor_class_gen.h" @@ -29,4 +28,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_headers_only_h */ diff --git a/src/accessor/grib_accessor_class_ifs_param.h b/src/accessor/grib_accessor_class_ifs_param.h index 1c86b8561..2beb90925 100644 --- a/src/accessor/grib_accessor_class_ifs_param.h +++ b/src/accessor/grib_accessor_class_ifs_param.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_ifs_param_h -#define eccodes_accessor_ifs_param_h +#pragma once #include "grib_accessor_class_gen.h" @@ -32,4 +31,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_ifs_param_h */ diff --git a/src/accessor/grib_accessor_class_julian_date.h b/src/accessor/grib_accessor_class_julian_date.h index b555ee9dc..c52380e10 100644 --- a/src/accessor/grib_accessor_class_julian_date.h +++ b/src/accessor/grib_accessor_class_julian_date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_julian_date_h -#define eccodes_accessor_julian_date_h +#pragma once #include "grib_accessor_class_double.h" @@ -44,4 +43,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_julian_date_h */ diff --git a/src/accessor/grib_accessor_class_julian_day.h b/src/accessor/grib_accessor_class_julian_day.h index 6bb48344f..5d06753b0 100644 --- a/src/accessor/grib_accessor_class_julian_day.h +++ b/src/accessor/grib_accessor_class_julian_day.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_julian_day_h -#define eccodes_accessor_julian_day_h +#pragma once #include "grib_accessor_class_double.h" @@ -36,4 +35,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_julian_day_h */ diff --git a/src/accessor/grib_accessor_class_ksec1expver.h b/src/accessor/grib_accessor_class_ksec1expver.h index 7225613a5..098a40a14 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.h +++ b/src/accessor/grib_accessor_class_ksec1expver.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_ksec1expver_h -#define eccodes_accessor_ksec1expver_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -30,4 +29,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_ksec1expver_h */ diff --git a/src/accessor/grib_accessor_class_label.h b/src/accessor/grib_accessor_class_label.h index 058ce9a11..59590e77c 100644 --- a/src/accessor/grib_accessor_class_label.h +++ b/src/accessor/grib_accessor_class_label.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_label_h -#define eccodes_accessor_label_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_label_h */ diff --git a/src/accessor/grib_accessor_class_latitudes.h b/src/accessor/grib_accessor_class_latitudes.h index 1b55b5210..cb1f6ada8 100644 --- a/src/accessor/grib_accessor_class_latitudes.h +++ b/src/accessor/grib_accessor_class_latitudes.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_latitudes_h -#define eccodes_accessor_latitudes_h +#pragma once #include "grib_accessor_class_double.h" @@ -34,4 +33,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_latitudes_h */ diff --git a/src/accessor/grib_accessor_class_latlon_increment.h b/src/accessor/grib_accessor_class_latlon_increment.h index 3c189450d..8dfa7cb93 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.h +++ b/src/accessor/grib_accessor_class_latlon_increment.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_latlon_increment_h -#define eccodes_accessor_latlon_increment_h +#pragma once #include "grib_accessor_class_double.h" @@ -39,4 +38,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_latlon_increment_h */ diff --git a/src/accessor/grib_accessor_class_latlonvalues.h b/src/accessor/grib_accessor_class_latlonvalues.h index 0109e7e86..7328688c6 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.h +++ b/src/accessor/grib_accessor_class_latlonvalues.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_latlonvalues_h -#define eccodes_accessor_latlonvalues_h +#pragma once #include "grib_accessor_class_double.h" @@ -30,4 +29,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_latlonvalues_h */ diff --git a/src/accessor/grib_accessor_class_library_version.h b/src/accessor/grib_accessor_class_library_version.h index d4c56b52c..cb2a45f04 100644 --- a/src/accessor/grib_accessor_class_library_version.h +++ b/src/accessor/grib_accessor_class_library_version.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_library_version_h -#define eccodes_accessor_library_version_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -29,4 +28,3 @@ public: size_t string_length(grib_accessor*) override; int value_count(grib_accessor*, long*) override; }; -#endif /* eccodes_accessor_library_version_h */ diff --git a/src/accessor/grib_accessor_class_local_definition.h b/src/accessor/grib_accessor_class_local_definition.h index 6ca10add6..f91ebbef4 100644 --- a/src/accessor/grib_accessor_class_local_definition.h +++ b/src/accessor/grib_accessor_class_local_definition.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_local_definition_h -#define eccodes_accessor_local_definition_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -39,4 +38,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_local_definition_h */ diff --git a/src/accessor/grib_accessor_class_long_vector.h b/src/accessor/grib_accessor_class_long_vector.h index aacd5e06e..010a4ed7e 100644 --- a/src/accessor/grib_accessor_class_long_vector.h +++ b/src/accessor/grib_accessor_class_long_vector.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_long_vector_h -#define eccodes_accessor_long_vector_h +#pragma once #include "grib_accessor_class_abstract_long_vector.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_long_vector_h */ diff --git a/src/accessor/grib_accessor_class_longitudes.h b/src/accessor/grib_accessor_class_longitudes.h index a1964ea51..def174a74 100644 --- a/src/accessor/grib_accessor_class_longitudes.h +++ b/src/accessor/grib_accessor_class_longitudes.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_longitudes_h -#define eccodes_accessor_longitudes_h +#pragma once #include "grib_accessor_class_double.h" @@ -34,4 +33,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_longitudes_h */ diff --git a/src/accessor/grib_accessor_class_lookup.h b/src/accessor/grib_accessor_class_lookup.h index 1fba42fe5..be1663ae7 100644 --- a/src/accessor/grib_accessor_class_lookup.h +++ b/src/accessor/grib_accessor_class_lookup.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_lookup_h -#define eccodes_accessor_lookup_h +#pragma once #include "grib_accessor_class_long.h" @@ -37,4 +36,3 @@ public: void post_init(grib_accessor*) override; int notify_change(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_lookup_h */ diff --git a/src/accessor/grib_accessor_class_mars_param.h b/src/accessor/grib_accessor_class_mars_param.h index d56488c0a..1eab50fb6 100644 --- a/src/accessor/grib_accessor_class_mars_param.h +++ b/src/accessor/grib_accessor_class_mars_param.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_mars_param_h -#define eccodes_accessor_mars_param_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -32,4 +31,3 @@ public: size_t string_length(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_mars_param_h */ diff --git a/src/accessor/grib_accessor_class_mars_step.h b/src/accessor/grib_accessor_class_mars_step.h index 5a570203f..8a49f56a6 100644 --- a/src/accessor/grib_accessor_class_mars_step.h +++ b/src/accessor/grib_accessor_class_mars_step.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_mars_step_h -#define eccodes_accessor_mars_step_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -36,4 +35,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_mars_step_h */ diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h index fdfc70718..ae66f397f 100644 --- a/src/accessor/grib_accessor_class_md5.h +++ b/src/accessor/grib_accessor_class_md5.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_md5_h -#define eccodes_accessor_md5_h +#pragma once #include "grib_accessor_class_gen.h" @@ -35,4 +34,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_md5_h */ diff --git a/src/accessor/grib_accessor_class_message.h b/src/accessor/grib_accessor_class_message.h index 478c01964..2e29d6ebd 100644 --- a/src/accessor/grib_accessor_class_message.h +++ b/src/accessor/grib_accessor_class_message.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_message_h -#define eccodes_accessor_message_h +#pragma once #include "grib_accessor_class_bytes.h" @@ -32,4 +31,3 @@ public: void update_size(grib_accessor*, size_t) override; void resize(grib_accessor*,size_t) override; }; -#endif /* eccodes_accessor_message_h */ diff --git a/src/accessor/grib_accessor_class_message_copy.h b/src/accessor/grib_accessor_class_message_copy.h index fa4110a1c..608817a93 100644 --- a/src/accessor/grib_accessor_class_message_copy.h +++ b/src/accessor/grib_accessor_class_message_copy.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_message_copy_h -#define eccodes_accessor_message_copy_h +#pragma once #include "grib_accessor_class_gen.h" @@ -32,4 +31,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_message_copy_h */ diff --git a/src/accessor/grib_accessor_class_multdouble.h b/src/accessor/grib_accessor_class_multdouble.h index 5cc218aac..025daf903 100644 --- a/src/accessor/grib_accessor_class_multdouble.h +++ b/src/accessor/grib_accessor_class_multdouble.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_multdouble_h -#define eccodes_accessor_multdouble_h +#pragma once #include "grib_accessor_class_double.h" @@ -30,4 +29,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_multdouble_h */ diff --git a/src/accessor/grib_accessor_class_non_alpha.h b/src/accessor/grib_accessor_class_non_alpha.h index 72674ac5d..83b1ca9ba 100644 --- a/src/accessor/grib_accessor_class_non_alpha.h +++ b/src/accessor/grib_accessor_class_non_alpha.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_non_alpha_h -#define eccodes_accessor_non_alpha_h +#pragma once #include "grib_accessor_class_gen.h" @@ -35,4 +34,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_non_alpha_h */ diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h b/src/accessor/grib_accessor_class_number_of_coded_values.h index 1d46cdd6b..6578e1dcf 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.h +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_number_of_coded_values_h -#define eccodes_accessor_number_of_coded_values_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_number_of_coded_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points.h b/src/accessor/grib_accessor_class_number_of_points.h index 4adaddaa2..f55d9bbeb 100644 --- a/src/accessor/grib_accessor_class_number_of_points.h +++ b/src/accessor/grib_accessor_class_number_of_points.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_number_of_points_h -#define eccodes_accessor_number_of_points_h +#pragma once #include "grib_accessor_class_long.h" @@ -32,4 +31,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_number_of_points_h */ diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h b/src/accessor/grib_accessor_class_number_of_points_gaussian.h index 48e63d28c..d00fb5b6e 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.h +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_number_of_points_gaussian_h -#define eccodes_accessor_number_of_points_gaussian_h +#pragma once #include "grib_accessor_class_long.h" @@ -38,4 +37,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_number_of_points_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values.h b/src/accessor/grib_accessor_class_number_of_values.h index 8b6418a9c..895669f34 100644 --- a/src/accessor/grib_accessor_class_number_of_values.h +++ b/src/accessor/grib_accessor_class_number_of_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_number_of_values_h -#define eccodes_accessor_number_of_values_h +#pragma once #include "grib_accessor_class_long.h" @@ -34,4 +33,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_number_of_values_h */ diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h index 0a4601852..798f428f5 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_number_of_values_data_raw_packing_h -#define eccodes_accessor_number_of_values_data_raw_packing_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_number_of_values_data_raw_packing_h */ diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h b/src/accessor/grib_accessor_class_octahedral_gaussian.h index f9c540018..cc7f52a25 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.h +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_octahedral_gaussian_h -#define eccodes_accessor_octahedral_gaussian_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_octahedral_gaussian_h */ diff --git a/src/accessor/grib_accessor_class_octet_number.h b/src/accessor/grib_accessor_class_octet_number.h index 35f536214..691dcb564 100644 --- a/src/accessor/grib_accessor_class_octet_number.h +++ b/src/accessor/grib_accessor_class_octet_number.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_octet_number_h -#define eccodes_accessor_octet_number_h +#pragma once #include "grib_accessor_class_long.h" @@ -31,4 +30,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_octet_number_h */ diff --git a/src/accessor/grib_accessor_class_offset_file.h b/src/accessor/grib_accessor_class_offset_file.h index 326559d81..6cb25b864 100644 --- a/src/accessor/grib_accessor_class_offset_file.h +++ b/src/accessor/grib_accessor_class_offset_file.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_offset_file_h -#define eccodes_accessor_offset_file_h +#pragma once #include "grib_accessor_class_double.h" @@ -29,4 +28,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_offset_file_h */ diff --git a/src/accessor/grib_accessor_class_offset_values.h b/src/accessor/grib_accessor_class_offset_values.h index 4fe2fc779..702e48da7 100644 --- a/src/accessor/grib_accessor_class_offset_values.h +++ b/src/accessor/grib_accessor_class_offset_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_offset_values_h -#define eccodes_accessor_offset_values_h +#pragma once #include "grib_accessor_class_double.h" @@ -31,4 +30,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_offset_values_h */ diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h b/src/accessor/grib_accessor_class_optimal_step_units.h index a62759390..e7aa35247 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.h +++ b/src/accessor/grib_accessor_class_optimal_step_units.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_optimal_step_units_h -#define eccodes_accessor_optimal_step_units_h +#pragma once #include "grib_accessor_class_gen.h" @@ -41,4 +40,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_optimal_step_units_h */ diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h b/src/accessor/grib_accessor_class_pack_bufr_values.h index 8cb218129..0a59a5141 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.h +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_pack_bufr_values_h -#define eccodes_accessor_pack_bufr_values_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_pack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_packing_type.h b/src/accessor/grib_accessor_class_packing_type.h index 2a454c1f4..7deb8f4cf 100644 --- a/src/accessor/grib_accessor_class_packing_type.h +++ b/src/accessor/grib_accessor_class_packing_type.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_packing_type_h -#define eccodes_accessor_packing_type_h +#pragma once #include "grib_accessor_class_gen.h" @@ -33,4 +32,3 @@ public: size_t string_length(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_packing_type_h */ diff --git a/src/accessor/grib_accessor_class_pad.h b/src/accessor/grib_accessor_class_pad.h index 08bf09727..5234e73a5 100644 --- a/src/accessor/grib_accessor_class_pad.h +++ b/src/accessor/grib_accessor_class_pad.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_pad_h -#define eccodes_accessor_pad_h +#pragma once #include "grib_accessor_class_padding.h" @@ -30,4 +29,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; size_t preferred_size(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_pad_h */ diff --git a/src/accessor/grib_accessor_class_padding.h b/src/accessor/grib_accessor_class_padding.h index 7544987e0..6d4175de3 100644 --- a/src/accessor/grib_accessor_class_padding.h +++ b/src/accessor/grib_accessor_class_padding.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_padding_h -#define eccodes_accessor_padding_h +#pragma once #include "grib_accessor_class_bytes.h" @@ -33,4 +32,3 @@ public: void resize(grib_accessor*,size_t) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_padding_h */ diff --git a/src/accessor/grib_accessor_class_padto.h b/src/accessor/grib_accessor_class_padto.h index fde8ebbef..a1b7b398a 100644 --- a/src/accessor/grib_accessor_class_padto.h +++ b/src/accessor/grib_accessor_class_padto.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_padto_h -#define eccodes_accessor_padto_h +#pragma once #include "grib_accessor_class_padding.h" @@ -30,4 +29,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; size_t preferred_size(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_padto_h */ diff --git a/src/accessor/grib_accessor_class_padtoeven.h b/src/accessor/grib_accessor_class_padtoeven.h index 5dff5ba39..9f42f5880 100644 --- a/src/accessor/grib_accessor_class_padtoeven.h +++ b/src/accessor/grib_accessor_class_padtoeven.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_padtoeven_h -#define eccodes_accessor_padtoeven_h +#pragma once #include "grib_accessor_class_padding.h" @@ -30,4 +29,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; size_t preferred_size(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_padtoeven_h */ diff --git a/src/accessor/grib_accessor_class_padtomultiple.h b/src/accessor/grib_accessor_class_padtomultiple.h index 5bcb0ea71..1de8e4059 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.h +++ b/src/accessor/grib_accessor_class_padtomultiple.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_padtomultiple_h -#define eccodes_accessor_padtomultiple_h +#pragma once #include "grib_accessor_class_padding.h" @@ -30,4 +29,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; size_t preferred_size(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_padtomultiple_h */ diff --git a/src/accessor/grib_accessor_class_position.h b/src/accessor/grib_accessor_class_position.h index 5597940b4..58e5beb24 100644 --- a/src/accessor/grib_accessor_class_position.h +++ b/src/accessor/grib_accessor_class_position.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_position_h -#define eccodes_accessor_position_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_position_h */ diff --git a/src/accessor/grib_accessor_class_proj_string.h b/src/accessor/grib_accessor_class_proj_string.h index 7205a8942..e214c32a9 100644 --- a/src/accessor/grib_accessor_class_proj_string.h +++ b/src/accessor/grib_accessor_class_proj_string.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_proj_string_h -#define eccodes_accessor_proj_string_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_proj_string_h */ diff --git a/src/accessor/grib_accessor_class_raw.h b/src/accessor/grib_accessor_class_raw.h index 5f4cc36ef..8a588ac61 100644 --- a/src/accessor/grib_accessor_class_raw.h +++ b/src/accessor/grib_accessor_class_raw.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_raw_h -#define eccodes_accessor_raw_h +#pragma once #include "grib_accessor_class_gen.h" @@ -37,4 +36,3 @@ public: void update_size(grib_accessor*, size_t) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_raw_h */ diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h b/src/accessor/grib_accessor_class_rdbtime_guess_date.h index 9cef89877..739c95e8d 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.h +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_rdbtime_guess_date_h -#define eccodes_accessor_rdbtime_guess_date_h +#pragma once #include "grib_accessor_class_long.h" @@ -34,4 +33,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_rdbtime_guess_date_h */ diff --git a/src/accessor/grib_accessor_class_reference_value_error.h b/src/accessor/grib_accessor_class_reference_value_error.h index bac786ca6..2a470562e 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.h +++ b/src/accessor/grib_accessor_class_reference_value_error.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_reference_value_error_h -#define eccodes_accessor_reference_value_error_h +#pragma once #include "grib_accessor_class_double.h" @@ -30,4 +29,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_reference_value_error_h */ diff --git a/src/accessor/grib_accessor_class_round.h b/src/accessor/grib_accessor_class_round.h index e235dfd85..364e24b34 100644 --- a/src/accessor/grib_accessor_class_round.h +++ b/src/accessor/grib_accessor_class_round.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_round_h -#define eccodes_accessor_round_h +#pragma once #include "grib_accessor_class_evaluate.h" @@ -28,4 +27,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; int unpack_string(grib_accessor*, char*, size_t* len) override; }; -#endif /* eccodes_accessor_round_h */ diff --git a/src/accessor/grib_accessor_class_scale.h b/src/accessor/grib_accessor_class_scale.h index e75fdb021..29b65f34b 100644 --- a/src/accessor/grib_accessor_class_scale.h +++ b/src/accessor/grib_accessor_class_scale.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_scale_h -#define eccodes_accessor_scale_h +#pragma once #include "grib_accessor_class_double.h" @@ -35,4 +34,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_scale_h */ diff --git a/src/accessor/grib_accessor_class_scale_values.h b/src/accessor/grib_accessor_class_scale_values.h index 4c807f696..f004db30e 100644 --- a/src/accessor/grib_accessor_class_scale_values.h +++ b/src/accessor/grib_accessor_class_scale_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_scale_values_h -#define eccodes_accessor_scale_values_h +#pragma once #include "grib_accessor_class_double.h" @@ -31,4 +30,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_scale_values_h */ diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h b/src/accessor/grib_accessor_class_second_order_bits_per_value.h index b5a38b417..c3459db41 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.h +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_second_order_bits_per_value_h -#define eccodes_accessor_second_order_bits_per_value_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_second_order_bits_per_value_h */ diff --git a/src/accessor/grib_accessor_class_section.h b/src/accessor/grib_accessor_class_section.h index b1905b182..8dbd831cc 100644 --- a/src/accessor/grib_accessor_class_section.h +++ b/src/accessor/grib_accessor_class_section.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_section_h -#define eccodes_accessor_section_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: grib_section* sub_section(grib_accessor*) override; grib_accessor* next(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_section_h */ diff --git a/src/accessor/grib_accessor_class_section_length.h b/src/accessor/grib_accessor_class_section_length.h index 0c56b4cb0..e7965b9b1 100644 --- a/src/accessor/grib_accessor_class_section_length.h +++ b/src/accessor/grib_accessor_class_section_length.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_section_length_h -#define eccodes_accessor_section_length_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -29,4 +28,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_section_length_h */ diff --git a/src/accessor/grib_accessor_class_section_padding.h b/src/accessor/grib_accessor_class_section_padding.h index f3ea9c821..f35da4977 100644 --- a/src/accessor/grib_accessor_class_section_padding.h +++ b/src/accessor/grib_accessor_class_section_padding.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_section_padding_h -#define eccodes_accessor_section_padding_h +#pragma once #include "grib_accessor_class_padding.h" @@ -29,4 +28,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; size_t preferred_size(grib_accessor*, int) override; }; -#endif /* eccodes_accessor_section_padding_h */ diff --git a/src/accessor/grib_accessor_class_section_pointer.h b/src/accessor/grib_accessor_class_section_pointer.h index e34125800..569e20201 100644 --- a/src/accessor/grib_accessor_class_section_pointer.h +++ b/src/accessor/grib_accessor_class_section_pointer.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_section_pointer_h -#define eccodes_accessor_section_pointer_h +#pragma once #include "grib_accessor_class_gen.h" @@ -34,4 +33,3 @@ public: long byte_offset(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_section_pointer_h */ diff --git a/src/accessor/grib_accessor_class_select_step_template.h b/src/accessor/grib_accessor_class_select_step_template.h index d2e58c757..e327a99da 100644 --- a/src/accessor/grib_accessor_class_select_step_template.h +++ b/src/accessor/grib_accessor_class_select_step_template.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_select_step_template_h -#define eccodes_accessor_select_step_template_h +#pragma once #include "grib_accessor_class_unsigned.h" @@ -32,4 +31,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_select_step_template_h */ diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h b/src/accessor/grib_accessor_class_sexagesimal2decimal.h index 0dec18f2c..d9051bca9 100644 --- a/src/accessor/grib_accessor_class_sexagesimal2decimal.h +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_sexagesimal2decimal_h -#define eccodes_accessor_sexagesimal2decimal_h +#pragma once #include "grib_accessor_class_to_double.h" @@ -30,4 +29,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_sexagesimal2decimal_h */ diff --git a/src/accessor/grib_accessor_class_signed.h b/src/accessor/grib_accessor_class_signed.h index 72d3c6657..9fbb6f8d2 100644 --- a/src/accessor/grib_accessor_class_signed.h +++ b/src/accessor/grib_accessor_class_signed.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_signed_h -#define eccodes_accessor_signed_h +#pragma once #include "grib_accessor_class_long.h" @@ -38,4 +37,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; }; -#endif /* eccodes_accessor_signed_h */ diff --git a/src/accessor/grib_accessor_class_signed_bits.h b/src/accessor/grib_accessor_class_signed_bits.h index d70a9a27a..dd49c5c75 100644 --- a/src/accessor/grib_accessor_class_signed_bits.h +++ b/src/accessor/grib_accessor_class_signed_bits.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_signed_bits_h -#define eccodes_accessor_signed_bits_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; }; -#endif /* eccodes_accessor_signed_bits_h */ diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h b/src/accessor/grib_accessor_class_simple_packing_error.h index 55f720b78..f0c005e03 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.h +++ b/src/accessor/grib_accessor_class_simple_packing_error.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_simple_packing_error_h -#define eccodes_accessor_simple_packing_error_h +#pragma once #include "grib_accessor_class_double.h" @@ -33,4 +32,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_simple_packing_error_h */ diff --git a/src/accessor/grib_accessor_class_size.h b/src/accessor/grib_accessor_class_size.h index 12914616e..9901c479e 100644 --- a/src/accessor/grib_accessor_class_size.h +++ b/src/accessor/grib_accessor_class_size.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_size_h -#define eccodes_accessor_size_h +#pragma once #include "grib_accessor_class_long.h" @@ -29,4 +28,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_size_h */ diff --git a/src/accessor/grib_accessor_class_smart_table_column.h b/src/accessor/grib_accessor_class_smart_table_column.h index f5787f780..9e1edcd2a 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.h +++ b/src/accessor/grib_accessor_class_smart_table_column.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_smart_table_column_h -#define eccodes_accessor_smart_table_column_h +#pragma once #include "grib_accessor_class_gen.h" @@ -34,4 +33,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_smart_table_column_h */ diff --git a/src/accessor/grib_accessor_class_spd.h b/src/accessor/grib_accessor_class_spd.h index 17ebb9b15..ee4fa5d12 100644 --- a/src/accessor/grib_accessor_class_spd.h +++ b/src/accessor/grib_accessor_class_spd.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_spd_h -#define eccodes_accessor_spd_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; }; -#endif /* eccodes_accessor_spd_h */ diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h b/src/accessor/grib_accessor_class_spectral_truncation.h index fb43b42d1..c9f85b9f8 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.h +++ b/src/accessor/grib_accessor_class_spectral_truncation.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_spectral_truncation_h -#define eccodes_accessor_spectral_truncation_h +#pragma once #include "grib_accessor_class_long.h" @@ -32,4 +31,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_spectral_truncation_h */ diff --git a/src/accessor/grib_accessor_class_sprintf.h b/src/accessor/grib_accessor_class_sprintf.h index c183db830..36d5f3e10 100644 --- a/src/accessor/grib_accessor_class_sprintf.h +++ b/src/accessor/grib_accessor_class_sprintf.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_sprintf_h -#define eccodes_accessor_sprintf_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -31,4 +30,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_sprintf_h */ diff --git a/src/accessor/grib_accessor_class_statistics.h b/src/accessor/grib_accessor_class_statistics.h index fcc866ca8..63d7cbc00 100644 --- a/src/accessor/grib_accessor_class_statistics.h +++ b/src/accessor/grib_accessor_class_statistics.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_statistics_h -#define eccodes_accessor_statistics_h +#pragma once #include "grib_accessor_class_abstract_vector.h" @@ -34,4 +33,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_statistics_h */ diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h b/src/accessor/grib_accessor_class_statistics_spectral.h index 1451a0d2e..41846c5c7 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.h +++ b/src/accessor/grib_accessor_class_statistics_spectral.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_statistics_spectral_h -#define eccodes_accessor_statistics_spectral_h +#pragma once #include "grib_accessor_class_abstract_vector.h" @@ -36,4 +35,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int compare(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_statistics_spectral_h */ diff --git a/src/accessor/grib_accessor_class_step_human_readable.h b/src/accessor/grib_accessor_class_step_human_readable.h index 4100f6008..cbd61ed31 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.h +++ b/src/accessor/grib_accessor_class_step_human_readable.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_step_human_readable_h -#define eccodes_accessor_step_human_readable_h +#pragma once #include "grib_accessor_class_gen.h" @@ -31,4 +30,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_step_human_readable_h */ diff --git a/src/accessor/grib_accessor_class_step_in_units.h b/src/accessor/grib_accessor_class_step_in_units.h index 0f8036d13..66f4b2b44 100644 --- a/src/accessor/grib_accessor_class_step_in_units.h +++ b/src/accessor/grib_accessor_class_step_in_units.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_step_in_units_h -#define eccodes_accessor_step_in_units_h +#pragma once #include "grib_accessor_class_long.h" @@ -39,4 +38,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_step_in_units_h */ diff --git a/src/accessor/grib_accessor_class_sum.h b/src/accessor/grib_accessor_class_sum.h index 5ee44d7a0..5667d8da9 100644 --- a/src/accessor/grib_accessor_class_sum.h +++ b/src/accessor/grib_accessor_class_sum.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_sum_h -#define eccodes_accessor_sum_h +#pragma once #include "grib_accessor_class_double.h" @@ -31,4 +30,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_sum_h */ diff --git a/src/accessor/grib_accessor_class_suppressed.h b/src/accessor/grib_accessor_class_suppressed.h index 5de58f430..5d764be35 100644 --- a/src/accessor/grib_accessor_class_suppressed.h +++ b/src/accessor/grib_accessor_class_suppressed.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_suppressed_h -#define eccodes_accessor_suppressed_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int value_count(grib_accessor*, long*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_suppressed_h */ diff --git a/src/accessor/grib_accessor_class_time.h b/src/accessor/grib_accessor_class_time.h index c343872b8..dee0325a9 100644 --- a/src/accessor/grib_accessor_class_time.h +++ b/src/accessor/grib_accessor_class_time.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_time_h -#define eccodes_accessor_time_h +#pragma once #include "grib_accessor_class_long.h" @@ -33,4 +32,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_time_h */ diff --git a/src/accessor/grib_accessor_class_to_double.h b/src/accessor/grib_accessor_class_to_double.h index 8b3d861e0..c8755c90f 100644 --- a/src/accessor/grib_accessor_class_to_double.h +++ b/src/accessor/grib_accessor_class_to_double.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_to_double_h -#define eccodes_accessor_to_double_h +#pragma once #include "grib_accessor_class_gen.h" @@ -39,4 +38,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_to_double_h */ diff --git a/src/accessor/grib_accessor_class_to_integer.h b/src/accessor/grib_accessor_class_to_integer.h index 38f909248..da8334e4f 100644 --- a/src/accessor/grib_accessor_class_to_integer.h +++ b/src/accessor/grib_accessor_class_to_integer.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_to_integer_h -#define eccodes_accessor_to_integer_h +#pragma once #include "grib_accessor_class_gen.h" @@ -41,4 +40,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_to_integer_h */ diff --git a/src/accessor/grib_accessor_class_to_string.h b/src/accessor/grib_accessor_class_to_string.h index 0a5077eb0..ea6981276 100644 --- a/src/accessor/grib_accessor_class_to_string.h +++ b/src/accessor/grib_accessor_class_to_string.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_to_string_h -#define eccodes_accessor_to_string_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_to_string_h */ diff --git a/src/accessor/grib_accessor_class_transient_darray.h b/src/accessor/grib_accessor_class_transient_darray.h index a1142dbe3..230dfa1a1 100644 --- a/src/accessor/grib_accessor_class_transient_darray.h +++ b/src/accessor/grib_accessor_class_transient_darray.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_transient_darray_h -#define eccodes_accessor_transient_darray_h +#pragma once #include "grib_accessor_class_gen.h" @@ -37,4 +36,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_transient_darray_h */ diff --git a/src/accessor/grib_accessor_class_trim.h b/src/accessor/grib_accessor_class_trim.h index df06a277f..d5c029a78 100644 --- a/src/accessor/grib_accessor_class_trim.h +++ b/src/accessor/grib_accessor_class_trim.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_trim_h -#define eccodes_accessor_trim_h +#pragma once #include "grib_accessor_class_ascii.h" @@ -33,4 +32,3 @@ public: size_t string_length(grib_accessor*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_trim_h */ diff --git a/src/accessor/grib_accessor_class_uint16.h b/src/accessor/grib_accessor_class_uint16.h index d77d2b6f6..05818ebbd 100644 --- a/src/accessor/grib_accessor_class_uint16.h +++ b/src/accessor/grib_accessor_class_uint16.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint16_h -#define eccodes_accessor_uint16_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint16_h */ diff --git a/src/accessor/grib_accessor_class_uint32.h b/src/accessor/grib_accessor_class_uint32.h index e327b275e..143dfc809 100644 --- a/src/accessor/grib_accessor_class_uint32.h +++ b/src/accessor/grib_accessor_class_uint32.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint32_h -#define eccodes_accessor_uint32_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint32_h */ diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h b/src/accessor/grib_accessor_class_uint32_little_endian.h index 554ea6a93..83e808bc5 100644 --- a/src/accessor/grib_accessor_class_uint32_little_endian.h +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint32_little_endian_h -#define eccodes_accessor_uint32_little_endian_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint32_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint64.h b/src/accessor/grib_accessor_class_uint64.h index 3e7779fa3..d442b736d 100644 --- a/src/accessor/grib_accessor_class_uint64.h +++ b/src/accessor/grib_accessor_class_uint64.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint64_h -#define eccodes_accessor_uint64_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint64_h */ diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h b/src/accessor/grib_accessor_class_uint64_little_endian.h index e2e1774b1..9e8f4327e 100644 --- a/src/accessor/grib_accessor_class_uint64_little_endian.h +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint64_little_endian_h -#define eccodes_accessor_uint64_little_endian_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint64_little_endian_h */ diff --git a/src/accessor/grib_accessor_class_uint8.h b/src/accessor/grib_accessor_class_uint8.h index fb18550e6..8a58b27f3 100644 --- a/src/accessor/grib_accessor_class_uint8.h +++ b/src/accessor/grib_accessor_class_uint8.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_uint8_h -#define eccodes_accessor_uint8_h +#pragma once #include "grib_accessor_class_gen.h" @@ -28,4 +27,3 @@ public: int get_native_type(grib_accessor*) override; int unpack_long(grib_accessor*, long* val, size_t* len) override; }; -#endif /* eccodes_accessor_uint8_h */ diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h b/src/accessor/grib_accessor_class_unexpanded_descriptors.h index eac0dbf6a..f9a016c1e 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.h +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_unexpanded_descriptors_h -#define eccodes_accessor_unexpanded_descriptors_h +#pragma once #include "grib_accessor_class_long.h" @@ -35,4 +34,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; }; -#endif /* eccodes_accessor_unexpanded_descriptors_h */ diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h b/src/accessor/grib_accessor_class_unpack_bufr_values.h index dde08dc9b..46dd91ec5 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.h +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_unpack_bufr_values_h -#define eccodes_accessor_unpack_bufr_values_h +#pragma once #include "grib_accessor_class_gen.h" @@ -38,4 +37,3 @@ public: void dump(grib_accessor*, grib_dumper*) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_unpack_bufr_values_h */ diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h b/src/accessor/grib_accessor_class_unsigned_bits.h index 3042ea3fa..52528ab83 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.h +++ b/src/accessor/grib_accessor_class_unsigned_bits.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_unsigned_bits_h -#define eccodes_accessor_unsigned_bits_h +#pragma once #include "grib_accessor_class_long.h" @@ -36,4 +35,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; void update_size(grib_accessor*, size_t) override; }; -#endif /* eccodes_accessor_unsigned_bits_h */ diff --git a/src/accessor/grib_accessor_class_validity_date.h b/src/accessor/grib_accessor_class_validity_date.h index ca2efb7c4..ca87b3282 100644 --- a/src/accessor/grib_accessor_class_validity_date.h +++ b/src/accessor/grib_accessor_class_validity_date.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_validity_date_h -#define eccodes_accessor_validity_date_h +#pragma once #include "grib_accessor_class_long.h" @@ -35,4 +34,3 @@ public: int unpack_long(grib_accessor*, long* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_validity_date_h */ diff --git a/src/accessor/grib_accessor_class_validity_time.h b/src/accessor/grib_accessor_class_validity_time.h index 7b998e595..023c3e30a 100644 --- a/src/accessor/grib_accessor_class_validity_time.h +++ b/src/accessor/grib_accessor_class_validity_time.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_validity_time_h -#define eccodes_accessor_validity_time_h +#pragma once #include "grib_accessor_class_long.h" @@ -35,4 +34,3 @@ public: int unpack_string(grib_accessor*, char*, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_validity_time_h */ diff --git a/src/accessor/grib_accessor_class_vector.h b/src/accessor/grib_accessor_class_vector.h index 12871fcc9..92dc6a13e 100644 --- a/src/accessor/grib_accessor_class_vector.h +++ b/src/accessor/grib_accessor_class_vector.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_vector_h -#define eccodes_accessor_vector_h +#pragma once #include "grib_accessor_class_abstract_vector.h" @@ -30,4 +29,3 @@ public: int unpack_double(grib_accessor*, double* val, size_t* len) override; void init(grib_accessor*, const long, grib_arguments*) override; }; -#endif /* eccodes_accessor_vector_h */ diff --git a/src/accessor/grib_accessor_class_when.h b/src/accessor/grib_accessor_class_when.h index 22c5bee97..515afb4b1 100644 --- a/src/accessor/grib_accessor_class_when.h +++ b/src/accessor/grib_accessor_class_when.h @@ -9,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#ifndef eccodes_accessor_when_h -#define eccodes_accessor_when_h +#pragma once #include "grib_accessor_class_gen.h" @@ -30,4 +29,3 @@ public: void init(grib_accessor*, const long, grib_arguments*) override; int notify_change(grib_accessor*, grib_accessor*) override; }; -#endif /* eccodes_accessor_when_h */ From 9d53a9e120b3468128f59f24d1bc8253f607bf0a Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 12:35:43 +0100 Subject: [PATCH 55/90] Compiler warnings re sprintf --- fortran/grib_fortran.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 3cb17739a..f5427df83 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -986,7 +986,7 @@ void grib_f_write_on_fail(int* gid) { file_count++; GRIB_MUTEX_UNLOCK(&handle_mutex) - sprintf(filename,"%ld_%d_error.grib",(long)pid,file_count); + snprintf(filename, sizeof(filename), "%ld_%d_error.grib",(long)pid,file_count); h=get_handle(*gid); if (h) grib_write_message(h,filename,"w"); @@ -1249,7 +1249,7 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) fort_char_clean(name, len); - sprintf(buf,"%s",grib_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s",grib_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; @@ -1321,7 +1321,7 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) fort_char_clean(name, len); - sprintf(buf, "%s", codes_bufr_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s", codes_bufr_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; From 98cf979823559e656bcdc1bd6bd88e1785c455fb Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 15:59:41 +0100 Subject: [PATCH 56/90] ECC-1820: grib_accessors_list.rank made private --- src/accessor/grib_accessors_list.cc | 10 +++++----- src/accessor/grib_accessors_list.h | 5 ++++- src/grib_query.cc | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc index 3ff166e42..c0114b255 100644 --- a/src/accessor/grib_accessors_list.cc +++ b/src/accessor/grib_accessors_list.cc @@ -46,14 +46,14 @@ void grib_accessors_list::push(grib_accessor* a, int rank) if (last && last->accessor) { last->next_ = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); last->next_->accessor = a; - last->next_->prev_ = last; - last->next_->rank = rank; - this->last_ = last->next_; + last->next_->prev_ = last; + last->next_->rank_ = rank; + this->last_ = last->next_; } else { this->accessor = a; - this->rank = rank; - this->last_ = this; + this->rank_ = rank; + this->last_ = this; } } diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h index 2bdd29de7..e136d955a 100644 --- a/src/accessor/grib_accessors_list.h +++ b/src/accessor/grib_accessors_list.h @@ -26,11 +26,14 @@ public: int unpack_float(float* val, size_t* buffer_len); int unpack_string(char** val, size_t* buffer_len); + int rank() const { return rank_; } + grib_accessor* accessor = nullptr; - int rank = 0; grib_accessors_list* next_ = nullptr; grib_accessors_list* prev_ = nullptr; grib_accessors_list* last_ = nullptr; +private: + int rank_ = 0; }; grib_accessors_list* grib_accessors_list_create(grib_context* c); diff --git a/src/grib_query.cc b/src/grib_query.cc index 29e3e1322..a1209efaf 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -384,7 +384,7 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces accessor_result = al->accessor; } if (accessor_result) { - result->push(accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } al = al->next_; @@ -398,7 +398,7 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces accessor_result = al->accessor; } if (accessor_result) { - result->push(accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } } @@ -453,7 +453,7 @@ static void grib_find_same_and_push(grib_accessors_list* al, grib_accessor* a) { if (a) { grib_find_same_and_push(al, a->same); - al->push(a, al->rank); + al->push(a, al->rank()); } } From 80d3a68ad1247ff8b459d0c46629dec209253fd4 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 16:05:15 +0100 Subject: [PATCH 57/90] Cosmetics --- src/accessor/grib_accessor_class_iterator.h | 6 ------ src/accessor/grib_accessor_class_nearest.h | 1 - src/accessor/grib_accessors_list.cc | 5 +++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/accessor/grib_accessor_class_iterator.h b/src/accessor/grib_accessor_class_iterator.h index 5f809c90e..03fbdf5b6 100644 --- a/src/accessor/grib_accessor_class_iterator.h +++ b/src/accessor/grib_accessor_class_iterator.h @@ -8,13 +8,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************** - * Enrico Fucile - *************************/ - #pragma once -#include "grib_api_internal.h" #include "grib_accessor_class_gen.h" class grib_accessor_iterator_t : public grib_accessor_gen_t @@ -32,5 +27,4 @@ public: void dump(grib_accessor* a, grib_dumper* dumper) override; }; - //grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) diff --git a/src/accessor/grib_accessor_class_nearest.h b/src/accessor/grib_accessor_class_nearest.h index efc7ebfc4..3ac4fdae2 100644 --- a/src/accessor/grib_accessor_class_nearest.h +++ b/src/accessor/grib_accessor_class_nearest.h @@ -28,5 +28,4 @@ public: void dump(grib_accessor* a, grib_dumper* dumper) override; }; - //grib_nearest* grib_nearest_new(const grib_handle* ch, int* error); diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc index c0114b255..173077e69 100644 --- a/src/accessor/grib_accessors_list.cc +++ b/src/accessor/grib_accessors_list.cc @@ -15,7 +15,8 @@ grib_accessors_list* grib_accessors_list_create(grib_context* c) return (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); } -void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) { +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) +{ grib_accessors_list* tmp; while (al) { tmp = al->next_; @@ -70,7 +71,7 @@ grib_accessors_list::~grib_accessors_list() grib_accessors_list* al = this; while (al) { tmp = al->next_; - //grib_accessor_delete(c, al->accessor); + // grib_accessor_delete(c, al->accessor); grib_context_free(c, al); al = tmp; } From ac80478fa4b8380915efd97b9ee084155920a485 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 16:15:08 +0100 Subject: [PATCH 58/90] Cosmetics --- src/accessor/grib_accessor_class_position.cc | 16 +-- .../grib_accessor_class_proj_string.cc | 80 ++++++++------- src/accessor/grib_accessor_class_raw.cc | 33 ++++--- .../grib_accessor_class_rdbtime_guess_date.cc | 16 +-- ...ib_accessor_class_reference_value_error.cc | 14 +-- src/accessor/grib_accessor_class_round.cc | 8 +- src/accessor/grib_accessor_class_scale.cc | 31 +++--- .../grib_accessor_class_scale_values.cc | 23 +++-- src/accessor/grib_accessor_class_signed.cc | 98 +++++++++++-------- src/accessor/grib_accessor_class_size.cc | 20 ++-- 10 files changed, 199 insertions(+), 140 deletions(-) diff --git a/src/accessor/grib_accessor_class_position.cc b/src/accessor/grib_accessor_class_position.cc index f1a429270..a2c3daacd 100644 --- a/src/accessor/grib_accessor_class_position.cc +++ b/src/accessor/grib_accessor_class_position.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_position.h" -grib_accessor_class_position_t _grib_accessor_class_position{"position"}; +grib_accessor_class_position_t _grib_accessor_class_position{ "position" }; grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position; -void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; @@ -23,17 +24,20 @@ void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -int grib_accessor_class_position_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_position_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } -void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_long(dumper, a, NULL); } -int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values ", a->name, 1); *len = 0; return GRIB_ARRAY_TOO_SMALL; } diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index f8c8e127f..03866753d 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_proj_string.h" -grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{"proj_string"}; +grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{ "proj_string" }; grib_accessor_class* grib_accessor_class_proj_string = &_grib_accessor_class_proj_string; -void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); self->grid_type = grib_arguments_get_name(h, arg, 0); self->endpoint = grib_arguments_get_long(h, arg, 1); @@ -27,7 +28,8 @@ void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, g a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } @@ -35,13 +37,14 @@ int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a){ typedef int (*proj_func)(grib_handle*, char*); struct proj_mapping { - const char* gridType; // key gridType - proj_func func; // function to compute proj string + const char* gridType; // key gridType + proj_func func; // function to compute proj string }; typedef struct proj_mapping proj_mapping; // This should only be called for GRID POINT data (not spherical harmonics etc) -static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ +static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor) +{ int err = 0; if (grib_is_earth_oblate(h)) { if ((err = grib_get_double_internal(h, "earthMinorAxisInMetres", pMinor)) != GRIB_SUCCESS) return err; @@ -56,19 +59,21 @@ static int get_major_minor_axes(grib_handle* h, double* pMajor, double* pMinor){ } // Caller must have allocated enough space in the 'result' argument -static int get_earth_shape(grib_handle* h, char* result){ +static int get_earth_shape(grib_handle* h, char* result) +{ int err = 0; double major = 0, minor = 0; if ((err = get_major_minor_axes(h, &major, &minor)) != GRIB_SUCCESS) return err; if (major == minor) - snprintf(result, 128, "+R=%lf", major); // spherical + snprintf(result, 128, "+R=%lf", major); // spherical else - snprintf(result, 128, "+a=%lf +b=%lf", major, minor); // oblate + snprintf(result, 128, "+a=%lf +b=%lf", major, minor); // oblate return err; } -static int proj_space_view(grib_handle* h, char* result){ +static int proj_space_view(grib_handle* h, char* result) +{ return GRIB_NOT_IMPLEMENTED; // int err = 0; // char shape[128] = {0,}; @@ -84,18 +89,22 @@ static int proj_space_view(grib_handle* h, char* result){ // return err; } -static int proj_albers(grib_handle* h, char* result){ +static int proj_albers(grib_handle* h, char* result) +{ return GRIB_NOT_IMPLEMENTED; } -static int proj_transverse_mercator(grib_handle* h, char* result){ +static int proj_transverse_mercator(grib_handle* h, char* result) +{ return GRIB_NOT_IMPLEMENTED; } -static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result){ +static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result) +{ return GRIB_NOT_IMPLEMENTED; } -static int proj_lambert_conformal(grib_handle* h, char* result){ - int err = 0; +static int proj_lambert_conformal(grib_handle* h, char* result) +{ + int err = 0; char shape[128] = {0,}; double LoVInDegrees = 0, LaDInDegrees = 0, Latin1InDegrees = 0, Latin2InDegrees = 0; @@ -110,12 +119,13 @@ static int proj_lambert_conformal(grib_handle* h, char* result){ if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=lcc +lon_0=%lf +lat_0=%lf +lat_1=%lf +lat_2=%lf %s", - LoVInDegrees, LaDInDegrees, Latin1InDegrees, Latin2InDegrees, shape); + LoVInDegrees, LaDInDegrees, Latin1InDegrees, Latin2InDegrees, shape); return err; } -static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ - int err = 0; +static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result) +{ + int err = 0; char shape[128] = {0,}; double standardParallel = 0, centralLongitude = 0; @@ -126,11 +136,12 @@ static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result){ if ((err = grib_get_double_internal(h, "centralLongitudeInDegrees", ¢ralLongitude)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=laea +lon_0=%lf +lat_0=%lf %s", - centralLongitude, standardParallel, shape); + centralLongitude, standardParallel, shape); return err; } -static int proj_polar_stereographic(grib_handle* h, char* result){ +static int proj_polar_stereographic(grib_handle* h, char* result) +{ int err = 0; double centralLongitude = 0, centralLatitude = 0; int has_northPole = 0; @@ -147,33 +158,35 @@ static int proj_polar_stereographic(grib_handle* h, char* result){ return err; has_northPole = ((projectionCentreFlag & 128) == 0); snprintf(result, 1024, "+proj=stere +lat_ts=%lf +lat_0=%s +lon_0=%lf +k_0=1 +x_0=0 +y_0=0 %s", - centralLatitude, has_northPole ? "90" : "-90", centralLongitude, shape); + centralLatitude, has_northPole ? "90" : "-90", centralLongitude, shape); return err; } // ECC-1552: This is for regular_ll, regular_gg, reduced_ll, reduced_gg // These are not 'projected' grids! -static int proj_unprojected(grib_handle* h, char* result){ +static int proj_unprojected(grib_handle* h, char* result) +{ int err = 0; - //char shape[128] = {0,}; - //if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; - //snprintf(result, 1024, "+proj=longlat %s", shape); + // char shape[128] = {0,}; + // if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; + // snprintf(result, 1024, "+proj=longlat %s", shape); snprintf(result, 1024, "+proj=longlat +datum=WGS84 +no_defs +type=crs"); return err; } -static int proj_mercator(grib_handle* h, char* result){ +static int proj_mercator(grib_handle* h, char* result) +{ int err = 0; double LaDInDegrees = 0; - char shape[128] = {0,}; + char shape[128] = {0,}; if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS) return err; if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=merc +lat_ts=%lf +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 %s", - LaDInDegrees, shape); + LaDInDegrees, shape); return err; } @@ -195,17 +208,18 @@ static proj_mapping proj_mappings[] = { #define ENDPOINT_SOURCE 0 #define ENDPOINT_TARGET 1 -int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len){ +int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; int err = 0, found = 0; - size_t i = 0; + size_t i = 0; char grid_type[64] = {0,}; grib_handle* h = grib_handle_of_accessor(a); - size_t size = sizeof(grid_type) / sizeof(*grid_type); + size_t size = sizeof(grid_type) / sizeof(*grid_type); Assert(self->endpoint == ENDPOINT_SOURCE || self->endpoint == ENDPOINT_TARGET); - size_t l = 100; // Safe bet + size_t l = 100; // Safe bet if (*len < l) { const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc index 4a80b772a..cf1f502c7 100644 --- a/src/accessor/grib_accessor_class_raw.cc +++ b/src/accessor/grib_accessor_class_raw.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_raw.h" -grib_accessor_class_raw_t _grib_accessor_class_raw{"raw"}; +grib_accessor_class_raw_t _grib_accessor_class_raw{ "raw" }; grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; -void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); int n = 0; int err = 0; @@ -42,31 +43,37 @@ void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_argu /* Assert(a->length>=0); */ } -int grib_accessor_class_raw_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_raw_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_BYTES; } -int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = GRIB_SUCCESS; - size_t alen = (size_t)a->byte_count(); size_t blen = (size_t)b->byte_count(); + size_t alen = (size_t)a->byte_count(); + size_t blen = (size_t)b->byte_count(); if (alen != blen) return GRIB_COUNT_MISMATCH; return retval; } -long grib_accessor_class_raw_t::byte_count(grib_accessor* a){ +long grib_accessor_class_raw_t::byte_count(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len) +{ *len = a->length; return 0; } -int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ +int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) +{ if (*len < a->length) { *len = a->length; return GRIB_ARRAY_TOO_SMALL; @@ -78,7 +85,8 @@ int grib_accessor_class_raw_t::unpack_bytes(grib_accessor* a, unsigned char* buf return GRIB_SUCCESS; } -void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s) +{ grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); a->length = s; Assert(a->length >= 0); @@ -94,13 +102,14 @@ long accessor_raw_get_offset(grib_accessor* a) return a->offset; } -int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len){ +int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) +{ size_t length = *len; long totalLength; long sectionLength; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); grib_accessor_raw_t* self = (grib_accessor_raw_t*)a; - long dlen = length - a->length; + long dlen = length - a->length; grib_get_long(h, self->totalLength, &totalLength); totalLength += dlen; diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc index 173e0a3dc..f4b317daa 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -15,10 +15,11 @@ grib_accessor_class_rdbtime_guess_date_t _grib_accessor_class_rdbtime_guess_date grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date; -void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; - int n = 0; + int n = 0; self->typicalYear = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->typicalMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -29,14 +30,14 @@ void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ } -int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); long typicalYear, typicalMonth, typicalDay, rdbDay; long rdbYear, rdbMonth; - ret = grib_get_long(h, self->typicalYear, &typicalYear); + int ret = grib_get_long(h, self->typicalYear, &typicalYear); if (ret) return ret; ret = grib_get_long(h, self->typicalMonth, &typicalMonth); @@ -70,7 +71,8 @@ int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long return GRIB_SUCCESS; } -int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len){ +int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ /* do nothing*/ return GRIB_SUCCESS; } diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc index 9a1dba20b..fbf1a1c1b 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.cc +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_reference_value_error.h" -grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{"reference_value_error"}; +grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{ "reference_value_error" }; grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error; -void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; - int n = 0; + int n = 0; self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -27,10 +28,11 @@ void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const l a->length = 0; } -int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; - int ret = 0; - double referenceValue = 0; + int ret = GRIB_SUCCESS; + double referenceValue = 0; if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->referenceValue, &referenceValue)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_round.cc b/src/accessor/grib_accessor_class_round.cc index f56fa4a1c..e1d6aaeda 100644 --- a/src/accessor/grib_accessor_class_round.cc +++ b/src/accessor/grib_accessor_class_round.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_round.h" -grib_accessor_class_round_t _grib_accessor_class_round{"round"}; +grib_accessor_class_round_t _grib_accessor_class_round{ "round" }; grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round; -int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_round_t* self = (grib_accessor_round_t*)a; int ret = GRIB_SUCCESS; @@ -42,7 +43,8 @@ int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, si return ret; } -int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ char result[1024]; int ret = GRIB_SUCCESS; size_t replen = 1; diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc index eb01412d2..59ab7bfb4 100644 --- a/src/accessor/grib_accessor_class_scale.cc +++ b/src/accessor/grib_accessor_class_scale.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_scale.h" -grib_accessor_class_scale_t _grib_accessor_class_scale{"scale"}; +grib_accessor_class_scale_t _grib_accessor_class_scale{ "scale" }; grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; -void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; - int n = 0; + int n = 0; self->value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->multiplier = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -26,12 +27,13 @@ void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_argu self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; - int ret = 0; - long value = 0; - long multiplier = 0; - long divisor = 0; + int ret = 0; + long value = 0; + long multiplier = 0; + long divisor = 0; if (*len < 1) { ret = GRIB_ARRAY_TOO_SMALL; @@ -61,14 +63,16 @@ int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, si return ret; } -int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ const double dval = (double)*val; return pack_double(a, &dval, len); } -int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; - int ret = 0; + int ret = 0; long value = 0; long divisor = 0; @@ -115,9 +119,10 @@ int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val return ret; } -int grib_accessor_class_scale_t::is_missing(grib_accessor* a){ +int grib_accessor_class_scale_t::is_missing(grib_accessor* a) +{ grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; - grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); + grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); if (!av) return GRIB_NOT_FOUND; diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc index 03c5e0de2..03072311d 100644 --- a/src/accessor/grib_accessor_class_scale_values.cc +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -11,36 +11,39 @@ #include "grib_accessor_class_scale_values.h" -grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{"scale_values"}; +grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{ "scale_values" }; grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values; -void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ +void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ grib_accessor_class_double_t::init(a, l, args); - int n = 0; + int n = 0; grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; } -int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ - int ret = 0; +int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + int ret = GRIB_SUCCESS; *val = 1; *len = 1; return ret; } -int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ double* values = NULL; double missingValue = 0; long missingValuesPresent = 0; size_t size = 0; int ret = 0, i = 0; grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; - const grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + const grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); if (*val == 1) return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index dea029231..36c20bd59 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -11,24 +11,28 @@ #include "grib_accessor_class_signed.h" -grib_accessor_class_signed_t _grib_accessor_class_signed{"signed"}; +grib_accessor_class_signed_t _grib_accessor_class_signed{ "signed" }; grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed; -void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_long_t::init(a, len, arg); grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; - long count = 0; + long count = 0; self->arg = arg; - a->value_count(&count); a->length = len * count; + a->value_count(&count); + a->length = len * count; self->nbytes = len; Assert(a->length >= 0); } -void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper) +{ long rlen = 0; - a->value_count(&rlen); if (rlen == 1) + a->value_count(&rlen); + if (rlen == 1) grib_dump_long(dumper, a, NULL); else grib_dump_values(dumper, a); @@ -42,17 +46,19 @@ static const long ones[] = { -0x7fffffff, }; -int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; - unsigned long rlen = 0; - int err = 0; - long count = 0; - unsigned long i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - long pos = a->offset; - long missing = 0; + unsigned long rlen = 0; + int err = 0; + long count = 0; + unsigned long i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + long pos = a->offset; + long missing = 0; - err = a->value_count(&count); if (err) + err = a->value_count(&count); + if (err) return err; rlen = count; @@ -79,19 +85,21 @@ int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_ return GRIB_SUCCESS; } -int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; - int ret = 0; - long off = 0; - unsigned long rlen = 0; - int err = 0; - long count = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long missing = 0; - err = a->value_count(&count); if (err) + int ret = 0; + long off = 0; + unsigned long rlen = 0; + long count = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long missing = 0; + + int err = a->value_count(&count); + if (err) return err; rlen = count; @@ -111,16 +119,17 @@ int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, s if (missing) { if (v == GRIB_MISSING_LONG) v = missing; - } else { + } + else { // ECC-1605: Check overflow/underflow - const int nbits = self->nbytes * 8; - const long minval = -(1L << (nbits-1)) + 1; - const long maxval = (1L << (nbits-1)) - 1; - //printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval); + const int nbits = self->nbytes * 8; + const long minval = -(1L << (nbits - 1)) + 1; + const long maxval = (1L << (nbits - 1)) - 1; + // printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval); if (v > maxval || v < minval) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode value of %ld but the allowable range is %ld to %ld (number of bits=%d)", - a->name, v, minval, maxval, nbits); + "Key \"%s\": Trying to encode value of %ld but the allowable range is %ld to %ld (number of bits=%d)", + a->name, v, minval, maxval, nbits); return GRIB_ENCODING_ERROR; } } @@ -156,13 +165,15 @@ int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, s return ret; } -long grib_accessor_class_signed_t::byte_count(grib_accessor* a){ +long grib_accessor_class_signed_t::byte_count(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len) +{ grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; - *len = 0; + *len = 0; if (!self->arg) { *len = 1; return 0; @@ -170,19 +181,24 @@ int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len){ return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -long grib_accessor_class_signed_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_signed_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s) +{ a->length = s; Assert(a->length >= 0); } -long grib_accessor_class_signed_t::next_offset(grib_accessor* a){ - return a->byte_offset() + a->byte_count();} +long grib_accessor_class_signed_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} -int grib_accessor_class_signed_t::is_missing(grib_accessor* a){ +int grib_accessor_class_signed_t::is_missing(grib_accessor* a) +{ int i = 0; unsigned char ff = 0xff; unsigned long offset = a->offset; diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc index a9aa37f06..71c0dd947 100644 --- a/src/accessor/grib_accessor_class_size.cc +++ b/src/accessor/grib_accessor_class_size.cc @@ -11,25 +11,27 @@ #include "grib_accessor_class_size.h" -grib_accessor_class_size_t _grib_accessor_class_size{"size"}; +grib_accessor_class_size_t _grib_accessor_class_size{ "size" }; grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; -void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_size_t* self = (grib_accessor_size_t*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; } -int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len){ - int ret = 0; - size_t size = 0; +int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_size_t* self = (grib_accessor_size_t*)a; - ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); - *val = (long)size; - *len = 1; + + size_t size = 0; + int ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); + *val = (long)size; + *len = 1; return ret; } From 22bd62c27647d85759c9f531a874992c99c222b3 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 16:53:58 +0100 Subject: [PATCH 59/90] Cosmetics --- src/accessor/grib_accessor_class_bitmap.cc | 2 +- src/accessor/grib_accessor_class_blob.cc | 17 +- .../grib_accessor_class_bufr_data_element.cc | 169 ++++++++++-------- .../grib_accessor_class_bufr_string_values.cc | 33 ++-- .../grib_accessor_class_codetable_title.cc | 21 ++- .../grib_accessor_class_codetable_units.cc | 13 +- .../grib_accessor_class_count_file.cc | 8 +- .../grib_accessor_class_count_total.cc | 8 +- src/accessor/grib_accessor_class_dirty.cc | 17 +- src/accessor/grib_accessor_class_evaluate.cc | 16 +- src/accessor/grib_accessor_class_mars_step.cc | 49 +++-- ...grib_accessor_class_step_human_readable.cc | 3 +- .../grib_accessor_class_step_in_units.cc | 28 +-- ...b_accessor_class_unexpanded_descriptors.cc | 52 +++--- .../grib_accessor_class_unpack_bufr_values.cc | 73 +++++--- src/accessor/grib_accessor_class_unsigned.cc | 32 ++-- .../grib_accessor_class_unsigned_bits.cc | 62 ++++--- .../grib_accessor_class_validity_date.cc | 24 +-- .../grib_accessor_class_validity_time.cc | 31 ++-- src/accessor/grib_accessor_class_values.cc | 30 ++-- src/accessor/grib_accessor_class_vector.cc | 17 +- src/accessor/grib_accessor_class_when.cc | 14 +- 22 files changed, 425 insertions(+), 294 deletions(-) diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index 505871a3a..05d9db3bf 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -104,7 +104,7 @@ int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_ } template -int unpack(grib_accessor* a, T* val, size_t* len) +static int unpack(grib_accessor* a, T* val, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating points numbers"); long pos = a->offset * 8; diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index ca7b21f24..4629de93a 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -11,21 +11,25 @@ #include "grib_accessor_class_blob.h" -grib_accessor_class_blob_t _grib_accessor_class_blob{"blob"}; +grib_accessor_class_blob_t _grib_accessor_class_blob{ "blob" }; grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; -void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); - grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); + grib_get_long_internal(grib_handle_of_accessor(a), + grib_arguments_get_name(a->parent->h, arg, 0), &a->length); Assert(a->length >= 0); } -int grib_accessor_class_blob_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_blob_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_BYTES; } -int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ +int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) +{ if (*len < (size_t)a->length) { *len = a->length; return GRIB_ARRAY_TOO_SMALL; @@ -37,6 +41,7 @@ int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* bu return GRIB_SUCCESS; } -void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_bytes(dumper, a, NULL); } diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index e2c9eafbe..8d483b96d 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -10,7 +10,7 @@ #include "grib_accessor_class_bufr_data_element.h" -grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{"bufr_data_element"}; +grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{ "bufr_data_element" }; grib_accessor_class* grib_accessor_class_bufr_data_element = &_grib_accessor_class_bufr_data_element; grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor* a, grib_section* s, int* err) @@ -21,7 +21,9 @@ grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor grib_accessor_bufr_data_element_t* self; char* copied_name = NULL; int i; - grib_action creator = {0,}; + grib_action creator = { + 0, + }; creator.op = (char*)"bufr_data_element"; creator.name_space = (char*)""; creator.set = 0; @@ -64,67 +66,69 @@ grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor void accessor_bufr_data_element_set_index(grib_accessor* a, long index) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->index = index; + self->index = index; } void accessor_bufr_data_element_set_type(grib_accessor* a, int type) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->type = type; + self->type = type; } void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->numberOfSubsets = numberOfSubsets; + self->numberOfSubsets = numberOfSubsets; } void accessor_bufr_data_element_set_subsetNumber(grib_accessor* a, long subsetNumber) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->subsetNumber = subsetNumber; + self->subsetNumber = subsetNumber; } void accessor_bufr_data_element_set_compressedData(grib_accessor* a, int compressedData) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->compressedData = compressedData; + self->compressedData = compressedData; } void accessor_bufr_data_element_set_descriptors(grib_accessor* a, bufr_descriptors_array* descriptors) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->descriptors = descriptors; + self->descriptors = descriptors; } void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray* numericValues) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->numericValues = numericValues; + self->numericValues = numericValues; } void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->stringValues = stringValues; + self->stringValues = stringValues; } void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->elementsDescriptorsIndex = elementsDescriptorsIndex; + self->elementsDescriptorsIndex = elementsDescriptorsIndex; } -void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - a->length = 0; + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA; /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ self->cname = NULL; } -void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper) +{ int type = get_native_type(a); switch (type) { @@ -140,7 +144,8 @@ void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper } } -int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = 0, idx = 0; @@ -160,7 +165,7 @@ int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* else { DEBUG_ASSERT(self->subsetNumber < self->numericValues->n); DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n); - idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; + idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; val[0] = grib_context_strdup(c, self->stringValues->v[idx]->v[0]); *len = 1; } @@ -168,12 +173,13 @@ int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* return ret; } -int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; - size_t i = 0; - char* s = NULL; + size_t i = 0; + char* s = NULL; grib_context* c = a->context; if (self->compressedData) { @@ -192,31 +198,32 @@ int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, } } else { - //ECC-1623 + // ECC-1623 if (*len != (size_t)self->numberOfSubsets) { grib_context_log(c, GRIB_LOG_ERROR, - "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", - a->name, *len, self->numberOfSubsets); + "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", + a->name, *len, self->numberOfSubsets); return GRIB_WRONG_ARRAY_SIZE; } for (i = 0; i < *len; i++) { - //idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; - idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; + // idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; + idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; self->stringValues->v[idx]->v[0] = strdup(v[i]); } - *len=1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - char* str = NULL; - char* p = 0; - size_t slen = 0; - double dval = 0; - size_t dlen = 1; + char* str = NULL; + char* p = 0; + size_t slen = 0; + double dval = 0; + size_t dlen = 1; int idx = 0, err = 0; grib_context* c = a->context; @@ -278,11 +285,12 @@ int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, cha return GRIB_SUCCESS; } -int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; - char* s = NULL; + char* s = NULL; grib_context* c = a->context; if (self->compressedData) { @@ -294,15 +302,16 @@ int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const grib_sarray_delete_content(c, self->stringValues->v[idx]); /* ECC-1172 */ grib_sarray_delete(c, self->stringValues->v[idx]); self->stringValues->v[idx] = grib_sarray_new(c, 1, 1); - s = grib_context_strdup(c, val); + s = grib_context_strdup(c, val); grib_sarray_push(c, self->stringValues->v[idx], s); return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -328,9 +337,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -356,9 +366,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, dou return ret; } -int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; size_t count = 1, i = 0; grib_context* c = a->context; @@ -379,15 +390,16 @@ int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const } else { self->numericValues->v[self->subsetNumber]->v[self->index] = val[0]; - *len = 1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = 0; + int ret = 0; size_t count = 1, i = 0; grib_context* c = a->context; @@ -408,15 +420,16 @@ int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const l } else { self->numericValues->v[self->subsetNumber]->v[self->index] = val[0] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[0]; - *len = 1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count) +{ int ret = 0, type = 0, idx = 0; - size_t size = 0; + size_t size = 0; grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; if (!self->compressedData) { @@ -440,11 +453,12 @@ int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ /* ECC-415 */ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; - long count = 0; + int ret = GRIB_SUCCESS; + long count = 0; value_count(a, &count); if (idx >= (size_t)count) { @@ -460,9 +474,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor return ret; } -int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_TYPE_DOUBLE; + int ret = GRIB_TYPE_DOUBLE; DEBUG_ASSERT(self); switch (self->type) { case BUFR_DESCRIPTOR_TYPE_STRING: @@ -485,9 +500,10 @@ int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a){ return ret; } -void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a){ +void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int i = 0; + int i = 0; if (self->cname) grib_context_free(ct, self->cname); /* ECC-765 */ while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { @@ -502,7 +518,8 @@ void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_acc #define MAX_STRING_SIZE 4096 /* Return 1 if BUFR element(s) is/are missing, 0 otherwise. In case of decoding errors, also return 0 */ -int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ +int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a) +{ const int ktype = get_native_type(a); int err = 0, result = 1; /* default: assume all are missing */ long count = 0; @@ -511,15 +528,17 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ if (ktype == GRIB_TYPE_LONG) { long* values = NULL; - long value = 0; + long value = 0; value_count(a, &count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = a->unpack_long(values, &size2); } + err = a->unpack_long(values, &size2); + } else { - err = a->unpack_long(&value, &size2); } + err = a->unpack_long(&value, &size2); + } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -530,21 +549,24 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ } } grib_context_free(c, values); - } else { + } + else { result = grib_is_missing_long(a, value); } } else if (ktype == GRIB_TYPE_DOUBLE) { - double value = 0; + double value = 0; double* values = NULL; value_count(a, &count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = a->unpack_double(values, &size2); } + err = a->unpack_double(values, &size2); + } else { - err = a->unpack_double(&value, &size2); } + err = a->unpack_double(&value, &size2); + } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -566,19 +588,23 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ size = count; if (size > 1) { values = (char**)grib_context_malloc_clear(a->context, size * sizeof(char*)); - err = a->unpack_string_array(values, &size); if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string_array(values, &size); + if (err) return 0; /* TODO: no way of propagating the error up */ for (i = 0; i < size; i++) { if (!grib_is_missing_string(a, (unsigned char*)values[i], size)) { result = 0; break; } } - for (i = 0; i < size; i++) grib_context_free(c, values[i]); + for (i = 0; i < size; i++) + grib_context_free(c, values[i]); grib_context_free(c, values); - } else { + } + else { char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */ size = MAX_STRING_SIZE; - err = a->unpack_string(value, &size); if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string(value, &size); + if (err) return 0; /* TODO: no way of propagating the error up */ result = grib_is_missing_string(a, (unsigned char*)value, size); } } @@ -588,10 +614,11 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ return result; } -int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a){ - int ktype = GRIB_TYPE_UNDEFINED; - int err = 0; - size_t size = 1; +int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a) +{ + int ktype = GRIB_TYPE_UNDEFINED; + int err = 0; + size_t size = 1; const int can_be_missing = (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING); if (!can_be_missing) return GRIB_VALUE_CANNOT_BE_MISSING; @@ -599,11 +626,11 @@ int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a){ ktype = get_native_type(a); if (ktype == GRIB_TYPE_LONG) { long missing = GRIB_MISSING_LONG; - err = pack_long(a, &missing, &size); + err = pack_long(a, &missing, &size); } else if (ktype == GRIB_TYPE_DOUBLE) { double missing = GRIB_MISSING_DOUBLE; - err = pack_double(a, &missing, &size); + err = pack_double(a, &missing, &size); } else if (ktype == GRIB_TYPE_STRING) { err = pack_string(a, "", &size); diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index eb76f6fb9..31e616b6f 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -12,21 +12,23 @@ #include "grib_accessor_class_bufr_string_values.h" #include "grib_accessor_class_bufr_data_array.h" -grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{"bufr_string_values"}; +grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{ "bufr_string_values" }; grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; -void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_ascii_t::init(a, len, args); grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; - int n = 0; - self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->dataAccessor = NULL; - a->length = 0; + int n = 0; + self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->dataAccessor = NULL; + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string_array(dumper, a, NULL); } @@ -39,11 +41,12 @@ static grib_accessor* get_accessor(grib_accessor* a) return self->dataAccessor; } -int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ grib_accessor* data = 0; grib_context* c = a->context; grib_vsarray* stringValues = NULL; - size_t l = 0, tl; + size_t l = 0, tl; size_t i, j, n = 0; char** b = buffer; @@ -72,14 +75,18 @@ int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* return GRIB_SUCCESS; } -int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen){ +int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen) +{ grib_accessor* descriptors = get_accessor(a); - return descriptors->value_count(rlen);} + return descriptors->value_count(rlen); +} -void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_class_ascii_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc index d124ee75f..2bcdfd215 100644 --- a/src/accessor/grib_accessor_class_codetable_title.cc +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -12,31 +12,34 @@ #include "grib_accessor_class_codetable_title.h" #include "grib_accessor_class_codetable.h" -grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{"codetable_title"}; +grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{ "codetable_title" }; grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; -void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; - grib_codetable* table = NULL; + grib_codetable* table = NULL; size_t size = 1; long value; int err = GRIB_SUCCESS; char tmp[1024]; - size_t l = 1024; + size_t l = 1024; grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc index 2e7ccda61..cc91ae2e2 100644 --- a/src/accessor/grib_accessor_class_codetable_units.cc +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -12,10 +12,11 @@ #include "grib_accessor_class_codetable_units.h" #include "grib_accessor_class_codetable.h" -grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{"codetable_units"}; +grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{ "codetable_units" }; grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; -void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; @@ -25,13 +26,15 @@ void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long le a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; - grib_codetable* table = NULL; + grib_codetable* table = NULL; size_t size = 1; long value; diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc index a347e49ff..268ba8051 100644 --- a/src/accessor/grib_accessor_class_count_file.cc +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -11,17 +11,19 @@ #include "grib_accessor_class_count_file.h" -grib_accessor_class_count_file_t _grib_accessor_class_count_file{"count_file"}; +grib_accessor_class_count_file_t _grib_accessor_class_count_file{ "count_file" }; grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; -void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } -int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ *val = grib_context_get_handle_file_count(a->context); *len = 1; return 0; diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc index 561a8743d..dc708b4b6 100644 --- a/src/accessor/grib_accessor_class_count_total.cc +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -11,17 +11,19 @@ #include "grib_accessor_class_count_total.h" -grib_accessor_class_count_total_t _grib_accessor_class_count_total{"count_total"}; +grib_accessor_class_count_total_t _grib_accessor_class_count_total{ "count_total" }; grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; -void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } -int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ *val = grib_context_get_handle_total_count(a->context); *len = 1; return 0; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc index 39df7e450..73f11c9d7 100644 --- a/src/accessor/grib_accessor_class_dirty.cc +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -11,22 +11,24 @@ #include "grib_accessor_class_dirty.h" -grib_accessor_class_dirty_t _grib_accessor_class_dirty{"dirty"}; +grib_accessor_class_dirty_t _grib_accessor_class_dirty{ "dirty" }; grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; -void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->length = 0; } -int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); if (x) x->dirty = *val; @@ -34,9 +36,10 @@ int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, si return GRIB_SUCCESS; } -int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); if (x) x->dirty = 1; diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc index efed99598..0312107a4 100644 --- a/src/accessor/grib_accessor_class_evaluate.cc +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -11,23 +11,25 @@ #include "grib_accessor_class_evaluate.h" -grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{"evaluate"}; +grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{ "evaluate" }; grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; -void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; - self->arg = c; + self->arg = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; - grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); + grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); - int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); - *len = 1; + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); + *len = 1; return ret; } diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc index 34d245998..8fd9f9dfa 100644 --- a/src/accessor/grib_accessor_class_mars_step.cc +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -11,25 +11,27 @@ #include "grib_accessor_class_mars_step.h" -grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{"mars_step"}; +grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{ "mars_step" }; grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; -void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_ascii_t::init(a, l, c); - int n = 0; + int n = 0; grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ char stepType[100]; size_t stepTypeLen = 100; char buf[100] = {0,}; int ret; grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); if (!stepRangeAcc) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); @@ -44,17 +46,20 @@ int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* v else snprintf(buf, sizeof(buf), "0-%s", val); - return stepRangeAcc->pack_string(buf, len);} + return stepRangeAcc->pack_string(buf, len); +} -int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len){ - int ret = 0; +int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - char buf[100] = {0,}; + + int ret = 0; + char buf[100] = {0,}; char* p = NULL; size_t buflen = 100; long step; grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - const char* cclass_name = a->cclass->name; + const char* cclass_name = a->cclass->name; if (!stepRangeAcc) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); @@ -83,7 +88,8 @@ int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, return ret; } -int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ char buff[100] = {0,}; size_t bufflen = 100; @@ -92,24 +98,29 @@ int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val return pack_string(a, buff, &bufflen); } -int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); if (!stepRangeAcc) return GRIB_NOT_FOUND; - return stepRangeAcc->unpack_long(val, len);} + return stepRangeAcc->unpack_long(val, len); +} -int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a) +{ return 16; } -int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index 929733705..18dec9c14 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -69,9 +69,10 @@ static int get_step_human_readable(grib_handle* h, char* result, size_t* length) int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + grib_handle* h = grib_handle_of_accessor(a); long stepUnits = 0; - int err = 0; + int err = 0; /* Save the current value of stepUnits */ err = grib_get_long_internal(h, self->stepUnits, &stepUnits); diff --git a/src/accessor/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc index 3bbdba009..52086d700 100644 --- a/src/accessor/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -17,8 +17,8 @@ grib_accessor_class_step_in_units_t _grib_accessor_class_step_in_units{"step_in_units"}; grib_accessor_class* grib_accessor_class_step_in_units = &_grib_accessor_class_step_in_units; - -void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); @@ -31,11 +31,13 @@ void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, g self->time_range_value = grib_arguments_get_name(hand, c, n++); } -void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_double(dumper, a, NULL); } -int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; @@ -65,7 +67,8 @@ int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; @@ -94,7 +97,8 @@ int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double return GRIB_SUCCESS; } -int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units){ +int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int err = 0; @@ -143,7 +147,8 @@ int pack_long_new_(grib_accessor* a, const long start_step_value, const long sta return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -174,7 +179,8 @@ int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* return ret; } -int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); //long force_step_units = eccodes::Unit(eccodes::Unit::Value::MISSING).value(); int ret = GRIB_SUCCESS; @@ -195,7 +201,8 @@ int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const cha return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -238,7 +245,8 @@ int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* v return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a) +{ grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index f430b4864..5c9402360 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -11,25 +11,28 @@ #include "grib_accessor_class_unexpanded_descriptors.h" -grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{"unexpanded_descriptors"}; +grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{ "unexpanded_descriptors" }; grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; -void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, len, args); grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); - self->createNewData = grib_arguments_get_name(hand, args, n++); - a->length = 0; + + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); + self->createNewData = grib_arguments_get_name(hand, args, n++); + a->length = 0; } -int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int ret = 0; - long pos = 0; - long rlen = 0; + int ret = 0; + long pos = 0; + long rlen = 0; long f, x, y; long* v = val; long i; @@ -64,10 +67,11 @@ int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, return GRIB_SUCCESS; } -int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int ret = 0; - long pos = 0; + int ret = 0; + long pos = 0; unsigned long f, x, y; unsigned char* buf = NULL; grib_accessor* expanded = NULL; @@ -90,7 +94,8 @@ int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, co grib_encode_unsigned_longb(buf, y, &pos, 8); } - self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); grib_context_free(hand->context, buf); + self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); + grib_context_free(hand->context, buf); if (createNewData == 0) return ret; @@ -110,23 +115,28 @@ int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, co return ret; } -int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors){ +int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - long n = 0; + long n = 0; - self->unexpandedDescriptorsEncoded->value_count(&n); *numberOfUnexpandedDescriptors = n / 2; + self->unexpandedDescriptorsEncoded->value_count(&n); + *numberOfUnexpandedDescriptors = n / 2; return 0; } -long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s) +{ a->length = s; } -long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a){ +long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a) +{ return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index 9942a64a8..3497bbbe2 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -12,58 +12,71 @@ #include "grib_accessor_class_unpack_bufr_values.h" #include "grib_accessor_class_bufr_data_array.h" -grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{"unpack_bufr_values"}; +grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{ "unpack_bufr_values" }; grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; -void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); char* key; grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); a->length = 0; } -void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ } -int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; strcpy(buffer, "0"); - *len=1; + *len = 1; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ +void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a) +{ grib_accessor_class_gen_t::destroy(context, a); } -int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } @@ -75,10 +88,11 @@ int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ // return "unknown proc flag"; // } -int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ - int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; +int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; if (*val == 2) unpackMode = CODES_BUFR_UNPACK_FLAT; @@ -87,10 +101,13 @@ int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const accessor_bufr_data_array_set_unpackMode(data, unpackMode); - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index 0a60e809c..8093e3a6a 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -19,8 +19,8 @@ void grib_accessor_class_unsigned_t::init(grib_accessor* a, const long len, grib { grib_accessor_class_long_t::init(a, len, arg); grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - self->arg = arg; - self->nbytes = len; + self->arg = arg; + self->nbytes = len; if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { a->length = 0; @@ -67,10 +67,10 @@ int value_is_missing(long val) int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, int check) { grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - int ret = 0; - long off = 0; - long rlen = 0; - int err = 0; + int ret = 0; + long off = 0; + long rlen = 0; + int err = 0; size_t buflen = 0; unsigned char* buf = NULL; @@ -114,7 +114,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in if (check) { if (val[0] < 0) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); + "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); return GRIB_ENCODING_ERROR; } /* See GRIB-23 and GRIB-262 */ @@ -124,8 +124,8 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in unsigned long maxval = (1UL << nbits) - 1; if (maxval > 0 && v > maxval) { /* See ECC-1002 */ grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %lu (number of bits=%ld)", - a->name, v, maxval, nbits); + "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %lu (number of bits=%ld)", + a->name, v, maxval, nbits); return GRIB_ENCODING_ERROR; } } @@ -164,13 +164,13 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) { grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - long rlen = 0; - unsigned long i = 0; - unsigned long missing = 0; - long count = 0; - int err = 0; - long pos = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); + long rlen = 0; + unsigned long i = 0; + unsigned long missing = 0; + long count = 0; + int err = 0; + long pos = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); err = a->value_count(&count); if (err) diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index 40088c17d..44873938a 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -11,12 +11,12 @@ #include "grib_accessor_class_unsigned_bits.h" -grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{"unsigned_bits"}; +grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{ "unsigned_bits" }; grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; - -static long compute_byte_count(grib_accessor* a){ +static long compute_byte_count(grib_accessor* a) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; long numberOfBits; long numberOfElements; @@ -40,21 +40,23 @@ static long compute_byte_count(grib_accessor* a){ } -void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, len, args); grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); } -int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; ret = value_count(a, &rlen); if (ret) @@ -84,16 +86,17 @@ int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - ret = value_count(a, &rlen); + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + ret = value_count(a, &rlen); if (ret) return ret; /* @@ -128,11 +131,13 @@ int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* return ret; } -long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements){ +int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; int ret; *numberOfElements = 0; @@ -146,14 +151,17 @@ int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* num return ret; } -long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s) +{ a->length = s; } -long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a) +{ return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc index 19c26bf48..331c4ec82 100644 --- a/src/accessor/grib_accessor_class_validity_date.cc +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -12,14 +12,15 @@ #include "grib_accessor_class_validity_date.h" #include "shared_functions.h" -grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{"validity_date"}; +grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{ "validity_date" }; grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; -void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->date = grib_arguments_get_name(hand, c, n++); self->time = grib_arguments_get_name(hand, c, n++); @@ -32,14 +33,15 @@ void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, g a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; if (self->year) { diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc index 9cbc445cb..350a19e92 100644 --- a/src/accessor/grib_accessor_class_validity_time.cc +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -12,15 +12,16 @@ #include "grib_accessor_class_validity_time.h" #include "shared_functions.h" -grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{"validity_time"}; +grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{ "validity_time" }; grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; -void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->date = grib_arguments_get_name(hand, c, n++); self->time = grib_arguments_get_name(hand, c, n++); @@ -32,14 +33,15 @@ void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, g a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; if (self->hours) { @@ -92,9 +94,10 @@ int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ - int err = 0; - long v = 0; +int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + int err = 0; + long v = 0; size_t lsize = 1, lmin = 5; err = unpack_long(a, &v, &lsize); diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index 5aa172a05..cd2107559 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -14,7 +14,8 @@ grib_accessor_class_values_t _grib_accessor_class_values{"values"}; grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; -long init_length(grib_accessor* a){ +long init_length(grib_accessor* a) +{ grib_accessor_values_t* self = (grib_accessor_values_t*)a; int ret = 0; @@ -46,7 +47,8 @@ long init_length(grib_accessor* a){ return seclen - (offsetdata - offsetsection); } -void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params){ +void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, v, params); grib_accessor_values_t* self = (grib_accessor_values_t*)a; self->carg = 0; @@ -60,34 +62,41 @@ void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arg /* Assert(a->length>=0); */ } -int grib_accessor_class_values_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_values_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_DOUBLE; } -void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_values(dumper, a); } -long grib_accessor_class_values_t::byte_count(grib_accessor* a){ +long grib_accessor_class_values_t::byte_count(grib_accessor* a) +{ grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); return a->length; } -long grib_accessor_class_values_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_values_t::byte_offset(grib_accessor* a) +{ return a->offset; } -long grib_accessor_class_values_t::next_offset(grib_accessor* a){ +long grib_accessor_class_values_t::next_offset(grib_accessor* a) +{ return a->offset + a->length; } -void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s) +{ grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); a->length = s; Assert(a->length >= 0); } -int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = 0; double* aval = 0; double* bval = 0; @@ -123,7 +132,8 @@ int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b){ return retval; } -int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_values_t* self = (grib_accessor_values_t*)a; double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index bd0185d73..f08809f6f 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -12,14 +12,15 @@ #include "grib_accessor_class_vector.h" #include "grib_accessor_class_abstract_vector.h" -grib_accessor_class_vector_t _grib_accessor_class_vector{"vector"}; +grib_accessor_class_vector_t _grib_accessor_class_vector{ "vector" }; grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; -void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; - int n = 0; + int n = 0; self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); @@ -28,12 +29,13 @@ void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arg a->length = 0; } -int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ int err = 0; size_t size = 0; double* stat; - grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; - grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); grib_accessor_abstract_vector_t* v = (grib_accessor_abstract_vector_t*)va; Assert(self->index >= 0); @@ -46,7 +48,8 @@ int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, s if (va->dirty) { grib_get_size(grib_handle_of_accessor(a), self->vector, &size); stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = va->unpack_double(stat, &size); grib_context_free(a->context, stat); + err = va->unpack_double(stat, &size); + grib_context_free(a->context, stat); if (err) return err; } diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc index 2ab2652f0..48db76803 100644 --- a/src/accessor/grib_accessor_class_when.cc +++ b/src/accessor/grib_accessor_class_when.cc @@ -11,25 +11,29 @@ #include "grib_accessor_class_when.h" -grib_accessor_class_when_t _grib_accessor_class_when{"when"}; +grib_accessor_class_when_t _grib_accessor_class_when{ "when" }; grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; -void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper) +{ /* grib_dump_when(dumper,a,NULL); */ } -int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed){ +int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed) +{ return grib_action_notify_change(a->creator, a, changed); } -int grib_accessor_class_when_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_when_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_UNDEFINED; } From 769d5dcbfec381d1e42fb3792d13138861d95dba Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 13 May 2024 10:57:39 +0100 Subject: [PATCH 60/90] ECC-1709: GRIB2: Rename indicatorOfUnitOfTimeRange to indicatorOfUnitForForecastTime --- definitions/grib2/template.4.20.def | 40 +++++++++---------- .../grib2/template.4.forecast_time.def | 4 +- .../grib2/template.4.forecast_time_44.def | 4 +- definitions/grib2/template.4.localtime.def | 4 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/definitions/grib2/template.4.20.def b/definitions/grib2/template.4.20.def index b739bf6bb..882691250 100644 --- a/definitions/grib2/template.4.20.def +++ b/definitions/grib2/template.4.20.def @@ -1,60 +1,60 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.20, Radar product -codetable[1] parameterCategory ('4.1.[discipline:l].table',masterDir,localDir) : dump; +codetable[1] parameterCategory('4.1.[discipline:l].table',masterDir,localDir) : dump; # Parameter number -codetable[1] parameterNumber ('4.2.[discipline:l].[parameterCategory:l].table',masterDir,localDir) : dump; +codetable[1] parameterNumber('4.2.[discipline:l].[parameterCategory:l].table',masterDir,localDir) : dump; meta parameterUnits codetable_units(parameterNumber) : dump; meta parameterName codetable_title(parameterNumber) : dump; -codetable[1] typeOfGeneratingProcess ('4.3.table',masterDir,localDir) : dump; +codetable[1] typeOfGeneratingProcess('4.3.table',masterDir,localDir) : dump; # Number of radar sites used -unsigned[1] numberOfRadarSitesUsed : dump; +unsigned[1] numberOfRadarSitesUsed : dump; -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" # Site latitude (in microdegrees) -unsigned[4] siteLatitude : dump; +unsigned[4] siteLatitude : dump; # Site longitude (in microdegrees) -unsigned[4] siteLongitude : dump; +unsigned[4] siteLongitude : dump; # Site elevation (meters) -unsigned[2] siteElevation : dump; +unsigned[2] siteElevation : dump; # Site ID (alphanumeric) -unsigned[4] siteId : dump; +unsigned[4] siteId : dump; # Site ID (numeric) -unsigned[2] siteId : dump; +unsigned[2] siteId : dump; # Operating mode -codetable[1] operatingMode ('4.12.table',masterDir,localDir) : dump; +codetable[1] operatingMode('4.12.table',masterDir,localDir) : dump; # Reflectivity calibration constant (tenths of dB) -unsigned[1] reflectivityCalibrationConstant : dump; +unsigned[1] reflectivityCalibrationConstant : dump; # Quality control indicator -codetable[1] qualityControlIndicator ('4.13.table',masterDir,localDir) : dump; +codetable[1] qualityControlIndicator('4.13.table',masterDir,localDir) : dump; # Clutter filter indicator -codetable[1] clutterFilterIndicator ('4.14.table',masterDir,localDir) : dump; +codetable[1] clutterFilterIndicator('4.14.table',masterDir,localDir) : dump; # Constant antenna elevation angle (tenths of degree true) -unsigned[1] constantAntennaElevationAngle : dump; +unsigned[1] constantAntennaElevationAngle : dump; # Accumulation interval (minutes) -unsigned[2] accumulationInterval : dump; +unsigned[2] accumulationInterval : dump; # Reference reflectivity for echo top (dB) -unsigned[1] referenceReflectivityForEchoTop : dump; +unsigned[1] referenceReflectivityForEchoTop : dump; # Range bin spacing (meters) -unsigned[3] rangeBinSpacing : dump; +unsigned[3] rangeBinSpacing : dump; # Radial angular spacing (tenths of degree true) -unsigned[2] radialAngularSpacing : dump; +unsigned[2] radialAngularSpacing : dump; diff --git a/definitions/grib2/template.4.forecast_time.def b/definitions/grib2/template.4.forecast_time.def index c12da70e3..e1c2822d9 100644 --- a/definitions/grib2/template.4.forecast_time.def +++ b/definitions/grib2/template.4.forecast_time.def @@ -9,8 +9,8 @@ unsigned[1] minutesAfterDataCutoff = missing() : edition_specific,can_be_missin alias minutesAfterReferenceTimeOfDataCutoff=minutesAfterDataCutoff; # Indicator of unit for forecastTime (ECC-1709) -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" diff --git a/definitions/grib2/template.4.forecast_time_44.def b/definitions/grib2/template.4.forecast_time_44.def index 0b4ad445b..30723622e 100644 --- a/definitions/grib2/template.4.forecast_time_44.def +++ b/definitions/grib2/template.4.forecast_time_44.def @@ -11,8 +11,8 @@ unsigned[1] minutesAfterDataCutoff = missing() : edition_specific,can_be_missin alias minutesAfterReferenceTimeOfDataCutoff=minutesAfterDataCutoff; # Indicator of unit for forecastTime (ECC-1709) -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" diff --git a/definitions/grib2/template.4.localtime.def b/definitions/grib2/template.4.localtime.def index 96d655d68..336d90068 100644 --- a/definitions/grib2/template.4.localtime.def +++ b/definitions/grib2/template.4.localtime.def @@ -34,7 +34,7 @@ localTimeForecastList list(numberOfForecastsUsedInLocalTime) unsigned[1] secondOfForecastUsedInLocalTime=0 : dump, edition_specific; # Indicator of unit of time for ForecastTime - codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir)=1 : dump; + codetable[1] indicatorOfUnitForForecastTime('4.4.table',masterDir,localDir)=1 : dump; # Length of the time range over which statistical processing is done, in units defined by the previous octet unsigned[4] forecastTime=0 : dump; @@ -43,7 +43,7 @@ localTimeForecastList list(numberOfForecastsUsedInLocalTime) unsigned[1] numberOfTimeIncrementsOfForecastsUsedInLocalTime=1 : dump; # Indicator of unit of time for the increment between the successive steps used - codetable[1] indicatorOfUnitForTimeIncrement ('4.4.table',masterDir,localDir)=255 : dump; + codetable[1] indicatorOfUnitForTimeIncrement('4.4.table',masterDir,localDir)=255 : dump; # Time increment between successive fields, in units defined by the previous octet unsigned[4] timeIncrement=0 : dump; From 501dc2c125296fa5b2746df01da6e49e16d9dbbf Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 13 May 2024 11:17:11 +0000 Subject: [PATCH 61/90] ECC-1824: GRIB2: Correct shortName for recently added time-mean parameters --- definitions/grib2/cfVarName.def | 70 +++++++++---------- .../grib2/localConcepts/cerise/cfVarName.def | 10 +-- .../grib2/localConcepts/cerise/shortName.def | 10 +-- .../grib2/localConcepts/ecmf/cfVarName.def | 10 +-- .../grib2/localConcepts/ecmf/shortName.def | 10 +-- definitions/grib2/shortName.def | 70 +++++++++---------- tests/grib_ecc-1806.sh | 4 +- 7 files changed, 92 insertions(+), 92 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 33c22592d..0893cd19c 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -4795,28 +4795,28 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean snow density -'mrsn' = { +'avg_rsn' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 61 ; typeOfStatisticalProcessing = 0 ; } #Time-mean low vegetation cover -'mcvl' = { +'avg_cvl' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 53 ; typeOfStatisticalProcessing = 0 ; } #Time-mean high vegetation cover -'mcvh' = { +'avg_cvh' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 54 ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction -'mci' = { +'avg_ci' = { discipline = 10 ; parameterCategory = 2 ; parameterNumber = 0 ; @@ -4824,7 +4824,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean sea surface temperature -'msst' = { +'avg_sst' = { discipline = 10 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -4832,21 +4832,21 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean leaf area index, low vegetation -'mlai_lv' = { +'avg_lai_lv' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 55 ; typeOfStatisticalProcessing = 0 ; } #Time-mean leaf area index, high vegetation -'mlai_hv' = { +'avg_lai_hv' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 56 ; typeOfStatisticalProcessing = 0 ; } #Time-mean total column liquid water -'mtclw' = { +'avg_tclw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 69 ; @@ -4855,7 +4855,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean total column cloud ice water -'mtciw' = { +'avg_tciw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 70 ; @@ -4864,7 +4864,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre specific humidity -'m2sh' = { +'avg_2sh' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 0 ; @@ -4875,7 +4875,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean lake mix-layer temperature -'mlmlt' = { +'avg_lmlt' = { discipline = 1 ; parameterCategory = 2 ; parameterNumber = 1 ; @@ -4884,7 +4884,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean lake mix-layer depth -'mlmld' = { +'avg_lmld' = { discipline = 1 ; parameterCategory = 2 ; parameterNumber = 0 ; @@ -4893,7 +4893,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre relative humidity -'m2r' = { +'avg_2r' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 1 ; @@ -4903,70 +4903,70 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean fraction of snow cover -'mfscov' = { +'avg_fscov' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 121 ; typeOfStatisticalProcessing = 0 ; } #Time-mean soil temperature -'msot' = { +'avg_sot' = { discipline = 2 ; parameterCategory = 3 ; parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } #Time-mean snow depth -'msde' = { +'avg_sde' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 11 ; typeOfStatisticalProcessing = 0 ; } #Time-mean snow cover -'msnowc' = { +'avg_snowc' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } #Time-mean geopotential -'mz' = { +'avg_z' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } #Time-mean temperature -'mt' = { +'avg_t' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 0 ; typeOfStatisticalProcessing = 0 ; } #Time-mean U component of wind -'mu' = { +'avg_u' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 2 ; typeOfStatisticalProcessing = 0 ; } #Time-mean V component of wind -'mv' = { +'avg_v' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 3 ; typeOfStatisticalProcessing = 0 ; } #Time-mean specific humidity -'mq' = { +'avg_q' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 0 ; typeOfStatisticalProcessing = 0 ; } #Time-mean surface pressure -'msp' = { +'avg_sp' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -4974,14 +4974,14 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean vertical velocity -'mw' = { +'avg_w' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } #Time-mean total column water -'mtcw' = { +'avg_tcw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 51 ; @@ -4990,7 +4990,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean total column vertically-integrated water vapour -'mtcwv' = { +'avg_tcwv' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 64 ; @@ -4999,7 +4999,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean mean sea level pressure -'mmsl' = { +'avg_msl' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -5007,21 +5007,21 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean relative humidity -'mr' = { +'avg_r' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 1 ; typeOfStatisticalProcessing = 0 ; } #Time-mean boundary layer height -'mblh' = { +'avg_blh' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } #Time-mean 10 metre U wind component -'m10u' = { +'avg_10u' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 2 ; @@ -5031,7 +5031,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 10 metre V wind component -'m10v' = { +'avg_10v' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 3 ; @@ -5041,7 +5041,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre dewpoint temperature -'m2d' = { +'avg_2d' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 6 ; @@ -5051,14 +5051,14 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean temperature of snow layer -'mtsn' = { +'avg_tsn' = { discipline = 2 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } #Time-mean forecast surface roughness -'mfsr' = { +'avg_fsr' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 1 ; @@ -5066,7 +5066,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast logarithm of surface roughness for heat -'mflsr' = { +'avg_flsr' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 54 ; diff --git a/definitions/grib2/localConcepts/cerise/cfVarName.def b/definitions/grib2/localConcepts/cerise/cfVarName.def index 0ccc6c90f..dfb69cc17 100644 --- a/definitions/grib2/localConcepts/cerise/cfVarName.def +++ b/definitions/grib2/localConcepts/cerise/cfVarName.def @@ -153,7 +153,7 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth -'msd_m' = { +'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; @@ -161,7 +161,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean low cloud cover -'mlcc_frac' = { +'avg_lcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -169,7 +169,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean medium cloud cover -'mmcc_frac' = { +'avg_mcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -177,7 +177,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean high cloud cover -'mhcc_frac' = { +'avg_hcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -185,7 +185,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast albedo -'mfal_frac' = { +'avg_fal_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 19 ; diff --git a/definitions/grib2/localConcepts/cerise/shortName.def b/definitions/grib2/localConcepts/cerise/shortName.def index 0ccc6c90f..dfb69cc17 100644 --- a/definitions/grib2/localConcepts/cerise/shortName.def +++ b/definitions/grib2/localConcepts/cerise/shortName.def @@ -153,7 +153,7 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth -'msd_m' = { +'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; @@ -161,7 +161,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean low cloud cover -'mlcc_frac' = { +'avg_lcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -169,7 +169,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean medium cloud cover -'mmcc_frac' = { +'avg_mcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -177,7 +177,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean high cloud cover -'mhcc_frac' = { +'avg_hcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -185,7 +185,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast albedo -'mfal_frac' = { +'avg_fal_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 19 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 6794b74a6..7efe686a0 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -13832,7 +13832,7 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth -'msd_m' = { +'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; @@ -13840,7 +13840,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean low cloud cover -'mlcc_frac' = { +'avg_lcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13848,7 +13848,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean medium cloud cover -'mmcc_frac' = { +'avg_mcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13856,7 +13856,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean high cloud cover -'mhcc_frac' = { +'avg_hcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13864,7 +13864,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast albedo -'mfal_frac' = { +'avg_fal_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 19 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index b476da6d8..b7e53c29d 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -13832,7 +13832,7 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth -'msd_m' = { +'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 1 ; @@ -13840,7 +13840,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean low cloud cover -'mlcc_frac' = { +'avg_lcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13848,7 +13848,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean medium cloud cover -'mmcc_frac' = { +'avg_mcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13856,7 +13856,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean high cloud cover -'mhcc_frac' = { +'avg_hcc_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 6 ; @@ -13864,7 +13864,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast albedo -'mfal_frac' = { +'avg_fal_frac' = { localTablesVersion = 1 ; discipline = 0 ; parameterCategory = 19 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index fbecc6945..fb3e581c8 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -4795,28 +4795,28 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean snow density -'mrsn' = { +'avg_rsn' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 61 ; typeOfStatisticalProcessing = 0 ; } #Time-mean low vegetation cover -'mcvl' = { +'avg_cvl' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 53 ; typeOfStatisticalProcessing = 0 ; } #Time-mean high vegetation cover -'mcvh' = { +'avg_cvh' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 54 ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction -'mci' = { +'avg_ci' = { discipline = 10 ; parameterCategory = 2 ; parameterNumber = 0 ; @@ -4824,7 +4824,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean sea surface temperature -'msst' = { +'avg_sst' = { discipline = 10 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -4832,21 +4832,21 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean leaf area index, low vegetation -'mlai_lv' = { +'avg_lai_lv' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 55 ; typeOfStatisticalProcessing = 0 ; } #Time-mean leaf area index, high vegetation -'mlai_hv' = { +'avg_lai_hv' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 56 ; typeOfStatisticalProcessing = 0 ; } #Time-mean total column liquid water -'mtclw' = { +'avg_tclw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 69 ; @@ -4855,7 +4855,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean total column cloud ice water -'mtciw' = { +'avg_tciw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 70 ; @@ -4864,7 +4864,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre specific humidity -'m2sh' = { +'avg_2sh' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 0 ; @@ -4875,7 +4875,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean lake mix-layer temperature -'mlmlt' = { +'avg_lmlt' = { discipline = 1 ; parameterCategory = 2 ; parameterNumber = 1 ; @@ -4884,7 +4884,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean lake mix-layer depth -'mlmld' = { +'avg_lmld' = { discipline = 1 ; parameterCategory = 2 ; parameterNumber = 0 ; @@ -4893,7 +4893,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre relative humidity -'m2r' = { +'avg_2r' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 1 ; @@ -4903,70 +4903,70 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean fraction of snow cover -'mfscov' = { +'avg_fscov' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 121 ; typeOfStatisticalProcessing = 0 ; } #Time-mean soil temperature -'msot' = { +'avg_sot' = { discipline = 2 ; parameterCategory = 3 ; parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } #Time-mean snow depth -'msde' = { +'avg_sde' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 11 ; typeOfStatisticalProcessing = 0 ; } #Time-mean snow cover -'msnowc' = { +'avg_snowc' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } #Time-mean geopotential -'mz' = { +'avg_z' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } #Time-mean temperature -'mt' = { +'avg_t' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 0 ; typeOfStatisticalProcessing = 0 ; } #Time-mean U component of wind -'mu' = { +'avg_u' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 2 ; typeOfStatisticalProcessing = 0 ; } #Time-mean V component of wind -'mv' = { +'avg_v' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 3 ; typeOfStatisticalProcessing = 0 ; } #Time-mean specific humidity -'mq' = { +'avg_q' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 0 ; typeOfStatisticalProcessing = 0 ; } #Time-mean surface pressure -'msp' = { +'avg_sp' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -4974,14 +4974,14 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean vertical velocity -'mw' = { +'avg_w' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } #Time-mean total column water -'mtcw' = { +'avg_tcw' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 51 ; @@ -4990,7 +4990,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean total column vertically-integrated water vapour -'mtcwv' = { +'avg_tcwv' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 64 ; @@ -4999,7 +4999,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean mean sea level pressure -'mmsl' = { +'avg_msl' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 0 ; @@ -5007,21 +5007,21 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean relative humidity -'mr' = { +'avg_r' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 1 ; typeOfStatisticalProcessing = 0 ; } #Time-mean boundary layer height -'mblh' = { +'avg_blh' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } #Time-mean 10 metre U wind component -'m10u' = { +'avg_10u' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 2 ; @@ -5031,7 +5031,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 10 metre V wind component -'m10v' = { +'avg_10v' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 3 ; @@ -5041,7 +5041,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean 2 metre dewpoint temperature -'m2d' = { +'avg_2d' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 6 ; @@ -5051,14 +5051,14 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean temperature of snow layer -'mtsn' = { +'avg_tsn' = { discipline = 2 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } #Time-mean forecast surface roughness -'mfsr' = { +'avg_fsr' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 1 ; @@ -5066,7 +5066,7 @@ typeOfStatisticalProcessing = 0 ; } #Time-mean forecast logarithm of surface roughness for heat -'mflsr' = { +'avg_flsr' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 54 ; diff --git a/tests/grib_ecc-1806.sh b/tests/grib_ecc-1806.sh index fcd4684f2..e08f667a6 100755 --- a/tests/grib_ecc-1806.sh +++ b/tests/grib_ecc-1806.sh @@ -42,11 +42,11 @@ test_conversion() test_conversion 174098 262000 sithick test_conversion 151163 262104 t20d test_conversion 151145 262124 zos -test_conversion 130232 235135 mw +test_conversion 130232 235135 avg_w test_conversion 172146 235033 msshf test_conversion 172147 235034 mslhf test_conversion 55 228004 mean2t -test_conversion 56 235168 m2d +test_conversion 56 235168 avg_2d test_conversion 172169 235035 msdwswrf test_conversion 172175 235036 msdwlwrf test_conversion 172176 235037 msnswrf From 0ce9327cb493fb2c197c3d42c799d1e4edd8233e Mon Sep 17 00:00:00 2001 From: Robert Osinski Date: Mon, 13 May 2024 13:17:41 +0000 Subject: [PATCH 62/90] New templates 4.124-127 added --- definitions/grib2/template.4.124.def | 12 +++++++ definitions/grib2/template.4.125.def | 13 ++++++++ definitions/grib2/template.4.126.def | 12 +++++++ definitions/grib2/template.4.127.def | 14 +++++++++ .../grib2/template.4.radionuclides.def | 31 +++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 definitions/grib2/template.4.124.def create mode 100644 definitions/grib2/template.4.125.def create mode 100644 definitions/grib2/template.4.126.def create mode 100644 definitions/grib2/template.4.127.def create mode 100644 definitions/grib2/template.4.radionuclides.def diff --git a/definitions/grib2/template.4.124.def b/definitions/grib2/template.4.124.def new file mode 100644 index 000000000..a3b83980e --- /dev/null +++ b/definitions/grib2/template.4.124.def @@ -0,0 +1,12 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.124, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" diff --git a/definitions/grib2/template.4.125.def b/definitions/grib2/template.4.125.def new file mode 100644 index 000000000..88ebd7894 --- /dev/null +++ b/definitions/grib2/template.4.125.def @@ -0,0 +1,13 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.125, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.eps.def" diff --git a/definitions/grib2/template.4.126.def b/definitions/grib2/template.4.126.def new file mode 100644 index 000000000..fed3fbac1 --- /dev/null +++ b/definitions/grib2/template.4.126.def @@ -0,0 +1,12 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.126, Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.statistical.def" diff --git a/definitions/grib2/template.4.127.def b/definitions/grib2/template.4.127.def new file mode 100644 index 000000000..baa754fca --- /dev/null +++ b/definitions/grib2/template.4.127.def @@ -0,0 +1,14 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.127, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.eps.def" +include "grib2/template.4.statistical.def" + diff --git a/definitions/grib2/template.4.radionuclides.def b/definitions/grib2/template.4.radionuclides.def new file mode 100644 index 000000000..0e55346ab --- /dev/null +++ b/definitions/grib2/template.4.radionuclides.def @@ -0,0 +1,31 @@ +codetable[2] transportModelUsed ('4.333.table',masterDir,localDir) : edition_specific; + +codetable[2] requestedByEntity 'common/c-11.table' : dump,string_type; + +codetable[2] scenarioOrigin ('4.335.table',masterDir,localDir) : edition_specific; + +codetable[2] NWPused ('4.336.table',masterDir,localDir) : edition_specific; + +unsigned[2] releaseStartYear : edition_specific; + +unsigned[1] releaseStartMonth : edition_specific; + +unsigned[1] releaseStartDay : edition_specific; + +unsigned[1] releaseStartHour : edition_specific; + +unsigned[1] releaseStartMinute : edition_specific; + +unsigned[1] releaseStartSecond : edition_specific; + +unsigned[2] WallClockInitialTimeOfExecutionYear : edition_specific; + +unsigned[1] WallClockInitialTimeOfExecutionMonth : edition_specific; + +unsigned[1] WallClockInitialTimeOfExecutionDay : edition_specific; + +unsigned[1] WallClockInitialTimeOfExecutionHour : edition_specific; + +unsigned[1] WallClockInitialTimeOfExecutionMinute : edition_specific; + +unsigned[1] WallClockInitialTimeOfExecutionSecond : edition_specific; From a46b75d1445ed77e6e89cf020d5502fa305ea0f6 Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 13 May 2024 17:04:12 +0100 Subject: [PATCH 63/90] Definitions: Cleanup --- .../grib2/template.4.focalStatistics.def | 1 + .../grib2/template.4.radionuclides.def | 42 ++++++++----------- .../grib2/template.4.referenceperiod.def | 9 ++-- definitions/grib2/template.4.reforecast.def | 1 + definitions/grib2/template.4.wave.def | 1 + .../grib2/template.4.wave_period_range.def | 1 + .../grib2/template.4.wave_spectra_formula.def | 1 + .../grib2/template.4.wave_spectra_list.def | 2 + 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/definitions/grib2/template.4.focalStatistics.def b/definitions/grib2/template.4.focalStatistics.def index 8aa8d2a33..490919bbc 100644 --- a/definitions/grib2/template.4.focalStatistics.def +++ b/definitions/grib2/template.4.focalStatistics.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. codetable[1] spatialVicinityType ('4.103.table',masterDir,localDir)=255 ; unsigned[1] numberOfSpatialVicinityValues = 1 : edition_specific; diff --git a/definitions/grib2/template.4.radionuclides.def b/definitions/grib2/template.4.radionuclides.def index 0e55346ab..c51ffa6c1 100644 --- a/definitions/grib2/template.4.radionuclides.def +++ b/definitions/grib2/template.4.radionuclides.def @@ -1,31 +1,23 @@ -codetable[2] transportModelUsed ('4.333.table',masterDir,localDir) : edition_specific; +# (C) Copyright 2005- ECMWF + +codetable[2] transportModelUsed ('4.333.table',masterDir,localDir) = 255 : dump; codetable[2] requestedByEntity 'common/c-11.table' : dump,string_type; -codetable[2] scenarioOrigin ('4.335.table',masterDir,localDir) : edition_specific; +codetable[2] scenarioOrigin ('4.335.table',masterDir,localDir) = 255 : dump; -codetable[2] NWPused ('4.336.table',masterDir,localDir) : edition_specific; +codetable[2] NWPused ('4.336.table',masterDir,localDir) = 255 : dump; -unsigned[2] releaseStartYear : edition_specific; +unsigned[2] releaseStartYear : dump; +unsigned[1] releaseStartMonth : dump; +unsigned[1] releaseStartDay : dump; +unsigned[1] releaseStartHour : dump; +unsigned[1] releaseStartMinute : dump; +unsigned[1] releaseStartSecond : dump; -unsigned[1] releaseStartMonth : edition_specific; - -unsigned[1] releaseStartDay : edition_specific; - -unsigned[1] releaseStartHour : edition_specific; - -unsigned[1] releaseStartMinute : edition_specific; - -unsigned[1] releaseStartSecond : edition_specific; - -unsigned[2] WallClockInitialTimeOfExecutionYear : edition_specific; - -unsigned[1] WallClockInitialTimeOfExecutionMonth : edition_specific; - -unsigned[1] WallClockInitialTimeOfExecutionDay : edition_specific; - -unsigned[1] WallClockInitialTimeOfExecutionHour : edition_specific; - -unsigned[1] WallClockInitialTimeOfExecutionMinute : edition_specific; - -unsigned[1] WallClockInitialTimeOfExecutionSecond : edition_specific; +unsigned[2] wallClockInitialTimeOfExecutionYear : dump; +unsigned[1] wallClockInitialTimeOfExecutionMonth : dump; +unsigned[1] wallClockInitialTimeOfExecutionDay : dump; +unsigned[1] wallClockInitialTimeOfExecutionHour : dump; +unsigned[1] wallClockInitialTimeOfExecutionMinute : dump; +unsigned[1] wallClockInitialTimeOfExecutionSecond : dump; diff --git a/definitions/grib2/template.4.referenceperiod.def b/definitions/grib2/template.4.referenceperiod.def index 90c05351f..49a45d571 100644 --- a/definitions/grib2/template.4.referenceperiod.def +++ b/definitions/grib2/template.4.referenceperiod.def @@ -1,10 +1,11 @@ -# Type of reference dataset +# (C) Copyright 2005- ECMWF. +# Type of reference dataset codetable[1] typeOfReferenceDataset ('4.100.table',masterDir,localDir) = 255 : dump,edition_specific; -# Type of relation to reference dataset +# Type of relation to reference dataset codetable[1] typeOfRelationToReferenceDataset ('4.101.table',masterDir,localDir) = 255 : dump,edition_specific; -# number of additional parameters +# Number of additional parameters unsigned[1] numberOfAdditionalParametersForReferencePeriod=0 ; additionalParameter list(numberOfAdditionalParametersForReferencePeriod) { @@ -32,7 +33,7 @@ meta startDateOfReferencePeriod g2date(yearOfStartOfReferencePeriod,monthOfStart unsigned[4] sampleSizeOfReferencePeriod = 0; -# n - number of time range specifications describing the time intervals used to calculate the statistically-processed field +# Number of time range specifications describing the time intervals used to calculate the statistically-processed field unsigned[1] numberOfReferencePeriodTimeRanges = 1 : edition_specific; alias nref = numberOfReferencePeriodTimeRanges; diff --git a/definitions/grib2/template.4.reforecast.def b/definitions/grib2/template.4.reforecast.def index f415ce80a..a8a431936 100644 --- a/definitions/grib2/template.4.reforecast.def +++ b/definitions/grib2/template.4.reforecast.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # The Model Version Date # This is the date when the reforecast is produced with a particular version of the model diff --git a/definitions/grib2/template.4.wave.def b/definitions/grib2/template.4.wave.def index 37c3f4523..742c0ece4 100644 --- a/definitions/grib2/template.4.wave.def +++ b/definitions/grib2/template.4.wave.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave parameters ## Direction part diff --git a/definitions/grib2/template.4.wave_period_range.def b/definitions/grib2/template.4.wave_period_range.def index 3bd02fa4f..278ddf689 100644 --- a/definitions/grib2/template.4.wave_period_range.def +++ b/definitions/grib2/template.4.wave_period_range.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave parameters defined on a certain period range # Type of period interval diff --git a/definitions/grib2/template.4.wave_spectra_formula.def b/definitions/grib2/template.4.wave_spectra_formula.def index c0893da1a..4a5e61fdd 100644 --- a/definitions/grib2/template.4.wave_spectra_formula.def +++ b/definitions/grib2/template.4.wave_spectra_formula.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave spectra defined using a formula for frequency and direction ## Direction part diff --git a/definitions/grib2/template.4.wave_spectra_list.def b/definitions/grib2/template.4.wave_spectra_list.def index 85fa6fc7d..ca7768604 100644 --- a/definitions/grib2/template.4.wave_spectra_list.def +++ b/definitions/grib2/template.4.wave_spectra_list.def @@ -1,3 +1,5 @@ +# (C) Copyright 2005- ECMWF. + # Template for wave spectra defined using an array of frequencies and directions ## Direction part From 54cb58bf31283864e779c2b40441fc85461ae0e7 Mon Sep 17 00:00:00 2001 From: shahramn Date: Tue, 14 May 2024 15:52:29 +0100 Subject: [PATCH 64/90] ECC-1706: Definitions: Align WMO Common Code Table 11 with ecCodes c-11 table --- definitions/common/c-11.table | 109 ++++++++++++++++++++++++++++++++-- tests/bufr_extract_headers.sh | 2 +- 2 files changed, 106 insertions(+), 5 deletions(-) diff --git a/definitions/common/c-11.table b/definitions/common/c-11.table index 778001045..6750fda58 100644 --- a/definitions/common/c-11.table +++ b/definitions/common/c-11.table @@ -23,6 +23,7 @@ 22 22 ACMAD 23 23 Mozambique (NMC) 24 fapr Pretoria (RSMC) +25 25 La Reunion (RSMC) 26 26 Khabarovsk (RSMC) 28 vabb New Delhi (IMD) 29 dems New Delhi (NCMRWF) @@ -58,12 +59,14 @@ 64 64 Honolulu 65 65 Darwin (RSMC) 67 67 Melbourne (RSMC) +# 68 Reserved 69 nzkl Wellington (RSMC/RAFC) 71 71 Nadi (RSMC) 72 72 Singapore 73 73 Malaysia (NMC) 74 egrr U.K. Met Office - Exeter 76 76 Moscow (RSMC/RAFC) +# 77 Reserved 78 edzw Offenbach (RSMC) 80 cnmc Rome (RSMC) 82 eswi Norrkoping @@ -93,15 +96,68 @@ 107 107 Uganda (NMC) 108 108 United Republic of Tanzania (NMC) 109 109 Zimbabwe (NMC) -110 110 Hong-Kong +110 110 Hong Kong +111 111 Afghanistan (NMC) +112 112 Bahrain (NMC) +113 113 Bangladesh (NMC) +114 114 Bhutan (NMC) +115 115 Cambodia (NMC) +116 116 Democratic People's Republic of Korea (NMC) +117 117 Islamic Republic of Iran (NMC) +118 118 Iraq (NMC) +119 119 Kazakhstan (NMC) +120 120 Kuwait (NMC) +121 121 Kyrgyzstan (NMC) +122 122 Lao People's Democratic Republic (NMC) +123 123 "Macao China" +124 124 Maldives (NMC) +125 125 Myanmar (NMC) +126 126 Nepal (NMC) +127 127 Oman (NMC) +128 128 Pakistan (NMC) +129 129 Qatar (NMC) +130 130 Yemen (NMC) +131 131 Sri Lanka (NMC) +132 132 Tajikistan (NMC) +133 133 Turkmenistan (NMC) +134 134 United Arab Emirates (NMC) +135 135 Uzbekistan (NMC) +136 136 Viet Nam (NMC) +# 137-139 Reserved for other centres +140 140 Bolivia (Plurinational State of) (NMC) +141 141 Guyana (NMC) +142 142 Paraguay (NMC) +143 143 Suriname (NMC) +144 144 Uruguay (NMC) 145 145 French Guiana 146 146 Brazilian Navy Hydrographic Centre 147 147 National Commission on Space Activities (CONAE) - Argentina 148 148 Brazilian Department of Airspace Control - DECEA +# 149 Reserved for other centres +150 150 Antigua and Barbuda (NMC) +151 151 Bahamas (NMC) +152 152 Barbados (NMC) +153 153 Belize (NMC) +154 154 British Caribbean Territories Centre +155 155 San Jose +156 156 Cuba (NMC) +157 157 Dominica (NMC) +158 158 Dominican Republic (NMC) +159 159 El Salvador (NMC) 160 160 US NOAA/NESDIS 161 161 US NOAA Office of Oceanic and Atmospheric Research +162 162 Guatemala (NMC) +163 163 Haiti (NMC) +164 164 Honduras (NMC) +165 165 Jamaica (NMC) +166 166 Mexico +167 167 Curacao and Sint Maarten (NMC) +168 168 Nicaragua (NMC) +169 169 Panama (NMC) +170 170 Saint Lucia (NMC) +171 171 Trinidad and Tobago (NMC) +172 172 French Departments in RA IV 173 nasa US National Aeronautics and Space Administration (NASA) - 174 174 Integrated Science Data Management/Marine Environmental Data Service (ISDM/MEDS - Canada) 175 175 University Corporation for Atmospheric Research (UCAR) - United States 176 176 Cooperative Institute for Meteorological Satellite Studies (CIMSS) - United States @@ -110,9 +166,23 @@ 179 179 GeoOptics, Inc. 180 180 PlanetiQ 181 181 Atmospheric and Environmental Research (AER) - +# 182-189 Reserved for other centres +190 190 Cook Islands (NMC) +191 191 French Polynesia (NMC) +192 192 Tonga (NMC) +193 193 Vanuatu (NMC) +194 194 Brunei Darussalam (NMC) 195 wiix Indonesia (NMC) +196 196 Kiribati (NMC) +197 197 Federated States of Micronesia (NMC) +198 198 New Caledonia (NMC) +199 199 Niue +200 200 Papua New Guinea (NMC) +201 201 Philippines (NMC) +202 202 Samoa (NMC) +203 203 Solomon Islands (NMC) 204 niwa National Institute of Water and Atmospheric Research (NIWA - New Zealand) +# 205-209 Reserved for other centres 210 210 Frascati (ESA/ESRIN) 211 211 Lannion 212 212 Lisboa @@ -139,18 +209,24 @@ 233 eidb Dublin 234 234 Israel (NMC) 235 ingv INGV +236 236 Latvia (NMC) +237 237 Lebanon (NMC) 238 238 Lithuania (NMC) 239 crfc CERFAX 240 240 Malta (NMC) 241 241 Monaco 242 242 Romania (NMC) +243 243 Syrian Arab Republic (NMC) 244 vuwien VUWien 245 knmi KNMI 246 ifmk IfM-Kiel 247 hadc Hadley Centre +248 248 Montenegro (NMC) +249 249 Barcelona Dust Forecast Center 250 cosmo COnsortium for Small scale MOdelling (COSMO) 251 251 Meteorological Cooperation on Operational NWP (MetCoOp) 252 mpim Max Planck Institute for Meteorology (MPI-M) +253 253 Alfred Wegener Institute (AWI) 254 eums EUMETSAT Operation Centre 255 consensus Consensus 256 256 Angola (NMC) @@ -184,9 +260,10 @@ 284 284 Sierra Leone (NMC) 285 285 Somalia (NMC) 286 286 Sudan (NMC) -287 287 Swaziland (NMC) +287 287 Eswatini (NMC) 288 288 Togo (NMC) 289 289 Zambia (NMC) +290 290 EUMETNET E-Profile 291 anso Alliance of International Science Organizations (Beijing, China) 292 ufz Helmholtz Centre for Environmental Research 293 293 University of Bremen @@ -196,4 +273,28 @@ 297 297 The Nanjing Institute of Environmental Sciences (NIES) 298 298 Dynamic Meteorology Laboratory (LMD) 299 299 The Rutherford Appleton Laboratory (RAL) +300 300 Greek Atomic Energy Commission (Greece) +301 301 United Stated Environmental Protection Agency (USA) +302 302 Autralian Radiation Protection and Nuclear Safety (Australia) +303 303 Authority for Nuclear Safety and Radiation Protection (The Netherlands) +304 304 Autorite de Surete Nucleaire (France) +305 305 Bundesamt für Strahlenschutz (Germany) +306 306 National Commission for Nuclear Activities Control (Romania) +307 307 Consejo de Seguridad Nuclear (Spain) +308 308 Danish Emergency Management Agency (Denmark) +309 309 Norwegian Radiation Protection Agency (Norway) +310 310 Federal Agency for Nuclear Control (Belgium) +311 311 Institute of Radiation Protection and Dosimetry (Brazil) +312 312 National Inspectorate for Nuclear Safety and Radiation Protection (Italy) +313 313 Nuclear Regulatory Authority (Turkiye) +314 314 Nuclear Regulation Authority (Japan) +315 315 Nuclear Regulatory Agency (Bulgaria) +316 316 Ukrainian Radiation Protection Institute (Ukriane) +317 317 Health Canada Radio Protection Bureau (Canada) +318 318 Portuguese Society for Radiation Protection (Portugal) +319 319 Swedish Radiation Safety Authority (Sweden) +320 320 Radiation and Nuclear Safety Authority (Finland) +321 321 State Office for Nuclear Safety (Czechia) +322 322 Nuclear Regulation Authority (Slovakia) +# 323-65534 Reserved for other centres 65535 65535 Missing value diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index 481a5cd2f..4b2b92b08 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -64,7 +64,7 @@ r=`${test_dir}/bufr_extract_headers centre ${data_dir}/bufr/israel_observations_ # Check all centres with an abbreviation centre_table=${ECCODES_DEFINITION_PATH}/common/c-11.table -centres=`awk 'NR > 1 {print $2}' < $centre_table` +centres=`awk 'NR > 1 && $1 !~ /#/ {print $2}' < $centre_table` for c in $centres; do ${tools_dir}/bufr_set -s centre=$c $ECCODES_SAMPLES_PATH/BUFR4.tmpl $temp1 r=`${test_dir}/bufr_extract_headers centre $temp1` From b9de295b4b62228cdd6368378e7858145b1dcec4 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 15 May 2024 09:52:37 +0000 Subject: [PATCH 65/90] ECC-1828: GRIB2: Add new FT2024-1 parameters from issue #221 --- definitions/grib2/cfVarName.def | 42 +++++++++++++++++++++++++++++++++ definitions/grib2/name.def | 42 +++++++++++++++++++++++++++++++++ definitions/grib2/paramId.def | 42 +++++++++++++++++++++++++++++++++ definitions/grib2/shortName.def | 42 +++++++++++++++++++++++++++++++++ definitions/grib2/units.def | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 210 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 0893cd19c..d72793b3b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -7168,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'spi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'spei' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'ssfi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'srsi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'swi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'smri' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'sdi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'utci' = { discipline = 20 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index ad51e0531..a64e2c630 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -7168,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'Standardised Precipitation Index (SPI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'Standardised Precipitation Evapotranspiration Index (SPEI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'Standardised Streamflow Index (SSFI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'Standardised Reservoir Supply Index (SRSI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'Standardised Water-level Index (SWI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'Standardised Snowmelt and Rain Index (SMRI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'Streamflow Drought Index (SDI)' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'Universal thermal climate index' = { discipline = 20 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index ebd8fa26b..a9f5f256e 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -7168,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'260658' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'260659' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'260660' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'260661' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'260662' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'260663' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'260664' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index '261001' = { discipline = 20 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index fb3e581c8..4d68cb57c 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -7168,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'spi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'spei' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'ssfi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'srsi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'swi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'smri' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'sdi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'utci' = { discipline = 20 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index e1ef35857..4a6bde706 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -7168,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'K' = { discipline = 20 ; From d34b870a595ea0b87a57ea559b3f8fcf3445c0c5 Mon Sep 17 00:00:00 2001 From: Sebastien Villaume Date: Wed, 15 May 2024 11:45:23 +0100 Subject: [PATCH 66/90] ECC-1821 adding configurations for mmsf/an --- definitions/mars/grib.mmsf.an.def | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 definitions/mars/grib.mmsf.an.def diff --git a/definitions/mars/grib.mmsf.an.def b/definitions/mars/grib.mmsf.an.def new file mode 100644 index 000000000..c002f9d76 --- /dev/null +++ b/definitions/mars/grib.mmsf.an.def @@ -0,0 +1,26 @@ +if (levtype is "o2d" || levtype is "o3d") { + alias mars.step = stepRange; +} else { + alias mars.step = endStep; +} + +if (class is "od") { alias mars.system = systemNumber; } +if (class is "me") { alias mars.system = systemNumber; } +if (class is "en") { alias mars.system = systemNumber; } +if (class is "c3") { alias mars.system = systemNumber; } +if (class is "ci") { alias mars.system = systemNumber; } +alias mars.number = perturbationNumber; +alias mars.method = methodNumber; + +if (!(class is "gw")) { # ECC-1448 + alias mars.origin = centre; +} + +# See ECC-624 +if (centre == 80 && subCentre == 98 && class is "c3") { + constant cnmc_cmcc = 'cmcc'; + alias mars.origin = cnmc_cmcc; +} + +if (class is "ci") { unalias mars.method; } + From b8fbaeeb8b4e3f2ada644d62235760396a0f1f36 Mon Sep 17 00:00:00 2001 From: Sebastien Villaume Date: Wed, 15 May 2024 14:48:36 +0100 Subject: [PATCH 67/90] unalias step as type an do not have steps --- definitions/mars/grib.mmsf.an.def | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/definitions/mars/grib.mmsf.an.def b/definitions/mars/grib.mmsf.an.def index c002f9d76..0a489319c 100644 --- a/definitions/mars/grib.mmsf.an.def +++ b/definitions/mars/grib.mmsf.an.def @@ -1,8 +1,5 @@ -if (levtype is "o2d" || levtype is "o3d") { - alias mars.step = stepRange; -} else { - alias mars.step = endStep; -} +#no step in type an +unalias mars.step; if (class is "od") { alias mars.system = systemNumber; } if (class is "me") { alias mars.system = systemNumber; } From 34346119200a1b1546f13fd792559e223727f2fc Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 15 May 2024 14:15:24 +0000 Subject: [PATCH 68/90] ECC-1827: GRIB2: Add new FT2024-1 parameters from issue #227 (Make 140254 legacy) --- definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def | 6 ++++++ definitions/grib2/localConcepts/ecmf/name.legacy.def | 6 ++++++ definitions/grib2/localConcepts/ecmf/paramId.legacy.def | 6 ++++++ definitions/grib2/localConcepts/ecmf/shortName.legacy.def | 6 ++++++ definitions/grib2/localConcepts/ecmf/units.legacy.def | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def index c1c9099b5..cb38cc6e2 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def @@ -1771,3 +1771,9 @@ parameterCategory = 172 ; parameterNumber = 212 ; } +#Wave spectral peakedness +'wsp' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 254 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/name.legacy.def b/definitions/grib2/localConcepts/ecmf/name.legacy.def index 7a451911c..28b2586ef 100644 --- a/definitions/grib2/localConcepts/ecmf/name.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/name.legacy.def @@ -1771,3 +1771,9 @@ parameterCategory = 172 ; parameterNumber = 212 ; } +#Wave spectral peakedness +'Wave spectral peakedness' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 254 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def index 4413e87b9..df813254f 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def @@ -1771,3 +1771,9 @@ parameterCategory = 172 ; parameterNumber = 212 ; } +#Wave spectral peakedness +'140254' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 254 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def index 1a5608823..498f6a3c1 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def @@ -1771,3 +1771,9 @@ parameterCategory = 172 ; parameterNumber = 212 ; } +#Wave spectral peakedness +'wsp' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 254 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/units.legacy.def b/definitions/grib2/localConcepts/ecmf/units.legacy.def index b6a28f51b..d7675c4d6 100644 --- a/definitions/grib2/localConcepts/ecmf/units.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/units.legacy.def @@ -1771,3 +1771,9 @@ parameterCategory = 172 ; parameterNumber = 212 ; } +#Wave spectral peakedness +'dimensionless' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 254 ; +} From 2f86e13c7858186a81e6e789591028dc4650c8ae Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 15 May 2024 14:28:55 +0000 Subject: [PATCH 69/90] ECC-1827: GRIB2: Add new FT2024-1 parameters from issue #227 --- definitions/grib2/cfVarName.def | 48 +++++++++++++++++++ .../grib2/localConcepts/ecmf/cfVarName.def | 6 --- definitions/grib2/localConcepts/ecmf/name.def | 6 --- .../grib2/localConcepts/ecmf/paramId.def | 6 --- .../grib2/localConcepts/ecmf/shortName.def | 6 --- .../grib2/localConcepts/ecmf/units.def | 6 --- definitions/grib2/name.def | 48 +++++++++++++++++++ definitions/grib2/paramId.def | 48 +++++++++++++++++++ definitions/grib2/shortName.def | 48 +++++++++++++++++++ definitions/grib2/units.def | 48 +++++++++++++++++++ 10 files changed, 240 insertions(+), 30 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index d72793b3b..468304658 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -5211,6 +5211,48 @@ parameterCategory = 0 ; parameterNumber = 19 ; } +#Floodplain depth +'flddep' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + } +#Floodplain flooded fraction +'fldffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + } +#Floodplain flooded area +'fldfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + } +#River fraction +'rivfr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + } +#River area +'rivar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + } +#Fraction of river coverage plus river related flooding +'rivcffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + } +#Area of river coverage plus river related flooding +'rivcfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + } #Latitude 'lat' = { discipline = 0 ; @@ -10602,6 +10644,12 @@ parameterCategory = 0 ; parameterNumber = 44 ; } +#Wave spectral peakedness +'wsp' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 98 ; + } #Skin reservoir content 'srcrea' = { discipline = 2 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 7efe686a0..e99c871c7 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -16607,12 +16607,6 @@ parameterCategory = 140 ; parameterNumber = 250 ; } -#Wave spectral peakedness -'wsp' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 254 ; - } #Indicates a missing value 'p255.140' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index c5d77647c..e70af2e1b 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -16607,12 +16607,6 @@ parameterCategory = 140 ; parameterNumber = 250 ; } -#Wave spectral peakedness -'Wave spectral peakedness' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 254 ; - } #Indicates a missing value 'Indicates a missing value' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 12fe43ab4..04d3a8625 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -16607,12 +16607,6 @@ parameterCategory = 140 ; parameterNumber = 250 ; } -#Wave spectral peakedness -'140254' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 254 ; - } #Indicates a missing value '140255' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index b7e53c29d..dd15a6b74 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -16607,12 +16607,6 @@ parameterCategory = 140 ; parameterNumber = 250 ; } -#Wave spectral peakedness -'wsp' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 254 ; - } #Indicates a missing value '~' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 1629e52b0..9b73ff42a 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -16607,12 +16607,6 @@ parameterCategory = 140 ; parameterNumber = 250 ; } -#Wave spectral peakedness -'dimensionless' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 254 ; - } #Indicates a missing value '~' = { discipline = 192 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index a64e2c630..f281ae65d 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -5211,6 +5211,48 @@ parameterCategory = 0 ; parameterNumber = 19 ; } +#Floodplain depth +'Floodplain depth' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + } +#Floodplain flooded fraction +'Floodplain flooded fraction' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + } +#Floodplain flooded area +'Floodplain flooded area' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + } +#River fraction +'River fraction' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + } +#River area +'River area' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + } +#Fraction of river coverage plus river related flooding +'Fraction of river coverage plus river related flooding' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + } +#Area of river coverage plus river related flooding +'Area of river coverage plus river related flooding' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + } #Latitude 'Latitude' = { discipline = 0 ; @@ -10602,6 +10644,12 @@ parameterCategory = 0 ; parameterNumber = 44 ; } +#Wave spectral peakedness +'Wave spectral peakedness' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 98 ; + } #Skin reservoir content 'Skin reservoir content' = { discipline = 2 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index a9f5f256e..7f2556ee7 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -5211,6 +5211,48 @@ parameterCategory = 0 ; parameterNumber = 19 ; } +#Floodplain depth +'240035' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + } +#Floodplain flooded fraction +'240036' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + } +#Floodplain flooded area +'240037' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + } +#River fraction +'240038' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + } +#River area +'240039' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + } +#Fraction of river coverage plus river related flooding +'240040' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + } +#Area of river coverage plus river related flooding +'240041' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + } #Latitude '250001' = { discipline = 0 ; @@ -10602,6 +10644,12 @@ parameterCategory = 0 ; parameterNumber = 44 ; } +#Wave spectral peakedness +'140254' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 98 ; + } #Skin reservoir content '160198' = { discipline = 2 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 4d68cb57c..18e2dc8a7 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -5211,6 +5211,48 @@ parameterCategory = 0 ; parameterNumber = 19 ; } +#Floodplain depth +'flddep' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + } +#Floodplain flooded fraction +'fldffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + } +#Floodplain flooded area +'fldfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + } +#River fraction +'rivfr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + } +#River area +'rivar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + } +#Fraction of river coverage plus river related flooding +'rivcffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + } +#Area of river coverage plus river related flooding +'rivcfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + } #Latitude 'lat' = { discipline = 0 ; @@ -10602,6 +10644,12 @@ parameterCategory = 0 ; parameterNumber = 44 ; } +#Wave spectral peakedness +'wsp' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 98 ; + } #Skin reservoir content 'srcrea' = { discipline = 2 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 4a6bde706..6aaba2634 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -5211,6 +5211,48 @@ parameterCategory = 0 ; parameterNumber = 19 ; } +#Floodplain depth +'m' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + } +#Floodplain flooded fraction +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + } +#Floodplain flooded area +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + } +#River fraction +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + } +#River area +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + } +#Fraction of river coverage plus river related flooding +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + } +#Area of river coverage plus river related flooding +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + } #Latitude 'Degree N' = { discipline = 0 ; @@ -10602,6 +10644,12 @@ parameterCategory = 0 ; parameterNumber = 44 ; } +#Wave spectral peakedness +'dimensionless' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 98 ; + } #Skin reservoir content 'kg m**-2' = { discipline = 2 ; From bfd47cf18b739dc40cd300efc079767c0e771452 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 16 May 2024 14:48:05 +0100 Subject: [PATCH 70/90] ECC-782: Multi-field GRIB: crash in grib_handle_new_from_file_multi --- src/grib_handle.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/grib_handle.cc b/src/grib_handle.cc index 1bbcef4ae..a1801650a 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -637,7 +637,6 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data, while (grib2_get_next_section((unsigned char*)message, olen, &secbegin, &seclen, &secnum, &err)) { // seccount++; /*printf(" - %d - section %d length=%d\n",(int)seccount,(int)secnum,(int)seclen);*/ - gm->sections[secnum] = secbegin; gm->sections_length[secnum] = seclen; @@ -686,6 +685,11 @@ static grib_handle* grib_handle_new_multi(grib_context* c, unsigned char** data, break; } } + // ECC-782 + if (err == GRIB_INVALID_SECTION_NUMBER) { + grib_context_log(c, GRIB_LOG_ERROR, "%s: Failed to get section info (%s)", __func__, grib_get_error_message(err)); + return NULL; + } } else if (edition == 3) { *error = GRIB_UNSUPPORTED_EDITION; @@ -840,6 +844,11 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in break; } } + // ECC-782 + if (err == GRIB_INVALID_SECTION_NUMBER) { + grib_context_log(c, GRIB_LOG_ERROR, "%s: Failed to get section info (%s)", __func__, grib_get_error_message(err)); + return NULL; + } } else if (edition == 3) { /* GRIB3: Multi-field mode not yet supported */ From dfdb16b3377abfc179cf10d693ee9691429ca970 Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Wed, 15 May 2024 09:51:39 +0000 Subject: [PATCH 71/90] ECC-1829: Added oper pf by combining oper.fc and enfo.pf. --- definitions/mars/grib.oper.pf.def | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 definitions/mars/grib.oper.pf.def diff --git a/definitions/mars/grib.oper.pf.def b/definitions/mars/grib.oper.pf.def new file mode 100644 index 000000000..48f64b0d4 --- /dev/null +++ b/definitions/mars/grib.oper.pf.def @@ -0,0 +1,7 @@ +if (levtype is "o2d" || levtype is "o3d") { + alias mars.step = stepRange; +} else { + alias mars.step = endStep; +} + +alias mars.number = perturbationNumber; \ No newline at end of file From 6882914944a7d392f2c60e695697ffc13118ca0d Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Wed, 15 May 2024 10:56:08 +0000 Subject: [PATCH 72/90] ECC-1829: Test for introduction of grib.oper.pf.def. --- tests/CMakeLists.txt | 1 + tests/grib_ecc-1829.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 tests/grib_ecc-1829.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ac0f133de..71116ab24 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -148,6 +148,7 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1691 grib_ecc-1766 grib_ecc-1806 + grib_ecc-1829 bufr_ecc-1028 bufr_ecc-1195 bufr_ecc-1259 diff --git a/tests/grib_ecc-1829.sh b/tests/grib_ecc-1829.sh new file mode 100755 index 000000000..971660a71 --- /dev/null +++ b/tests/grib_ecc-1829.sh @@ -0,0 +1,38 @@ +#!/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 + +REDIRECT=/dev/null + +# ECC-1829: Add MARS support for stream & type combinations required for AIFS ensemble + +label="grib_ecc-1829_test" +temp_grib=temp.$label.grib +mars_sample=temp.$label.mars.grib +sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +# Setup ensemble GRIB2 message with MARS keys +${tools_dir}/grib_set -s setLocalDefinition=1,grib2LocalSectionNumber=1 $sample_grib2 $mars_sample + +# Set ensemble related keys and check number key is present +${tools_dir}/grib_set -s productDefinitionTemplateNumber=1,stream=oper,type=pf $mars_sample $temp_grib +grib_check_key_exists $temp_grib mars.number + +# Now check stepRange is used for mars.step for o2d and o3d fields, and that number is still present +${tools_dir}/grib_set -s productDefinitionTemplateNumber=11,stream=oper,type=pf,param=263101,typeOfLevel=oceanSurface,startStep=0,endStep=6 $mars_sample $temp_grib +grib_check_key_exists $temp_grib mars.number +grib_check_key_equals $temp_grib "step" "0-6" +${tools_dir}/grib_set -s productDefinitionTemplateNumber=11,stream=oper,type=pf,param=263501,typeOfLevel=oceanModel,level=1,startStep=0,endStep=6 $mars_sample $temp_grib +grib_check_key_exists $temp_grib mars.number +grib_check_key_equals $temp_grib "step" "0-6" + +# Clean up +rm -f $temp_grib $mars_sample From cf2a975b311e3cfe265b4c080b1d8b90353acffa Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Thu, 16 May 2024 15:03:51 +0000 Subject: [PATCH 73/90] ECC-1829: Added efi, es and em types to oper stream plus added to test Remaining to decide is behaviour between using endStep vs. using stepRange consistently and consequences. --- definitions/mars/grib.oper.efi.def | 1 + definitions/mars/grib.oper.em.def | 1 + definitions/mars/grib.oper.es.def | 1 + tests/grib_ecc-1829.sh | 24 ++++++++++++++++++------ 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 definitions/mars/grib.oper.efi.def create mode 100644 definitions/mars/grib.oper.em.def create mode 100644 definitions/mars/grib.oper.es.def diff --git a/definitions/mars/grib.oper.efi.def b/definitions/mars/grib.oper.efi.def new file mode 100644 index 000000000..a4cef5d68 --- /dev/null +++ b/definitions/mars/grib.oper.efi.def @@ -0,0 +1 @@ +alias mars.step = stepRange; diff --git a/definitions/mars/grib.oper.em.def b/definitions/mars/grib.oper.em.def new file mode 100644 index 000000000..a4cef5d68 --- /dev/null +++ b/definitions/mars/grib.oper.em.def @@ -0,0 +1 @@ +alias mars.step = stepRange; diff --git a/definitions/mars/grib.oper.es.def b/definitions/mars/grib.oper.es.def new file mode 100644 index 000000000..a4cef5d68 --- /dev/null +++ b/definitions/mars/grib.oper.es.def @@ -0,0 +1 @@ +alias mars.step = stepRange; diff --git a/tests/grib_ecc-1829.sh b/tests/grib_ecc-1829.sh index 971660a71..9e075e6b8 100755 --- a/tests/grib_ecc-1829.sh +++ b/tests/grib_ecc-1829.sh @@ -19,20 +19,32 @@ temp_grib=temp.$label.grib mars_sample=temp.$label.mars.grib sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl -# Setup ensemble GRIB2 message with MARS keys +# Setup GRIB2 message with MARS keys ${tools_dir}/grib_set -s setLocalDefinition=1,grib2LocalSectionNumber=1 $sample_grib2 $mars_sample -# Set ensemble related keys and check number key is present -${tools_dir}/grib_set -s productDefinitionTemplateNumber=1,stream=oper,type=pf $mars_sample $temp_grib +# Now set ensemble related keys and check number key is present +${tools_dir}/grib_set -s stream=oper,type=pf,productDefinitionTemplateNumber=1 $mars_sample $temp_grib grib_check_key_exists $temp_grib mars.number -# Now check stepRange is used for mars.step for o2d and o3d fields, and that number is still present -${tools_dir}/grib_set -s productDefinitionTemplateNumber=11,stream=oper,type=pf,param=263101,typeOfLevel=oceanSurface,startStep=0,endStep=6 $mars_sample $temp_grib +# Now set keys and check stepRange is used for mars.step for o2d and o3d fields, and that number is still present +${tools_dir}/grib_set -s stream=oper,type=pf,productDefinitionTemplateNumber=11,param=263101,typeOfLevel=oceanSurface,startStep=0,endStep=6 $mars_sample $temp_grib grib_check_key_exists $temp_grib mars.number grib_check_key_equals $temp_grib "step" "0-6" -${tools_dir}/grib_set -s productDefinitionTemplateNumber=11,stream=oper,type=pf,param=263501,typeOfLevel=oceanModel,level=1,startStep=0,endStep=6 $mars_sample $temp_grib +${tools_dir}/grib_set -s stream=oper,type=pf,productDefinitionTemplateNumber=11,param=263501,typeOfLevel=oceanModel,level=1,startStep=0,endStep=6 $mars_sample $temp_grib grib_check_key_exists $temp_grib mars.number grib_check_key_equals $temp_grib "step" "0-6" +# Now set keys and check stepRange is used for type efi data (just need any template with stat proc keys) +${tools_dir}/grib_set -s stream=oper,type=efi,productDefinitionTemplateNumber=12,startStep=0,endStep=6 $mars_sample $temp_grib +grib_check_key_equals $temp_grib "step" "0-6" + +# Now set keys and check stepRange is used for type em data +${tools_dir}/grib_set -s stream=oper,type=em,productDefinitionTemplateNumber=12,startStep=0,endStep=6 $mars_sample $temp_grib +grib_check_key_equals $temp_grib "step" "0-6" + +# Now set keys and check stepRange is used for type es data +${tools_dir}/grib_set -s stream=oper,type=es,productDefinitionTemplateNumber=12,startStep=0,endStep=6 $mars_sample $temp_grib +grib_check_key_equals $temp_grib "step" "0-6" + # Clean up rm -f $temp_grib $mars_sample From b066a1a5c35e521f89a238ebdfd4dba57c07fa20 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 17 May 2024 09:54:45 +0000 Subject: [PATCH 74/90] ECC-1826: GRIB2: Add time-mean versions of hydro dis / swi parameters --- definitions/grib2/cfVarName.def | 54 ++++++++++++------- .../grib2/localConcepts/hydro/cfVarName.def | 20 +++++++ .../grib2/localConcepts/hydro/name.def | 20 +++++++ .../grib2/localConcepts/hydro/paramId.def | 20 +++++++ .../grib2/localConcepts/hydro/shortName.def | 20 +++++++ .../grib2/localConcepts/hydro/units.def | 20 +++++++ definitions/grib2/name.def | 54 ++++++++++++------- definitions/grib2/paramId.def | 54 ++++++++++++------- definitions/grib2/shortName.def | 54 ++++++++++++------- definitions/grib2/units.def | 54 ++++++++++++------- 10 files changed, 270 insertions(+), 100 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 468304658..79e815ce2 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -5073,6 +5073,40 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean discharge from rivers or streams +'avg_dis' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (total layer) +'avg_swit' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (root zone) +'avg_swir' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 167 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index(layer) +'avg_swil' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 151 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; @@ -5139,26 +5173,6 @@ parameterCategory = 0 ; parameterNumber = 15 ; } -#Mean discharge in the last 6 hours -'dis06' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 6 ; - } -#Mean discharge in the last 24 hours -'dis24' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 24 ; - } #Snow depth at elevation bands 'sd_elev' = { discipline = 2 ; diff --git a/definitions/grib2/localConcepts/hydro/cfVarName.def b/definitions/grib2/localConcepts/hydro/cfVarName.def index 19b565498..a0f1b1f69 100644 --- a/definitions/grib2/localConcepts/hydro/cfVarName.def +++ b/definitions/grib2/localConcepts/hydro/cfVarName.def @@ -1,4 +1,24 @@ # Automatically generated by ./create_def.pl, do not edit +#Mean discharge in the last 6 hours +'dis06' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 6 ; + } +#Mean discharge in the last 24 hours +'dis24' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 24 ; + } #Total precipitation in the last 6 hours 'tp06' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/hydro/name.def b/definitions/grib2/localConcepts/hydro/name.def index 5390805f1..8becdbb9b 100644 --- a/definitions/grib2/localConcepts/hydro/name.def +++ b/definitions/grib2/localConcepts/hydro/name.def @@ -1,4 +1,24 @@ # Automatically generated by ./create_def.pl, do not edit +#Mean discharge in the last 6 hours +'Mean discharge in the last 6 hours' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 6 ; + } +#Mean discharge in the last 24 hours +'Mean discharge in the last 24 hours' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 24 ; + } #Total precipitation in the last 6 hours 'Total precipitation in the last 6 hours' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/hydro/paramId.def b/definitions/grib2/localConcepts/hydro/paramId.def index dfd704793..6f29e63ed 100644 --- a/definitions/grib2/localConcepts/hydro/paramId.def +++ b/definitions/grib2/localConcepts/hydro/paramId.def @@ -1,4 +1,24 @@ # Automatically generated by ./create_def.pl, do not edit +#Mean discharge in the last 6 hours +'240023' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 6 ; + } +#Mean discharge in the last 24 hours +'240024' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 24 ; + } #Total precipitation in the last 6 hours '260267' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/hydro/shortName.def b/definitions/grib2/localConcepts/hydro/shortName.def index 19b565498..a0f1b1f69 100644 --- a/definitions/grib2/localConcepts/hydro/shortName.def +++ b/definitions/grib2/localConcepts/hydro/shortName.def @@ -1,4 +1,24 @@ # Automatically generated by ./create_def.pl, do not edit +#Mean discharge in the last 6 hours +'dis06' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 6 ; + } +#Mean discharge in the last 24 hours +'dis24' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 24 ; + } #Total precipitation in the last 6 hours 'tp06' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/hydro/units.def b/definitions/grib2/localConcepts/hydro/units.def index 60d462f2d..11078673a 100644 --- a/definitions/grib2/localConcepts/hydro/units.def +++ b/definitions/grib2/localConcepts/hydro/units.def @@ -1,4 +1,24 @@ # Automatically generated by ./create_def.pl, do not edit +#Mean discharge in the last 6 hours +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 6 ; + } +#Mean discharge in the last 24 hours +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfFirstFixedSurface = 1 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 0 ; + lengthOfTimeRange = 24 ; + } #Total precipitation in the last 6 hours 'kg m**-2' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index f281ae65d..3c0160a0a 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -5073,6 +5073,40 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean discharge from rivers or streams +'Time-mean discharge from rivers or streams' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (total layer) +'Time-mean soil wetness index (total layer)' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (root zone) +'Time-mean soil wetness index (root zone)' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 167 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index(layer) +'Time-mean soil wetness index(layer)' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 151 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'Cross sectional area of flow in channel' = { discipline = 1 ; @@ -5139,26 +5173,6 @@ parameterCategory = 0 ; parameterNumber = 15 ; } -#Mean discharge in the last 6 hours -'Mean discharge in the last 6 hours' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 6 ; - } -#Mean discharge in the last 24 hours -'Mean discharge in the last 24 hours' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 24 ; - } #Snow depth at elevation bands 'Snow depth at elevation bands' = { discipline = 2 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 7f2556ee7..b8bd59db2 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -5073,6 +5073,40 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean discharge from rivers or streams +'235270' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (total layer) +'235271' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (root zone) +'235272' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 167 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index(layer) +'235273' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 151 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel '240011' = { discipline = 1 ; @@ -5139,26 +5173,6 @@ parameterCategory = 0 ; parameterNumber = 15 ; } -#Mean discharge in the last 6 hours -'240023' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 6 ; - } -#Mean discharge in the last 24 hours -'240024' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 24 ; - } #Snow depth at elevation bands '240026' = { discipline = 2 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 18e2dc8a7..bc55e8f9a 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -5073,6 +5073,40 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean discharge from rivers or streams +'avg_dis' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (total layer) +'avg_swit' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (root zone) +'avg_swir' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 167 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index(layer) +'avg_swil' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 151 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; @@ -5139,26 +5173,6 @@ parameterCategory = 0 ; parameterNumber = 15 ; } -#Mean discharge in the last 6 hours -'dis06' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 6 ; - } -#Mean discharge in the last 24 hours -'dis24' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 24 ; - } #Snow depth at elevation bands 'sd_elev' = { discipline = 2 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 6aaba2634..00797338a 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -5073,6 +5073,40 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean discharge from rivers or streams +'m**3 s**-1' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 7 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (total layer) +'Numeric' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index (root zone) +'Numeric' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 167 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil wetness index(layer) +'Numeric' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 30 ; + typeOfFirstFixedSurface = 151 ; + typeOfSecondFixedSurface = 151 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'm**2' = { discipline = 1 ; @@ -5139,26 +5173,6 @@ parameterCategory = 0 ; parameterNumber = 15 ; } -#Mean discharge in the last 6 hours -'m**3 s**-1' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 6 ; - } -#Mean discharge in the last 24 hours -'m**3 s**-1' = { - discipline = 1 ; - parameterCategory = 0 ; - parameterNumber = 7 ; - typeOfFirstFixedSurface = 1 ; - indicatorOfUnitForTimeRange = 1 ; - typeOfStatisticalProcessing = 0 ; - lengthOfTimeRange = 24 ; - } #Snow depth at elevation bands 'kg m**-2' = { discipline = 2 ; From 1fdd7195c5893ec0126f9873b675f451dcc829c0 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 17 May 2024 11:04:34 +0000 Subject: [PATCH 75/90] ECC-1825: GRIB2: Add remaining time-mean parameter encodings related to ERA pseudo-centre --- definitions/grib2/cfVarName.def | 77 ++++++++++++++++ .../grib2/localConcepts/ecmf/cfVarName.def | 8 ++ definitions/grib2/localConcepts/ecmf/name.def | 8 ++ .../grib2/localConcepts/ecmf/paramId.def | 8 ++ .../grib2/localConcepts/ecmf/shortName.def | 8 ++ .../grib2/localConcepts/ecmf/units.def | 8 ++ .../grib2/localConcepts/era/cfName.def | 21 +++++ definitions/grib2/localConcepts/era/name.def | 92 +++++++++++++++++++ .../grib2/localConcepts/era/paramId.def | 92 +++++++++++++++++++ .../grib2/localConcepts/era/shortName.def | 92 +++++++++++++++++++ definitions/grib2/localConcepts/era/units.def | 92 +++++++++++++++++++ definitions/grib2/localConcepts/era6/name.def | 8 ++ .../grib2/localConcepts/era6/paramId.def | 8 ++ .../grib2/localConcepts/era6/shortName.def | 8 ++ .../grib2/localConcepts/era6/units.def | 8 ++ .../grib2/localConcepts/uerra/cfVarName.def | 35 +++++++ .../grib2/localConcepts/uerra/name.def | 35 +++++++ .../grib2/localConcepts/uerra/paramId.def | 35 +++++++ .../grib2/localConcepts/uerra/shortName.def | 35 +++++++ .../grib2/localConcepts/uerra/units.def | 35 +++++++ definitions/grib2/name.def | 77 ++++++++++++++++ definitions/grib2/paramId.def | 77 ++++++++++++++++ definitions/grib2/shortName.def | 77 ++++++++++++++++ definitions/grib2/units.def | 77 ++++++++++++++++ 24 files changed, 1021 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 79e815ce2..3e0b0f0f4 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -4930,6 +4930,27 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific rain water content +'avg_crwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific snow water content +'avg_cswc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean eta-coordinate vertical velocity +'avg_etadot' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean geopotential 'avg_z' = { discipline = 0 ; @@ -4998,6 +5019,13 @@ typeOfSecondFixedSurface = 8 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean vorticity (relative) +'avg_vo' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean mean sea level pressure 'avg_msl' = { discipline = 0 ; @@ -5006,6 +5034,13 @@ typeOfFirstFixedSurface = 101 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean divergence +'avg_d' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean relative humidity 'avg_r' = { discipline = 0 ; @@ -5050,6 +5085,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean ozone mass mixing ratio +'avg_o3' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean temperature of snow layer 'avg_tsn' = { discipline = 2 ; @@ -5073,6 +5115,41 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific cloud liquid water content +'avg_clwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific cloud ice water content +'avg_ciwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of cloud cover +'avg_cc' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean K index +'avg_kx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total totals index +'avg_totalx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'avg_dis' = { discipline = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index e99c871c7..957489177 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -13839,6 +13839,14 @@ parameterNumber = 254 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean logarithm of surface pressure +'avg_lnsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean low cloud cover 'avg_lcc_frac' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index e70af2e1b..2f7444e2a 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -13839,6 +13839,14 @@ parameterNumber = 254 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean logarithm of surface pressure +'Time-mean logarithm of surface pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean low cloud cover 'Time-mean low cloud cover' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 04d3a8625..109f9f001 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -13839,6 +13839,14 @@ parameterNumber = 254 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean logarithm of surface pressure +'235152' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean low cloud cover '235186' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index dd15a6b74..0c36a8dd0 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -13839,6 +13839,14 @@ parameterNumber = 254 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean logarithm of surface pressure +'avg_lnsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean low cloud cover 'avg_lcc_frac' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 9b73ff42a..8a166eaa4 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -13839,6 +13839,14 @@ parameterNumber = 254 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean logarithm of surface pressure +'Numeric' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean low cloud cover '(0 - 1)' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era/cfName.def b/definitions/grib2/localConcepts/era/cfName.def index f4a8abea5..8292efdd2 100644 --- a/definitions/grib2/localConcepts/era/cfName.def +++ b/definitions/grib2/localConcepts/era/cfName.def @@ -27,6 +27,27 @@ parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } +#Vorticity (relative) +'atmosphere_relative_vorticity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } +#Divergence +'divergence_of_wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } +#Ozone mass mixing ratio +'mass_fraction_of_ozone_in_air' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Snow depth 'lwe_thickness_of_surface_snow_amount' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/era/name.def b/definitions/grib2/localConcepts/era/name.def index 78a476de6..82944f3b2 100644 --- a/definitions/grib2/localConcepts/era/name.def +++ b/definitions/grib2/localConcepts/era/name.def @@ -1,4 +1,25 @@ # Automatically generated by ./create_def.pl, do not edit +#Specific rain water content +'Specific rain water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'Specific snow water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Eta-coordinate vertical velocity +'Eta-coordinate vertical velocity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Geopotential 'Geopotential' = { discipline = 0 ; @@ -27,6 +48,13 @@ parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } +#Vorticity (relative) +'Vorticity (relative)' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Logarithm of surface pressure 'Logarithm of surface pressure' = { discipline = 0 ; @@ -34,6 +62,49 @@ parameterNumber = 25 ; typeOfFirstFixedSurface = 105 ; } +#Logarithm of surface pressure +'Logarithm of surface pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } +#Divergence +'Divergence' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } +#Ozone mass mixing ratio +'Ozone mass mixing ratio' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud liquid water content +'Specific cloud liquid water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'Specific cloud ice water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Fraction of cloud cover +'Fraction of cloud cover' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Temperature difference 'Temperature difference' = { discipline = 192 ; @@ -479,6 +550,13 @@ parameterCategory = 228 ; parameterNumber = 103 ; } +#Precipitation type +'Precipitation type' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Snow cover 'Snow cover' = { discipline = 0 ; @@ -486,6 +564,20 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#K index +'K index' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Total totals index +'Total totals index' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Sea water potential temperature 'Sea water potential temperature' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/era/paramId.def b/definitions/grib2/localConcepts/era/paramId.def index 31219cfa9..b4c978e14 100644 --- a/definitions/grib2/localConcepts/era/paramId.def +++ b/definitions/grib2/localConcepts/era/paramId.def @@ -1,4 +1,25 @@ # Automatically generated by ./create_def.pl, do not edit +#Specific rain water content +'75' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'76' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Eta-coordinate vertical velocity +'77' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Geopotential '129' = { discipline = 0 ; @@ -27,6 +48,13 @@ parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } +#Vorticity (relative) +'138' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Logarithm of surface pressure '152' = { discipline = 0 ; @@ -34,6 +62,49 @@ parameterNumber = 25 ; typeOfFirstFixedSurface = 105 ; } +#Logarithm of surface pressure +'152' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } +#Divergence +'155' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } +#Ozone mass mixing ratio +'203' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud liquid water content +'246' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'247' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Fraction of cloud cover +'248' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Temperature difference '200130' = { discipline = 192 ; @@ -479,6 +550,13 @@ parameterCategory = 228 ; parameterNumber = 103 ; } +#Precipitation type +'260015' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Snow cover '260038' = { discipline = 0 ; @@ -486,6 +564,20 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#K index +'260121' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Total totals index +'260123' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Sea water potential temperature '151129' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/era/shortName.def b/definitions/grib2/localConcepts/era/shortName.def index beb0f3d79..088ae3b62 100644 --- a/definitions/grib2/localConcepts/era/shortName.def +++ b/definitions/grib2/localConcepts/era/shortName.def @@ -1,4 +1,25 @@ # Automatically generated by ./create_def.pl, do not edit +#Specific rain water content +'crwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'cswc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Eta-coordinate vertical velocity +'etadot' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Geopotential 'z' = { discipline = 0 ; @@ -27,6 +48,13 @@ parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } +#Vorticity (relative) +'vo' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Logarithm of surface pressure 'lnsp' = { discipline = 0 ; @@ -34,6 +62,49 @@ parameterNumber = 25 ; typeOfFirstFixedSurface = 105 ; } +#Logarithm of surface pressure +'lnsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } +#Divergence +'d' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } +#Ozone mass mixing ratio +'o3' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud liquid water content +'clwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'ciwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Fraction of cloud cover +'cc' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Temperature difference 'tdiff' = { discipline = 192 ; @@ -479,6 +550,13 @@ parameterCategory = 228 ; parameterNumber = 103 ; } +#Precipitation type +'ptype' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Snow cover 'snowc' = { discipline = 0 ; @@ -486,6 +564,20 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#K index +'kx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Total totals index +'totalx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Sea water potential temperature 'thetao' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/era/units.def b/definitions/grib2/localConcepts/era/units.def index 95c5b4af8..01a6a7a9d 100644 --- a/definitions/grib2/localConcepts/era/units.def +++ b/definitions/grib2/localConcepts/era/units.def @@ -1,4 +1,25 @@ # Automatically generated by ./create_def.pl, do not edit +#Specific rain water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Eta-coordinate vertical velocity +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Geopotential 'm**2 s**-2' = { discipline = 0 ; @@ -27,6 +48,13 @@ parameterNumber = 8 ; typeOfStatisticalProcessing = 0 ; } +#Vorticity (relative) +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Logarithm of surface pressure 'Numeric' = { discipline = 0 ; @@ -34,6 +62,49 @@ parameterNumber = 25 ; typeOfFirstFixedSurface = 105 ; } +#Logarithm of surface pressure +'Numeric' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; + } +#Divergence +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } +#Ozone mass mixing ratio +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud liquid water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Fraction of cloud cover +'(0 - 1)' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Temperature difference 'K' = { discipline = 192 ; @@ -479,6 +550,13 @@ parameterCategory = 228 ; parameterNumber = 103 ; } +#Precipitation type +'code table (4.201)' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Snow cover '%' = { discipline = 0 ; @@ -486,6 +564,20 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#K index +'K' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Total totals index +'K' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Sea water potential temperature 'deg C' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/era6/name.def b/definitions/grib2/localConcepts/era6/name.def index b5c4fefb8..9505d62b1 100644 --- a/definitions/grib2/localConcepts/era6/name.def +++ b/definitions/grib2/localConcepts/era6/name.def @@ -408,4 +408,12 @@ constituentType = 3 ; typeOfStatisticalProcessing = 0 ; is_chemical = 1 ; + } +#Time-mean logarithm of surface pressure +'Time-mean logarithm of surface pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/era6/paramId.def b/definitions/grib2/localConcepts/era6/paramId.def index 85dc31997..fa04cbd0c 100644 --- a/definitions/grib2/localConcepts/era6/paramId.def +++ b/definitions/grib2/localConcepts/era6/paramId.def @@ -408,4 +408,12 @@ constituentType = 3 ; typeOfStatisticalProcessing = 0 ; is_chemical = 1 ; + } +#Time-mean logarithm of surface pressure +'235152' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/era6/shortName.def b/definitions/grib2/localConcepts/era6/shortName.def index 0b9c836b9..31ab28239 100644 --- a/definitions/grib2/localConcepts/era6/shortName.def +++ b/definitions/grib2/localConcepts/era6/shortName.def @@ -408,4 +408,12 @@ constituentType = 3 ; typeOfStatisticalProcessing = 0 ; is_chemical = 1 ; + } +#Time-mean logarithm of surface pressure +'avg_lnsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/era6/units.def b/definitions/grib2/localConcepts/era6/units.def index 699b0c19a..f80451dd4 100644 --- a/definitions/grib2/localConcepts/era6/units.def +++ b/definitions/grib2/localConcepts/era6/units.def @@ -408,4 +408,12 @@ constituentType = 3 ; typeOfStatisticalProcessing = 0 ; is_chemical = 1 ; + } +#Time-mean logarithm of surface pressure +'Numeric' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/uerra/cfVarName.def b/definitions/grib2/localConcepts/uerra/cfVarName.def index 2242d96a0..2b45a70b1 100644 --- a/definitions/grib2/localConcepts/uerra/cfVarName.def +++ b/definitions/grib2/localConcepts/uerra/cfVarName.def @@ -75,6 +75,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Specific rain water content +'crwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'cswc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } #Total column cloud liquid water 'tclw' = { discipline = 0 ; @@ -287,6 +301,20 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Specific cloud liquid water content +'clwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'ciwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } #2 metre specific humidity 'sh2' = { discipline = 0 ; @@ -298,6 +326,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Precipitation type +'ptype' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Total column integrated water vapour 'tciwv' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/name.def b/definitions/grib2/localConcepts/uerra/name.def index 59a55bdf5..95013cab1 100644 --- a/definitions/grib2/localConcepts/uerra/name.def +++ b/definitions/grib2/localConcepts/uerra/name.def @@ -75,6 +75,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Specific rain water content +'Specific rain water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'Specific snow water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } #Total column cloud liquid water 'Total column cloud liquid water' = { discipline = 0 ; @@ -287,6 +301,20 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Specific cloud liquid water content +'Specific cloud liquid water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'Specific cloud ice water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } #2 metre specific humidity '2 metre specific humidity' = { discipline = 0 ; @@ -298,6 +326,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Precipitation type +'Precipitation type' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Total column integrated water vapour 'Total column integrated water vapour' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/paramId.def b/definitions/grib2/localConcepts/uerra/paramId.def index 8db696b0d..e7e0a9d65 100644 --- a/definitions/grib2/localConcepts/uerra/paramId.def +++ b/definitions/grib2/localConcepts/uerra/paramId.def @@ -75,6 +75,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Specific rain water content +'75' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'76' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } #Total column cloud liquid water '78' = { discipline = 0 ; @@ -287,6 +301,20 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Specific cloud liquid water content +'246' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'247' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } #2 metre specific humidity '174096' = { discipline = 0 ; @@ -298,6 +326,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Precipitation type +'260015' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Total column integrated water vapour '260057' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/shortName.def b/definitions/grib2/localConcepts/uerra/shortName.def index 9eefdd1fe..113e3e824 100644 --- a/definitions/grib2/localConcepts/uerra/shortName.def +++ b/definitions/grib2/localConcepts/uerra/shortName.def @@ -75,6 +75,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Specific rain water content +'crwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'cswc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } #Total column cloud liquid water 'tclw' = { discipline = 0 ; @@ -287,6 +301,20 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Specific cloud liquid water content +'clwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'ciwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } #2 metre specific humidity '2sh' = { discipline = 0 ; @@ -298,6 +326,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Precipitation type +'ptype' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Total column integrated water vapour 'tciwv' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/units.def b/definitions/grib2/localConcepts/uerra/units.def index 1abfdfd20..760c09d28 100644 --- a/definitions/grib2/localConcepts/uerra/units.def +++ b/definitions/grib2/localConcepts/uerra/units.def @@ -75,6 +75,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Specific rain water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific snow water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } #Total column cloud liquid water 'kg m**-2' = { discipline = 0 ; @@ -287,6 +301,20 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Specific cloud liquid water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific cloud ice water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } #2 metre specific humidity 'kg kg**-1' = { discipline = 0 ; @@ -298,6 +326,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Precipitation type +'code table (4.201)' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } #Total column integrated water vapour 'kg m**-2' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 3c0160a0a..ceddbd354 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -4930,6 +4930,27 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific rain water content +'Time-mean specific rain water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific snow water content +'Time-mean specific snow water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean eta-coordinate vertical velocity +'Time-mean eta-coordinate vertical velocity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean geopotential 'Time-mean geopotential' = { discipline = 0 ; @@ -4998,6 +5019,13 @@ typeOfSecondFixedSurface = 8 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean vorticity (relative) +'Time-mean vorticity (relative)' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean mean sea level pressure 'Time-mean mean sea level pressure' = { discipline = 0 ; @@ -5006,6 +5034,13 @@ typeOfFirstFixedSurface = 101 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean divergence +'Time-mean divergence' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean relative humidity 'Time-mean relative humidity' = { discipline = 0 ; @@ -5050,6 +5085,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean ozone mass mixing ratio +'Time-mean ozone mass mixing ratio' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean temperature of snow layer 'Time-mean temperature of snow layer' = { discipline = 2 ; @@ -5073,6 +5115,41 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific cloud liquid water content +'Time-mean specific cloud liquid water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific cloud ice water content +'Time-mean specific cloud ice water content' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of cloud cover +'Time-mean fraction of cloud cover' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean K index +'Time-mean K index' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total totals index +'Time-mean total totals index' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'Time-mean discharge from rivers or streams' = { discipline = 1 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index b8bd59db2..9d5c36c08 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -4930,6 +4930,27 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific rain water content +'235101' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific snow water content +'235102' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean eta-coordinate vertical velocity +'235103' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean geopotential '235129' = { discipline = 0 ; @@ -4998,6 +5019,13 @@ typeOfSecondFixedSurface = 8 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean vorticity (relative) +'235138' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean mean sea level pressure '235151' = { discipline = 0 ; @@ -5006,6 +5034,13 @@ typeOfFirstFixedSurface = 101 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean divergence +'235155' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean relative humidity '235157' = { discipline = 0 ; @@ -5050,6 +5085,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean ozone mass mixing ratio +'235203' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean temperature of snow layer '235238' = { discipline = 2 ; @@ -5073,6 +5115,41 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific cloud liquid water content +'235246' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific cloud ice water content +'235247' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of cloud cover +'235248' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean K index +'235257' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total totals index +'235258' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams '235270' = { discipline = 1 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index bc55e8f9a..ef199a6b9 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -4930,6 +4930,27 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific rain water content +'avg_crwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific snow water content +'avg_cswc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean eta-coordinate vertical velocity +'avg_etadot' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean geopotential 'avg_z' = { discipline = 0 ; @@ -4998,6 +5019,13 @@ typeOfSecondFixedSurface = 8 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean vorticity (relative) +'avg_vo' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean mean sea level pressure 'avg_msl' = { discipline = 0 ; @@ -5006,6 +5034,13 @@ typeOfFirstFixedSurface = 101 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean divergence +'avg_d' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean relative humidity 'avg_r' = { discipline = 0 ; @@ -5050,6 +5085,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean ozone mass mixing ratio +'avg_o3' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean temperature of snow layer 'avg_tsn' = { discipline = 2 ; @@ -5073,6 +5115,41 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific cloud liquid water content +'avg_clwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific cloud ice water content +'avg_ciwc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of cloud cover +'avg_cc' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean K index +'avg_kx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total totals index +'avg_totalx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'avg_dis' = { discipline = 1 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 00797338a..bd2bb02d3 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -4930,6 +4930,27 @@ parameterNumber = 42 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific rain water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 85 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific snow water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 86 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean eta-coordinate vertical velocity +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean geopotential 'm**2 s**-2' = { discipline = 0 ; @@ -4998,6 +5019,13 @@ typeOfSecondFixedSurface = 8 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean vorticity (relative) +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 12 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean mean sea level pressure 'Pa' = { discipline = 0 ; @@ -5006,6 +5034,13 @@ typeOfFirstFixedSurface = 101 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean divergence +'s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 13 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean relative humidity '%' = { discipline = 0 ; @@ -5050,6 +5085,13 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean ozone mass mixing ratio +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean temperature of snow layer 'K' = { discipline = 2 ; @@ -5073,6 +5115,41 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean specific cloud liquid water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 83 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific cloud ice water content +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 84 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of cloud cover +'(0 - 1)' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 32 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean K index +'K' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total totals index +'K' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'm**3 s**-1' = { discipline = 1 ; From ff790c48225c8878297df75fe99578b77ced17c4 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 17 May 2024 15:10:47 +0000 Subject: [PATCH 76/90] ECC-1822: GRIB2: Modification of sea ice thickness parameters --- definitions/grib2/cfVarName.def | 12 ------------ definitions/grib2/name.def | 12 ------------ definitions/grib2/paramId.def | 12 ------------ definitions/grib2/shortName.def | 12 ------------ definitions/grib2/units.def | 12 ------------ 5 files changed, 60 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 3e0b0f0f4..d96c4f5f2 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -7480,12 +7480,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; } #Sea ice area fraction 'siconc' = { @@ -8590,12 +8584,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index ceddbd354..a429aa897 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -7480,12 +7480,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; } #Sea ice area fraction 'Sea ice area fraction' = { @@ -8590,12 +8584,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 9d5c36c08..3e534871d 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -7480,12 +7480,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; } #Sea ice area fraction '262001' = { @@ -8590,12 +8584,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index ef199a6b9..29c96c4c4 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -7480,12 +7480,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; } #Sea ice area fraction 'siconc' = { @@ -8590,12 +8584,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index bd2bb02d3..108e1fb71 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -7480,12 +7480,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; } #Sea ice area fraction 'Fraction' = { @@ -8590,12 +8584,6 @@ discipline = 10 ; parameterCategory = 2 ; parameterNumber = 1 ; - typeOfFirstFixedSurface = 174 ; - typeOfSecondFixedSurface = 176 ; - scaledValueOfFirstFixedSurface = missing() ; - scaleFactorOfFirstFixedSurface = missing() ; - scaledValueOfSecondFixedSurface = missing() ; - scaleFactorOfSecondFixedSurface = missing() ; typeOfStatisticalProcessing = 0 ; } #Time-mean sea ice area fraction From a2761b997a887bcc678c2c36129b3e5a2d7f6381 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 18 May 2024 17:25:22 +0100 Subject: [PATCH 77/90] Testing: grib_to_netcdf options --- tests/grib_to_netcdf.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index f13d8475b..ba3589329 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -110,6 +110,14 @@ ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib ${tools_dir}/grib_set -s productDefinitionTemplateNumber=31 $sample2 $tempGrib ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib +ECCODES_DEBUG=-1 ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib + + +# The -u option +input=${data_dir}/sample.grib2 +${tools_dir}/grib_to_netcdf -u time -o $tempNetcdf $input + + echo "Test different resolutions ..." # ------------------------------------ # This should fail as messages have different resolutions @@ -170,6 +178,26 @@ set -e grep -q "Wrong message length" $tempText +# Non-GRIB input +input=$data_dir/bufr/aaen_55.bufr +set +e +${tools_dir}/grib_to_netcdf -o $tempNetcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Input does not contain any field" $tempText + + +# Bad reference date +input=$data_dir/sample.grib2 +set +e +${tools_dir}/grib_to_netcdf -Rxxx -o $tempNetcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid reference date" $tempText + + # Validity time check export GRIB_TO_NETCDF_CHECKVALIDTIME=0 ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib From 404a72ceb5bb761e5b18842a0bc9d2beb138081b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 20 May 2024 15:44:09 +0000 Subject: [PATCH 78/90] ECC-1833: GRIB2: Move parameters to CERISE pseudocentre --- definitions/grib2/cfVarName.def | 14 -------------- .../grib2/localConcepts/cerise/cfVarName.def | 14 ++++++++++++++ definitions/grib2/localConcepts/cerise/name.def | 14 ++++++++++++++ definitions/grib2/localConcepts/cerise/paramId.def | 14 ++++++++++++++ .../grib2/localConcepts/cerise/shortName.def | 14 ++++++++++++++ definitions/grib2/localConcepts/cerise/units.def | 14 ++++++++++++++ definitions/grib2/name.def | 14 -------------- definitions/grib2/paramId.def | 14 -------------- definitions/grib2/shortName.def | 14 -------------- definitions/grib2/units.def | 14 -------------- 10 files changed, 70 insertions(+), 70 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index d96c4f5f2..79f723514 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -4916,20 +4916,6 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } -#Time-mean snow depth -'avg_sde' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 11 ; - typeOfStatisticalProcessing = 0 ; - } -#Time-mean snow cover -'avg_snowc' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 42 ; - typeOfStatisticalProcessing = 0 ; - } #Time-mean specific rain water content 'avg_crwc' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/cerise/cfVarName.def b/definitions/grib2/localConcepts/cerise/cfVarName.def index dfb69cc17..9d88fb46e 100644 --- a/definitions/grib2/localConcepts/cerise/cfVarName.def +++ b/definitions/grib2/localConcepts/cerise/cfVarName.def @@ -153,6 +153,20 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth +'avg_sde' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'avg_snowc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth 'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; diff --git a/definitions/grib2/localConcepts/cerise/name.def b/definitions/grib2/localConcepts/cerise/name.def index cac36cdea..3d758e137 100644 --- a/definitions/grib2/localConcepts/cerise/name.def +++ b/definitions/grib2/localConcepts/cerise/name.def @@ -153,6 +153,20 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth +'Time-mean snow depth' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'Time-mean snow cover' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth 'Time-mean snow depth' = { localTablesVersion = 1 ; discipline = 0 ; diff --git a/definitions/grib2/localConcepts/cerise/paramId.def b/definitions/grib2/localConcepts/cerise/paramId.def index c4af1e971..a3f2a3407 100644 --- a/definitions/grib2/localConcepts/cerise/paramId.def +++ b/definitions/grib2/localConcepts/cerise/paramId.def @@ -153,6 +153,20 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth +'235095' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'235096' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth '235141' = { localTablesVersion = 1 ; discipline = 0 ; diff --git a/definitions/grib2/localConcepts/cerise/shortName.def b/definitions/grib2/localConcepts/cerise/shortName.def index dfb69cc17..9d88fb46e 100644 --- a/definitions/grib2/localConcepts/cerise/shortName.def +++ b/definitions/grib2/localConcepts/cerise/shortName.def @@ -153,6 +153,20 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth +'avg_sde' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'avg_snowc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth 'avg_sd_m' = { localTablesVersion = 1 ; discipline = 0 ; diff --git a/definitions/grib2/localConcepts/cerise/units.def b/definitions/grib2/localConcepts/cerise/units.def index afc663307..d5215c398 100644 --- a/definitions/grib2/localConcepts/cerise/units.def +++ b/definitions/grib2/localConcepts/cerise/units.def @@ -153,6 +153,20 @@ typeOfStatisticalProcessing = 1 ; } #Time-mean snow depth +'m' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth 'm of water equivalent' = { localTablesVersion = 1 ; discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index a429aa897..9f853ca7d 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -4916,20 +4916,6 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } -#Time-mean snow depth -'Time-mean snow depth' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 11 ; - typeOfStatisticalProcessing = 0 ; - } -#Time-mean snow cover -'Time-mean snow cover' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 42 ; - typeOfStatisticalProcessing = 0 ; - } #Time-mean specific rain water content 'Time-mean specific rain water content' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 3e534871d..3c8dea65b 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -4916,20 +4916,6 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } -#Time-mean snow depth -'235095' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 11 ; - typeOfStatisticalProcessing = 0 ; - } -#Time-mean snow cover -'235096' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 42 ; - typeOfStatisticalProcessing = 0 ; - } #Time-mean specific rain water content '235101' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 29c96c4c4..cf8f6b8d1 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -4916,20 +4916,6 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } -#Time-mean snow depth -'avg_sde' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 11 ; - typeOfStatisticalProcessing = 0 ; - } -#Time-mean snow cover -'avg_snowc' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 42 ; - typeOfStatisticalProcessing = 0 ; - } #Time-mean specific rain water content 'avg_crwc' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 108e1fb71..d8b24c9c4 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -4916,20 +4916,6 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } -#Time-mean snow depth -'m' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 11 ; - typeOfStatisticalProcessing = 0 ; - } -#Time-mean snow cover -'%' = { - discipline = 0 ; - parameterCategory = 1 ; - parameterNumber = 42 ; - typeOfStatisticalProcessing = 0 ; - } #Time-mean specific rain water content 'kg kg**-1' = { discipline = 0 ; From 869c7cdb1cba3f177643ca519eeaca43cf4a3fb2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 3 Jun 2024 09:11:28 +0000 Subject: [PATCH 79/90] ECC-1834: GRIB2: Add time-mean version of hydro parameters from WMO FT2024-1 --- definitions/grib2/cfVarName.def | 49 +++++++++++++++++++++++++++++++++ definitions/grib2/name.def | 49 +++++++++++++++++++++++++++++++++ definitions/grib2/paramId.def | 49 +++++++++++++++++++++++++++++++++ definitions/grib2/shortName.def | 49 +++++++++++++++++++++++++++++++++ definitions/grib2/units.def | 49 +++++++++++++++++++++++++++++++++ 5 files changed, 245 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 79f723514..ab2927b4a 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -5170,6 +5170,55 @@ typeOfSecondFixedSurface = 151 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean floodplain depth +'avg_flddep' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded fraction +'avg_fldffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded area +'avg_fldfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river fraction +'avg_rivfr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river area +'avg_rivar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of river coverage plus river related flooding +'avg_rivcffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean area of river coverage plus river related flooding +'avg_rivcfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 9f853ca7d..3432f9662 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -5170,6 +5170,55 @@ typeOfSecondFixedSurface = 151 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean floodplain depth +'Time-mean floodplain depth' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded fraction +'Time-mean floodplain flooded fraction' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded area +'Time-mean floodplain flooded area' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river fraction +'Time-mean river fraction' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river area +'Time-mean river area' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of river coverage plus river related flooding +'Time-mean fraction of river coverage plus river related flooding' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean area of river coverage plus river related flooding +'Time-mean area of river coverage plus river related flooding' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'Cross sectional area of flow in channel' = { discipline = 1 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 3c8dea65b..8f88f9348 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -5170,6 +5170,55 @@ typeOfSecondFixedSurface = 151 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean floodplain depth +'235274' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded fraction +'235275' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded area +'235276' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river fraction +'235277' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river area +'235278' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of river coverage plus river related flooding +'235279' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean area of river coverage plus river related flooding +'235280' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel '240011' = { discipline = 1 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index cf8f6b8d1..31b6cf9fe 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -5170,6 +5170,55 @@ typeOfSecondFixedSurface = 151 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean floodplain depth +'avg_flddep' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded fraction +'avg_fldffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded area +'avg_fldfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river fraction +'avg_rivfr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river area +'avg_rivar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of river coverage plus river related flooding +'avg_rivcffr' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean area of river coverage plus river related flooding +'avg_rivcfar' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index d8b24c9c4..90204df45 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -5170,6 +5170,55 @@ typeOfSecondFixedSurface = 151 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean floodplain depth +'m' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded fraction +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean floodplain flooded area +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 19 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river fraction +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 20 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean river area +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 21 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of river coverage plus river related flooding +'Proportion' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 22 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean area of river coverage plus river related flooding +'m**2' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 23 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'm**2' = { discipline = 1 ; From 0ced0096b17856f31c209ae42e358b62fc106c03 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 3 Jun 2024 10:20:05 +0000 Subject: [PATCH 80/90] ECC-1837: GRIB: Make code table units consistent --- .../grib1/localConcepts/ecmf/units.def | 4 +- .../grib1/localConcepts/rjtd/units.def | 2 +- definitions/grib2/localConcepts/era/units.def | 2 +- .../grib2/localConcepts/uerra/units.def | 2 +- definitions/grib2/units.def | 54 +++++++++---------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index 193a0e3c6..a5789c54c 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -195,12 +195,12 @@ indicatorOfParameter = 28 ; } #Type of low vegetation -'(code table 4.234)' = { +'(Code table 4.234)' = { table2Version = 128 ; indicatorOfParameter = 29 ; } #Type of high vegetation -'(code table 4.234)' = { +'(Code table 4.234)' = { table2Version = 128 ; indicatorOfParameter = 30 ; } diff --git a/definitions/grib1/localConcepts/rjtd/units.def b/definitions/grib1/localConcepts/rjtd/units.def index 05a2a7758..8e177dd35 100644 --- a/definitions/grib1/localConcepts/rjtd/units.def +++ b/definitions/grib1/localConcepts/rjtd/units.def @@ -486,7 +486,7 @@ indicatorOfParameter = 253 ; } #Type of vegetation -'Code Table JMA-252' = { +'(Code table JMA-252)' = { table2Version = 200 ; indicatorOfParameter = 252 ; } diff --git a/definitions/grib2/localConcepts/era/units.def b/definitions/grib2/localConcepts/era/units.def index 01a6a7a9d..28ac983af 100644 --- a/definitions/grib2/localConcepts/era/units.def +++ b/definitions/grib2/localConcepts/era/units.def @@ -551,7 +551,7 @@ parameterNumber = 103 ; } #Precipitation type -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; diff --git a/definitions/grib2/localConcepts/uerra/units.def b/definitions/grib2/localConcepts/uerra/units.def index 760c09d28..57ef3426f 100644 --- a/definitions/grib2/localConcepts/uerra/units.def +++ b/definitions/grib2/localConcepts/uerra/units.def @@ -327,7 +327,7 @@ typeOfStatisticalProcessing = 0 ; } #Precipitation type -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 90204df45..3d9d63a65 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -194,13 +194,13 @@ parameterNumber = 54 ; } #Type of low vegetation -'(code table 4.234)' = { +'(Code table 4.234)' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 57 ; } #Type of high vegetation -'(code table 4.234)' = { +'(Code table 4.234)' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 58 ; @@ -3377,7 +3377,7 @@ parameterNumber = 45 ; } #Wetland type -'Code table 4.239' = { +'(Code table 4.239)' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 46 ; @@ -5552,7 +5552,7 @@ parameterNumber = 18 ; } #Precipitation type -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -5620,7 +5620,7 @@ typeOfStatisticalProcessing = 1 ; } #Precipitable water category -'code table (4.202)' = { +'(Code table 4.202)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 30 ; @@ -6037,7 +6037,7 @@ parameterNumber = 7 ; } #Cloud type -'code table (4.203)' = { +'(Code table 4.203)' = { discipline = 0 ; parameterCategory = 6 ; parameterNumber = 8 ; @@ -6049,7 +6049,7 @@ parameterNumber = 9 ; } #Thunderstorm coverage -'code table (4.204)' = { +'(Code table 4.204)' = { discipline = 0 ; parameterCategory = 6 ; parameterNumber = 10 ; @@ -6181,7 +6181,7 @@ parameterNumber = 11 ; } #Aerosol type -'code table (4.205)' = { +'(Code table 4.205)' = { discipline = 0 ; parameterCategory = 13 ; parameterNumber = 0 ; @@ -6291,7 +6291,7 @@ parameterNumber = 8 ; } #Volcanic ash -'code table (4.206)' = { +'(Code table 4.206)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 4 ; @@ -6309,7 +6309,7 @@ parameterNumber = 6 ; } #Icing -'code table (4.207)' = { +'(Code table 4.207)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 7 ; @@ -6327,7 +6327,7 @@ parameterNumber = 9 ; } #Turbulence -'code table (4.208)' = { +'(Code table 4.208)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 10 ; @@ -6339,19 +6339,19 @@ parameterNumber = 11 ; } #Planetary boundary layer regime -'code table (4.209)' = { +'(Code table 4.209)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 12 ; } #Contrail intensity -'code table (4.210)' = { +'(Code table 4.210)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 13 ; } #Contrail engine type -'code table (4.211)' = { +'(Code table 4.211)' = { discipline = 0 ; parameterCategory = 19 ; parameterNumber = 14 ; @@ -6429,13 +6429,13 @@ parameterNumber = 1 ; } #Remotely sensed snow cover -'(code table 4.215)' = { +'(Code table 4.215)' = { discipline = 1 ; parameterCategory = 0 ; parameterNumber = 2 ; } #Elevation of snow covered terrain -'(code table 4.216)' = { +'(Code table 4.216)' = { discipline = 1 ; parameterCategory = 0 ; parameterNumber = 3 ; @@ -6501,7 +6501,7 @@ parameterNumber = 7 ; } #Land use -'code table (4.212)' = { +'(Code table 4.212)' = { discipline = 2 ; parameterCategory = 0 ; parameterNumber = 8 ; @@ -6669,7 +6669,7 @@ parameterNumber = 2 ; } #Cloud top height quality indicator -'Code table 4.219' = { +'(Code table 4.219)' = { discipline = 3 ; parameterCategory = 1 ; parameterNumber = 3 ; @@ -6875,7 +6875,7 @@ parameterNumber = 0 ; } #Precipitation type (most severe) in the last 1 hour -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -6884,7 +6884,7 @@ lengthOfTimeRange = 1 ; } #Precipitation type (most severe) in the last 3 hours -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -6893,7 +6893,7 @@ lengthOfTimeRange = 3 ; } #Precipitation type (most frequent) in the last 1 hour -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -6902,7 +6902,7 @@ lengthOfTimeRange = 1 ; } #Precipitation type (most frequent) in the last 3 hours -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -6911,7 +6911,7 @@ lengthOfTimeRange = 3 ; } #Precipitation type (most severe) in the last 6 hours -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -6920,7 +6920,7 @@ lengthOfTimeRange = 6 ; } #Precipitation type (most frequent) in the last 6 hours -'code table (4.201)' = { +'(Code table 4.201)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 19 ; @@ -7096,19 +7096,19 @@ parameterNumber = 6 ; } #Cloud mask -'Code table 4.217' = { +'(Code table 4.217)' = { discipline = 3 ; parameterCategory = 0 ; parameterNumber = 7 ; } #Pixel scene type -'Code table 4.218' = { +'(Code table 4.218)' = { discipline = 3 ; parameterCategory = 0 ; parameterNumber = 8 ; } #Fire detection indicator -'Code table 4.223' = { +'(Code table 4.223)' = { discipline = 3 ; parameterCategory = 0 ; parameterNumber = 9 ; From 2b0a0624ad4cc9a4f063cbe0cbb160c9aac98767 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 3 Jun 2024 15:13:39 +0000 Subject: [PATCH 81/90] ECC-1838: GRIB2: Aerosol diagnostics parameter --- definitions/grib2/cfVarName.def | 32 ++++++++++++++++++++++++++++++++ definitions/grib2/name.def | 32 ++++++++++++++++++++++++++++++++ definitions/grib2/paramId.def | 32 ++++++++++++++++++++++++++++++++ definitions/grib2/shortName.def | 32 ++++++++++++++++++++++++++++++++ definitions/grib2/units.def | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index ab2927b4a..68a976c5b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -10230,6 +10230,38 @@ is_chemical_srcsink = 1 ; sourceSinkChemicalPhysicalProcess = 7 ; } +#Aerosol optical depth +'aod' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 102 ; + } +#Single scattering albedo +'ssa' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 103 ; + } +#Asymmetry Factor +'asymf' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 104 ; + } +#Aerosol backscatter from top of atmosphere +'aerbscattoa' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 107 ; + typeOfFirstFixedSurface = 8 ; + } +#Aerosol backscatter from ground +'aerbscatgnd' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 108 ; + typeOfFirstFixedSurface = 1 ; + } #Pressure tendency 'ptend' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 3432f9662..d79232bcc 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -10230,6 +10230,38 @@ is_chemical_srcsink = 1 ; sourceSinkChemicalPhysicalProcess = 7 ; } +#Aerosol optical depth +'Aerosol optical depth' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 102 ; + } +#Single scattering albedo +'Single scattering albedo' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 103 ; + } +#Asymmetry Factor +'Asymmetry Factor' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 104 ; + } +#Aerosol backscatter from top of atmosphere +'Aerosol backscatter from top of atmosphere' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 107 ; + typeOfFirstFixedSurface = 8 ; + } +#Aerosol backscatter from ground +'Aerosol backscatter from ground' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 108 ; + typeOfFirstFixedSurface = 1 ; + } #Pressure tendency 'Pressure tendency' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 8f88f9348..e819eb5ab 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -10230,6 +10230,38 @@ is_chemical_srcsink = 1 ; sourceSinkChemicalPhysicalProcess = 7 ; } +#Aerosol optical depth +'457000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 102 ; + } +#Single scattering albedo +'458000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 103 ; + } +#Asymmetry Factor +'459000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 104 ; + } +#Aerosol backscatter from top of atmosphere +'460000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 107 ; + typeOfFirstFixedSurface = 8 ; + } +#Aerosol backscatter from ground +'461000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 108 ; + typeOfFirstFixedSurface = 1 ; + } #Pressure tendency '3003' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 31b6cf9fe..3019ffd73 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -10230,6 +10230,38 @@ is_chemical_srcsink = 1 ; sourceSinkChemicalPhysicalProcess = 7 ; } +#Aerosol optical depth +'aod' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 102 ; + } +#Single scattering albedo +'ssa' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 103 ; + } +#Asymmetry Factor +'asymf' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 104 ; + } +#Aerosol backscatter from top of atmosphere +'aerbscattoa' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 107 ; + typeOfFirstFixedSurface = 8 ; + } +#Aerosol backscatter from ground +'aerbscatgnd' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 108 ; + typeOfFirstFixedSurface = 1 ; + } #Pressure tendency 'ptend' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 3d9d63a65..175168e60 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -10230,6 +10230,38 @@ is_chemical_srcsink = 1 ; sourceSinkChemicalPhysicalProcess = 7 ; } +#Aerosol optical depth +'Numeric' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 102 ; + } +#Single scattering albedo +'(0 - 1)' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 103 ; + } +#Asymmetry Factor +'Numeric' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 104 ; + } +#Aerosol backscatter from top of atmosphere +'m**-1 sr**-1' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 107 ; + typeOfFirstFixedSurface = 8 ; + } +#Aerosol backscatter from ground +'m**-1 sr**-1' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 108 ; + typeOfFirstFixedSurface = 1 ; + } #Pressure tendency 'Pa s**-1' = { discipline = 0 ; From dbaaec7055ea795471b02a4977e44b2d3b1a8065 Mon Sep 17 00:00:00 2001 From: Sebastien Villaume Date: Mon, 3 Jun 2024 16:28:41 +0100 Subject: [PATCH 82/90] ECC-1831 remove the modelName concept --- .../grib2/localConcepts/cnmc/modelName.def | 7 -- .../grib2/localConcepts/edzw/modelName.def | 107 ------------------ .../grib2/localConcepts/lssw/modelName.def | 17 --- definitions/grib2/modelName.def | 43 ------- definitions/grib2/parameters.def | 3 - 5 files changed, 177 deletions(-) delete mode 100644 definitions/grib2/localConcepts/cnmc/modelName.def delete mode 100644 definitions/grib2/localConcepts/edzw/modelName.def delete mode 100644 definitions/grib2/localConcepts/lssw/modelName.def delete mode 100644 definitions/grib2/modelName.def diff --git a/definitions/grib2/localConcepts/cnmc/modelName.def b/definitions/grib2/localConcepts/cnmc/modelName.def deleted file mode 100644 index e7a85ed1f..000000000 --- a/definitions/grib2/localConcepts/cnmc/modelName.def +++ /dev/null @@ -1,7 +0,0 @@ -# modelName: Contribution from Daniel Lee @ DWD - -# defintions for Roma (COSMO LEPS) -'cosmo-leps' = { - subCentre=98; - grib2LocalSectionNumber=28; -} diff --git a/definitions/grib2/localConcepts/edzw/modelName.def b/definitions/grib2/localConcepts/edzw/modelName.def deleted file mode 100644 index 5af6fb6e6..000000000 --- a/definitions/grib2/localConcepts/edzw/modelName.def +++ /dev/null @@ -1,107 +0,0 @@ -# modelName: Contribution from Daniel Lee @ DWD - -# definitions for Offenbach -'cosmo_eu' = { - generatingProcessIdentifier=131; -} -'cosmo_eu' = { - generatingProcessIdentifier=132; -} -'cosmo_eu' = { - generatingProcessIdentifier=134; -} -'cosmo_eu' = { - generatingProcessIdentifier=135; -} -'cosmo_de' = { - generatingProcessIdentifier=137; -} -'cosmo_de' = { - generatingProcessIdentifier=138; -} -'cosmo_de-eps' = { - generatingProcessIdentifier=137; - typeOfEnsembleForecast=192; -} -'cosmo_de-eps' = { - generatingProcessIdentifier=138; - typeOfEnsembleForecast=192; -} - -#DWD model names for ICON -'icogl' = { - gridDefinitionTemplateNumber=101; - generatingProcessIdentifier=1; -} -'icogl130' = { - numberOfGridUsed=26; - generatingProcessIdentifier=1; -} -'icogl130l90' = { - numberOfGridUsed=26; - nlev=91; - generatingProcessIdentifier=1; -} -'icogl130p' = { - numberOfGridUsed=26; - typeOfFirstFixedSurface=100; - generatingProcessIdentifier=1; -} -'icoeu'= { - gridDefinitionTemplateNumber=101; - generatingProcessIdentifier=2; -} -'icoeu065' = { - numberOfGridUsed=27; - generatingProcessIdentifier=2; -} -'icoeu065l60' = { - numberOfGridUsed=27; - nlev=61; - generatingProcessIdentifier=2; -} -'icreu' = { - gridDefinitionTemplateNumber=0; - generatingProcessIdentifier=2; -} -'icreu_0.625' = { - gridDefinitionTemplateNumber=0; - Dx=62500; - Dy=62500; - generatingProcessIdentifier=2; -} -'icreu_0.625l60' = { - gridDefinitionTemplateNumber=0; - Dx=62500; - Dy=62500; - nlev=61; - generatingProcessIdentifier=2; -} -'icreu_0.625p' = { - gridDefinitionTemplateNumber=0; - Dx=62500; - Dy=62500; - typeOfFirstFixedSurface=100; - generatingProcessIdentifier=2; -} -'icreu_0.625z' = { - gridDefinitionTemplateNumber=0; - Dx=62500; - Dy=62500; - typeOfFirstFixedSurface=102; - generatingProcessIdentifier=2; -} -'icrde' = { - gridDefinitionTemplateNumber=0; - generatingProcessIdentifier=3; -} -'icrgl' = { - gridDefinitionTemplateNumber=0; - generatingProcessIdentifier=1; -} -'icrgl_0.25' = { - gridDefinitionTemplateNumber=0; - Dx=250000; - Dy=250000; - generatingProcessIdentifier=1; -} diff --git a/definitions/grib2/localConcepts/lssw/modelName.def b/definitions/grib2/localConcepts/lssw/modelName.def deleted file mode 100644 index 6413c0d1c..000000000 --- a/definitions/grib2/localConcepts/lssw/modelName.def +++ /dev/null @@ -1,17 +0,0 @@ -# modelName: Contribution from Daniel Lee @ DWD -# definitions for Zurich -'cosmo-1' = { - generatingProcessIdentifier=101; -} -'cosmo-2' = { - generatingProcessIdentifier=102; -} -'cosmo-7' = { - generatingProcessIdentifier=107; -} -'cosmo-e' = { - generatingProcessIdentifier=103; -} -'cosmo-e' = { - generatingProcessIdentifier=130; -} diff --git a/definitions/grib2/modelName.def b/definitions/grib2/modelName.def deleted file mode 100644 index 25b89c3d1..000000000 --- a/definitions/grib2/modelName.def +++ /dev/null @@ -1,43 +0,0 @@ -# modelName: Contribution from Daniel Lee @ DWD - -# COSMO -# general definition -'cosmo' = { originatingCentre=250; } -'cosmo' = { subCentre=250; } - -# definitions for ARPA-SIMC -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=36; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=139; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=144; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=148; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=31; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=32; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=34; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=38; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=42; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=46; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=131; } -# definitions for Moscow -'cosmo_ru' = { originatingCentre=76; - generatingProcessIdentifier=135; } -'cosmo_ru-eps' = { originatingCentre=76; - generatingProcessIdentifier=235;} - -# definitions for Athens -'cosmo-greece' = { originatingCentre=96;} -# definitions for Warsaw / Poland -'cosmo-poland' = { originatingCentre=220;} -# definitions for Romania -'cosmo-romania' = { originatingCentre=242;} - diff --git a/definitions/grib2/parameters.def b/definitions/grib2/parameters.def index 6ffe2fe0d..0ddf9f901 100644 --- a/definitions/grib2/parameters.def +++ b/definitions/grib2/parameters.def @@ -27,9 +27,6 @@ concept cfVarNameLegacyECMF(defaultShortName,"cfVarName.legacy.def",conceptsMast concept cfVarNameECMF (cfVarNameLegacyECMF,"cfVarName.def",conceptsMasterDir,conceptsLocalDirECMF): no_copy; concept cfVarName (cfVarNameECMF,"cfVarName.def",conceptsDir2,conceptsDir1): no_copy,dump; -# modelName: Contribution from Daniel Lee @ DWD -concept modelName (defaultName,"modelName.def",conceptsDir2,conceptsDir1): no_copy,dump,read_only; - template_nofail names "grib2/products_[productionStatusOfProcessedData].def"; meta ifsParam ifs_param(paramId,type); From aecae70c75e931d639603333864eed3d52282601 Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 3 Jun 2024 17:13:01 +0100 Subject: [PATCH 83/90] ECC-1831: GRIB2: Remove the 'modelName' concept --- definitions/grib3/modelName.def | 43 -------------------------------- definitions/grib3/parameters.def | 3 --- 2 files changed, 46 deletions(-) delete mode 100644 definitions/grib3/modelName.def diff --git a/definitions/grib3/modelName.def b/definitions/grib3/modelName.def deleted file mode 100644 index 25b89c3d1..000000000 --- a/definitions/grib3/modelName.def +++ /dev/null @@ -1,43 +0,0 @@ -# modelName: Contribution from Daniel Lee @ DWD - -# COSMO -# general definition -'cosmo' = { originatingCentre=250; } -'cosmo' = { subCentre=250; } - -# definitions for ARPA-SIMC -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=36; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=139; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=144; } -'cosmo-i2' = { originatingCentre=200; - generatingProcessIdentifier=148; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=31; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=32; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=34; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=38; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=42; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=46; } -'cosmo-i7' = { originatingCentre=200; - generatingProcessIdentifier=131; } -# definitions for Moscow -'cosmo_ru' = { originatingCentre=76; - generatingProcessIdentifier=135; } -'cosmo_ru-eps' = { originatingCentre=76; - generatingProcessIdentifier=235;} - -# definitions for Athens -'cosmo-greece' = { originatingCentre=96;} -# definitions for Warsaw / Poland -'cosmo-poland' = { originatingCentre=220;} -# definitions for Romania -'cosmo-romania' = { originatingCentre=242;} - diff --git a/definitions/grib3/parameters.def b/definitions/grib3/parameters.def index 907431c7b..322d0cd21 100644 --- a/definitions/grib3/parameters.def +++ b/definitions/grib3/parameters.def @@ -23,9 +23,6 @@ concept cfName (cfNameECMF,"cfName.def",conceptsMasterDir,conceptsLocalDirAll) : concept cfVarNameECMF (defaultShortName,"cfVarName.def",conceptsMasterDir,conceptsLocalDirECMF) : no_copy,dump; concept cfVarName (cfVarNameECMF,"cfVarName.def",conceptsMasterDir,conceptsLocalDirAll) : no_copy,dump; -# modelName: Contribution from Daniel Lee @ DWD -concept modelName (defaultName,"modelName.def",conceptsMasterDir,conceptsLocalDirAll): no_copy,dump,read_only; - template_nofail names "grib3/products_[productionStatusOfProcessedData].def"; meta ifsParam ifs_param(paramId,type); From df5896e885f499ba54e9e0519aa52d851e21d058 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 5 Jun 2024 15:32:21 +0000 Subject: [PATCH 84/90] ECC-1839: GRIB2: Add encoding for aerosol extinction coefficient --- definitions/grib2/cfVarName.def | 6 ++++++ definitions/grib2/name.def | 6 ++++++ definitions/grib2/paramId.def | 6 ++++++ definitions/grib2/shortName.def | 6 ++++++ definitions/grib2/units.def | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 68a976c5b..23f21f92b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -10262,6 +10262,12 @@ parameterNumber = 108 ; typeOfFirstFixedSurface = 1 ; } +#Aerosol extinction coefficient +'aerext' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 105 ; + } #Pressure tendency 'ptend' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index d79232bcc..28662c804 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -10262,6 +10262,12 @@ parameterNumber = 108 ; typeOfFirstFixedSurface = 1 ; } +#Aerosol extinction coefficient +'Aerosol extinction coefficient' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 105 ; + } #Pressure tendency 'Pressure tendency' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index e819eb5ab..79cac4f50 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -10262,6 +10262,12 @@ parameterNumber = 108 ; typeOfFirstFixedSurface = 1 ; } +#Aerosol extinction coefficient +'462000' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 105 ; + } #Pressure tendency '3003' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 3019ffd73..0069ad87e 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -10262,6 +10262,12 @@ parameterNumber = 108 ; typeOfFirstFixedSurface = 1 ; } +#Aerosol extinction coefficient +'aerext' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 105 ; + } #Pressure tendency 'ptend' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 175168e60..fe33403b3 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -10262,6 +10262,12 @@ parameterNumber = 108 ; typeOfFirstFixedSurface = 1 ; } +#Aerosol extinction coefficient +'m**-1' = { + discipline = 0 ; + parameterCategory = 20 ; + parameterNumber = 105 ; + } #Pressure tendency 'Pa s**-1' = { discipline = 0 ; From 7ac53385ae002ea52c166c3538fdd68bd2e9e0ff Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 6 Jun 2024 11:11:16 +0000 Subject: [PATCH 85/90] ECC-1836: GRIB2: Add correct unit to paramId 43 --- definitions/grib1/localConcepts/ecmf/units.def | 2 +- definitions/grib2/units.def | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index a5789c54c..bc63e7cd7 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -265,7 +265,7 @@ indicatorOfParameter = 42 ; } #Soil type -'~' = { +'(Code table 4.213)' = { table2Version = 128 ; indicatorOfParameter = 43 ; } diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index fe33403b3..3822020b3 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -226,7 +226,7 @@ typeOfFirstFixedSurface = 1 ; } #Soil type -'~' = { +'(Code table 4.213)' = { discipline = 2 ; parameterCategory = 3 ; parameterNumber = 0 ; From 2faecdb54b77b79ed448faad616b2bb0c56df7c0 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 6 Jun 2024 12:35:28 +0000 Subject: [PATCH 86/90] ECC-1835: GRIB2: Time-mean parameters for ERA6 on pressure levels --- definitions/grib2/cfVarName.def | 28 ++++++++++++++++++++++++++++ definitions/grib2/name.def | 28 ++++++++++++++++++++++++++++ definitions/grib2/paramId.def | 28 ++++++++++++++++++++++++++++ definitions/grib2/shortName.def | 28 ++++++++++++++++++++++++++++ definitions/grib2/units.def | 28 ++++++++++++++++++++++++++++ 5 files changed, 140 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 23f21f92b..b8f5167ce 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -4916,6 +4916,27 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean wind speed +'avg_ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean pressure +'avg_pres' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean potential vorticity +'avg_pv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean specific rain water content 'avg_crwc' = { discipline = 0 ; @@ -5136,6 +5157,13 @@ parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean clear air turbulence (CAT) +'avg_cat' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 29 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'avg_dis' = { discipline = 1 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 28662c804..5549e2347 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -4916,6 +4916,27 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean wind speed +'Time-mean wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean pressure +'Time-mean pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean potential vorticity +'Time-mean potential vorticity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean specific rain water content 'Time-mean specific rain water content' = { discipline = 0 ; @@ -5136,6 +5157,13 @@ parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean clear air turbulence (CAT) +'Time-mean clear air turbulence (CAT)' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 29 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'Time-mean discharge from rivers or streams' = { discipline = 1 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 79cac4f50..d46e87724 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -4916,6 +4916,27 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean wind speed +'235097' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean pressure +'235098' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean potential vorticity +'235100' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean specific rain water content '235101' = { discipline = 0 ; @@ -5136,6 +5157,13 @@ parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean clear air turbulence (CAT) +'235262' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 29 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams '235270' = { discipline = 1 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 0069ad87e..98e7bfd79 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -4916,6 +4916,27 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean wind speed +'avg_ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean pressure +'avg_pres' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean potential vorticity +'avg_pv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean specific rain water content 'avg_crwc' = { discipline = 0 ; @@ -5136,6 +5157,13 @@ parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean clear air turbulence (CAT) +'avg_cat' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 29 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'avg_dis' = { discipline = 1 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 3822020b3..23520ecec 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -4916,6 +4916,27 @@ parameterNumber = 18 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean pressure +'Pa' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean potential vorticity +'K m**2 kg**-1 s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean specific rain water content 'kg kg**-1' = { discipline = 0 ; @@ -5136,6 +5157,13 @@ parameterNumber = 4 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean clear air turbulence (CAT) +'m**2/3 s**-1' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 29 ; + typeOfStatisticalProcessing = 0 ; + } #Time-mean discharge from rivers or streams 'm**3 s**-1' = { discipline = 1 ; From 76179dc5183bd34083fa9497b2a0b7e630894f67 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 6 Jun 2024 12:49:11 +0000 Subject: [PATCH 87/90] ECC-1835: GRIB2: Time-mean parameters for ERA6 on pressure levels (part 2) --- .../grib2/localConcepts/uerra/cfVarName.def | 41 +++++++++++++++++++ .../grib2/localConcepts/uerra/name.def | 41 +++++++++++++++++++ .../grib2/localConcepts/uerra/paramId.def | 41 +++++++++++++++++++ .../grib2/localConcepts/uerra/shortName.def | 41 +++++++++++++++++++ .../grib2/localConcepts/uerra/units.def | 41 +++++++++++++++++++ 5 files changed, 205 insertions(+) diff --git a/definitions/grib2/localConcepts/uerra/cfVarName.def b/definitions/grib2/localConcepts/uerra/cfVarName.def index 2b45a70b1..f7f2d915c 100644 --- a/definitions/grib2/localConcepts/uerra/cfVarName.def +++ b/definitions/grib2/localConcepts/uerra/cfVarName.def @@ -17,6 +17,33 @@ scaledValueOfFirstFixedSurface = 200 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Sea ice area fraction 'ci' = { discipline = 10 ; @@ -75,6 +102,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Pressure +'pres' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Potential vorticity +'pv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Specific rain water content 'crwc' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/name.def b/definitions/grib2/localConcepts/uerra/name.def index 95013cab1..da1a828b1 100644 --- a/definitions/grib2/localConcepts/uerra/name.def +++ b/definitions/grib2/localConcepts/uerra/name.def @@ -17,6 +17,33 @@ scaledValueOfFirstFixedSurface = 200 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Wind speed +'Wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'Wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'Wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Sea ice area fraction 'Sea ice area fraction' = { discipline = 10 ; @@ -75,6 +102,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Pressure +'Pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Potential vorticity +'Potential vorticity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Specific rain water content 'Specific rain water content' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/paramId.def b/definitions/grib2/localConcepts/uerra/paramId.def index e7e0a9d65..729478df6 100644 --- a/definitions/grib2/localConcepts/uerra/paramId.def +++ b/definitions/grib2/localConcepts/uerra/paramId.def @@ -17,6 +17,33 @@ scaledValueOfFirstFixedSurface = 200 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Wind speed +'10' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'10' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'10' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Sea ice area fraction '31' = { discipline = 10 ; @@ -75,6 +102,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Pressure +'54' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Potential vorticity +'60' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Specific rain water content '75' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/shortName.def b/definitions/grib2/localConcepts/uerra/shortName.def index 113e3e824..b16b48100 100644 --- a/definitions/grib2/localConcepts/uerra/shortName.def +++ b/definitions/grib2/localConcepts/uerra/shortName.def @@ -17,6 +17,33 @@ scaledValueOfFirstFixedSurface = 200 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Sea ice area fraction 'ci' = { discipline = 10 ; @@ -75,6 +102,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Pressure +'pres' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Potential vorticity +'pv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Specific rain water content 'crwc' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/uerra/units.def b/definitions/grib2/localConcepts/uerra/units.def index 57ef3426f..f86099f59 100644 --- a/definitions/grib2/localConcepts/uerra/units.def +++ b/definitions/grib2/localConcepts/uerra/units.def @@ -17,6 +17,33 @@ scaledValueOfFirstFixedSurface = 200 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Sea ice area fraction '(0 - 1)' = { discipline = 10 ; @@ -75,6 +102,20 @@ indicatorOfUnitForTimeRange = 1 ; typeOfStatisticalProcessing = 2 ; } +#Pressure +'Pa' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Potential vorticity +'K m**2 kg**-1 s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 14 ; + typeOfStatisticalProcessing = 0 ; + } #Specific rain water content 'kg kg**-1' = { discipline = 0 ; From 9cd97a7d73c79255a30021047dd2edf517947e25 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 6 Jun 2024 15:22:06 +0100 Subject: [PATCH 88/90] ECC-1840: BUFR: Problem with edition 3 typicalDate and typicalTime --- definitions/bufr/section.1.3.def | 3 ++- tests/CMakeLists.txt | 1 + tests/bufr_ecc-1840.sh | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 tests/bufr_ecc-1840.sh diff --git a/definitions/bufr/section.1.3.def b/definitions/bufr/section.1.3.def index 84ac947b0..811b0955a 100644 --- a/definitions/bufr/section.1.3.def +++ b/definitions/bufr/section.1.3.def @@ -20,7 +20,8 @@ unsigned[1] localTablesVersionNumber : dump; transient typicalCentury=21; unsigned[1] typicalYearOfCentury : dump; -transient typicalYear = (typicalCentury - 1) * 100 + typicalYearOfCentury : no_copy; +# ECC-1840: Use the 'evaluate' accessor so typicalYear is updated if user changes typicalCentury +meta typicalYear evaluate( (typicalCentury - 1) * 100 + typicalYearOfCentury ) : no_copy; unsigned[1] typicalMonth : dump; unsigned[1] typicalDay : dump; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71116ab24..0169e4986 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -156,6 +156,7 @@ if( HAVE_BUILD_TOOLS ) bufr_ecc-1304 bufr_ecc-1347 bufr_ecc-1395 + bufr_ecc-1840 bufr_json_samples bufr_ecc-359 bufr_ecc-517 diff --git a/tests/bufr_ecc-1840.sh b/tests/bufr_ecc-1840.sh new file mode 100755 index 000000000..34acb5bf6 --- /dev/null +++ b/tests/bufr_ecc-1840.sh @@ -0,0 +1,35 @@ +#!/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 + +REDIRECT=/dev/null + +label="bufr_ecc-1840_test" +tempBufr=temp.$label.bufr +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempOut=temp.$label.txt +tempRef=temp.$label.ref + +sample_bufr3=$ECCODES_SAMPLES_PATH/BUFR3.tmpl + +# This sample has: +# typicalYearOfCentury = 12 +# typicalMonth = 10 +# typicalDay = 31 +result=$(${tools_dir}/bufr_get -p typicalYear,typicalDate $sample_bufr3) +[ "$result" = "2012 20121031" ] +result=$(${tools_dir}/bufr_get -p typicalYear,typicalDate -s typicalCentury=20 $sample_bufr3) +[ "$result" = "1912 19121031" ] + + +# Clean up +rm -f $tempBufr $tempFilt $tempLog $tempOut $tempRef From fda9677fd9ee1f6c8805721578cf8c84fedd7a3d Mon Sep 17 00:00:00 2001 From: Philipp Geier Date: Fri, 7 Jun 2024 09:20:57 +0200 Subject: [PATCH 89/90] Update ci.yml to fix notification The notify step was skipped on failing jobs because the `always()` was not handled properly. Instead of `always() && ${{ ... }}` we have to pull in the always `${{ always() && .. }}` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16c400bec..17873147b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,7 @@ jobs: - private-downstream-ci - downstream-ci-hpc - private-downstream-ci-hpc - if: always() && ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + if: ${{ always() && !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} steps: - name: Trigger Teams notification uses: ecmwf-actions/notify-teams@v1 From ca0c5f100504d8e1e128cfca2e56bb45be806a5c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 7 Jun 2024 13:41:26 +0000 Subject: [PATCH 90/90] ECC-1841: GRIB2: Overload wind components/speed for ERA6 with heights... --- .../grib2/localConcepts/era6/cfName.def | 36 +++++++++++++ definitions/grib2/localConcepts/era6/name.def | 54 +++++++++++++++++++ .../grib2/localConcepts/era6/paramId.def | 54 +++++++++++++++++++ .../grib2/localConcepts/era6/shortName.def | 54 +++++++++++++++++++ .../grib2/localConcepts/era6/units.def | 54 +++++++++++++++++++ 5 files changed, 252 insertions(+) diff --git a/definitions/grib2/localConcepts/era6/cfName.def b/definitions/grib2/localConcepts/era6/cfName.def index 04675741a..e86ee85d4 100644 --- a/definitions/grib2/localConcepts/era6/cfName.def +++ b/definitions/grib2/localConcepts/era6/cfName.def @@ -1,4 +1,40 @@ # Automatically generated by ./create_def.pl, do not edit +#U component of wind +'eastward_wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#U component of wind +'eastward_wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'northward_wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'northward_wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Snow depth 'lwe_thickness_of_surface_snow_amount' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/name.def b/definitions/grib2/localConcepts/era6/name.def index 9505d62b1..af79f7845 100644 --- a/definitions/grib2/localConcepts/era6/name.def +++ b/definitions/grib2/localConcepts/era6/name.def @@ -17,6 +17,24 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#Wind speed +'Wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#Wind speed +'Wind speed' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #UV visible albedo for direct radiation (climatological) 'UV visible albedo for direct radiation (climatological)' = { localTablesVersion = 1 ; @@ -74,6 +92,42 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#U component of wind +'U component of wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#U component of wind +'U component of wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'V component of wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'V component of wind' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Snow depth 'Snow depth' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/paramId.def b/definitions/grib2/localConcepts/era6/paramId.def index fa04cbd0c..efa120d15 100644 --- a/definitions/grib2/localConcepts/era6/paramId.def +++ b/definitions/grib2/localConcepts/era6/paramId.def @@ -17,6 +17,24 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#Wind speed +'10' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#Wind speed +'10' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #UV visible albedo for direct radiation (climatological) '15' = { localTablesVersion = 1 ; @@ -74,6 +92,42 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#U component of wind +'131' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#U component of wind +'131' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'132' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'132' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Snow depth '141' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/shortName.def b/definitions/grib2/localConcepts/era6/shortName.def index 31ab28239..118656c0f 100644 --- a/definitions/grib2/localConcepts/era6/shortName.def +++ b/definitions/grib2/localConcepts/era6/shortName.def @@ -17,6 +17,24 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#Wind speed +'ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #UV visible albedo for direct radiation (climatological) 'aluvp' = { localTablesVersion = 1 ; @@ -74,6 +92,42 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#U component of wind +'u' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#U component of wind +'u' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'v' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'v' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Snow depth 'sd' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/units.def b/definitions/grib2/localConcepts/era6/units.def index f80451dd4..edd86225f 100644 --- a/definitions/grib2/localConcepts/era6/units.def +++ b/definitions/grib2/localConcepts/era6/units.def @@ -17,6 +17,24 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#Wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#Wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #UV visible albedo for direct radiation (climatological) '(0 - 1)' = { localTablesVersion = 1 ; @@ -74,6 +92,42 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#U component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#U component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 100 ; + scaleFactorOfFirstFixedSurface = 0 ; + } +#V component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 200 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Snow depth 'm of water equivalent' = { localTablesVersion = 1 ;