Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unlike errors on communicators and windows, the default behavior for files is to...
[simgrid.git] / src / smpi / mpi / smpi_errhandler.cpp
1 /* Copyright (c) 2007-2019. 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 mpi_MPI_ERRORS_RETURN;
12 MPI_Errhandler MPI_ERRORS_RETURN=&mpi_MPI_ERRORS_RETURN;
13 simgrid::smpi::Errhandler mpi_MPI_ERRORS_ARE_FATAL;
14 MPI_Errhandler MPI_ERRORS_ARE_FATAL=&mpi_MPI_ERRORS_ARE_FATAL;
15
16 namespace simgrid{
17 namespace smpi{
18
19 MPI_Errhandler Errhandler::f2c(int id) {
20   if(F2C::f2c_lookup() != nullptr && id >= 0) {
21     char key[KEY_SIZE];
22     return static_cast<MPI_Errhandler>(F2C::f2c_lookup()->at(get_key(key, id)));
23   } else {
24     return static_cast<MPI_Errhandler>(MPI_ERRHANDLER_NULL);
25   }
26 }
27
28 void Errhandler::call(MPI_Comm comm, int errorcode){
29   comm_func_(&comm, &errorcode);
30 }
31
32 void Errhandler::call(MPI_Win win, int errorcode){
33   win_func_(&win, &errorcode);
34 }
35
36 void Errhandler::call(MPI_File file, int errorcode){
37   file_func_(&file, &errorcode);
38 }
39
40 void Errhandler::ref()
41 {
42   refcount_++;
43 }
44
45 void Errhandler::unref(Errhandler* errhandler){
46   errhandler->refcount_--;
47   if(errhandler->refcount_==0){
48     delete errhandler;
49   }
50 }
51
52 }
53 }