| 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 |
#include <cstring> |
| 12 |
|
| 13 |
#include "RedistributionInterface.h" |
| 14 |
|
| 15 |
#include "RedistributeGeneric.h" |
| 16 |
#include "RedistributionImpl.h" |
| 17 |
|
| 18 |
#include "atlas/functionspace/FunctionSpace.h" |
| 19 |
#include "atlas/redistribution/detail/RedistributionImplFactory.h" |
| 20 |
|
| 21 |
namespace atlas { |
| 22 |
namespace redistribution { |
| 23 |
|
| 24 |
// ---------------------------------------------------------------------------- |
| 25 |
// Fortran interfaces |
| 26 |
// ---------------------------------------------------------------------------- |
| 27 |
|
| 28 |
extern "C" { |
| 29 |
|
| 30 |
detail::RedistributionImpl* atlas__Redistribution__new__config( |
| 31 |
const functionspace::FunctionSpaceImpl* fspace1, const functionspace::FunctionSpaceImpl* fspace2, |
| 32 |
const eckit::Configuration* config) { |
| 33 |
ATLAS_ASSERT(config != nullptr); |
| 34 |
std::string type = detail::RedistributeGeneric::static_type(); |
| 35 |
config->get("type", type); |
| 36 |
auto redist = redistribution::detail::RedistributionImplFactory::build(type); |
| 37 |
FunctionSpace fs1(fspace1); |
| 38 |
FunctionSpace fs2(fspace2); |
| 39 |
redist->setup(fs1, fs2); |
| 40 |
return redist; |
| 41 |
} |
| 42 |
|
| 43 |
void atlas__Redistribution__execute( |
| 44 |
const detail::RedistributionImpl* This, const field::FieldImpl* field_1, field::FieldImpl* field_2) { |
| 45 |
Field f1(field_1); |
| 46 |
Field f2(field_2); |
| 47 |
This->execute(f1, f2); |
| 48 |
} |
| 49 |
|
| 50 |
const functionspace::FunctionSpaceImpl* atlas__Redistribution__source( |
| 51 |
const detail::RedistributionImpl* This) { |
| 52 |
return This->source().get(); |
| 53 |
} |
| 54 |
|
| 55 |
const functionspace::FunctionSpaceImpl* atlas__Redistribution__target( |
| 56 |
const detail::RedistributionImpl* This) { |
| 57 |
return This->target().get(); |
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
// ---------------------------------------------------------------------------- |
| 64 |
|
| 65 |
} // namespace redistribution |
| 66 |
} // namespace atlas |