Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…plit' into feature/mtg2_switch_paramtype_timeproc
  • Loading branch information
rdosinski committed Dec 9, 2024
2 parents 8e0b929 + 4735174 commit 9c5870e
Show file tree
Hide file tree
Showing 284 changed files with 161,821 additions and 76,200 deletions.
37,670 changes: 19,378 additions & 18,292 deletions definitions/grib2/localConcepts/ecmf/name.33.def

Large diffs are not rendered by default.

37,686 changes: 19,386 additions & 18,300 deletions definitions/grib2/localConcepts/ecmf/paramId.33.def

Large diffs are not rendered by default.

36,976 changes: 19,031 additions & 17,945 deletions definitions/grib2/localConcepts/ecmf/shortName.33.def

Large diffs are not rendered by default.

36,006 changes: 18,546 additions & 17,460 deletions definitions/grib2/localConcepts/ecmf/units.33.def

Large diffs are not rendered by default.

20,404 changes: 20,404 additions & 0 deletions definitions/grib2/name.33.def

Large diffs are not rendered by default.

20,404 changes: 20,404 additions & 0 deletions definitions/grib2/paramId.33.def

Large diffs are not rendered by default.

20,404 changes: 20,404 additions & 0 deletions definitions/grib2/shortName.33.def

Large diffs are not rendered by default.

20,404 changes: 20,404 additions & 0 deletions definitions/grib2/units.33.def

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/F90/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if( HAVE_BUILD_TOOLS )
bufr_ecc-1284
bufr_ecc-1019
get_native_type
key_is_computed
grib_ecc-671 )
list( APPEND tests_extra
grib_index
Expand Down Expand Up @@ -81,6 +82,7 @@ else()
codes_set_paths
codes_f90_misc
get_native_type
key_is_computed
grib_ecc-671 )
list( APPEND tests_extra
grib_index
Expand Down
38 changes: 38 additions & 0 deletions examples/F90/key_is_computed.f90
Original file line number Diff line number Diff line change
@@ -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/LICENSECODES_INTERNAL_ERROR.0.
!
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
!
program key_is_computed
use eccodes
implicit none
integer :: ihandle, is_computed=0

CALL codes_grib_new_from_samples(ihandle, "regular_ll_sfc_grib2")

CALL codes_key_is_computed(ihandle, 'edition', is_computed)
IF (is_computed /= 0) THEN
call codes_check(CODES_INTERNAL_ERROR, 'Error', 'key edition is coded')
END IF

CALL codes_key_is_computed(ihandle, 'longitudeOfLastGridPoint', is_computed)
IF (is_computed /= 0) THEN
call codes_check(CODES_INTERNAL_ERROR, 'Error', 'key longitudeOfLastGridPoint is coded')
END IF

CALL codes_key_is_computed(ihandle, 'longitudeOfLastGridPointInDegrees', is_computed)
IF (is_computed /= 1) THEN
call codes_check(CODES_INTERNAL_ERROR, 'Error', 'key longitudeOfLastGridPointInDegrees is computed')
END IF

CALL codes_key_is_computed(ihandle, 'gridType', is_computed)
IF (is_computed /= 1) THEN
call codes_check(CODES_INTERNAL_ERROR, 'Error', 'key gridType is computed')
END IF

CALL codes_release(ihandle)

end program key_is_computed
16 changes: 16 additions & 0 deletions examples/F90/key_is_computed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/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

label="f_key_is_computed"

${examples_dir}/eccodes_f_key_is_computed

30 changes: 30 additions & 0 deletions fortran/eccodes_f90_tail.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,36 @@ subroutine codes_is_defined(msgid, key, is_defined, status)
call grib_is_defined(msgid, key, is_defined, status)
end subroutine codes_is_defined

!!!
!> Check if a key is computed(virtual) or coded
!>
!> In case of error, if the status parameter (optional) is not given, the program will
!> exit with an error message.\n Otherwise the error message can be
!> gathered with @ref codes_get_error_string.
!>
!> @param msgid id of the message loaded in memory
!> @param key key name
!> @param is_computed 0->coded, 1->computed
!> @param status CODES_SUCCESS if OK, integer value on error
subroutine codes_key_is_computed(msgid, key, is_computed, status)
integer(kind=kindOfInt), intent(in) :: msgid
character(len=*), intent(in) :: key
integer(kind=kindOfInt), intent(out) :: is_computed
integer(kind=kindOfInt), optional, intent(out) :: status
integer(kind=kindOfInt) :: iret

iret = grib_f_key_is_computed(msgid, key, is_computed)
if (iret /= 0) then
call grib_f_write_on_fail(msgid)
end if
if (present(status)) then
status = iret
else
call grib_check(iret, 'key_is_computed', key)
end if
end subroutine codes_key_is_computed
!!!

!> Get the real(4) value of a key from a message.
!>
!> In case of error, if the status parameter (optional) is not given, the program will
Expand Down
2 changes: 1 addition & 1 deletion fortran/eccodes_visibility.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public :: codes_get, codes_set, codes_set_force, codes_grib_get_data, codes_is_missing, codes_is_defined
public :: codes_get, codes_set, codes_set_force, codes_grib_get_data, codes_is_missing, codes_is_defined, codes_key_is_computed
public :: codes_open_file, codes_close_file,codes_read_bytes,codes_write_bytes
public :: codes_grib_multi_support_on, codes_grib_multi_support_off
public :: codes_keys_iterator_new, &
Expand Down
2 changes: 1 addition & 1 deletion fortran/grib_api_externals.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ integer, external :: grib_f_get_int, grib_f_get_long,grib_f_get_int_array, &
grib_f_get_real4_elements, grib_f_get_real8_elements, &
grib_f_get_string,grib_f_get_string_array, &
codes_f_bufr_copy_data, &
grib_f_is_missing,grib_f_is_defined
grib_f_is_missing, grib_f_is_defined, grib_f_key_is_computed
integer, external :: grib_f_new_from_index, &
grib_f_index_new_from_file, &
grib_f_index_add_file, &
Expand Down
14 changes: 13 additions & 1 deletion fortran/grib_fortran.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ int grib_f_is_missing_(int* gid, char* key,int* isMissing,int len)
int err=0;
grib_handle *h = get_handle(*gid);
char buf[1024];
if(!h) return GRIB_INVALID_GRIB;
if (!h) return GRIB_INVALID_GRIB;

*isMissing=grib_is_missing(h, cast_char(buf,key,len),&err);
return err;
Expand All @@ -2240,6 +2240,18 @@ int grib_f_is_defined_(int* gid, char* key,int* isDefined,int len)
return GRIB_SUCCESS;
}

