Skip to content

Commit

Permalink
Merge branch 'develop' into feature/modernisation_merge_accessor_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
joobog committed Sep 13, 2024
2 parents 16c4797 + b74bc1e commit 0627b52
Show file tree
Hide file tree
Showing 46 changed files with 176 additions and 149 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@

cmake_minimum_required( VERSION 3.12 FATAL_ERROR )

find_package( ecbuild 3.7 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
find_package( ecbuild 3.7 HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
if(NOT ecbuild_FOUND)
message(STATUS "Fetching ecbuild...")
include(FetchContent)
FetchContent_Populate(ecbuild
GIT_REPOSITORY https://github.com/ecmwf/ecbuild.git
GIT_TAG 3.8.5
)
find_package( ecbuild 3.7 REQUIRED HINTS ${ecbuild_SOURCE_DIR})
endif()

# Initialise project
project( eccodes LANGUAGES CXX )
Expand Down
5 changes: 3 additions & 2 deletions definitions/mars/grib.mmam.fcmean.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ alias mars.fcmonth = marsForecastMonth;
unalias mars.step;

alias mars.method = methodNumber;
if (class is "od") { alias mars.system = systemNumber; }
if (class is "en") { alias mars.system = systemNumber; }
if (class is "od" || class is "en") {
alias mars.system = systemNumber;
}
5 changes: 4 additions & 1 deletion definitions/mars/grib.mmsa.em.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ if (class is "od") { alias mars.system = systemNumber; }
if (class is "c3") { alias mars.system = systemNumber; }

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }

5 changes: 4 additions & 1 deletion definitions/mars/grib.mmsa.fcmean.def
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ if (class is "od") { alias mars.system = systemNumber; }
if (class is "c3") { alias mars.system = systemNumber; }

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }

2 changes: 1 addition & 1 deletion definitions/mars/grib.mmsf.an.def
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (class isnot "gw") { # ECC-1448
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}
Expand Down
2 changes: 1 addition & 1 deletion definitions/mars/grib.mmsf.fc.def
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (class isnot "gw") { # ECC-1448
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}
Expand Down
12 changes: 7 additions & 5 deletions definitions/mars/grib.msmm.em.def
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ unalias mars.step;
alias mars.origin = centre;
alias mars.method = methodNumber;

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 "od" || class is "me" || class is "en" || class is "c3") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }

12 changes: 7 additions & 5 deletions definitions/mars/grib.msmm.fcmax.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ alias mars.number = perturbationNumber;
alias mars.origin = centre;
alias mars.method = methodNumber;

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 "od" || class is "me" || class is "en" || class is "c3") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }

10 changes: 4 additions & 6 deletions definitions/mars/grib.msmm.fcmean.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ alias mars.method = methodNumber;

unalias mars.step;

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; }
if (class is "od" || class is "me" || class is "en" || class is "c3" || class is "ci") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}
Expand Down
12 changes: 6 additions & 6 deletions definitions/mars/grib.msmm.fcmin.def
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ alias mars.number = perturbationNumber;
alias mars.origin = centre;
alias mars.method = methodNumber;


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 "od" || class is "me" || class is "en" || class is "c3") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }
11 changes: 6 additions & 5 deletions definitions/mars/grib.msmm.fcstdev.def
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ unalias mars.step;

alias mars.method = methodNumber;

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 "od" || class is "me" || class is "en" || class is "c3") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && class is "c3") {
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }
1 change: 0 additions & 1 deletion definitions/mars/grib.msmm.hcmean.def

This file was deleted.

18 changes: 18 additions & 0 deletions definitions/mars/grib.msmm.hcmean.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# assert(16);
alias mars.fcmonth = marsForecastMonth;
unalias mars.step;

alias mars.origin = centre;
alias mars.method = methodNumber;

if (class is "od" || class is "me" || class is "en" || class is "c3") {
alias mars.system = systemNumber;
}

# See ECC-624
if (centre == 80 && subCentre == 98 && (class is "c3" || class is "ci")) {
constant cnmc_cmcc = 'cmcc';
alias mars.origin = cnmc_cmcc;
}

if (class is "ci") { unalias mars.method; }
7 changes: 4 additions & 3 deletions definitions/mars/grib.ocea.an.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.ocea.ff.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.ocea.fx.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.ocea.of.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.ocea.or.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias mars.number = perturbationNumber;
alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.swmm.fcmax.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber;
unalias mars.step;

alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.swmm.fcmean.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber;
unalias mars.step;

alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.swmm.fcmin.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber;
unalias mars.step;

alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
6 changes: 3 additions & 3 deletions definitions/mars/grib.swmm.fcstdev.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ alias mars.number = perturbationNumber;
unalias mars.step;

alias mars.method = methodNumber;
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 "od" || class is "me" || class is "en") {
alias mars.system = systemNumber;
}
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ list( APPEND eccodes_src_files
eccodes_prototypes.h
grib_dumper_class.h
grib_dumper_factory.h
grib_emoslib.h
grib_iterator_class.h
grib_iterator_factory.h
grib_nearest_class.h
Expand Down
6 changes: 4 additions & 2 deletions src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ int grib_accessor_g1end_of_interval_monthly_t::compare(grib_accessor* b)
long count = 0;
size_t alen = 0;
size_t blen = 0;
int err = 0;

err = value_count(&count);
int err = value_count(&count);
if (err)
return err;
alen = count;
Expand All @@ -128,7 +127,10 @@ int grib_accessor_g1end_of_interval_monthly_t::compare(grib_accessor* b)
dirty_ = 1;

err = unpack_double(aval, &alen);
if (err) return err;
err = b->unpack_double(bval, &blen);
if (err) return err;

for (size_t i = 0; i < alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
}
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ long grib_accessor_gen_t::byte_offset()

int grib_accessor_gen_t::unpack_bytes(unsigned char* val, size_t* len)
{
unsigned char* buf = grib_handle_of_accessor(this)->buffer->data;
const unsigned char* buf = grib_handle_of_accessor(this)->buffer->data;
const long length = byte_count();
const long offset = byte_offset();

Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_getenv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void grib_accessor_getenv_t::init(const long l, grib_arguments* args)
grib_accessor_ascii_t::init(l, args);
static char undefined[] = "undefined";

name_ = grib_arguments_get_string(grib_handle_of_accessor(this), args, 0);
envvar_ = grib_arguments_get_string(grib_handle_of_accessor(this), args, 0);
default_value_ = grib_arguments_get_string(grib_handle_of_accessor(this), args, 1);
if (!default_value_)
default_value_ = undefined;
Expand All @@ -36,7 +36,7 @@ int grib_accessor_getenv_t::unpack_string(char* val, size_t* len)
size_t l = 0;

if (!value_) {
v = getenv(name_);
v = getenv(envvar_);
if (!v)
v = (char*)default_value_;
value_ = v;
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_getenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class grib_accessor_getenv_t : public grib_accessor_ascii_t

private:
// TODO(maee): shadows name_?
const char* name_;
const char* envvar_;
char* value_;
const char* default_value_;
};
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_group = &_grib_accessor_group;
void grib_accessor_group_t::init(const long len, grib_arguments* arg)
{
grib_accessor_gen_t::init(len, arg);
grib_buffer* buffer = grib_handle_of_accessor(this)->buffer;
const grib_buffer* buffer = grib_handle_of_accessor(this)->buffer;

size_t i = 0;
unsigned char* v;
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_gts_header.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ int grib_accessor_gts_header_t::value_count(long* count)

size_t grib_accessor_gts_header_t::string_length()
{
grib_handle* h = grib_handle_of_accessor(this);
const grib_handle* h = grib_handle_of_accessor(this);
return h->gts_header_len;
}
8 changes: 4 additions & 4 deletions src/accessor/grib_accessor_class_md5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void grib_accessor_md5_t::init(const long len, grib_arguments* arg)
grib_string_list* current = 0;
grib_context* context = context_;

offset_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
length_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, n++);
offset_key_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++);
length_key_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, n++);
blocklist_ = NULL;
while ((b = (char*)grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++)) != NULL) {
if (!blocklist_) {
Expand Down Expand Up @@ -97,9 +97,9 @@ int grib_accessor_md5_t::unpack_string(char* v, size_t* len)
return GRIB_BUFFER_TOO_SMALL;
}

if ((ret = grib_get_long_internal(grib_handle_of_accessor(this), offset_, &offset)) != GRIB_SUCCESS)
if ((ret = grib_get_long_internal(grib_handle_of_accessor(this), offset_key_, &offset)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(this), length_, &length)) != GRIB_SUCCESS)
if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(this), length_key_, &length)) != GRIB_SUCCESS)
return ret;
mess = (unsigned char*)grib_context_malloc(context_, length);
memcpy(mess, grib_handle_of_accessor(this)->buffer->data + offset, length);
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class grib_accessor_md5_t : public grib_accessor_gen_t
int compare(grib_accessor*) override;

private:
const char* offset_;
grib_expression* length_;
const char* offset_key_;
grib_expression* length_key_;
grib_string_list* blocklist_;
};
Loading

0 comments on commit 0627b52

Please sign in to comment.