// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #define DEBUG_REPART #include #include #include #include #include #include #include #include #include class MPIError { public: /** @brief Constructor. */ MPIError(std::string s, int e) : errorstring(s), errorcode(e){} /** @brief The error string. */ std::string errorstring; /** @brief The mpi error code. */ int errorcode; }; void MPI_err_handler(MPI_Comm *, int *err_code, ...){ char *err_string=new char[MPI_MAX_ERROR_STRING]; int err_length; MPI_Error_string(*err_code, err_string, &err_length); std::string s(err_string, err_length); std::cerr << "An MPI Error occurred:"< int testRepart(int N, int coarsenTarget) { std::cout<<"==================================================="<communicator().size()>0) printGlobalSparseMatrix(newMat, *coarseComm, std::cout); comm.communicator().barrier(); // Check for symmetry int ret=0; typedef typename BCRSMat::ConstRowIterator RIter; for(RIter row=newMat.begin(), rend=newMat.end(); row != rend; ++row) { typedef typename BCRSMat::ConstColIterator CIter; for(CIter col=row->begin(), cend=row->end(); col!=cend; ++col) { if(col.index()<=row.index()) try{ newMat[col.index()][row.index()]; }catch(const Dune::ISTLError&) { std::cerr<communicator().rank()<<": entry (" <communicator().rank()==0) //Dune::printmatrix(std::cout, newMat, "redist", "row"); return ret; } int main(int argc, char** argv) { MPI_Init(&argc, &argv); MPI_Errhandler handler; MPI_Comm_create_errhandler(MPI_err_handler, &handler); MPI_Comm_set_errhandler(MPI_COMM_WORLD, handler); int procs; MPI_Comm_size(MPI_COMM_WORLD, &procs); int N=4*procs; int coarsenTarget=1; if(argc>1) N = atoi(argv[1]); if(argc>2) coarsenTarget = atoi(argv[2]); if(N>(N,coarsenTarget); testRepart>(N/2,coarsenTarget); testRepart(N,coarsenTarget); MPI_Finalize(); }