From 9ba6f099811eda66f36a675266049739d8b9ab5b Mon Sep 17 00:00:00 2001 From: Willem Deconinck Date: Mon, 31 Jul 2023 15:48:42 +0200 Subject: [PATCH] Remove functionspace::Spectral via Trans initialisation (fixes #153) --- src/atlas/functionspace/Spectral.cc | 3 -- src/atlas/functionspace/Spectral.h | 1 - .../functionspace/detail/SpectralInterface.cc | 7 ----- .../functionspace/detail/SpectralInterface.h | 2 -- src/atlas/trans/ifs/TransIFS.cc | 2 +- .../atlas_functionspace_Spectral_module.F90 | 29 ------------------- .../benchmark_ifs_setup/CMakeLists.txt | 1 + src/tests/trans/fctest_trans.F90 | 10 +++---- .../trans/fctest_trans_invtrans_grad.F90 | 2 +- src/tests/trans/test_trans.cc | 2 +- 10 files changed, 8 insertions(+), 51 deletions(-) diff --git a/src/atlas/functionspace/Spectral.cc b/src/atlas/functionspace/Spectral.cc index e737aba9e..223410346 100644 --- a/src/atlas/functionspace/Spectral.cc +++ b/src/atlas/functionspace/Spectral.cc @@ -439,9 +439,6 @@ Spectral::Spectral(const int truncation, const eckit::Configuration& config): FunctionSpace(new detail::Spectral(truncation, config)), functionspace_(dynamic_cast(get())) {} -Spectral::Spectral(const trans::Trans& trans, const eckit::Configuration& config): - FunctionSpace(new detail::Spectral(trans, config)), functionspace_(dynamic_cast(get())) {} - idx_t Spectral::nb_spectral_coefficients() const { return functionspace_->nb_spectral_coefficients(); } diff --git a/src/atlas/functionspace/Spectral.h b/src/atlas/functionspace/Spectral.h index 68c5ff966..dbb32b0fd 100644 --- a/src/atlas/functionspace/Spectral.h +++ b/src/atlas/functionspace/Spectral.h @@ -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_; } diff --git a/src/atlas/functionspace/detail/SpectralInterface.cc b/src/atlas/functionspace/detail/SpectralInterface.cc index 85cf6811a..5d694b65d 100644 --- a/src/atlas/functionspace/detail/SpectralInterface.cc +++ b/src/atlas/functionspace/detail/SpectralInterface.cc @@ -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; diff --git a/src/atlas/functionspace/detail/SpectralInterface.h b/src/atlas/functionspace/detail/SpectralInterface.h index ab8f40f70..392fe6404 100644 --- a/src/atlas/functionspace/detail/SpectralInterface.h +++ b/src/atlas/functionspace/detail/SpectralInterface.h @@ -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, diff --git a/src/atlas/trans/ifs/TransIFS.cc b/src/atlas/trans/ifs/TransIFS.cc index 1e4076da1..0ee7f999b 100644 --- a/src/atlas/trans/ifs/TransIFS.cc +++ b/src/atlas/trans/ifs/TransIFS.cc @@ -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_; } diff --git a/src/atlas_f/functionspace/atlas_functionspace_Spectral_module.F90 b/src/atlas_f/functionspace/atlas_functionspace_Spectral_module.F90 index ab8492ddf..8b2b1b92e 100644 --- a/src/atlas_f/functionspace/atlas_functionspace_Spectral_module.F90 +++ b/src/atlas_f/functionspace/atlas_functionspace_Spectral_module.F90 @@ -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 @@ -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 @@ -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 !------------------------------------------------------------------------------ @@ -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 diff --git a/src/sandbox/benchmark_ifs_setup/CMakeLists.txt b/src/sandbox/benchmark_ifs_setup/CMakeLists.txt index aa3950e61..28658ad29 100644 --- a/src/sandbox/benchmark_ifs_setup/CMakeLists.txt +++ b/src/sandbox/benchmark_ifs_setup/CMakeLists.txt @@ -11,5 +11,6 @@ ecbuild_add_executable( SOURCES atlas-benchmark-ifs-setup.cc LIBS atlas # NOINSTALL + CONDITION atlas_HAVE_ATLAS_NUMERICS ) diff --git a/src/tests/trans/fctest_trans.F90 b/src/tests/trans/fctest_trans.F90 index 739acf409..413e7e839 100644 --- a/src/tests/trans/fctest_trans.F90 +++ b/src/tests/trans/fctest_trans.F90 @@ -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) @@ -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) ) @@ -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)) @@ -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") @@ -488,7 +487,6 @@ function sp_value(m,n,complex_component) endif endif end function - END_TEST diff --git a/src/tests/trans/fctest_trans_invtrans_grad.F90 b/src/tests/trans/fctest_trans_invtrans_grad.F90 index 5c99a2080..8c9b62219 100644 --- a/src/tests/trans/fctest_trans_invtrans_grad.F90 +++ b/src/tests/trans/fctest_trans_invtrans_grad.F90 @@ -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) diff --git a/src/tests/trans/test_trans.cc b/src/tests/trans/test_trans.cc index 2ae749319..30b4fb2bb 100644 --- a/src/tests/trans/test_trans.cc +++ b/src/tests/trans/test_trans.cc @@ -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(option::name("spf") | option::global());