Skip to content

Commit

Permalink
MIR-665 interpolation from matrix file, tests (ci diagnostics)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Jun 17, 2024
1 parent 7125609 commit 155096f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 8 additions & 10 deletions src/mir/method/Matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "mir/method/Matrix.h"

#include "eckit/filesystem/PathName.h"
#include "eckit/log/JSON.h"
#include "eckit/utils/MD5.h"

Expand All @@ -26,20 +27,17 @@ static const MethodBuilder<Matrix> __builder("matrix");


Matrix::Matrix(const param::MIRParametrisation& param) : MethodWeighted(param) {
std::string matrix;
if (!parametrisation_.get("interpolation-matrix", matrix)) {
if (!parametrisation_.get("interpolation-matrix", matrix_)) {
throw exception::UserError("Matrix: option interpolation-matrix missing");
}

matrix_ = matrix;
if (!matrix_.exists()) {
throw exception::UserError("Matrix: path does not exist '" + matrix + "'");
const eckit::PathName path = matrix_;
if (!path.exists()) {
throw exception::UserError("Matrix: path does not exist '" + path + "'");
}

matrix_path_ = matrix_.realName();
if (matrix_path_.front() != '/') {
throw exception::UserError("Matrix: path is not absolute '" + matrix_path_ + "'");
}
// matrix path is a fully-resolved absolute path (unique)
matrix_path_ = path.realName().asString();
}


Expand Down Expand Up @@ -77,7 +75,7 @@ void Matrix::hash(eckit::MD5& h) const {

bool Matrix::sameAs(const Method& other) const {
const auto* o = dynamic_cast<const Matrix*>(&other);
return (o != nullptr) && matrix_path_ == o->matrix_path_ && MethodWeighted::sameAs(other);
return (o != nullptr) && matrix_ == o->matrix_ && MethodWeighted::sameAs(other);
}


Expand Down
4 changes: 1 addition & 3 deletions src/mir/method/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#pragma once

#include "eckit/filesystem/PathName.h"

#include "mir/method/MethodWeighted.h"


Expand All @@ -29,7 +27,7 @@ class Matrix final : public MethodWeighted {
private:
// -- Members

eckit::PathName matrix_;
std::string matrix_;
std::string matrix_path_;

// -- Overridden methods
Expand Down
6 changes: 4 additions & 2 deletions src/mir/method/MethodWeighted.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,15 @@ const WeightMatrix& MethodWeighted::getMatrix(context::Context& ctx, const repre
eckit::PathName cacheFile;

bool caching = LibMir::caching();
if (parametrisation_.get("caching", caching); caching) {
parametrisation_.get("caching", caching);

if (caching) {

// The WeightCache is parametrised by 'caching',
// as caching may be disabled on a field by field basis (unstructured grids)
static caching::WeightCache cache(parametrisation_);

if (disk_key.front() == '/' && eckit::PathName(disk_key).exists()) {
if (disk_key.front() == '/') {
caching::WeightCacheTraits::load(cache, W, disk_key);
}
else {
Expand Down

0 comments on commit 155096f

Please sign in to comment.