/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #include #include #include #include #include #include "atlas/array.h" #include "atlas/field/Field.h" #include "atlas/functionspace/NodeColumns.h" #include "atlas/library/config.h" #include "atlas/mesh/IsGhostNode.h" #include "atlas/mesh/Nodes.h" #include "atlas/parallel/GatherScatter.h" #include "atlas/parallel/omp/omp.h" #include "atlas/runtime/Exception.h" #include "atlas/runtime/Trace.h" #undef atlas_omp_critical_ordered #define atlas_omp_critical_ordered atlas_omp_critical namespace atlas { namespace functionspace { namespace detail { namespace { template array::LocalView make_leveled_view(Field& field) { using namespace array; if (field.levels()) { if (field.variables()) { return make_view(field).slice(Range::all(), Range::all(), Range::all()); } else { return make_view(field).slice(Range::all(), Range::all(), Range::dummy()); } } else { if (field.variables()) { return make_view(field).slice(Range::all(), Range::dummy(), Range::all()); } else { return make_view(field).slice(Range::all(), Range::dummy(), Range::dummy()); } } } template array::LocalView make_leveled_scalar_view(Field& field) { using namespace array; if (field.levels()) { return make_view(field).slice(Range::all(), Range::all()); } else { return make_view(field).slice(Range::all(), Range::dummy()); } } template array::LocalView make_surface_view(Field& field) { using namespace array; if (field.variables()) { return make_view(field).slice(Range::all(), Range::all()); } else { return make_view(field).slice(Range::all(), Range::dummy()); } } template array::LocalView make_per_level_view(Field& field) { using namespace array; if (field.rank() == 2) { return make_view(field).slice(Range::all(), Range::all()); } else { return make_view(field).slice(Range::all(), Range::dummy()); } } } // namespace namespace { inline double sqr(const double& val) { return val * val; } } // namespace namespace detail { // Collectives implementation template void dispatch_sum(const NodeColumns& fs, const Field& field, T& result, idx_t& N) { const mesh::IsGhostNode is_ghost(fs.nodes()); const array::LocalView arr = make_leveled_scalar_view(field); T local_sum = 0; const idx_t npts = std::min(arr.shape(0), fs.nb_nodes()); const idx_t nlev = arr.shape(1); atlas_omp_pragma( omp parallel for default(shared) reduction(+:local_sum) ) for( idx_t n=0; n void sum(const NodeColumns& fs, const Field& field, T& result, idx_t& N) { if (field.datatype() == array::DataType::kind()) { dispatch_sum(fs, field, result, N); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { int tmp; dispatch_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_INT64: { long tmp; dispatch_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_REAL32: { float tmp; dispatch_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_REAL64: { double tmp; dispatch_sum(fs, field, tmp, N); result = tmp; return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_sum(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { auto arr = make_leveled_view(field); const mesh::IsGhostNode is_ghost(fs.nodes()); const idx_t npts = std::min(arr.shape(0), fs.nb_nodes()); const idx_t nlev = arr.shape(1); const idx_t nvar = arr.shape(2); std::vector local_sum(nvar, 0); result.resize(nvar); atlas_omp_parallel { std::vector local_sum_private(nvar, 0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { if (!is_ghost(n)) { for (idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { local_sum_private[j] += arr(n, l, j); } } } } atlas_omp_critical { for (idx_t j = 0; j < nvar; ++j) { local_sum[j] += local_sum_private[j]; } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(local_sum, result, eckit::mpi::sum()); } N = fs.nb_nodes_global() * nlev; } template void sum(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { if (field.datatype() == array::DataType::kind()) { dispatch_sum(fs, field, result, N); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_sum_per_level(const NodeColumns& fs, const Field& field, Field& sum, idx_t& N) { mesh::IsGhostNode is_ghost(fs.nodes()); array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } sum.resize(shape); auto arr = make_leveled_view(field); const idx_t npts = std::min(arr.shape(0), fs.nb_nodes()); const idx_t nlev = arr.shape(1); const idx_t nvar = arr.shape(2); auto sum_per_level = make_per_level_view(sum); for (idx_t l = 0; l < sum_per_level.shape(0); ++l) { for (idx_t j = 0; j < sum_per_level.shape(1); ++j) { sum_per_level(l, j) = 0; } } atlas_omp_parallel { array::ArrayT sum_per_level_private(sum_per_level.shape(0), sum_per_level.shape(1)); array::ArrayView sum_per_level_private_view = array::make_view(sum_per_level_private); for (idx_t l = 0; l < sum_per_level_private_view.shape(0); ++l) { for (idx_t j = 0; j < sum_per_level_private_view.shape(1); ++j) { sum_per_level_private_view(l, j) = 0; } } atlas_omp_for(idx_t n = 0; n < npts; ++n) { if (!is_ghost(n)) { for (idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { sum_per_level_private_view(l, j) += arr(n, l, j); } } } } atlas_omp_critical { for (idx_t l = 0; l < sum_per_level_private.shape(0); ++l) { for (idx_t j = 0; j < sum_per_level_private.shape(1); ++j) { sum_per_level(l, j) += sum_per_level_private_view(l, j); } } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduceInPlace(sum_per_level.data(), sum.size(), eckit::mpi::sum()); } N = fs.nb_nodes_global(); } void sum_per_level(const NodeColumns& fs, const Field& field, Field& sum, idx_t& N) { if (field.datatype() != sum.datatype()) { throw_Exception("Field and sum are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_sum_per_level(fs, field, sum, N); case array::DataType::KIND_INT64: return dispatch_sum_per_level(fs, field, sum, N); case array::DataType::KIND_REAL32: return dispatch_sum_per_level(fs, field, sum, N); case array::DataType::KIND_REAL64: return dispatch_sum_per_level(fs, field, sum, N); default: throw_Exception("datatype not supported", Here()); } } template void dispatch_order_independent_sum_2d(const NodeColumns& fs, const Field& field, DATATYPE& result, idx_t& N) { idx_t root = 0; Field global = fs.createField(field, option::global()); fs.gather(field, global); result = 0; auto glb = array::make_view(global); for (idx_t jnode = 0; jnode < glb.size(); ++jnode) { result += glb(jnode); } ATLAS_TRACE_MPI(BROADCAST) { mpi::comm(fs.mpi_comm()).broadcast(&result, 1, root); } N = fs.nb_nodes_global(); } template void dispatch_order_independent_sum(const NodeColumns& fs, const Field& field, T& result, idx_t& N) { if (field.levels()) { auto arr = make_leveled_scalar_view(field); Field surface_field = fs.createField(option::name("surface") | option::levels(false)); auto surface = array::make_view(surface_field); const idx_t N0 = std::min(surface.shape(0), arr.shape(0)); const idx_t N1 = arr.shape(1); for (idx_t n = 0; n < N0; ++n) { surface(n) = 0; for (idx_t l = 0; l < N1; ++l) { surface(n) += arr(n, l); } } dispatch_order_independent_sum_2d(fs, surface_field, result, N); N *= arr.shape(1); } else { dispatch_order_independent_sum_2d(fs, field, result, N); } } template void order_independent_sum(const NodeColumns& fs, const Field& field, T& result, idx_t& N) { if (field.datatype() == array::DataType::kind()) { dispatch_order_independent_sum(fs, field, result, N); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { int tmp; dispatch_order_independent_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_INT64: { long tmp; dispatch_order_independent_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_REAL32: { float tmp; dispatch_order_independent_sum(fs, field, tmp, N); result = tmp; return; } case array::DataType::KIND_REAL64: { double tmp; dispatch_order_independent_sum(fs, field, tmp, N); result = tmp; return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_order_independent_sum_2d(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { idx_t nvar = field.variables(); result.resize(nvar); for (idx_t j = 0; j < nvar; ++j) { result[j] = 0.; } Field global = fs.createField(field, option::name("global") | option::global()); fs.gather(field, global); if (mpi::rank() == 0) { const auto glb = make_surface_view(global); for (idx_t n = 0; n < fs.nb_nodes_global(); ++n) { for (idx_t j = 0; j < nvar; ++j) { result[j] += glb(n, j); } } } idx_t root = global.metadata().get("owner"); ATLAS_TRACE_MPI(BROADCAST) { mpi::comm(fs.mpi_comm()).broadcast(result, root); } N = fs.nb_nodes_global(); } template void dispatch_order_independent_sum(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { if (field.levels()) { const auto arr = make_leveled_view(field); const idx_t npts = std::min(arr.shape(0), fs.nb_nodes()); const idx_t nlev = arr.shape(1); const idx_t nvar = arr.shape(2); Field surface_field = fs.createField(option::name("surface") | option::variables(nvar) | option::levels(false)); auto surface = make_surface_view(surface_field); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t j = 0; j < nvar; ++j) { surface(n, j) = 0; } } for (idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { surface(n, j) += arr(n, l, j); } } } dispatch_order_independent_sum_2d(fs, surface_field, result, N); N *= arr.shape(1); } else { dispatch_order_independent_sum_2d(fs, field, result, N); } } template void order_independent_sum(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { if (field.datatype() == array::DataType::kind()) { dispatch_order_independent_sum(fs, field, result, N); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_order_independent_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_order_independent_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_order_independent_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_order_independent_sum(fs, field, tmp, N); result.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_order_independent_sum_per_level(const NodeColumns& fs, const Field& field, Field& sumfield, idx_t& N) { array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } sumfield.resize(shape); auto sum = make_per_level_view(sumfield); for (idx_t l = 0; l < sum.shape(0); ++l) { for (idx_t j = 0; j < sum.shape(1); ++j) { sum(l, j) = 0.; } } idx_t root = 0; Field global = fs.createField(field, option::name("global") | option::global()); fs.gather(field, global); if (mpi::rank() == 0) { const array::LocalView glb = make_leveled_view(global); for (idx_t n = 0; n < glb.shape(0); ++n) { for (idx_t l = 0; l < glb.shape(1); ++l) { for (idx_t j = 0; j < glb.shape(2); ++j) { sum(l, j) += glb(n, l, j); } } } } ATLAS_TRACE_MPI(BROADCAST) { std::vector sum_array(sumfield.size()); if (mpi::rank() == root) { idx_t c(0); for (idx_t l = 0; l < sum.shape(0); ++l) { for (idx_t j = 0; j < sum.shape(1); ++j) { sum_array[c++] = sum(l, j); } } } mpi::comm(fs.mpi_comm()).broadcast(sum_array, root); if (mpi::rank() != root) { idx_t c(0); for (idx_t l = 0; l < sum.shape(0); ++l) { for (idx_t j = 0; j < sum.shape(1); ++j) { sum(l, j) = sum_array[c++]; } } } } N = fs.nb_nodes_global(); } void order_independent_sum_per_level(const NodeColumns& fs, const Field& field, Field& sum, idx_t& N) { if (field.datatype() != sum.datatype()) { throw_Exception("Field and sum are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_order_independent_sum_per_level(fs, field, sum, N); case array::DataType::KIND_INT64: return dispatch_order_independent_sum_per_level(fs, field, sum, N); case array::DataType::KIND_REAL32: return dispatch_order_independent_sum_per_level(fs, field, sum, N); case array::DataType::KIND_REAL64: return dispatch_order_independent_sum_per_level(fs, field, sum, N); default: throw_Exception("datatype not supported", Here()); } } template void dispatch_minimum(const NodeColumns& fs, const Field& field, std::vector& min) { auto arr = make_leveled_view(field); const idx_t nvar = arr.shape(2); min.resize(nvar); std::vector local_minimum(nvar, std::numeric_limits::max()); atlas_omp_parallel { std::vector local_minimum_private(nvar, std::numeric_limits::max()); const idx_t npts = std::min(arr.shape(0), fs.size()); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < arr.shape(2); ++j) { local_minimum_private[j] = std::min(arr(n, l, j), local_minimum_private[j]); } } } atlas_omp_critical { for (idx_t j = 0; j < arr.shape(2); ++j) { local_minimum[j] = std::min(local_minimum_private[j], local_minimum[j]); } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(local_minimum, min, eckit::mpi::min()); } } template void minimum(const NodeColumns& fs, const Field& field, std::vector& min) { if (field.datatype() == array::DataType::kind()) { dispatch_minimum(fs, field, min); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_minimum(fs, field, tmp); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_minimum(fs, field, tmp); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_minimum(fs, field, tmp); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_minimum(fs, field, tmp); min.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_maximum(const NodeColumns& fs, const Field& field, std::vector& max) { auto arr = make_leveled_view(field); const idx_t nvar = arr.shape(2); max.resize(nvar); std::vector local_maximum(nvar, -std::numeric_limits::max()); atlas_omp_parallel { std::vector local_maximum_private(nvar, -std::numeric_limits::max()); const idx_t npts = std::min(arr.shape(0), fs.size()); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { local_maximum_private[j] = std::max(arr(n, l, j), local_maximum_private[j]); } } } atlas_omp_critical { for (idx_t j = 0; j < nvar; ++j) { local_maximum[j] = std::max(local_maximum_private[j], local_maximum[j]); } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(local_maximum, max, eckit::mpi::max()); } } template void maximum(const NodeColumns& fs, const Field& field, std::vector& max) { if (field.datatype() == array::DataType::kind()) { dispatch_maximum(fs, field, max); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_maximum(fs, field, tmp); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_maximum(fs, field, tmp); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_maximum(fs, field, tmp); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_maximum(fs, field, tmp); max.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void minimum(const NodeColumns& fs, const Field& field, T& min) { std::vector v; minimum(fs, field, v); min = v[0]; } template void maximum(const NodeColumns& fs, const Field& field, T& max) { std::vector v; maximum(fs, field, v); max = v[0]; } template void dispatch_minimum_per_level(const NodeColumns& fs, const Field& field, Field& min_field) { array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } min_field.resize(shape); auto min = make_per_level_view(min_field); for (idx_t l = 0; l < min.shape(0); ++l) { for (idx_t j = 0; j < min.shape(1); ++j) { min(l, j) = std::numeric_limits::max(); } } auto arr = make_leveled_view(field); atlas_omp_parallel { array::ArrayT min_private(min.shape(0), min.shape(1)); array::ArrayView min_private_view = array::make_view(min_private); for (idx_t l = 0; l < min.shape(0); ++l) { for (idx_t j = 0; j < min.shape(1); ++j) { min_private_view(l, j) = std::numeric_limits::max(); } } const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < arr.shape(2); ++j) { min_private_view(l, j) = std::min(arr(n, l, j), min_private_view(l, j)); } } } atlas_omp_critical { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < arr.shape(2); ++j) { min(l, j) = std::min(min_private_view(l, j), min(l, j)); } } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduceInPlace(min.data(), min_field.size(), eckit::mpi::min()); } } void minimum_per_level(const NodeColumns& fs, const Field& field, Field& min) { if (field.datatype() != min.datatype()) { throw_Exception("Field and min are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_minimum_per_level(fs, field, min); case array::DataType::KIND_INT64: return dispatch_minimum_per_level(fs, field, min); case array::DataType::KIND_REAL32: return dispatch_minimum_per_level(fs, field, min); case array::DataType::KIND_REAL64: return dispatch_minimum_per_level(fs, field, min); default: throw_Exception("datatype not supported", Here()); } } template void dispatch_maximum_per_level(const NodeColumns& fs, const Field& field, Field& max_field) { array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } max_field.resize(shape); auto max = make_per_level_view(max_field); for (idx_t l = 0; l < max.shape(0); ++l) { for (idx_t j = 0; j < max.shape(1); ++j) { max(l, j) = -std::numeric_limits::max(); } } auto arr = make_leveled_view(field); atlas_omp_parallel { array::ArrayT max_private(max.shape(0), max.shape(1)); array::ArrayView max_private_view = array::make_view(max_private); for (idx_t l = 0; l < max_private_view.shape(0); ++l) { for (idx_t j = 0; j < max_private_view.shape(1); ++j) { max_private_view(l, j) = -std::numeric_limits::max(); } } const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < arr.shape(2); ++j) { max_private_view(l, j) = std::max(arr(n, l, j), max_private_view(l, j)); } } } atlas_omp_critical { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < arr.shape(2); ++j) { max(l, j) = std::max(max_private_view(l, j), max(l, j)); } } } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduceInPlace(max.data(), max_field.size(), eckit::mpi::max()); } } void maximum_per_level(const NodeColumns& fs, const Field& field, Field& max) { if (field.datatype() != max.datatype()) { throw_Exception("Field and max are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_maximum_per_level(fs, field, max); case array::DataType::KIND_INT64: return dispatch_maximum_per_level(fs, field, max); case array::DataType::KIND_REAL32: return dispatch_maximum_per_level(fs, field, max); case array::DataType::KIND_REAL64: return dispatch_maximum_per_level(fs, field, max); default: throw_Exception("datatype not supported", Here()); } } template void dispatch_minimum_and_location(const NodeColumns& fs, const Field& field, std::vector& min, std::vector& glb_idx, std::vector& level) { auto arr = make_leveled_view(field); idx_t nvar = arr.shape(2); min.resize(nvar); glb_idx.resize(nvar); level.resize(nvar); std::vector local_minimum(nvar, std::numeric_limits::max()); std::vector loc_node(nvar); std::vector loc_level(nvar); atlas_omp_parallel { std::vector local_minimum_private(nvar, std::numeric_limits::max()); std::vector loc_node_private(nvar); std::vector loc_level_private(nvar); const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (arr(n, l, j) < local_minimum_private[j]) { local_minimum_private[j] = arr(n, l, j); loc_node_private[j] = n; loc_level_private[j] = l; } } } } atlas_omp_critical_ordered { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (local_minimum_private[j] < local_minimum[j]) { local_minimum[j] = local_minimum_private[j]; loc_node[j] = loc_node_private[j]; loc_level[j] = loc_level_private[j]; } } } } } std::vector> min_and_gidx_loc(nvar); std::vector> min_and_level_loc(nvar); std::vector> min_and_gidx_glb(nvar); std::vector> min_and_level_glb(nvar); const array::ArrayView global_index = array::make_view(fs.nodes().global_index()); for (idx_t j = 0; j < nvar; ++j) { gidx_t glb_idx = global_index(loc_node[j]); ATLAS_ASSERT(glb_idx < std::numeric_limits::max()); // pairs with 64bit // integer for second not // implemented min_and_gidx_loc[j] = std::make_pair(local_minimum[j], glb_idx); min_and_level_loc[j] = std::make_pair(local_minimum[j], loc_level[j]); } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(min_and_gidx_loc, min_and_gidx_glb, eckit::mpi::minloc()); mpi::comm(fs.mpi_comm()).allReduce(min_and_level_loc, min_and_level_glb, eckit::mpi::minloc()); } for (idx_t j = 0; j < nvar; ++j) { min[j] = min_and_gidx_glb[j].first; glb_idx[j] = min_and_gidx_glb[j].second; level[j] = min_and_level_glb[j].second; } } template void minimum_and_location(const NodeColumns& fs, const Field& field, std::vector& min, std::vector& glb_idx, std::vector& level) { if (field.datatype() == array::DataType::kind()) { return dispatch_minimum_and_location(fs, field, min, glb_idx, level); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_minimum_and_location(fs, field, tmp, glb_idx, level); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_minimum_and_location(fs, field, tmp, glb_idx, level); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_minimum_and_location(fs, field, tmp, glb_idx, level); min.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_minimum_and_location(fs, field, tmp, glb_idx, level); min.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void dispatch_maximum_and_location(const NodeColumns& fs, const Field& field, std::vector& max, std::vector& glb_idx, std::vector& level) { auto arr = make_leveled_view(field); idx_t nvar = arr.shape(2); max.resize(nvar); glb_idx.resize(nvar); level.resize(nvar); std::vector local_maximum(nvar, -std::numeric_limits::max()); std::vector loc_node(nvar); std::vector loc_level(nvar); atlas_omp_parallel { std::vector local_maximum_private(nvar, -std::numeric_limits::max()); std::vector loc_node_private(nvar); std::vector loc_level_private(nvar); const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (arr(n, l, j) > local_maximum_private[j]) { local_maximum_private[j] = arr(n, l, j); loc_node_private[j] = n; loc_level_private[j] = l; } } } } atlas_omp_critical_ordered { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (local_maximum_private[j] > local_maximum[j]) { local_maximum[j] = local_maximum_private[j]; loc_node[j] = loc_node_private[j]; loc_level[j] = loc_level_private[j]; } } } } } std::vector> max_and_gidx_loc(nvar); std::vector> max_and_level_loc(nvar); std::vector> max_and_gidx_glb(nvar); std::vector> max_and_level_glb(nvar); const array::ArrayView global_index = array::make_view(fs.nodes().global_index()); for (idx_t j = 0; j < nvar; ++j) { gidx_t glb_idx = global_index(loc_node[j]); ATLAS_ASSERT(glb_idx < std::numeric_limits::max()); // pairs with 64bit // integer for second not // implemented max_and_gidx_loc[j] = std::make_pair(local_maximum[j], glb_idx); max_and_level_loc[j] = std::make_pair(local_maximum[j], loc_level[j]); } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(max_and_gidx_loc, max_and_gidx_glb, eckit::mpi::maxloc()); mpi::comm(fs.mpi_comm()).allReduce(max_and_level_loc, max_and_level_glb, eckit::mpi::maxloc()); } for (idx_t j = 0; j < nvar; ++j) { max[j] = max_and_gidx_glb[j].first; glb_idx[j] = max_and_gidx_glb[j].second; level[j] = max_and_level_glb[j].second; } } template void maximum_and_location(const NodeColumns& fs, const Field& field, std::vector& max, std::vector& glb_idx, std::vector& level) { if (field.datatype() == array::DataType::kind()) { return dispatch_maximum_and_location(fs, field, max, glb_idx, level); } else { switch (field.datatype().kind()) { case array::DataType::KIND_INT32: { std::vector tmp; dispatch_maximum_and_location(fs, field, tmp, glb_idx, level); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_INT64: { std::vector tmp; dispatch_maximum_and_location(fs, field, tmp, glb_idx, level); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL32: { std::vector tmp; dispatch_maximum_and_location(fs, field, tmp, glb_idx, level); max.assign(tmp.begin(), tmp.end()); return; } case array::DataType::KIND_REAL64: { std::vector tmp; dispatch_maximum_and_location(fs, field, tmp, glb_idx, level); max.assign(tmp.begin(), tmp.end()); return; } default: throw_Exception("datatype not supported", Here()); } } } template void minimum_and_location(const NodeColumns& fs, const Field& field, std::vector& min, std::vector& glb_idx) { std::vector level; minimum_and_location(fs, field, min, glb_idx, level); } template void maximum_and_location(const NodeColumns& fs, const Field& field, std::vector& max, std::vector& glb_idx) { std::vector level; maximum_and_location(fs, field, max, glb_idx, level); } template void minimum_and_location(const NodeColumns& fs, const Field& field, T& min, gidx_t& glb_idx, idx_t& level) { std::vector minv; std::vector gidxv; std::vector levelv; minimum_and_location(fs, field, minv, gidxv, levelv); min = minv[0]; glb_idx = gidxv[0]; level = levelv[0]; } template void maximum_and_location(const NodeColumns& fs, const Field& field, T& max, gidx_t& glb_idx, idx_t& level) { std::vector maxv; std::vector gidxv; std::vector levelv; maximum_and_location(fs, field, maxv, gidxv, levelv); max = maxv[0]; glb_idx = gidxv[0]; level = levelv[0]; } template void minimum_and_location(const NodeColumns& fs, const Field& field, T& min, gidx_t& glb_idx) { idx_t level; minimum_and_location(fs, field, min, glb_idx, level); } template void maximum_and_location(const NodeColumns& fs, const Field& field, T& max, gidx_t& glb_idx) { idx_t level; maximum_and_location(fs, field, max, glb_idx, level); } template void dispatch_minimum_and_location_per_level(const NodeColumns& fs, const Field& field, Field& min_field, Field& glb_idx_field) { auto arr = make_leveled_view(field); array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } min_field.resize(shape); glb_idx_field.resize(shape); const idx_t nvar = arr.shape(2); auto min = make_per_level_view(min_field); auto glb_idx = make_per_level_view(glb_idx_field); for (idx_t l = 0; l < min.shape(0); ++l) { for (idx_t j = 0; j < min.shape(1); ++j) { min(l, j) = std::numeric_limits::max(); } } atlas_omp_parallel { array::ArrayT min_private(min.shape(0), min.shape(1)); array::ArrayView min_private_view = array::make_view(min_private); for (idx_t l = 0; l < min_private_view.shape(0); ++l) { for (idx_t j = 0; j < min_private_view.shape(1); ++j) { min_private_view(l, j) = std::numeric_limits::max(); } } array::ArrayT glb_idx_private(glb_idx.shape(0), glb_idx.shape(1)); array::ArrayView glb_idx_private_view = array::make_view(glb_idx_private); const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (arr(n, l, j) < min(l, j)) { min_private_view(l, j) = arr(n, l, j); glb_idx_private_view(l, j) = n; } } } } atlas_omp_critical_ordered { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (min_private_view(l, j) < min(l, j)) { min(l, j) = min_private_view(l, j); glb_idx(l, j) = glb_idx_private_view(l, j); } } } } } const idx_t nlev = arr.shape(1); std::vector> min_and_gidx_loc(nlev * nvar); std::vector> min_and_gidx_glb(nlev * nvar); const array::ArrayView global_index = array::make_view(fs.nodes().global_index()); atlas_omp_parallel_for(idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { gidx_t gidx = global_index(glb_idx(l, j)); ATLAS_ASSERT(gidx < std::numeric_limits::max()); // pairs with 64bit // integer for second not // implemented min_and_gidx_loc[j + nvar * l] = std::make_pair(min(l, j), gidx); } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(min_and_gidx_loc, min_and_gidx_glb, eckit::mpi::minloc()); } atlas_omp_parallel_for(idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { min(l, j) = min_and_gidx_glb[j + l * nvar].first; glb_idx(l, j) = min_and_gidx_glb[j + l * nvar].second; } } } void minimum_and_location_per_level(const NodeColumns& fs, const Field& field, Field& min, Field& glb_idx) { if (field.datatype() != min.datatype()) { throw_Exception("Field and min are not of same datatype.", Here()); } if (glb_idx.datatype() != array::DataType::kind()) { throw_Exception("glb_idx Field is not of correct datatype", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_minimum_and_location_per_level(fs, field, min, glb_idx); case array::DataType::KIND_INT64: return dispatch_minimum_and_location_per_level(fs, field, min, glb_idx); case array::DataType::KIND_REAL32: return dispatch_minimum_and_location_per_level(fs, field, min, glb_idx); case array::DataType::KIND_REAL64: return dispatch_minimum_and_location_per_level(fs, field, min, glb_idx); default: throw_Exception("datatype not supported", Here()); } } template void dispatch_maximum_and_location_per_level(const NodeColumns& fs, const Field& field, Field& max_field, Field& glb_idx_field) { auto arr = make_leveled_view(field); array::ArrayShape shape; shape.reserve(field.rank() - 1); for (idx_t j = 1; j < field.rank(); ++j) { shape.push_back(field.shape(j)); } max_field.resize(shape); glb_idx_field.resize(shape); const idx_t nvar = arr.shape(2); auto max = make_per_level_view(max_field); auto glb_idx = make_per_level_view(glb_idx_field); for (idx_t l = 0; l < max.shape(0); ++l) { for (idx_t j = 0; j < max.shape(1); ++j) { max(l, j) = -std::numeric_limits::max(); } } atlas_omp_parallel { array::ArrayT max_private(max.shape(0), max.shape(1)); array::ArrayView max_private_view = array::make_view(max_private); for (idx_t l = 0; l < max_private_view.shape(0); ++l) { for (idx_t j = 0; j < max_private_view.shape(1); ++j) { max_private_view(l, j) = -std::numeric_limits::max(); } } array::ArrayT glb_idx_private(glb_idx.shape(0), glb_idx.shape(1)); array::ArrayView glb_idx_private_view = array::make_view(glb_idx_private); const idx_t npts = arr.shape(0); atlas_omp_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (arr(n, l, j) > max(l, j)) { max_private_view(l, j) = arr(n, l, j); glb_idx_private_view(l, j) = n; } } } } atlas_omp_critical_ordered { for (idx_t l = 0; l < arr.shape(1); ++l) { for (idx_t j = 0; j < nvar; ++j) { if (max_private_view(l, j) > max(l, j)) { max(l, j) = max_private_view(l, j); glb_idx(l, j) = glb_idx_private_view(l, j); } } } } } const idx_t nlev = arr.shape(1); std::vector> max_and_gidx_loc(nlev * nvar); std::vector> max_and_gidx_glb(nlev * nvar); const array::ArrayView global_index = array::make_view(fs.nodes().global_index()); atlas_omp_parallel_for(idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { gidx_t gidx = global_index(glb_idx(l, j)); ATLAS_ASSERT(gidx < std::numeric_limits::max()); // pairs with 64bit // integer for second not // implemented max_and_gidx_loc[j + nvar * l] = std::make_pair(max(l, j), gidx); } } ATLAS_TRACE_MPI(ALLREDUCE) { mpi::comm(fs.mpi_comm()).allReduce(max_and_gidx_loc, max_and_gidx_glb, eckit::mpi::maxloc()); } atlas_omp_parallel_for(idx_t l = 0; l < nlev; ++l) { for (idx_t j = 0; j < nvar; ++j) { max(l, j) = max_and_gidx_glb[j + l * nvar].first; glb_idx(l, j) = max_and_gidx_glb[j + l * nvar].second; } } } void maximum_and_location_per_level(const NodeColumns& fs, const Field& field, Field& max, Field& glb_idx) { if (field.datatype() != max.datatype()) { throw_Exception("Field and max are not of same datatype.", Here()); } if (glb_idx.datatype() != array::DataType::kind()) { throw_Exception("glb_idx Field is not of correct datatype", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_maximum_and_location_per_level(fs, field, max, glb_idx); case array::DataType::KIND_INT64: return dispatch_maximum_and_location_per_level(fs, field, max, glb_idx); case array::DataType::KIND_REAL32: return dispatch_maximum_and_location_per_level(fs, field, max, glb_idx); case array::DataType::KIND_REAL64: return dispatch_maximum_and_location_per_level(fs, field, max, glb_idx); default: throw_Exception("datatype not supported", Here()); } } template void mean(const NodeColumns& fs, const Field& field, T& result, idx_t& N) { sum(fs, field, result, N); result /= static_cast(N); } template void mean(const NodeColumns& fs, const Field& field, std::vector& result, idx_t& N) { sum(fs, field, result, N); for (size_t j = 0; j < result.size(); ++j) { result[j] /= static_cast(N); } } template void dispatch_mean_per_level(const NodeColumns& fs, const Field& field, Field& mean, idx_t& N) { dispatch_sum_per_level(fs, field, mean, N); auto view = make_per_level_view(mean); for (idx_t l = 0; l < view.shape(0); ++l) { for (idx_t j = 0; j < view.shape(1); ++j) { view(l, j) /= static_cast(N); } } } void mean_per_level(const NodeColumns& fs, const Field& field, Field& mean, idx_t& N) { if (field.datatype() != mean.datatype()) { throw_Exception("Field and sum are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_mean_per_level(fs, field, mean, N); case array::DataType::KIND_INT64: return dispatch_mean_per_level(fs, field, mean, N); case array::DataType::KIND_REAL32: return dispatch_mean_per_level(fs, field, mean, N); case array::DataType::KIND_REAL64: return dispatch_mean_per_level(fs, field, mean, N); default: throw_Exception("datatype not supported", Here()); } } template void mean_and_standard_deviation(const NodeColumns& fs, const Field& field, T& mu, T& sigma, idx_t& N) { mean(fs, field, mu, N); Field squared_diff_field = fs.createField(option::name("sqr_diff") | option::datatype(field.datatype()) | option::levels(field.levels())); auto squared_diff = make_leveled_scalar_view(squared_diff_field); auto values = make_leveled_scalar_view(field); const idx_t npts = std::min(values.shape(0), fs.nb_nodes()); atlas_omp_parallel_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < values.shape(1); ++l) { squared_diff(n, l) = sqr(values(n, l) - mu); } } mean(fs, squared_diff_field, sigma, N); sigma = std::sqrt(sigma); } template void mean_and_standard_deviation(const NodeColumns& fs, const Field& field, std::vector& mu, std::vector& sigma, idx_t& N) { mean(fs, field, mu, N); Field squared_diff_field = fs.createField(option::name("sqr_diff") | option::levels(field.levels()) | option::variables(field.variables())); auto squared_diff = make_leveled_view(squared_diff_field); auto values = make_leveled_view(field); const idx_t npts = std::min(values.shape(0), fs.nb_nodes()); atlas_omp_parallel_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < values.shape(1); ++l) { for (idx_t j = 0; j < values.shape(2); ++j) { squared_diff(n, l, j) = sqr(values(n, l, j) - mu[j]); } } } mean(fs, squared_diff_field, sigma, N); for (size_t j = 0; j < sigma.size(); ++j) { sigma[j] = std::sqrt(sigma[j]); } } template void dispatch_mean_and_standard_deviation_per_level(const NodeColumns& fs, const Field& field, Field& mean, Field& stddev, idx_t& N) { dispatch_mean_per_level(fs, field, mean, N); Field squared_diff_field = fs.createField(option::name("sqr_diff") | option::levels(field.levels()) | option::variables(field.variables())); auto squared_diff = make_leveled_view(squared_diff_field); auto values = make_leveled_view(field); auto mu = make_per_level_view(mean); const idx_t npts = std::min(values.shape(0), fs.nb_nodes()); atlas_omp_parallel_for(idx_t n = 0; n < npts; ++n) { for (idx_t l = 0; l < values.shape(1); ++l) { for (idx_t j = 0; j < values.shape(2); ++j) { squared_diff(n, l, j) = sqr(values(n, l, j) - mu(l, j)); } } } dispatch_mean_per_level(fs, squared_diff_field, stddev, N); auto sigma = make_per_level_view(stddev); atlas_omp_for(idx_t l = 0; l < sigma.shape(0); ++l) { for (idx_t j = 0; j < sigma.shape(1); ++j) { sigma(l, j) = std::sqrt(sigma(l, j)); } } } void mean_and_standard_deviation_per_level(const NodeColumns& fs, const Field& field, Field& mean, Field& stddev, idx_t& N) { if (field.datatype() != mean.datatype()) { throw_Exception("Field and mean are not of same datatype.", Here()); } if (field.datatype() != stddev.datatype()) { throw_Exception("Field and stddev are not of same datatype.", Here()); } switch (field.datatype().kind()) { case array::DataType::KIND_INT32: return dispatch_mean_and_standard_deviation_per_level(fs, field, mean, stddev, N); case array::DataType::KIND_INT64: return dispatch_mean_and_standard_deviation_per_level(fs, field, mean, stddev, N); case array::DataType::KIND_REAL32: return dispatch_mean_and_standard_deviation_per_level(fs, field, mean, stddev, N); case array::DataType::KIND_REAL64: return dispatch_mean_and_standard_deviation_per_level(fs, field, mean, stddev, N); default: throw_Exception("datatype not supported", Here()); } } } // namespace detail template NodeColumns::FieldStatisticsT::FieldStatisticsT(const NodeColumns* f): functionspace(*f) {} template NodeColumns::FieldStatisticsVectorT::FieldStatisticsVectorT(const NodeColumns* f): functionspace(*f) {} NodeColumns::FieldStatistics::FieldStatistics(const NodeColumns* f): functionspace(*f) {} template void NodeColumns::FieldStatisticsT::sum(const Field& field, Value& result, idx_t& N) const { detail::sum(functionspace, field, result, N); } template void NodeColumns::FieldStatisticsVectorT::sum(const Field& field, Vector& result, idx_t& N) const { detail::sum(functionspace, field, result, N); } void NodeColumns::FieldStatistics::sumPerLevel(const Field& field, Field& result, idx_t& N) const { detail::sum_per_level(functionspace, field, result, N); } template void NodeColumns::FieldStatisticsT::orderIndependentSum(const Field& field, Value& result, idx_t& N) const { detail::order_independent_sum(functionspace, field, result, N); } template void NodeColumns::FieldStatisticsVectorT::orderIndependentSum(const Field& field, Vector& result, idx_t& N) const { detail::order_independent_sum(functionspace, field, result, N); } void NodeColumns::FieldStatistics::orderIndependentSumPerLevel(const Field& field, Field& result, idx_t& N) const { detail::order_independent_sum_per_level(functionspace, field, result, N); } template void NodeColumns::FieldStatisticsT::minimum(const Field& field, Value& minimum) const { detail::minimum(functionspace, field, minimum); } template void NodeColumns::FieldStatisticsT::maximum(const Field& field, Value& maximum) const { detail::maximum(functionspace, field, maximum); } template void NodeColumns::FieldStatisticsVectorT::minimum(const Field& field, Vector& minimum) const { detail::minimum(functionspace, field, minimum); } template void NodeColumns::FieldStatisticsVectorT::maximum(const Field& field, Vector& maximum) const { detail::maximum(functionspace, field, maximum); } void NodeColumns::FieldStatistics::minimumPerLevel(const Field& field, Field& minimum) const { detail::minimum_per_level(functionspace, field, minimum); } void NodeColumns::FieldStatistics::maximumPerLevel(const Field& field, Field& maximum) const { detail::maximum_per_level(functionspace, field, maximum); } template void NodeColumns::FieldStatisticsT::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx) const { detail::minimum_and_location(functionspace, field, minimum, glb_idx); } template void NodeColumns::FieldStatisticsT::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx) const { detail::maximum_and_location(functionspace, field, maximum, glb_idx); } template void NodeColumns::FieldStatisticsT::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx, idx_t& level) const { detail::minimum_and_location(functionspace, field, minimum, glb_idx, level); } template void NodeColumns::FieldStatisticsT::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx, idx_t& level) const { detail::maximum_and_location(functionspace, field, maximum, glb_idx, level); } template void NodeColumns::FieldStatisticsVectorT::minimumAndLocation(const Field& field, Vector& minimum, std::vector& glb_idx) const { detail::minimum_and_location(functionspace, field, minimum, glb_idx); } template void NodeColumns::FieldStatisticsVectorT::maximumAndLocation(const Field& field, Vector& maximum, std::vector& glb_idx) const { detail::maximum_and_location(functionspace, field, maximum, glb_idx); } template void NodeColumns::FieldStatisticsVectorT::minimumAndLocation(const Field& field, Vector& minimum, std::vector& glb_idx, std::vector& level) const { detail::minimum_and_location(functionspace, field, minimum, glb_idx, level); } template void NodeColumns::FieldStatisticsVectorT::maximumAndLocation(const Field& field, Vector& maximum, std::vector& glb_idx, std::vector& level) const { detail::maximum_and_location(functionspace, field, maximum, glb_idx, level); } void NodeColumns::FieldStatistics::minimumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const { detail::minimum_and_location_per_level(functionspace, field, column, glb_idx); } void NodeColumns::FieldStatistics::maximumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const { detail::maximum_and_location_per_level(functionspace, field, column, glb_idx); } template void NodeColumns::FieldStatisticsT::mean(const Field& field, Value& mean, idx_t& N) const { detail::mean(functionspace, field, mean, N); } template void NodeColumns::FieldStatisticsVectorT::mean(const Field& field, Vector& mean, idx_t& N) const { detail::mean(functionspace, field, mean, N); } void NodeColumns::FieldStatistics::meanPerLevel(const Field& field, Field& mean, idx_t& N) const { detail::mean_per_level(functionspace, field, mean, N); } template void NodeColumns::FieldStatisticsT::meanAndStandardDeviation(const Field& field, Value& mean, Value& stddev, idx_t& N) const { detail::mean_and_standard_deviation(functionspace, field, mean, stddev, N); } template void NodeColumns::FieldStatisticsVectorT::meanAndStandardDeviation(const Field& field, Vector& mean, Vector& stddev, idx_t& N) const { detail::mean_and_standard_deviation(functionspace, field, mean, stddev, N); } void NodeColumns::FieldStatistics::meanAndStandardDeviationPerLevel(const Field& field, Field& mean, Field& stddev, idx_t& N) const { detail::mean_and_standard_deviation_per_level(functionspace, field, mean, stddev, N); } template struct NodeColumns::FieldStatisticsT; template struct NodeColumns::FieldStatisticsT; template struct NodeColumns::FieldStatisticsT; template struct NodeColumns::FieldStatisticsT; // template struct NodeColumns::FieldStatisticsT; template struct NodeColumns::FieldStatisticsVectorT>; template struct NodeColumns::FieldStatisticsVectorT>; template struct NodeColumns::FieldStatisticsVectorT>; template struct NodeColumns::FieldStatisticsVectorT>; // template struct NodeColumns::FieldStatisticsVectorT< std::vector >; } // namespace detail } // namespace functionspace } // namespace atlas