Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / mpi / smpi_errhandler.cpp
1 /* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "smpi_errhandler.hpp"
7 #include "private.hpp"
8
9 #include <cstdio>
10
11 simgrid::smpi::Errhandler smpi_MPI_ERRORS_RETURN;
12 simgrid::smpi::Errhandler smpi_MPI_ERRORS_ARE_FATAL;
13
14 namespace simgrid{
15 namespace smpi{
16
17 MPI_Errhandler Errhandler::f2c(int id) {
18   if (F2C::lookup() != nullptr && id >= 0) {
19     return static_cast<MPI_Errhandler>(F2C::lookup()->at(id));
20   } else {
21     return MPI_ERRHANDLER_NULL;
22   }
23 }
24
25 void Errhandler::call(MPI_Comm comm, int errorcode) const
26 {
27   comm_func_(&comm, &errorcode);
28 }
29
30 void Errhandler::call(MPI_Win win, int errorcode) const
31 {
32   win_func_(&win, &errorcode);
33 }
34
35 void Errhandler::call(MPI_File file, int errorcode) const
36 {
37   file_func_(&file, &errorcode);
38 }
39
40 void Errhandler::ref()
41 {
42   refcount_++;
43 }
44
45 void Errhandler::unref(Errhandler* errhandler){
46   if(errhandler == MPI_ERRORS_ARE_FATAL || errhandler == MPI_ERRORS_RETURN)
47     return;
48   errhandler->refcount_--;
49   if(errhandler->refcount_==0){
50     F2C::free_f(errhandler->f2c_id());
51     delete errhandler;
52   }
53 }
54
55 }
56
57 }