Skip to content

Commit

Permalink
Merge pull request #113 from ecmwf/release/1.26.0
Browse files Browse the repository at this point in the history
thanks for the good work (including fixes required in production + in preparation for the orca grids)
  • Loading branch information
danovaro authored Mar 25, 2024
2 parents 83f6f3e + bd368c0 commit 3101f61
Show file tree
Hide file tree
Showing 104 changed files with 1,339 additions and 181 deletions.
31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,32 @@ ecbuild_add_option( FEATURE AEC
ecbuild_add_option( FEATURE XXHASH
DESCRIPTION "xxHash support for hashing" )

### Codec options
### eckit::codec

ecbuild_add_option( FEATURE ECKIT_CODEC
DEFAULT OFF
DESCRIPTION "Encoding/Decoding library ported from atlas_io" )
DEFAULT ON
DESCRIPTION "eckit::codec encoding/decoding library" )

set( eckit_CODEC_STATIC_ASSERT ON CACHE BOOL "eckit::codec static assertions" )

### eckit::maths

ecbuild_add_option( FEATURE CONVEX_HULL
DEFAULT OFF
DESCRIPTION "eckit::maths library convex hull/Delaunay triangulation" )
# REQUIRED_PACKAGES "Qhull COMPONENTS C CXX"

if( eckit_HAVE_CONVEX_HULL )
find_package( Qhull REQUIRED CONFIG )

if( NOT TARGET Qhull::qhullcpp OR NOT TARGET Qhull::qhullstatic_r )
message( FATAL_ERROR "eckit::maths ENABLE_CONVEX_HULL requires Qhull C/C++ libraries" )
endif()

add_library(Qhull::Qhull INTERFACE IMPORTED)
target_link_libraries(Qhull::Qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r )
endif()

### LAPACK

if( eckit_HAVE_MKL )
Expand All @@ -162,9 +180,10 @@ else()
REQUIRED_PACKAGES "LAPACK QUIET" )
endif()

### OpenSSL (for SHA1)
### OpenSSL (for SHA1 and MD4)

ecbuild_add_option( FEATURE SSL
DEFAULT OFF # We only use deprecated functionality from OpenSSL
DESCRIPTION "OpenSSL support"
REQUIRED_PACKAGES OpenSSL )

Expand Down Expand Up @@ -283,8 +302,8 @@ add_subdirectory( tests )
add_subdirectory( regressions )

ecbuild_add_resources( TARGET ${PROJECT_NAME}_top_files
SOURCES AUTHORS README.md NOTICE LICENSE
INSTALL ChangeLog COPYING )
SOURCES AUTHORS README.md NOTICE LICENSE
INSTALL ChangeLog COPYING )

############################################################################################
# finalize
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Now proceed with installation as follows:
# Environment --- Edit as needed
srcdir=$(pwd)
builddir=build
installdir=$HOME/local
installdir=$HOME/.local

# 1. Create the build directory:
mkdir $builddir
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25.2
1.26.0
4 changes: 0 additions & 4 deletions src/eckit/cmd/CmdParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ static History history_;
// For Lex
static bool eckit_cmd_debug_;

static long pos_ = 0;

//----------------------------------------------------------------------------------------------------------------------

