Skip to content

Commit

Permalink
Add Fortran bindings to gather/scatter fieldsets using a StructuredCo…
Browse files Browse the repository at this point in the history
…lumns object.
  • Loading branch information
pmarguinaud authored and wdeconinck committed May 15, 2020
1 parent 7b2dc80 commit 68a08b5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
24 changes: 22 additions & 2 deletions src/atlas/functionspace/detail/StructuredColumnsInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const detail::StructuredColumns* atlas__functionspace__StructuredColumns__new__g
return new detail::StructuredColumns( Grid( grid ), *vert, grid::Partitioner( partitioner ), *config );
}

void atlas__functionspace__StructuredColumns__gather( const detail::StructuredColumns* This,
void atlas__functionspace__StructuredColumns__gather_field( const detail::StructuredColumns* This,
const field::FieldImpl* local, field::FieldImpl* global ) {
ATLAS_ASSERT( This != nullptr, "Cannot access uninitialised atlas_functionspace_StructuredColumns" );
ATLAS_ASSERT( global != nullptr, "Cannot access uninitialised atlas_Field" );
Expand All @@ -79,7 +79,7 @@ void atlas__functionspace__StructuredColumns__gather( const detail::StructuredCo
This->gather( l, g );
}

void atlas__functionspace__StructuredColumns__scatter( const detail::StructuredColumns* This,
void atlas__functionspace__StructuredColumns__scatter_field( const detail::StructuredColumns* This,
const field::FieldImpl* global, field::FieldImpl* local ) {
ATLAS_ASSERT( This != nullptr, "Cannot access uninitialised atlas_functionspace_StructuredColumns" );
ATLAS_ASSERT( global != nullptr, "Cannot access uninitialised atlas_Field" );
Expand All @@ -89,6 +89,26 @@ void atlas__functionspace__StructuredColumns__scatter( const detail::StructuredC
This->scatter( g, l );
}

void atlas__functionspace__StructuredColumns__gather_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* local, field::FieldSetImpl* global ) {
ATLAS_ASSERT( This != nullptr, "Cannot access uninitialised atlas_functionspace_StructuredColumns" );
ATLAS_ASSERT( global != nullptr, "Cannot access uninitialised atlas_FieldSet" );
ATLAS_ASSERT( local != nullptr, "Cannot access uninitialised atlas_FieldSet" );
const FieldSet l (local);
FieldSet g (global);
This->gather (l, g);
}

void atlas__functionspace__StructuredColumns__scatter_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* global, field::FieldSetImpl* local ) {
ATLAS_ASSERT( This != nullptr, "Cannot access uninitialised atlas_functionspace_StructuredColumns" );
ATLAS_ASSERT( global != nullptr, "Cannot access uninitialised atlas_FieldSet" );
ATLAS_ASSERT( local != nullptr, "Cannot access uninitialised atlas_FieldSet" );
const FieldSet g (global);
FieldSet l (local);
This->scatter (g, l);
}

void atlas__fs__StructuredColumns__checksum_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* fieldset, char*& checksum, idx_t& size,
int& allocated ) {
Expand Down
8 changes: 6 additions & 2 deletions src/atlas/functionspace/detail/StructuredColumnsInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ void atlas__functionspace__StructuredColumns__delete( detail::StructuredColumns*
field::FieldImpl* atlas__fs__StructuredColumns__create_field( const detail::StructuredColumns* This,
const eckit::Configuration* options );

void atlas__functionspace__StructuredColumns__gather( const detail::StructuredColumns* This,
void atlas__functionspace__StructuredColumns__gather_field( const detail::StructuredColumns* This,
const field::FieldImpl* local, field::FieldImpl* global );
void atlas__functionspace__StructuredColumns__scatter( const detail::StructuredColumns* This,
void atlas__functionspace__StructuredColumns__scatter_field( const detail::StructuredColumns* This,
const field::FieldImpl* global, field::FieldImpl* local );
void atlas__functionspace__StructuredColumns__gather_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* local, field::FieldSetImpl* global );
void atlas__functionspace__StructuredColumns__scatter_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* global, field::FieldSetImpl* local );
void atlas__fs__StructuredColumns__checksum_fieldset( const detail::StructuredColumns* This,
const field::FieldSetImpl* fieldset, char*& checksum, idx_t& size,
int& allocated );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ module atlas_functionspace_StructuredColumns_module

procedure, public :: assignment_operator_hook

procedure, public :: gather
procedure, public :: scatter
procedure, private :: gather_fieldset
procedure, private :: gather_field
generic, public :: gather => gather_fieldset, gather_field

procedure, private :: scatter_fieldset
procedure, private :: scatter_field
generic, public :: scatter => scatter_fieldset, scatter_field

procedure, private :: checksum_fieldset
procedure, private :: checksum_field
Expand Down Expand Up @@ -296,20 +301,36 @@ function ctor_grid_part_vertical(grid, partitioner, vertical, halo) result(this)
end function


subroutine gather(this,local,global)
subroutine gather_field(this,local,global)
use atlas_functionspace_StructuredColumns_c_binding
class(atlas_functionspace_StructuredColumns), intent(in) :: this
type(atlas_Field), intent(in) :: local
type(atlas_Field), intent(inout) :: global
call atlas__functionspace__StructuredColumns__gather(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
call atlas__functionspace__StructuredColumns__gather_field(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
end subroutine

subroutine gather_fieldset(this,local,global)
use atlas_functionspace_StructuredColumns_c_binding
class(atlas_functionspace_StructuredColumns), intent(in) :: this
type(atlas_FieldSet), intent(in) :: local
type(atlas_FieldSet), intent(inout) :: global
call atlas__functionspace__StructuredColumns__gather_fieldset(this%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A)
end subroutine

subroutine scatter(this,global,local)
subroutine scatter_field(this,global,local)
use atlas_functionspace_StructuredColumns_c_binding
class(atlas_functionspace_StructuredColumns), intent(in) :: this
type(atlas_Field), intent(in) :: global
type(atlas_Field), intent(inout) :: local
call atlas__functionspace__StructuredColumns__scatter(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
call atlas__functionspace__StructuredColumns__scatter_field(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
end subroutine

subroutine scatter_fieldset(this,global,local)
use atlas_functionspace_StructuredColumns_c_binding
class(atlas_functionspace_StructuredColumns), intent(in) :: this
type(atlas_FieldSet), intent(in) :: global
type(atlas_FieldSet), intent(inout) :: local
call atlas__functionspace__StructuredColumns__scatter_fieldset(this%CPTR_PGIBUG_A,global%CPTR_PGIBUG_A,local%CPTR_PGIBUG_A)
end subroutine

function checksum_fieldset(this,fieldset) result(checksum)
Expand Down

0 comments on commit 68a08b5

Please sign in to comment.