diff --git a/src/mir/method/Matrix.cc b/src/mir/method/Matrix.cc index 0910c77eb..b6c22a105 100644 --- a/src/mir/method/Matrix.cc +++ b/src/mir/method/Matrix.cc @@ -12,6 +12,7 @@ #include "mir/method/Matrix.h" +#include "eckit/filesystem/PathName.h" #include "eckit/log/JSON.h" #include "eckit/utils/MD5.h" @@ -26,20 +27,17 @@ static const MethodBuilder __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(); } @@ -77,7 +75,7 @@ void Matrix::hash(eckit::MD5& h) const { bool Matrix::sameAs(const Method& other) const { const auto* o = dynamic_cast(&other); - return (o != nullptr) && matrix_path_ == o->matrix_path_ && MethodWeighted::sameAs(other); + return (o != nullptr) && matrix_ == o->matrix_ && MethodWeighted::sameAs(other); } diff --git a/src/mir/method/Matrix.h b/src/mir/method/Matrix.h index 8a53c1012..b3a3b2f47 100644 --- a/src/mir/method/Matrix.h +++ b/src/mir/method/Matrix.h @@ -12,8 +12,6 @@ #pragma once -#include "eckit/filesystem/PathName.h" - #include "mir/method/MethodWeighted.h" @@ -29,7 +27,7 @@ class Matrix final : public MethodWeighted { private: // -- Members - eckit::PathName matrix_; + std::string matrix_; std::string matrix_path_; // -- Overridden methods diff --git a/src/mir/method/MethodWeighted.cc b/src/mir/method/MethodWeighted.cc index 6bfac7680..fedff7e8f 100644 --- a/src/mir/method/MethodWeighted.cc +++ b/src/mir/method/MethodWeighted.cc @@ -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 {