/*****************************************************************************/
int grib_f_key_is_computed_(int* gid, char* key,int* isComputed,int len)
{
int err = 0;
grib_handle *h = get_handle(*gid);
char buf[1024];
if (!h) return GRIB_INVALID_GRIB;

*isComputed = codes_key_is_computed(h, cast_char(buf,key,len), &err);
return err;
}

/*****************************************************************************/
int grib_f_set_real4_(int* gid, char* key, float* val, int len)
{
Expand Down
1 change: 1 addition & 0 deletions fortran/grib_fortran_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long
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_();
int grib_f_key_is_computed_(int *gid, char *key, int *isComputed, int len);


#ifdef __cplusplus
Expand Down
40 changes: 23 additions & 17 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,27 @@ list( APPEND eccodes_src_files
grib_dependency.cc
grib_value.cc
grib_errors.cc
grib_expression_class_binop.cc
grib_expression_class_logical_and.cc
grib_expression_class_logical_or.cc
grib_expression_class_is_in_dict.cc
grib_expression_class_true.cc
grib_expression_class_string_compare.cc
grib_expression_class_unop.cc
grib_expression_class_functor.cc
grib_expression_class_accessor.cc
grib_expression_class_is_in_list.cc
grib_expression_class_is_integer.cc
grib_expression_class_length.cc
grib_expression_class_long.cc
grib_expression_class_double.cc
grib_expression_class_string.cc
grib_expression_class_sub_string.cc

expression/grib_arguments.cc

expression/grib_expression.cc
expression/grib_expression_class_binop.cc
expression/grib_expression_class_logical_and.cc
expression/grib_expression_class_logical_or.cc
expression/grib_expression_class_is_in_dict.cc
expression/grib_expression_class_true.cc
expression/grib_expression_class_string_compare.cc
expression/grib_expression_class_unop.cc
expression/grib_expression_class_functor.cc
expression/grib_expression_class_accessor.cc
expression/grib_expression_class_is_in_list.cc
expression/grib_expression_class_is_integer.cc
expression/grib_expression_class_length.cc
expression/grib_expression_class_long.cc
expression/grib_expression_class_double.cc
expression/grib_expression_class_string.cc
expression/grib_expression_class_sub_string.cc

geo_nearest/grib_nearest.cc
geo_nearest/grib_nearest_class_gen.cc
geo_nearest/grib_nearest_class_healpix.cc
Expand All @@ -337,6 +342,7 @@ list( APPEND eccodes_src_files
geo_nearest/grib_nearest_class_reduced.cc
geo_nearest/grib_nearest_class_regular.cc
geo_nearest/grib_nearest_class_space_view.cc

geo_iterator/grib_iterator.cc
geo_iterator/grib_iterator_class_gaussian.cc
geo_iterator/grib_iterator_class_gaussian_reduced.cc
Expand All @@ -351,7 +357,7 @@ list( APPEND eccodes_src_files
geo_iterator/grib_iterator_class_regular.cc
geo_iterator/grib_iterator_class_space_view.cc
geo_iterator/grib_iterator_class_unstructured.cc
grib_expression.cc

codes_util.cc
grib_util.cc
bufr_util.cc
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void grib_accessor_bit_t::init(const long len, grib_arguments* arg)
{
grib_accessor_long_t::init(len, arg);
length_ = 0;
owner_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, 0);
bit_index_ = grib_arguments_get_long(grib_handle_of_accessor(this), arg, 1);
owner_ = arg->get_name(grib_handle_of_accessor(this), 0);
bit_index_ = arg->get_long(grib_handle_of_accessor(this), 1);
}

int grib_accessor_bit_t::unpack_long(long* val, size_t* len)
Expand Down
8 changes: 4 additions & 4 deletions src/accessor/grib_accessor_class_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ void grib_accessor_bitmap_t::init(const long len, grib_arguments* arg)
grib_handle* hand = grib_handle_of_accessor(this);
int n = 0;

tableReference_ = grib_arguments_get_name(hand, arg, n++);
missing_value_ = grib_arguments_get_name(hand, arg, n++);
offsetbsec_ = grib_arguments_get_name(hand, arg, n++);
sLength_ = grib_arguments_get_name(hand, arg, n++);
tableReference_ = arg->get_name(hand, n++);
missing_value_ = arg->get_name(hand, n++);
offsetbsec_ = arg->get_name(hand, n++);
sLength_ = arg->get_name(hand, n++);

compute_size();
}
Expand Down
12 changes: 6 additions & 6 deletions src/accessor/grib_accessor_class_bits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ void grib_accessor_bits_t::init(const long l, grib_arguments* c)
int n = 0;
referenceValue_ = 0;

argument_ = grib_arguments_get_name(hand, c, n++);
start_ = grib_arguments_get_long(hand, c, n++);
len_ = grib_arguments_get_long(hand, c, n++);
e = grib_arguments_get_expression(hand, c, n++);
argument_ = c->get_name(hand, n++);
start_ = c->get_long(hand, n++);
len_ = c->get_long(hand, n++);
e = c->get_expression(hand, n++);
if (e) {
grib_expression_evaluate_double(hand, e, &(referenceValue_));
e->evaluate_double(hand, &(referenceValue_));
referenceValuePresent_ = 1;
}
else {
referenceValuePresent_ = 0;
}
scale_ = 1;
if (referenceValuePresent_) {
scale_ = grib_arguments_get_double(hand, c, n++);
scale_ = c->get_double(hand, n++);
}

Assert(len_ <= sizeof(long) * 8);
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bits_per_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void grib_accessor_bits_per_value_t::init(const long l, grib_arguments* args)
{
grib_accessor_long_t::init(l, args);
int n = 0;
values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++);
bits_per_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++);
values_ = args->get_name(grib_handle_of_accessor(this), n++);
bits_per_value_ = args->get_name(grib_handle_of_accessor(this), n++);
flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION;
length_ = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void grib_accessor_blob_t::init(const long len, grib_arguments* arg)
{
grib_accessor_gen_t::init(len, arg);
grib_get_long_internal(grib_handle_of_accessor(this),
grib_arguments_get_name(parent_->h, arg, 0), &length_);
arg->get_name(parent_->h, 0), &length_);
Assert(length_ >= 0);
}

