-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/fortran api redistribution #160
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ab8533f
add Fortran API for redistribution
sbrdar a6a501c
1) add a unit test for Fortran API redistribution; 2) fix compile bug…
sbrdar ad7cd24
default to RedistributeGeneric if nothing is provided in the configur…
sbrdar d25aff8
use static name from a redistribution factory
sbrdar 7704a12
code coverage
sbrdar 94a6364
extend the unit test for Fortran API Redistribution (setup works, exe…
sbrdar 70f5626
protect fortran test with HAVE_FORTRAN
sbrdar 3a52671
tidy up (still runtime error on redistribute%execute)
sbrdar 806b19f
1) fix Fortran API for Redistribution; 2) improve unit test (with Wil…
sbrdar 648fb47
fix C++ unit test
sbrdar ec7ca97
use generic structures in Fortran
sbrdar 390eb0b
use parameter variable for atlas_Grid
sbrdar fb0080b
check also NodeColumns and EdgeColumns for Fortran API Redistribution
sbrdar 536daf2
workaround for intel compiler (tnx Willem)
sbrdar 35e1906
Revert changes in existing C++ classes
wdeconinck adbb751
Fix forward declare
wdeconinck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/atlas/redistribution/detail/RedistributionInterface.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* (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 <cstring> | ||
|
||
#include "RedistributionInterface.h" | ||
|
||
#include "RedistributeGeneric.h" | ||
#include "RedistributionImpl.h" | ||
|
||
#include "atlas/functionspace/FunctionSpace.h" | ||
#include "atlas/redistribution/detail/RedistributionImplFactory.h" | ||
|
||
namespace atlas { | ||
namespace redistribution { | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Fortran interfaces | ||
// ---------------------------------------------------------------------------- | ||
|
||
extern "C" { | ||
|
||
detail::RedistributionImpl* atlas__Redistribution__new__config( | ||
const functionspace::FunctionSpaceImpl* fspace1, const functionspace::FunctionSpaceImpl* fspace2, | ||
const eckit::Configuration* config) { | ||
ATLAS_ASSERT(config != nullptr); | ||
std::string type = detail::RedistributeGeneric::static_type(); | ||
config->get("type", type); | ||
auto redist = redistribution::detail::RedistributionImplFactory::build(type); | ||
FunctionSpace fs1(fspace1); | ||
FunctionSpace fs2(fspace2); | ||
redist->setup(fs1, fs2); | ||
return redist; | ||
} | ||
|
||
void atlas__Redistribution__execute( | ||
const detail::RedistributionImpl* This, const field::FieldImpl* field_1, field::FieldImpl* field_2) { | ||
Field f1(field_1); | ||
Field f2(field_2); | ||
This->execute(f1, f2); | ||
} | ||
|
||
const functionspace::FunctionSpaceImpl* atlas__Redistribution__source( | ||
const detail::RedistributionImpl* This) { | ||
return This->source().get(); | ||
} | ||
|
||
const functionspace::FunctionSpaceImpl* atlas__Redistribution__target( | ||
const detail::RedistributionImpl* This) { | ||
return This->target().get(); | ||
} | ||
|
||
} | ||
|
||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
} // namespace redistribution | ||
} // namespace atlas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* (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 | ||
|
||
namespace eckit { | ||
class Configuration; | ||
} | ||
|
||
namespace atlas { | ||
namespace functionspace { | ||
class FunctionSpaceImpl; | ||
} | ||
namespace field { | ||
class FieldImpl; | ||
} | ||
} // namespace atlas | ||
|
||
namespace atlas { | ||
namespace redistribution { | ||
namespace detail { | ||
class RedistributionImpl; | ||
|
||
// ------------------------------------------------------------------- | ||
// C wrapper interfaces to C++ routines | ||
extern "C" { | ||
|
||
RedistributionImpl* atlas__Redistribution__new__config( | ||
const functionspace::FunctionSpaceImpl* fspace1, const functionspace::FunctionSpaceImpl* fspace2, | ||
const eckit::Configuration* config); | ||
|
||
void atlas__Redistribution__execute( | ||
const RedistributionImpl* This, const field::FieldImpl* field_1, field::FieldImpl* field_2); | ||
|
||
const functionspace::FunctionSpaceImpl* atlas__Redistribution__source( | ||
const RedistributionImpl* This); | ||
|
||
const functionspace::FunctionSpaceImpl* atlas__Redistribution__target( | ||
const RedistributionImpl* This); | ||
|
||
} | ||
|
||
|
||
} // namespace detail | ||
} // namespace redistribution | ||
} // namespace atlas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
src/atlas_f/redistribution/atlas_Redistribution_module.F90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
! (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_config_module, only : atlas_Config | ||
use atlas_functionspace_module, only : atlas_FunctionSpace | ||
use fckit_owned_object_module, only: fckit_owned_object | ||
|
||
implicit none | ||
|
||
public :: atlas_Redistribution | ||
|
||
private | ||
|
||
!------------------------------------------------------------------------------ | ||
TYPE, extends(fckit_owned_object) :: atlas_Redistribution | ||
|
||
! Purpose : | ||
! ------- | ||
! *atlas_Redistribution* : Object passed from atlas to inspect redistribution | ||
|
||
! Methods : | ||
! ------- | ||
|
||
! Author : | ||
! ------ | ||
! October-2023 Slavko Brdar *ECMWF* | ||
! August-2015 Willem Deconinck *ECMWF* | ||
|
||
!------------------------------------------------------------------------------ | ||
contains | ||
|
||
procedure, public :: execute => atlas_Redistribution__execute | ||
procedure, public :: source => atlas_Redistribution__source | ||
procedure, public :: target => atlas_Redistribution__target | ||
|
||
#if FCKIT_FINAL_NOT_INHERITING | ||
final :: atlas_Redistribution__final_auto | ||
#endif | ||
END TYPE atlas_Redistribution | ||
|
||
!------------------------------------------------------------------------------ | ||
|
||
interface atlas_Redistribution | ||
module procedure ctor_cptr | ||
module procedure ctor_create | ||
end interface | ||
|
||
private :: c_ptr | ||
private :: fckit_owned_object | ||
|
||
!======================================================== | ||
contains | ||
!======================================================== | ||
! ----------------------------------------------------------------------------- | ||
! Redistribution routines | ||
|
||
function empty_config() result(config) | ||
type(atlas_Config) :: config | ||
config = atlas_Config() | ||
call config%return() | ||
end function | ||
|
||
function ctor_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 ctor_create(fspace1, fspace2, redist_name) result(this) | ||
use atlas_redistribution_c_binding | ||
class(atlas_FunctionSpace), intent(in) :: fspace1, fspace2 | ||
character(len=*), intent(in), optional :: redist_name | ||
type(atlas_Redistribution) :: this | ||
type(atlas_Config) :: config | ||
config = empty_config() | ||
if (present(redist_name)) call config%set("type", redist_name) | ||
call this%reset_c_ptr( atlas__Redistribution__new__config(fspace1%CPTR_PGIBUG_A, fspace2%CPTR_PGIBUG_A, config%CPTR_PGIBUG_B) ) | ||
call config%final() | ||
call this%return() | ||
end function | ||
|
||
subroutine atlas_Redistribution__execute(this, field_1, field_2) | ||
use atlas_redistribution_c_binding | ||
use atlas_Field_module | ||
class(atlas_Redistribution), intent(in) :: this | ||
class(atlas_Field), intent(in) :: field_1 | ||
class(atlas_Field), intent(inout) :: field_2 | ||
call atlas__Redistribution__execute(this%CPTR_PGIBUG_A, field_1%CPTR_PGIBUG_A, field_2%CPTR_PGIBUG_A) | ||
end subroutine | ||
|
||
function atlas_Redistribution__source(this) result(fspace) | ||
use atlas_redistribution_c_binding | ||
class(atlas_Redistribution), intent(in) :: this | ||
type(atlas_FunctionSpace) :: fspace | ||
call fspace%reset_c_ptr(atlas__Redistribution__source(this%CPTR_PGIBUG_A)) | ||
call fspace%return() | ||
end function | ||
|
||
function atlas_Redistribution__target(this) result(fspace) | ||
use atlas_redistribution_c_binding | ||
class(atlas_Redistribution), intent(in) :: this | ||
type(atlas_FunctionSpace) :: fspace | ||
call fspace%reset_c_ptr(atlas__Redistribution__target(this%CPTR_PGIBUG_A)) | ||
call fspace%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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
add_fctest
command needs to be guarded by