namespace CmdYacc {
Expand Down Expand Up @@ -94,7 +92,6 @@ void eckit_cmd_error(const char* msg) {

void CmdParser::parse(const std::string& line, std::ostream& out) {
command_ = line;
pos_ = 0;
out_ = &out;

if (command_.size() > 0) {
Expand Down Expand Up @@ -153,7 +150,6 @@ void CmdParser::parse(std::istream& in, std::ostream& out, const Prompter& promp
}

command_ = p;
pos_ = 0;

if (command_.size() > 0) {
// Prepare for parse
Expand Down
12 changes: 4 additions & 8 deletions src/eckit/cmd/UserInput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ typedef struct context {
static bool processCode(int c, context* s);

static void output(const context* s) {
char* buffer = (char*)malloc(strlen(s->prompt) + strlen(s->curr->edit) + 20);
sprintf(buffer, "\r%s%s\033[0K\r\033[%luC", s->prompt, s->curr->edit, strlen(s->prompt) + s->pos);
const size_t numBytes = strlen(s->prompt) + strlen(s->curr->edit) + 20;
char* buffer = (char*)malloc(numBytes);
snprintf(buffer, numBytes,"\r%s%s\033[0K\r\033[%luC", s->prompt, s->curr->edit, strlen(s->prompt) + s->pos);
write(1, buffer, strlen(buffer));
free(buffer);
}
Expand Down Expand Up @@ -285,10 +286,7 @@ static bool processCode(int c, context* s) {
if (strlen(s->curr->edit)) {
return processCode(BACKSPACE, s);
}
else {
return processCode(0, s);
}
break;
return processCode(0, s);

case BACKSPACE:
case CONTROL_H:
Expand Down Expand Up @@ -420,14 +418,12 @@ static bool processCode(int c, context* s) {
case CR:
write(1, "\r\n", 2);
return true;
break;

case CONTROL_C:
write(1, "\r\n", 2);
s->pos = 0;
return processCode(0,
s); // CONTROL_C behaves as CONTROL_D -- for backward compatibility to previous marsadm
break;

case CONTROL_G:
break;
Expand Down
21 changes: 3 additions & 18 deletions src/eckit/codec/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ class Metadata : public LocalConfiguration {

// extended LocalConfiguration:
using LocalConfiguration::set;
Metadata& set(const LocalConfiguration& other) {
auto& root = const_cast<Value&>(get());
const auto& other_root = other.get();
std::vector<std::string> other_keys;
fromValue(other_keys, other_root.keys());
for (auto& key : other_keys) {
root[key] = other_root[key];
}
Metadata& set(const Configuration& other) {
LocalConfiguration::set(other);
return *this;
}

Expand All @@ -79,18 +73,9 @@ class Metadata : public LocalConfiguration {


Metadata& remove(const std::string& name) {
auto& root = const_cast<Value&>(get());
root.remove(name);
LocalConfiguration::remove(name);
return *this;
}


std::vector<std::string> keys() const {
// Preserves order of keys
std::vector<std::string> result;
fromValue(result, get().keys());
return result;
}
};

//---------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/eckit/codec/detail/demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#pragma once

#include <string>
#include <typeinfo>

namespace eckit::codec {

Expand Down
4 changes: 2 additions & 2 deletions src/eckit/codec/types/array/ArrayMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class ArrayShape : public std::vector<size_t> {

class ArrayMetadata {
public:
using ArrayShape = ArrayShape;
using DataType = DataType;
using ArrayShape = eckit::codec::ArrayShape;
using DataType = eckit::codec::DataType;

static std::string type() { return "array"; }

Expand Down
2 changes: 1 addition & 1 deletion src/eckit/codec/types/scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#endif

// GNU C++ compiler (version 11) should not try to optimize this code
#if defined(__GNUC__) && !defined(__NVCOMPILER)
#if defined(__GNUC__) && !defined(__NVCOMPILER) && !defined(__clang__)
#pragma GCC optimize("O0")
#endif

Expand Down
7 changes: 2 additions & 5 deletions src/eckit/config/Configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ bool Configuration::get(const std::string& name, LocalConfiguration& value) cons
return found;
}

const Value& Configuration::get() const {
const Value& Configuration::getValue() const {
return *root_;
}

Expand Down Expand Up @@ -581,10 +581,7 @@ void Configuration::json(JSON& s) const {

std::vector<std::string> Configuration::keys() const {
std::vector<std::string> result;
ValueMap m = *root_;
for (ValueMap::const_iterator j = m.begin(); j != m.end(); ++j) {
result.push_back((*j).first);
}
eckit::fromValue(result, root_->keys());
return result;
}

Expand Down
10 changes: 8 additions & 2 deletions src/eckit/config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ class Configuration : public Parametrisation {
bool get(const std::string& name, LocalConfiguration&) const;

/// @todo This method should be protected. As per note above,
/// we don't wnat to expose eckit::Value out of Configuration.
const Value& get() const;
/// we don't want to expose eckit::Value out of Configuration.
[[deprecated("eckit::Value should not be exposed via eckit::Configuration::get(). This method Will be removed in a next release.")]]
const Value& get() const {
return getValue();
}

virtual void hash(eckit::Hash&) const;

Expand All @@ -144,7 +147,10 @@ class Configuration : public Parametrisation {

operator Value() const;

const Value& getValue() const;

protected: // members
friend class LocalConfiguration;
std::unique_ptr<Value> root_;
char separator_;

Expand Down
24 changes: 19 additions & 5 deletions src/eckit/config/LocalConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,34 @@ LocalConfiguration& LocalConfiguration::set(const std::string& s, const std::vec
}


LocalConfiguration& LocalConfiguration::set(const std::string& s, const LocalConfiguration& value) {
setValue(s, *value.root_);
LocalConfiguration& LocalConfiguration::set(const std::string& s, const Configuration& value) {
setValue(s, value.getValue());
return *this;
}

LocalConfiguration& LocalConfiguration::set(const std::string& s, const std::vector<LocalConfiguration>& value) {
LocalConfiguration& LocalConfiguration::set(const std::string& s, const Configuration* value[], size_t size) {
ValueList values;
for (std::vector<LocalConfiguration>::const_iterator v = value.begin(); v != value.end(); ++v) {
values.push_back(*v->root_);
for (size_t i=0; i<size; ++i) {
values.push_back(value[i]->getValue());
}
setValue(s, values);
return *this;
}

LocalConfiguration& LocalConfiguration::set(const Configuration& other) {
eckit::Value& root = *root_;
eckit::Value const& other_root = *other.root_;
for (auto& key : other.keys()) {
root[key] = other_root[key];
}
return *this;
}

LocalConfiguration& LocalConfiguration::remove(const std::string& name) {
root_->remove(name);
return *this;
}

//----------------------------------------------------------------------------------------------------------------------

} // namespace eckit
34 changes: 32 additions & 2 deletions src/eckit/config/LocalConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#ifndef eckit_LocalConfiguration_H
#define eckit_LocalConfiguration_H

#include <initializer_list>
#include <vector>
#include <type_traits>

#include "eckit/config/Configuration.h"
#include "eckit/config/Configured.h"
Expand All @@ -42,6 +44,8 @@ class LocalConfiguration : public Configuration, public Configured {

~LocalConfiguration() override;

LocalConfiguration& set(const Configuration& other);

LocalConfiguration& set(const std::string& name, const std::string& value) override;
LocalConfiguration& set(const std::string& name, const char* value) override;
LocalConfiguration& set(const std::string& name, bool value) override;
Expand All @@ -60,8 +64,32 @@ class LocalConfiguration : public Configuration, public Configured {
LocalConfiguration& set(const std::string& name, const std::vector<double>& value) override;
LocalConfiguration& set(const std::string& name, const std::vector<std::string>& value) override;

LocalConfiguration& set(const std::string& name, const LocalConfiguration& value);
LocalConfiguration& set(const std::string& name, const std::vector<LocalConfiguration>& value);
LocalConfiguration& set(const std::string& name, const Configuration& value);

template <typename ConfigurationT,
typename = std::enable_if_t<std::is_base_of_v<Configuration, std::decay_t<ConfigurationT>>>>
LocalConfiguration& set(const std::string& name, const std::vector<ConfigurationT>& value) {
std::vector<const Configuration*> abstract_pointers;
abstract_pointers.reserve(value.size());
for (auto& v: value) {
abstract_pointers.emplace_back(&v);
}
return set(name, abstract_pointers.data(), abstract_pointers.size());
}

template <typename ConfigurationT,
typename = std::enable_if_t<std::is_base_of_v<Configuration, std::decay_t<ConfigurationT>>>>
LocalConfiguration& set(const std::string& name, std::initializer_list<ConfigurationT>&& value) {
std::vector<const Configuration*> abstract_pointers;
abstract_pointers.reserve(value.size());
for (auto& v: value) {
abstract_pointers.emplace_back(&v);
}
return set(name, abstract_pointers.data(), abstract_pointers.size());
}


LocalConfiguration& remove(const std::string& name);

protected:
friend class Configuration;
Expand All @@ -71,6 +99,8 @@ class LocalConfiguration : public Configuration, public Configured {

void print(std::ostream&) const override;

LocalConfiguration& set(const std::string& name, const Configuration* abstract_pointers[], size_t size);

private:
void setValue(const std::vector<std::string>& path, size_t i, Value& root, const Value& value);
void setValue(const std::string& s, const Value& value);
Expand Down
4 changes: 2 additions & 2 deletions src/eckit/config/ResourceMgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ int ResourceQualifier::operator<(const ResourceQualifier& other) const {
char buf1[1024];
char buf2[1024];

sprintf(buf1, "%s.%s.%s", owner_.c_str(), kind_.c_str(), name_.c_str());
sprintf(buf2, "%s.%s.%s", other.owner_.c_str(), other.kind_.c_str(), other.name_.c_str());
snprintf(buf1, sizeof(buf1), "%s.%s.%s", owner_.c_str(), kind_.c_str(), name_.c_str());
snprintf(buf2, sizeof(buf2), "%s.%s.%s", other.owner_.c_str(), other.kind_.c_str(), other.name_.c_str());

return strcmp(buf1, buf2) < 0;
}
Expand Down
Loading

0 comments on commit 3101f61

Please sign in to comment.