Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add support for MPI Errhandlers in Comm, File, Win.
[simgrid.git] / src / smpi / bindings / smpi_f77.cpp
index 0c25e44..9e96429 100644 (file)
@@ -6,6 +6,7 @@
 #include "private.hpp"
 #include "smpi_comm.hpp"
 #include "smpi_datatype.hpp"
+#include "smpi_errhandler.hpp"
 #include "smpi_op.hpp"
 #include "smpi_request.hpp"
 #include "smpi_win.hpp"
@@ -33,8 +34,8 @@ void smpi_init_fortran_types(){
      MPI_REAL4->add_f();//MPI_REAL4
      MPI_REAL8->add_f();//MPI_REAL8
      MPI_DOUBLE->add_f();//MPI_DOUBLE_PRECISION
-     MPI_C_FLOAT_COMPLEX->add_f();//MPI_COMPLEX
-     MPI_C_DOUBLE_COMPLEX->add_f();//MPI_DOUBLE_COMPLEX
+     MPI_COMPLEX8->add_f();//MPI_COMPLEX
+     MPI_COMPLEX16->add_f();//MPI_DOUBLE_COMPLEX
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
      MPI_2INT->add_f();//MPI_2INTEGER
 #else
@@ -51,6 +52,9 @@ void smpi_init_fortran_types(){
      MPI_AINT->add_f();//MPI_COUNT
      MPI_REAL16->add_f();//MPI_REAL16
      MPI_PACKED->add_f();//MPI_PACKED
+     MPI_COMPLEX8->add_f();//MPI_COMPLEX8
+     MPI_COMPLEX16->add_f();//MPI_COMPLEX16
+     MPI_COMPLEX32->add_f();//MPI_COMPLEX32
 
      MPI_MAX->add_f();
      MPI_MIN->add_f();
@@ -64,6 +68,9 @@ void smpi_init_fortran_types(){
      MPI_BAND->add_f();
      MPI_BOR->add_f();
      MPI_BXOR->add_f();
+
+     MPI_ERRORS_RETURN->add_f();
+     MPI_ERRORS_ARE_FATAL->add_f();
    }
 }
 
@@ -107,6 +114,8 @@ void mpi_initialized_(int* flag, int* ierr){
 }
 
 void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){
+  //fortran does not handle string endings cleanly, so initialize everything before
+  memset(name, 0, MPI_MAX_PROCESSOR_NAME);
   *ierr = MPI_Get_processor_name(name, resultlen);
 }
 
@@ -675,20 +684,32 @@ void mpi_error_class_ (int* errorcode, int* errorclass, int* ierr) {
  *ierr = MPI_Error_class(*errorcode, errorclass);
 }
 
-void mpi_errhandler_create_ (void* function, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_create(reinterpret_cast<MPI_Handler_function*>(function), static_cast<MPI_Errhandler*>(errhandler));
+void mpi_errhandler_create_ (void* function, int* errhandler, int* ierr) {
+ MPI_Errhandler tmp;
+ *ierr = MPI_Errhandler_create( reinterpret_cast<MPI_Handler_function*>(function), &tmp);
+ if(*ierr==MPI_SUCCESS){
+   *errhandler = tmp->c2f();
+ }
 }
 
-void mpi_errhandler_free_ (void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_free(static_cast<MPI_Errhandler*>(errhandler));
+void mpi_errhandler_free_ (int* errhandler, int* ierr) {
+  MPI_Errhandler tmp = simgrid::smpi::Errhandler::f2c(*errhandler);
+  *ierr =  MPI_Errhandler_free(&tmp);
+  if(*ierr == MPI_SUCCESS) {
+    simgrid::smpi::F2C::free_f(*errhandler);
+  }
 }
 
-void mpi_errhandler_get_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_get(simgrid::smpi::Comm::f2c(*comm), static_cast<MPI_Errhandler*>(errhandler));
+void mpi_errhandler_get_ (int* comm, int* errhandler, int* ierr) {
+ MPI_Errhandler tmp;
+ *ierr = MPI_Errhandler_get(simgrid::smpi::Comm::f2c(*comm), &tmp);
+ if(*ierr == MPI_SUCCESS) {
+   *errhandler = tmp->c2f();
+ }
 }
 
-void mpi_errhandler_set_ (int* comm, void* errhandler, int* ierr) {
- *ierr = MPI_Errhandler_set(simgrid::smpi::Comm::f2c(*comm), *static_cast<MPI_Errhandler*>(errhandler));
+void mpi_errhandler_set_ (int* comm, int* errhandler, int* ierr) {
+ *ierr = MPI_Errhandler_set(simgrid::smpi::Comm::f2c(*comm), simgrid::smpi::Errhandler::f2c(*errhandler));
 }
 
 void mpi_cancel_ (int* request, int* ierr) {
@@ -849,19 +870,19 @@ void mpi_status_set_elements_ ( MPI_Status* status, int* datatype, int* count, i
 }
 
 void mpi_publish_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Publish_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
+ *ierr = MPI_Publish_name( service_name, simgrid::smpi::Info::f2c(*info), port_name);
 }
 
 void mpi_unpublish_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Unpublish_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
+ *ierr = MPI_Unpublish_name( service_name, simgrid::smpi::Info::f2c(*info), port_name);
 }
 
 void mpi_lookup_name_ ( char *service_name, int* info, char *port_name, int* ierr){
- *ierr = MPI_Lookup_name( service_name, *reinterpret_cast<MPI_Info*>(info), port_name);
+ *ierr = MPI_Lookup_name( service_name, simgrid::smpi::Info::f2c(*info), port_name);
 }
 
 void mpi_open_port_ ( int* info, char *port_name, int* ierr){
- *ierr = MPI_Open_port( *reinterpret_cast<MPI_Info*>(info),port_name);
+ *ierr = MPI_Open_port( simgrid::smpi::Info::f2c(*info),port_name);
 }
 
 void mpi_close_port_ ( char *port_name, int* ierr){