From 62b054ec78f65a375b453084be9db38ab42f8356 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Wed, 20 Mar 2024 11:55:05 -0400 Subject: [PATCH] Fix comment and add a test --- include/deal.II/base/init_finalize.h | 4 +- tests/base/init_finalize.cc | 47 +++++++++++++++++++ ...nalize.wit_mpi=true.with_p4est=true.output | 2 + 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/base/init_finalize.cc create mode 100644 tests/base/init_finalize.wit_mpi=true.with_p4est=true.output diff --git a/include/deal.II/base/init_finalize.h b/include/deal.II/base/init_finalize.h index 57045746dd..85d3b8dcf2 100644 --- a/include/deal.II/base/init_finalize.h +++ b/include/deal.II/base/init_finalize.h @@ -79,8 +79,8 @@ operator|(const InitializeLibrary f1, const InitializeLibrary f2) /** - * Global operator which sets the bits from the second argument also in the - * first one. + * Global operator which returns an object in which all bits are set that are + * set both in the first and second argument. */ inline InitializeLibrary operator&(const InitializeLibrary f1, const InitializeLibrary f2) diff --git a/tests/base/init_finalize.cc b/tests/base/init_finalize.cc new file mode 100644 index 0000000000..0b87253a43 --- /dev/null +++ b/tests/base/init_finalize.cc @@ -0,0 +1,47 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2024 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +// Check that InitFinalize can initialize/finalize only the selected library + +#include + +#include +#include + +#include "../tests.h" + +int +main(int argc, char *argv[]) +{ + MPI_Init(&argc, &argv); + Kokkos::initialize(argc, argv); + mpi_initlog(); + { + // Only initialize P4EST. If it tries to initialize MPI or Kokkos, we will + // get an error. + InitFinalize init_finalize(argc, argv, InitializeLibrary::P4EST); + // p4est_is_initialized was introduced in version 2.8. Instead we create the + // connectivity. If P4EST was not initialized the code below will crash. + auto *conn = p4est_connectivity_new_unitsquare(); + p4est_connectivity_destroy(conn); + } + deallog << "OK" << std::endl; + + Kokkos::finalize(); + + MPI_Finalize(); + + return 0; +} diff --git a/tests/base/init_finalize.wit_mpi=true.with_p4est=true.output b/tests/base/init_finalize.wit_mpi=true.with_p4est=true.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/base/init_finalize.wit_mpi=true.with_p4est=true.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5