diff --git a/src/atlas/CMakeLists.txt b/src/atlas/CMakeLists.txt index 2b92a933b..1f0f1ee25 100644 --- a/src/atlas/CMakeLists.txt +++ b/src/atlas/CMakeLists.txt @@ -691,6 +691,8 @@ linalg/dense/MatrixMultiply_EckitLinalg.cc list (APPEND atlas_redistribution_srcs redistribution/Redistribution.h redistribution/Redistribution.cc +redistribution/detail/RedistributionInterface.h +redistribution/detail/RedistributionInterface.cc redistribution/detail/RedistributionImpl.h redistribution/detail/RedistributionImpl.cc redistribution/detail/RedistributionImplFactory.h diff --git a/src/atlas/redistribution/detail/RedistributionInterface.cc b/src/atlas/redistribution/detail/RedistributionInterface.cc new file mode 100644 index 000000000..cc0e0d2c4 --- /dev/null +++ b/src/atlas/redistribution/detail/RedistributionInterface.cc @@ -0,0 +1,35 @@ +/* + * (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 "RedistributionInterface.h" + +//#include "atlas/functionspace/FunctionSpace.h" +#include "atlas/functionspace/detail/FunctionSpaceImpl.h" + +namespace atlas { + +// ---------------------------------------------------------------------------- +// Fortran interfaces +// ---------------------------------------------------------------------------- + +extern "C" { + +const Redistribution* atlas__Redistribution__new( + const functionspace::FunctionSpaceImpl* fspace1, const functionspace::FunctionSpaceImpl* fspace2) { + return new Redistribution(fspace1, fspace2); +} +} + + +// ---------------------------------------------------------------------------- + +} // namespace atlas diff --git a/src/atlas/redistribution/detail/RedistributionInterface.h b/src/atlas/redistribution/detail/RedistributionInterface.h new file mode 100644 index 000000000..0518d4273 --- /dev/null +++ b/src/atlas/redistribution/detail/RedistributionInterface.h @@ -0,0 +1,61 @@ +/* + * (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. + */ +#pragma once + +//#include "atlas/functionspace/detail/FunctionSpaceImpl.h" +#include "atlas/redistribution/Redistribution.h" + +namespace atlas { +namespace functionspace{ +class FunctionSpaceImpl; +} +namespace field { +class FieldSetImpl; +} +namespace grid { +class DistributionImpl; +} +} // namespace atlas + +namespace atlas { +namespace grid { +namespace detail { +namespace grid { +class Grid; +} // namespace grid +} // namespace detail +} // namespace grid +using GridImpl = grid::detail::grid::Grid; +} // namespace atlas + +namespace atlas { +namespace grid { +namespace detail { +namespace partitioner { +class Partitioner; +} // namespace partitioner +} // namespace detail +} // namespace grid +using PartitionerImpl = grid::detail::partitioner::Partitioner; +} // namespace atlas + + +namespace atlas { + +// ------------------------------------------------------------------- +// C wrapper interfaces to C++ routines +extern "C" { + +const Redistribution* atlas__Redistribution__new( + const functionspace::FunctionSpaceImpl* fspace1, const functionspace::FunctionSpaceImpl* fspace2); + +} + +} // namespace atlas diff --git a/src/atlas_f/CMakeLists.txt b/src/atlas_f/CMakeLists.txt index f01da0392..3a0130115 100644 --- a/src/atlas_f/CMakeLists.txt +++ b/src/atlas_f/CMakeLists.txt @@ -127,6 +127,9 @@ generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/functionspace/EdgeColumns.h generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/functionspace/detail/PointCloudInterface.h MODULE atlas_functionspace_PointCloud_c_binding OUTPUT functionspace_PointCloud_c_binding.f90) +generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/redistribution/detail/RedistributionInterface.h + MODULE atlas_redistribution_c_binding + OUTPUT redistribution_c_binding.f90) if( atlas_HAVE_ATLAS_NUMERICS ) generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/numerics/Nabla.h) @@ -233,6 +236,7 @@ ecbuild_add_library( TARGET atlas_f parallel/atlas_Checksum_module.fypp parallel/atlas_HaloExchange_module.fypp projection/atlas_Projection_module.F90 + redistribution/atlas_Redistribution_module.F90 internals/atlas_read_file.h internals/atlas_read_file.cc internals/Library.h diff --git a/src/atlas_f/redistribution/atlas_Redistribution_module.F90 b/src/atlas_f/redistribution/atlas_Redistribution_module.F90 new file mode 100644 index 000000000..08005e659 --- /dev/null +++ b/src/atlas_f/redistribution/atlas_Redistribution_module.F90 @@ -0,0 +1,98 @@ +! (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 "atlas/atlas_f.h" + +module atlas_Redistribution_module + +use, intrinsic :: iso_c_binding, only : c_ptr +use atlas_functionspace_module, only : atlas_FunctionSpace +use fckit_owned_object_module, only: fckit_owned_object + +implicit none + +public :: atlas_Redistribution + +private + +!----------------------------- +! atlas_Redistribution ! +!----------------------------- + + +!------------------------------------------------------------------------------ +TYPE, extends(fckit_owned_object) :: atlas_Redistribution + +! Purpose : +! ------- +! *Redistribution* : Object passed from atlas to inspect redistribution + +! Methods : +! ------- + +! Author : +! ------ + +!------------------------------------------------------------------------------ +contains + +#if FCKIT_FINAL_NOT_INHERITING + final :: atlas_Redistribution__final_auto +#endif +END TYPE atlas_Redistribution + +!------------------------------------------------------------------------------ + +interface atlas_Redistribution + module procedure atlas_Redistribution__cptr + module procedure atlas_Redistribution__ctor +end interface + +private :: c_ptr +private :: fckit_owned_object + +!======================================================== +contains +!======================================================== +! ----------------------------------------------------------------------------- +! Redistribution routines + +function atlas_Redistribution__cptr( cptr ) result(this) + use atlas_redistribution_c_binding + type(atlas_Redistribution) :: this + type(c_ptr), intent(in) :: cptr + call this%reset_c_ptr( cptr ) + call this%return() +end function + +function atlas_Redistribution__ctor( fspace1, fspace2 ) result(this) + use atlas_redistribution_c_binding + type(atlas_FunctionSpace), intent(in) :: fspace1, fspace2 + type(atlas_Redistribution) :: this + call this%reset_c_ptr( atlas__Redistribution__new(fspace1%CPTR_PGIBUG_A, fspace2%CPTR_PGIBUG_A) ) + call this%return() +end function + +! ---------------------------------------------------------------------------------------- + +#if FCKIT_FINAL_NOT_INHERITING +ATLAS_FINAL subroutine atlas_Redistribution__final_auto(this) + type(atlas_Redistribution), intent(inout) :: this +#if FCKIT_FINAL_DEBUGGING + write(0,*) "atlas_Redistribution__final_auto" +#endif +#if FCKIT_FINAL_NOT_PROPAGATING + call this%final() +#endif + FCKIT_SUPPRESS_UNUSED( this ) +end subroutine +#endif + +! ---------------------------------------------------------------------------------------- + +end module atlas_Redistribution_module