Expand Down
6 changes: 3 additions & 3 deletions src/accessor/grib_accessor_class_budgdate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ void grib_accessor_budgdate_t::init(const long l, grib_arguments* c)
grib_accessor_long_t::init(l, c);
int n = 0;

year_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++);
month_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++);
day_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++);
year_ = c->get_name(grib_handle_of_accessor(this), n++);
month_ = c->get_name(grib_handle_of_accessor(this), n++);
day_ = c->get_name(grib_handle_of_accessor(this), n++);
}

int grib_accessor_budgdate_t::unpack_long(long* val, size_t* len)
Expand Down
14 changes: 7 additions & 7 deletions src/accessor/grib_accessor_class_bufr_data_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ void grib_accessor_bufr_data_array_t::init(const long v, grib_arguments* params)
tempStrings_ = NULL;


bufrDataEncodedName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
numberOfSubsetsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
expandedDescriptorsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
flagsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
elementsDescriptorsIndexName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
compressedDataName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
dataKeysName = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
bufrDataEncodedName_ = params->get_name(grib_handle_of_accessor(this), n++);
numberOfSubsetsName_ = params->get_name(grib_handle_of_accessor(this), n++);
expandedDescriptorsName_ = params->get_name(grib_handle_of_accessor(this), n++);
flagsName_ = params->get_name(grib_handle_of_accessor(this), n++);
elementsDescriptorsIndexName_ = params->get_name(grib_handle_of_accessor(this), n++);
compressedDataName_ = params->get_name(grib_handle_of_accessor(this), n++);
dataKeysName = params->get_name(grib_handle_of_accessor(this), n++);

