| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <type_traits> |
| 14 |
#include <utility> |
| 15 |
#include <sstream> |
| 16 |
|
| 17 |
#include "atlas/field/detail/for_each.h" |
| 18 |
|
| 19 |
#include "atlas/array/Array.h" |
| 20 |
|
| 21 |
#include "Field.h" |
| 22 |
#include "FieldSet.h" |
| 23 |
#include "atlas/array/helpers/ArrayForEach.h" |
| 24 |
#include "atlas/runtime/Exception.h" |
| 25 |
|
| 26 |
namespace atlas { |
| 27 |
namespace field { |
| 28 |
|
| 29 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 30 |
// void for_each_value_masked( const eckit::Parametrisation& , const Mask& , std::tuple<Field...>&& , const Function& ) |
| 31 |
|
| 32 |
template <typename Mask, typename... Field, typename Function> |
| 33 |
void for_each_value_masked(const eckit::Parametrisation& config, const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 34 |
auto field_1 = std::get<0>(fields); |
| 35 |
if constexpr (std::is_same_v<std::decay_t<Mask>,atlas::Field>) { |
| 36 |
auto h_dim = field_1.horizontal_dimension(); |
| 37 |
|
| 38 |
ATLAS_ASSERT( mask.datatype() == array::make_datatype<int>() ); |
| 39 |
ATLAS_ASSERT( mask.rank() <= h_dim.size() ); |
| 40 |
|
| 41 |
if (h_dim.size() == 1) { |
| 42 |
ATLAS_ASSERT(h_dim[0] == 0); |
| 43 |
auto mask_view = array::make_view<const int,1>(mask); |
| 44 |
auto mask_wrap = [mask_view](idx_t i, auto&&... args) { return mask_view(i); }; |
| 45 |
return for_each_value_masked(config, mask_wrap, std::move(fields), function); |
| 46 |
} |
| 47 |
else if (h_dim.size() == 2) { |
| 48 |
if (mask.rank() == 1) { |
| 49 |
auto mask_view_1d = array::make_view<const int,1>(mask); |
| 50 |
auto mask_view_shape2d = array::make_shape(field_1.shape(h_dim[0]), field_1.shape(h_dim[1])); |
| 51 |
auto mask_view = array::View<const int,2>( mask_view_1d.data(), mask_view_shape2d ); |
| 52 |
if( h_dim[0] == 0 && h_dim[1] == 2) { |
| 53 |
auto mask_wrap = [mask_view](idx_t i, idx_t /*dummy*/, idx_t j, auto&&... args) { return mask_view(i,j); }; |
| 54 |
return for_each_value_masked(config, mask_wrap, std::move(fields), function); |
| 55 |
} |
| 56 |
else { |
| 57 |
ATLAS_ASSERT(h_dim[0] == 0 && h_dim[1] == 1); |
| 58 |
auto mask_wrap = [mask_view](idx_t i, idx_t j, auto&&... args) { return mask_view(i,j); }; |
| 59 |
return for_each_value_masked(config, mask_wrap, std::move(fields), function); |
| 60 |
} |
| 61 |
} |
| 62 |
else { |
| 63 |
auto mask_view = array::make_view<const int,2>(mask); |
| 64 |
if( h_dim[0] == 0 && h_dim[1] == 2) { |
| 65 |
auto mask_wrap = [mask_view](idx_t i, idx_t /*dummy*/, idx_t j, auto&&... args) { return mask_view(i,j); }; |
| 66 |
return for_each_value_masked(config, mask_wrap, std::move(fields), function); |
| 67 |
} |
| 68 |
else { |
| 69 |
ATLAS_ASSERT(h_dim[0] == 0 && h_dim[1] == 1); |
| 70 |
auto mask_wrap = [mask_view](idx_t i, idx_t j, auto&&... args) { return mask_view(i,j); }; |
| 71 |
return for_each_value_masked(config, mask_wrap, std::move(fields), function); |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
else { |
| 76 |
ATLAS_THROW_EXCEPTION("More than 2 horizontal indices is not yet supported"); |
| 77 |
} |
| 78 |
} |
| 79 |
else { |
| 80 |
constexpr auto num_fields = std::tuple_size_v<std::tuple<Field...>>; |
| 81 |
static_assert(num_fields == detail::function_traits<Function>::arity,"!"); |
| 82 |
using value_type = std::decay_t<detail::first_argument<Function>>; |
| 83 |
switch (field_1.rank()) { |
| 84 |
case 1: return detail::for_each_value_masked_rank<value_type,1>(config,mask,std::move(fields),function); |
| 85 |
case 2: return detail::for_each_value_masked_rank<value_type,2>(config,mask,std::move(fields),function); |
| 86 |
case 3: return detail::for_each_value_masked_rank<value_type,3>(config,mask,std::move(fields),function); |
| 87 |
case 4: return detail::for_each_value_masked_rank<value_type,4>(config,mask,std::move(fields),function); |
| 88 |
case 5: return detail::for_each_value_masked_rank<value_type,5>(config,mask,std::move(fields),function); |
| 89 |
default: ATLAS_THROW_EXCEPTION("Only fields with rank <= 5 are currently supported. Given rank: " << std::get<0>(fields).rank()); |
| 90 |
} |
| 91 |
} |
| 92 |
ATLAS_THROW_EXCEPTION("Invalid function"); |
| 93 |
} |
| 94 |
|
| 95 |
template <typename Mask, typename Function> |
| 96 |
void for_each_value_masked(const eckit::Parametrisation& config, const Mask& mask, Field field, const Function& function) { |
| 97 |
return for_each_value_masked(config, mask, std::make_tuple(field), function); |
| 98 |
} |
| 99 |
|
| 100 |
template <typename Mask, typename Function> |
| 101 |
void for_each_value_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 102 |
return for_each_value_masked(config, mask, std::make_tuple(field_1, field_2), function); |
| 103 |
} |
| 104 |
|
| 105 |
template <typename Mask, typename Function> |
| 106 |
void for_each_value_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 107 |
return for_each_value_masked(config, mask, std::make_tuple(field_1, field_2, field_3), function); |
| 108 |
} |
| 109 |
|
| 110 |
template <typename Mask, typename Function> |
| 111 |
void for_each_value_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 112 |
return for_each_value_masked(config, mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 113 |
} |
| 114 |
|
| 115 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 116 |
// void for_each_value_masked( const ExecutionPolicy&& , const Mask& , std::tuple<Field...>&& , const Function& ) |
| 117 |
|
| 118 |
template <typename ExecutionPolicy, typename Mask, typename... Field, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 119 |
void for_each_value_masked(ExecutionPolicy, const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 120 |
return for_each_value_masked(option::execution_policy<ExecutionPolicy>(), mask, std::move(fields), function); |
| 121 |
} |
| 122 |
|
| 123 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 124 |
void for_each_value_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field, const Function& function) { |
| 125 |
return for_each_value_masked(execution_policy, mask, std::make_tuple(field), function); |
| 126 |
} |
| 127 |
|
| 128 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 129 |
void for_each_value_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 130 |
return for_each_value_masked(execution_policy, mask, std::make_tuple(field_1, field_2), function); |
| 131 |
} |
| 132 |
|
| 133 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 134 |
void for_each_value_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 135 |
return for_each_value_masked(execution_policy, mask, std::make_tuple(field_1, field_2, field_3), function); |
| 136 |
} |
| 137 |
|
| 138 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 139 |
void for_each_value_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 140 |
return for_each_value_masked(execution_policy, mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 141 |
} |
| 142 |
|
| 143 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 144 |
// void for_each_value_masked( const Mask& , std::tuple<Field...>&& , const Function& ) |
| 145 |
|
| 146 |
template <typename Mask, typename... Field, typename Function> |
| 147 |
void for_each_value_masked(const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 148 |
return for_each_value_masked(util::NoConfig(), mask, std::move(fields), function); |
| 149 |
} |
| 150 |
|
| 151 |
template <typename Mask, typename Function> |
| 152 |
void for_each_value_masked(const Mask& mask, Field field, const Function& function) { |
| 153 |
return for_each_value_masked(mask, std::make_tuple(field), function); |
| 154 |
} |
| 155 |
|
| 156 |
template <typename Mask, typename Function> |
| 157 |
void for_each_value_masked(const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 158 |
return for_each_value_masked(mask, std::make_tuple(field_1, field_2), function); |
| 159 |
} |
| 160 |
|
| 161 |
template <typename Mask, typename Function> |
| 162 |
void for_each_value_masked(const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 163 |
return for_each_value_masked(mask, std::make_tuple(field_1, field_2, field_3), function); |
| 164 |
} |
| 165 |
|
| 166 |
template <typename Mask, typename Function> |
| 167 |
void for_each_value_masked(const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 168 |
return for_each_value_masked(mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 169 |
} |
| 170 |
|
| 171 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 172 |
// void for_each_value( const eckit::Parametrisation& , std::tuple<Field...>&& , const Function& ) |
| 173 |
|
| 174 |
template <typename... Field, typename Function> |
| 175 |
void for_each_value(const eckit::Parametrisation& config, std::tuple<Field...>&& fields, const Function& function) { |
| 176 |
return for_each_value_masked(config, array::helpers::detail::no_mask, std::move(fields), function); |
| 177 |
} |
| 178 |
|
| 179 |
template <typename Function> |
| 180 |
void for_each_value(const eckit::Parametrisation& config, Field field, const Function& function) { |
| 181 |
return for_each_value_masked(config, std::make_tuple(field), function); |
| 182 |
} |
| 183 |
|
| 184 |
template <typename Function> |
| 185 |
void for_each_value(const eckit::Parametrisation& config, Field field_1, Field field_2, const Function& function) { |
| 186 |
return for_each_value_masked(config, std::make_tuple(field_1, field_2), function); |
| 187 |
} |
| 188 |
|
| 189 |
template <typename Function> |
| 190 |
void for_each_value(const eckit::Parametrisation& config, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 191 |
return for_each_value_masked(config, std::make_tuple(field_1, field_2, field_3), function); |
| 192 |
} |
| 193 |
|
| 194 |
template <typename Function> |
| 195 |
void for_each_value(const eckit::Parametrisation& config, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 196 |
return for_each_value_masked(config, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 197 |
} |
| 198 |
|
| 199 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 200 |
// void for_each_value( const ExecutionPolicy&& , std::tuple<Field...>&& , const Function& ) |
| 201 |
|
| 202 |
template <typename ExecutionPolicy, typename... Field, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 203 |
void for_each_value(ExecutionPolicy, std::tuple<Field...>&& fields, const Function& function) { |
| 204 |
return for_each_value_masked(option::execution_policy<ExecutionPolicy>(), array::helpers::detail::no_mask, std::move(fields), function); |
| 205 |
} |
| 206 |
|
| 207 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 208 |
void for_each_value(ExecutionPolicy execution_policy, Field field, const Function& function) { |
| 209 |
return for_each_value(execution_policy, std::make_tuple(field), function); |
| 210 |
} |
| 211 |
|
| 212 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 213 |
void for_each_value(ExecutionPolicy execution_policy, Field field_1, Field field_2, const Function& function) { |
| 214 |
return for_each_value(execution_policy, std::make_tuple(field_1, field_2), function); |
| 215 |
} |
| 216 |
|
| 217 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 218 |
void for_each_value(ExecutionPolicy execution_policy, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 219 |
return for_each_value(execution_policy, std::make_tuple(field_1, field_2, field_3), function); |
| 220 |
} |
| 221 |
|
| 222 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 223 |
void for_each_value(ExecutionPolicy execution_policy, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 224 |
return for_each_value(execution_policy, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 225 |
} |
| 226 |
|
| 227 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 228 |
// void for_each_value( std::tuple<Field...>&& , const Function& ) |
| 229 |
|
| 230 |
template <typename... Field, typename Function> |
| 231 |
void for_each_value(std::tuple<Field...>&& fields, const Function& function) { |
| 232 |
return for_each_value_masked(util::NoConfig(), array::helpers::detail::no_mask, std::move(fields), function); |
| 233 |
} |
| 234 |
|
| 235 |
template <typename Function> |
| 236 |
void for_each_value(Field field, const Function& function) { |
| 237 |
return for_each_value(std::make_tuple(field), function); |
| 238 |
} |
| 239 |
|
| 240 |
template <typename Function> |
| 241 |
void for_each_value(Field field_1, Field field_2, const Function& function) { |
| 242 |
return for_each_value(std::make_tuple(field_1, field_2), function); |
| 243 |
} |
| 244 |
|
| 245 |
template <typename Function> |
| 246 |
void for_each_value(Field field_1, Field field_2, Field field_3, const Function& function) { |
| 247 |
return for_each_value(std::make_tuple(field_1, field_2, field_3), function); |
| 248 |
} |
| 249 |
|
| 250 |
template <typename Function> |
| 251 |
void for_each_value(Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 252 |
return for_each_value(std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 258 |
// void for_each_column_masked( const eckit::Parametrisation& , const Mask& , std::tuple<Field...>&& , const Function& ) |
| 259 |
|
| 260 |
template <typename Mask, typename... Field, typename Function> |
| 261 |
void for_each_column_masked(const eckit::Parametrisation& config, const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 262 |
if constexpr (std::is_same_v<std::decay_t<Mask>,atlas::Field>) { |
| 263 |
auto field_1 = std::get<0>(fields); |
| 264 |
auto h_dim = field_1.horizontal_dimension(); |
| 265 |
|
| 266 |
ATLAS_ASSERT( mask.datatype() == array::make_datatype<int>() ); |
| 267 |
ATLAS_ASSERT( mask.rank() <= h_dim.size() ); |
| 268 |
|
| 269 |
if (h_dim.size() == 1) { |
| 270 |
return for_each_column_masked(config, array::make_view<const int,1>(mask), std::move(fields), function); |
| 271 |
} |
| 272 |
else if (h_dim.size() == 2) { |
| 273 |
if (mask.rank() == 1) { |
| 274 |
auto mask_view_1d = array::make_view<const int,1>(mask); |
| 275 |
auto mask_view_shape2d = array::make_shape(field_1.shape(h_dim[0]), field_1.shape(h_dim[1])); |
| 276 |
auto mask_view = array::View<const int,2>( mask_view_1d.data(), mask_view_shape2d ); |
| 277 |
return for_each_column_masked(config, mask_view, std::move(fields), function); |
| 278 |
} |
| 279 |
else { |
| 280 |
return for_each_column_masked(config, array::make_view<const int,2>(mask), std::move(fields), function); |
| 281 |
} |
| 282 |
} |
| 283 |
else { |
| 284 |
ATLAS_THROW_EXCEPTION("More than 2 horizontal indices is not yet supported"); |
| 285 |
} |
| 286 |
} |
| 287 |
else { |
| 288 |
switch (std::get<0>(fields).rank()) { |
| 289 |
case 2: return detail::for_each_column_masked_rank<2>(config, mask, std::move(fields), function); |
| 290 |
case 3: return detail::for_each_column_masked_rank<3>(config, mask, std::move(fields), function); |
| 291 |
case 4: return detail::for_each_column_masked_rank<4>(config, mask, std::move(fields), function); |
| 292 |
} |
| 293 |
} |
| 294 |
ATLAS_THROW_EXCEPTION("Invalid function"); |
| 295 |
} |
| 296 |
|
| 297 |
template <typename Mask, typename Function> |
| 298 |
void for_each_column_masked(const eckit::Parametrisation& config, const Mask& mask, Field field, const Function& function) { |
| 299 |
return for_each_column_masked(config, mask, std::make_tuple(field), function); |
| 300 |
} |
| 301 |
|
| 302 |
template <typename Mask, typename Function> |
| 303 |
void for_each_column_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 304 |
return for_each_column_masked(config, mask, std::make_tuple(field_1, field_2), function); |
| 305 |
} |
| 306 |
|
| 307 |
template <typename Mask, typename Function> |
| 308 |
void for_each_column_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 309 |
return for_each_column_masked(config, mask, std::make_tuple(field_1, field_2, field_3), function); |
| 310 |
} |
| 311 |
|
| 312 |
template <typename Mask, typename Function> |
| 313 |
void for_each_column_masked(const eckit::Parametrisation& config, const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 314 |
return for_each_column_masked(config, mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 315 |
} |
| 316 |
|
| 317 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 318 |
// void for_each_column_masked( const ExecutionPolicy&& , const Mask& , std::tuple<Field...>&& , const Function& ) |
| 319 |
|
| 320 |
template <typename ExecutionPolicy, typename Mask, typename... Field, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 321 |
void for_each_column_masked(ExecutionPolicy, const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 322 |
return for_each_column_masked(option::execution_policy<ExecutionPolicy>(), mask, std::move(fields), function); |
| 323 |
} |
| 324 |
|
| 325 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 326 |
void for_each_column_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field, const Function& function) { |
| 327 |
return for_each_column_masked(execution_policy, mask, std::make_tuple(field), function); |
| 328 |
} |
| 329 |
|
| 330 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 331 |
void for_each_column_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 332 |
return for_each_column_masked(execution_policy, mask, std::make_tuple(field_1, field_2), function); |
| 333 |
} |
| 334 |
|
| 335 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 336 |
void for_each_column_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 337 |
return for_each_column_masked(execution_policy, mask, std::make_tuple(field_1, field_2, field_3), function); |
| 338 |
} |
| 339 |
|
| 340 |
template <typename ExecutionPolicy, typename Mask, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 341 |
void for_each_column_masked(ExecutionPolicy execution_policy, const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 342 |
return for_each_column_masked(execution_policy, mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 343 |
} |
| 344 |
|
| 345 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 346 |
// void for_each_column_masked( const Mask& , std::tuple<Field...>&& , const Function& ) |
| 347 |
|
| 348 |
template <typename Mask, typename... Field, typename Function> |
| 349 |
void for_each_column_masked(const Mask& mask, std::tuple<Field...>&& fields, const Function& function) { |
| 350 |
return for_each_column_masked(util::NoConfig(), mask, std::move(fields), function); |
| 351 |
} |
| 352 |
|
| 353 |
template <typename Mask, typename Function> |
| 354 |
void for_each_column_masked(const Mask& mask, Field field, const Function& function) { |
| 355 |
return for_each_column_masked(mask, std::make_tuple(field), function); |
| 356 |
} |
| 357 |
|
| 358 |
template <typename Mask, typename Function> |
| 359 |
void for_each_column_masked(const Mask& mask, Field field_1, Field field_2, const Function& function) { |
| 360 |
return for_each_column_masked(mask, std::make_tuple(field_1, field_2), function); |
| 361 |
} |
| 362 |
|
| 363 |
template <typename Mask, typename Function> |
| 364 |
void for_each_column_masked(const Mask& mask, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 365 |
return for_each_column_masked(mask, std::make_tuple(field_1, field_2, field_3), function); |
| 366 |
} |
| 367 |
|
| 368 |
template <typename Mask, typename Function> |
| 369 |
void for_each_column_masked(const Mask& mask, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 370 |
return for_each_column_masked(mask, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 371 |
} |
| 372 |
|
| 373 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 374 |
// void for_each_column( const eckit::Parametrisation& , std::tuple<Field...>&& , const Function& ) |
| 375 |
|
| 376 |
template <typename... Field, typename Function> |
| 377 |
void for_each_column(const eckit::Parametrisation& config, std::tuple<Field...>&& fields, const Function& function) { |
| 378 |
return for_each_column_masked(config, array::helpers::detail::no_mask, std::move(fields), function); |
| 379 |
} |
| 380 |
|
| 381 |
template <typename Function> |
| 382 |
void for_each_column(const eckit::Parametrisation& config, Field field, const Function& function) { |
| 383 |
return for_each_column_masked(config, std::make_tuple(field), function); |
| 384 |
} |
| 385 |
|
| 386 |
template <typename Function> |
| 387 |
void for_each_column(const eckit::Parametrisation& config, Field field_1, Field field_2, const Function& function) { |
| 388 |
return for_each_column_masked(config, std::make_tuple(field_1, field_2), function); |
| 389 |
} |
| 390 |
|
| 391 |
template <typename Function> |
| 392 |
void for_each_column(const eckit::Parametrisation& config, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 393 |
return for_each_column_masked(config, std::make_tuple(field_1, field_2, field_3), function); |
| 394 |
} |
| 395 |
|
| 396 |
template <typename Function> |
| 397 |
void for_each_column(const eckit::Parametrisation& config, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 398 |
return for_each_column_masked(config, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 399 |
} |
| 400 |
|
| 401 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 402 |
// void for_each_column( const ExecutionPolicy&& , std::tuple<Field...>&& , const Function& ) |
| 403 |
|
| 404 |
template <typename ExecutionPolicy, typename... Field, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 405 |
void for_each_column(ExecutionPolicy, std::tuple<Field...>&& fields, const Function& function) { |
| 406 |
return for_each_column_masked(option::execution_policy<ExecutionPolicy>(), array::helpers::detail::no_mask, std::move(fields), function); |
| 407 |
} |
| 408 |
|
| 409 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 410 |
void for_each_column(ExecutionPolicy execution_policy, Field field, const Function& function) { |
| 411 |
return for_each_column(execution_policy, std::make_tuple(field), function); |
| 412 |
} |
| 413 |
|
| 414 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 415 |
void for_each_column(ExecutionPolicy execution_policy, Field field_1, Field field_2, const Function& function) { |
| 416 |
return for_each_column(execution_policy, std::make_tuple(field_1, field_2), function); |
| 417 |
} |
| 418 |
|
| 419 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 420 |
void for_each_column(ExecutionPolicy execution_policy, Field field_1, Field field_2, Field field_3, const Function& function) { |
| 421 |
return for_each_column(execution_policy, std::make_tuple(field_1, field_2, field_3), function); |
| 422 |
} |
| 423 |
|
| 424 |
template <typename ExecutionPolicy, typename Function, typename = std::enable_if_t<execution::is_execution_policy<ExecutionPolicy>()>> |
| 425 |
void for_each_column(ExecutionPolicy execution_policy, Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 426 |
return for_each_column(execution_policy, std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 427 |
} |
| 428 |
|
| 429 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 430 |
// void for_each_column( std::tuple<Field...>&& , const Function& ) |
| 431 |
|
| 432 |
template <typename... Field, typename Function> |
| 433 |
void for_each_column(std::tuple<Field...>&& fields, const Function& function) { |
| 434 |
return for_each_column_masked(util::NoConfig(), array::helpers::detail::no_mask, std::move(fields), function); |
| 435 |
} |
| 436 |
|
| 437 |
template <typename Function> |
| 438 |
void for_each_column(Field field, const Function& function) { |
| 439 |
return for_each_column(std::make_tuple(field), function); |
| 440 |
} |
| 441 |
|
| 442 |
template <typename Function> |
| 443 |
void for_each_column(Field field_1, Field field_2, const Function& function) { |
| 444 |
return for_each_column(std::make_tuple(field_1, field_2), function); |
| 445 |
} |
| 446 |
|
| 447 |
template <typename Function> |
| 448 |
void for_each_column(Field field_1, Field field_2, Field field_3, const Function& function) { |
| 449 |
return for_each_column(std::make_tuple(field_1, field_2, field_3), function); |
| 450 |
} |
| 451 |
|
| 452 |
template <typename Function> |
| 453 |
void for_each_column(Field field_1, Field field_2, Field field_3, Field field_4, const Function& function) { |
| 454 |
return for_each_column(std::make_tuple(field_1, field_2, field_3, field_4), function); |
| 455 |
} |
| 456 |
|
| 457 |
//------------------------------------------------------------------------------------------------------------------------------------------------ |
| 458 |
|
| 459 |
} // namespace field |
| 460 |
} // namespace atlas |