Skip to content

Commit

Permalink
Remove functionspace::Spectral via Trans initialisation (fixes #153)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdeconinck committed Jul 31, 2023
1 parent 0bae8c3 commit 9ba6f09
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 51 deletions.
3 changes: 0 additions & 3 deletions src/atlas/functionspace/Spectral.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,6 @@ Spectral::Spectral(const int truncation, const eckit::Configuration& config):
FunctionSpace(new detail::Spectral(truncation, config)),
functionspace_(dynamic_cast<const detail::Spectral*>(get())) {}

Spectral::Spectral(const trans::Trans& trans, const eckit::Configuration& config):
FunctionSpace(new detail::Spectral(trans, config)), functionspace_(dynamic_cast<const detail::Spectral*>(get())) {}

idx_t Spectral::nb_spectral_coefficients() const {
return functionspace_->nb_spectral_coefficients();
}
Expand Down
1 change: 0 additions & 1 deletion src/atlas/functionspace/Spectral.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class Spectral : public FunctionSpace {
Spectral(const FunctionSpace&);
Spectral(const eckit::Configuration&);
Spectral(const int truncation, const eckit::Configuration& = util::NoConfig());
Spectral(const trans::Trans&, const eckit::Configuration& = util::NoConfig());

operator bool() const { return valid(); }
bool valid() const { return functionspace_; }
Expand Down
7 changes: 0 additions & 7 deletions src/atlas/functionspace/detail/SpectralInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ const detail::Spectral* atlas__SpectralFunctionSpace__new__config(const eckit::C
return new detail::Spectral(*config);
}

const detail::Spectral* atlas__SpectralFunctionSpace__new__trans(trans::TransImpl* trans,
const eckit::Configuration* config) {
ATLAS_ASSERT(trans != nullptr);
ATLAS_ASSERT(config != nullptr);
return new detail::Spectral(trans::Trans(trans), *config);
}

void atlas__SpectralFunctionSpace__delete(detail::Spectral* This) {
ATLAS_ASSERT(This != nullptr);
delete This;
Expand Down
2 changes: 0 additions & 2 deletions src/atlas/functionspace/detail/SpectralInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ namespace functionspace {

extern "C" {
const detail::Spectral* atlas__SpectralFunctionSpace__new__config(const eckit::Configuration* config);
const detail::Spectral* atlas__SpectralFunctionSpace__new__trans(trans::TransImpl* trans,
const eckit::Configuration* config);
void atlas__SpectralFunctionSpace__delete(detail::Spectral* This);
field::FieldImpl* atlas__fs__Spectral__create_field(const detail::Spectral* This, const eckit::Configuration* options);
void atlas__SpectralFunctionSpace__gather(const detail::Spectral* This, const field::FieldImpl* local,
Expand Down
2 changes: 1 addition & 1 deletion src/atlas/trans/ifs/TransIFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ size_t TransIFS::nb_spectral_coefficients_global() const {

const functionspace::Spectral& TransIFS::spectral() const {
if (not spectral_) {
spectral_ = functionspace::Spectral(Trans(this));
spectral_ = functionspace::Spectral( truncation() );
}
return spectral_;
}
Expand Down
29 changes: 0 additions & 29 deletions src/atlas_f/functionspace/atlas_functionspace_Spectral_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ module atlas_functionspace_Spectral_module
use atlas_functionspace_module, only : atlas_FunctionSpace
use atlas_Field_module, only: atlas_Field
use atlas_FieldSet_module, only: atlas_FieldSet
#if ATLAS_HAVE_TRANS
use atlas_Trans_module, only: atlas_Trans
#endif
use atlas_Config_module, only: atlas_Config

implicit none
Expand All @@ -28,9 +25,6 @@ module atlas_functionspace_Spectral_module
private :: atlas_Field
private :: atlas_FieldSet
private :: atlas_Config
#if ATLAS_HAVE_TRANS
private :: atlas_Trans
#endif

public :: atlas_functionspace_Spectral

Expand Down Expand Up @@ -84,9 +78,6 @@ module atlas_functionspace_Spectral_module
interface atlas_functionspace_Spectral
module procedure atlas_functionspace_Spectral__cptr
module procedure atlas_functionspace_Spectral__config
#if ATLAS_HAVE_TRANS
module procedure atlas_functionspace_Spectral__trans
#endif
end interface

!------------------------------------------------------------------------------
Expand Down Expand Up @@ -120,26 +111,6 @@ function atlas_functionspace_Spectral__config(truncation,levels) result(this)
call this%return()
end function

#if ATLAS_HAVE_TRANS
function atlas_functionspace_Spectral__trans(trans,levels) result(this)
use atlas_functionspace_spectral_c_binding
type(atlas_functionspace_Spectral) :: this
type(atlas_Trans), intent(in) :: trans
integer(c_int), intent(in), optional :: levels

type(atlas_Config) :: options
options = atlas_Config()

if( present(levels) ) call options%set("levels",levels)

call this%reset_c_ptr( atlas__SpectralFunctionSpace__new__trans(trans%CPTR_PGIBUG_A, &
options%CPTR_PGIBUG_B ) )
call options%final()

call this%return()
end function
#endif

subroutine gather_field(this,local,global)
use atlas_functionspace_spectral_c_binding
class(atlas_functionspace_Spectral), intent(in) :: this
Expand Down
1 change: 1 addition & 0 deletions src/sandbox/benchmark_ifs_setup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ ecbuild_add_executable(
SOURCES atlas-benchmark-ifs-setup.cc
LIBS atlas
# NOINSTALL
CONDITION atlas_HAVE_ATLAS_NUMERICS
)

10 changes: 4 additions & 6 deletions src/tests/trans/fctest_trans.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ end module fctest_atlas_trans_fixture
FCTEST_CHECK( .not. trans%is_null() )
FCTEST_CHECK_EQUAL( trans%truncation(), truncation )

trans_spectral = trans%spectral()
FCTEST_CHECK_EQUAL( trans_spectral%nb_spectral_coefficients_global(), (truncation+1)*(truncation+2) )
spectral_fs = trans%spectral()
FCTEST_CHECK_EQUAL( spectral_fs%nb_spectral_coefficients_global(), (truncation+1)*(truncation+2) )

nodes = mesh%nodes()
nodes_fs = atlas_functionspace_NodeColumns(mesh,0)
Expand All @@ -123,7 +123,6 @@ end module fctest_atlas_trans_fixture
scalarfield2 = nodes_fs%create_field(name="scalar2",kind=atlas_real(c_double))
write(msg,*) "nodes_fs%owners()",nodes_fs%owners(); call fckit_log%info(msg)

spectral_fs = atlas_functionspace_Spectral(trans)
write(msg,*) "spectral_fs%owners()",spectral_fs%owners(); call fckit_log%info(msg)

FCTEST_CHECK_EQUAL( spectral_fs%nb_spectral_coefficients_global(), (truncation+1)*(truncation+2) )
Expand Down Expand Up @@ -269,7 +268,7 @@ end module fctest_atlas_trans_fixture
scalarfield1 = gridpoints_fs%create_field(name="scalar1",kind=atlas_real(c_double),levels=nlev)
scalarfield2 = gridpoints_fs%create_field(name="scalar2",kind=atlas_real(c_double))

spectral_fs = atlas_functionspace_Spectral(trans)
spectral_fs = atlas_functionspace_Spectral(trans%truncation())
spectralfield1 = spectral_fs%create_field(name="spectral1",kind=atlas_real(c_double),levels=nlev)
spectralfield2 = spectral_fs%create_field(name="spectral2",kind=atlas_real(c_double))

Expand Down Expand Up @@ -352,7 +351,7 @@ end module fctest_atlas_trans_fixture
trans = atlas_Trans(grid,23)
partitioner = atlas_Partitioner("ectrans")
gridpoints = atlas_functionspace_StructuredColumns(grid,partitioner)
spectral = atlas_functionspace_Spectral(trans)
spectral = atlas_functionspace_Spectral(trans%truncation())

gpfields = atlas_FieldSet("gridpoint")
spfields = atlas_FieldSet("spectral")
Expand Down Expand Up @@ -488,7 +487,6 @@ function sp_value(m,n,complex_component)
endif
endif
end function

END_TEST


Expand Down
2 changes: 1 addition & 1 deletion src/tests/trans/fctest_trans_invtrans_grad.F90
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ subroutine rotated_flow_magnitude(fs,field,beta)
trans = atlas_Trans(grid, int(grid%N()-1) )

nodes_fs = atlas_functionspace_NodeColumns(mesh,0)
spectral_fs = atlas_functionspace_Spectral(trans)
spectral_fs = atlas_functionspace_Spectral(trans%truncation())

scalar = nodes_fs%create_field(name="scalar",kind=atlas_real(c_double))
grad = nodes_fs%create_field(name="grad",kind=atlas_real(c_double),variables=2)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/trans/test_trans.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ CASE("test_nomesh") {
Grid g("O48");
trans::Trans trans(g, 47);

functionspace::Spectral spectral(trans);
functionspace::Spectral spectral(trans.truncation());
functionspace::StructuredColumns gridpoints(g, grid::Partitioner("ectrans"));

Field spfg = spectral.createField<double>(option::name("spf") | option::global());
Expand Down

0 comments on commit 9ba6f09

Please sign in to comment.