dataKeysAcc = grib_find_accessor(grib_handle_of_accessor(this), dataKeysName);
dataKeys_ = dataKeysAcc->parent_;
Expand Down
6 changes: 3 additions & 3 deletions src/accessor/grib_accessor_class_bufr_elements_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ void grib_accessor_bufr_elements_table_t::init(const long len, grib_arguments* p
grib_accessor_gen_t::init(len, params);
int n = 0;

dictionary_ = grib_arguments_get_string(grib_handle_of_accessor(this), params, n++);
masterDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
localDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++);
dictionary_ = params->get_string(grib_handle_of_accessor(this), n++);
masterDir_ = params->get_name(grib_handle_of_accessor(this), n++);
localDir_ = params->get_name(grib_handle_of_accessor(this), n++);

length_ = 0;
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
Expand Down
20 changes: 10 additions & 10 deletions src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ void grib_accessor_bufr_extract_area_subsets_t::init(const long len, grib_argume
int n = 0;

length_ = 0;
doExtractSubsets_ = grib_arguments_get_name(h, arg, n++);
numberOfSubsets_ = grib_arguments_get_name(h, arg, n++);
extractSubsetList_ = grib_arguments_get_name(h, arg, n++);
extractAreaWestLongitude_ = grib_arguments_get_name(h, arg, n++);
extractAreaEastLongitude_ = grib_arguments_get_name(h, arg, n++);
extractAreaNorthLatitude_ = grib_arguments_get_name(h, arg, n++);
extractAreaSouthLatitude_ = grib_arguments_get_name(h, arg, n++);
extractAreaLongitudeRank_ = grib_arguments_get_name(h, arg, n++);
extractAreaLatitudeRank_ = grib_arguments_get_name(h, arg, n++);
extractedAreaNumberOfSubsets_ = grib_arguments_get_name(h, arg, n++);
doExtractSubsets_ = arg->get_name(h, n++);
numberOfSubsets_ = arg->get_name(h, n++);
extractSubsetList_ = arg->get_name(h, n++);
extractAreaWestLongitude_ = arg->get_name(h, n++);
extractAreaEastLongitude_ = arg->get_name(h, n++);
extractAreaNorthLatitude_ = arg->get_name(h, n++);
extractAreaSouthLatitude_ = arg->get_name(h, n++);
extractAreaLongitudeRank_ = arg->get_name(h, n++);
extractAreaLatitudeRank_ = arg->get_name(h, n++);
extractedAreaNumberOfSubsets_ = arg->get_name(h, n++);

flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ void grib_accessor_bufr_extract_datetime_subsets_t::init(const long len, grib_ar
int n = 0;

length_ = 0;
doExtractSubsets_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
numberOfSubsets_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
extractSubsetList_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
doExtractSubsets_ = arg->get_name(grib_handle_of_accessor(this), n++);
numberOfSubsets_ = arg->get_name(grib_handle_of_accessor(this), n++);
extractSubsetList_ = arg->get_name(grib_handle_of_accessor(this), n++);

flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION;
}
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bufr_extract_subsets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ void grib_accessor_bufr_extract_subsets_t::init(const long len, grib_arguments*
int n = 0;

length_ = 0;
numericValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
pack_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
numericValues_ = arg->get_name(grib_handle_of_accessor(this), n++);
pack_ = arg->get_name(grib_handle_of_accessor(this), n++);
flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION;

numericValuesAccessor_ = NULL;
Expand Down
Loading

0 comments on commit 9c5870e

Please sign in to comment.