diff --git a/src/atlas/interpolation/method/sphericalvector/ComplexMatrixMultiply.h b/src/atlas/interpolation/method/sphericalvector/ComplexMatrixMultiply.h index d9812ba97..05253f9f1 100644 --- a/src/atlas/interpolation/method/sphericalvector/ComplexMatrixMultiply.h +++ b/src/atlas/interpolation/method/sphericalvector/ComplexMatrixMultiply.h @@ -58,7 +58,7 @@ class ComplexMatrixMultiply { ATLAS_ASSERT(complexWeightsPtr_->cols() == realWeightsPtr_->cols()); ATLAS_ASSERT(complexWeightsPtr_->nonZeros() == realWeightsPtr_->nonZeros()); - for (auto rowIndex = Size{0}; rowIndex < complexWeightsPtr_->rows(); + for (auto rowIndex = Index{0}; rowIndex < complexWeightsPtr_->rows(); ++rowIndex) { for (auto [complexRowIter, realRowIter] = rowIters(rowIndex); complexRowIter; ++complexRowIter, ++realRowIter) { @@ -100,7 +100,7 @@ class ComplexMatrixMultiply { // We could probably optimise contiguous arrays using // reinterpret_cast*>(view.data()). This is fine // according to the C++ standard! - atlas_omp_parallel_for(auto rowIndex = Size{0}; + atlas_omp_parallel_for(auto rowIndex = Index{0}; rowIndex < complexWeightsPtr_->rows(); ++rowIndex) { auto targetSlice = sliceColumn(targetView, rowIndex); if constexpr (InitialiseTarget) { @@ -129,7 +129,7 @@ class ComplexMatrixMultiply { template void applyThreeVector(const array::ArrayView& sourceView, array::ArrayView& targetView) const { - atlas_omp_parallel_for(auto rowIndex = Size{0}; + atlas_omp_parallel_for(auto rowIndex = Index{0}; rowIndex < complexWeightsPtr_->rows(); ++rowIndex) { auto targetSlice = sliceColumn(targetView, rowIndex); if constexpr (InitialiseTarget) { @@ -158,7 +158,7 @@ class ComplexMatrixMultiply { /// @brief Return a pair of complex and real row iterators std::pair rowIters( - Size rowIndex) const { + Index rowIndex) const { return std::make_pair(complexWeightsPtr_->rowIter(rowIndex), realWeightsPtr_->rowIter(rowIndex)); } diff --git a/src/atlas/interpolation/method/sphericalvector/SparseMatrix.h b/src/atlas/interpolation/method/sphericalvector/SparseMatrix.h index 4f5c079e6..4b0786559 100644 --- a/src/atlas/interpolation/method/sphericalvector/SparseMatrix.h +++ b/src/atlas/interpolation/method/sphericalvector/SparseMatrix.h @@ -17,6 +17,7 @@ #endif #include "atlas/runtime/Exception.h" +#include "eckit/log/CodeLocation.h" namespace atlas { namespace interpolation { @@ -31,12 +32,10 @@ namespace detail { /// class is Eigen library is not present. template class SparseMatrix { - using EigenMatrix = Eigen::SparseMatrix; - public: - using Index = typename EigenMatrix::StorageIndex; - using Size = typename EigenMatrix::Index; - using Triplet = Eigen::Triplet; + using Index = int; + using EigenMatrix = Eigen::SparseMatrix; + using Triplet = Eigen::Triplet; using Triplets = std::vector; using RowIter = typename EigenMatrix::InnerIterator; @@ -45,10 +44,10 @@ class SparseMatrix { eigenMatrix_.setFromTriplets(triplets.begin(), triplets.end()); } - Size nonZeros() const { return eigenMatrix_.nonZeros(); } - Size rows() const { return eigenMatrix_.rows(); } - Size cols() const { return eigenMatrix_.cols(); } - RowIter rowIter(Size rowIndex) const { + Index nonZeros() const { return eigenMatrix_.nonZeros(); } + Index rows() const { return eigenMatrix_.rows(); } + Index cols() const { return eigenMatrix_.cols(); } + RowIter rowIter(Index rowIndex) const { return RowIter(eigenMatrix_, rowIndex); } SparseMatrix adjoint() const { @@ -66,7 +65,6 @@ template class SparseMatrix { public: using Index = int; - using Size = long int; class Triplet { public: @@ -90,10 +88,10 @@ class SparseMatrix { SparseMatrix(const Args&... args) { throw_Exception("Atlas has been compiled without Eigen", Here()); } - constexpr Size nonZeros() const { return Size{}; } - constexpr Size rows() const { return Size{}; } - constexpr Size cols() const { return Size{}; } - constexpr RowIter rowIter(Size rowIndex) const { return RowIter{}; } + constexpr Index nonZeros() const { return Index{}; } + constexpr Index rows() const { return Index{}; } + constexpr Index cols() const { return Index{}; } + constexpr RowIter rowIter(Index rowIndex) const { return RowIter{}; } constexpr SparseMatrix adjoint() const { return SparseMatrix{}; } diff --git a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc index 2efd610b3..410f19a01 100644 --- a/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc +++ b/src/atlas/interpolation/method/sphericalvector/SphericalVector.cc @@ -34,6 +34,8 @@ using namespace detail; SphericalVector::SphericalVector(const Config& config) : Method(config) { const auto& conf = dynamic_cast(config); + ATLAS_ASSERT_MSG(&conf, + "config must be castable to an eckit::LocalConfiguration"); interpolationScheme_ = conf.getSubConfiguration("scheme"); adjoint_ = conf.getBool("adjoint", false); } @@ -56,9 +58,9 @@ void SphericalVector::do_setup(const FunctionSpace& source, setMatrix(Interpolation(interpolationScheme_, source_, target_)); // Get matrix data. - const auto nRows = matrix().rows(); - const auto nCols = matrix().cols(); - const auto nNonZeros = matrix().nonZeros(); + const auto nRows = static_cast(matrix().rows()); + const auto nCols = static_cast(matrix().cols()); + const auto nNonZeros = static_cast(matrix().nonZeros()); const auto* outerIndices = matrix().outer(); const auto* innerIndices = matrix().inner(); const auto* baseWeights = matrix().data(); @@ -87,7 +89,7 @@ void SphericalVector::do_setup(const FunctionSpace& source, ++rowIndex) { for (auto dataIndex = outerIndices[rowIndex]; dataIndex < outerIndices[rowIndex + 1]; ++dataIndex) { - const auto colIndex = innerIndices[dataIndex]; + const auto colIndex = static_cast(innerIndices[dataIndex]); const auto baseWeight = baseWeights[dataIndex]; const auto sourceLonLat = PointLonLat(sourceLonLatsView(colIndex, 0), diff --git a/src/atlas/interpolation/method/sphericalvector/Types.h b/src/atlas/interpolation/method/sphericalvector/Types.h index 8ad44092a..fcffc26c8 100644 --- a/src/atlas/interpolation/method/sphericalvector/Types.h +++ b/src/atlas/interpolation/method/sphericalvector/Types.h @@ -22,7 +22,6 @@ using Complex = std::complex; using ComplexMatrix = SparseMatrix; using RealMatrix = SparseMatrix; using Index = ComplexMatrix::Index; -using Size = ComplexMatrix::Size; using ComplexTriplet = ComplexMatrix::Triplet; using ComplexTriplets = ComplexMatrix::Triplets; using RealTriplet = RealMatrix::Triplet;