root/ompi/mpi/fortran/mpif-h/type_get_contents_f.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ompi_type_get_contents_f

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2011-2012 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2015      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 
  22 #include "ompi_config.h"
  23 
  24 #include "ompi/mpi/fortran/mpif-h/bindings.h"
  25 #include "ompi/errhandler/errhandler.h"
  26 #include "ompi/communicator/communicator.h"
  27 
  28 #if OMPI_BUILD_MPI_PROFILING
  29 #if OPAL_HAVE_WEAK_SYMBOLS
  30 #pragma weak PMPI_TYPE_GET_CONTENTS = ompi_type_get_contents_f
  31 #pragma weak pmpi_type_get_contents = ompi_type_get_contents_f
  32 #pragma weak pmpi_type_get_contents_ = ompi_type_get_contents_f
  33 #pragma weak pmpi_type_get_contents__ = ompi_type_get_contents_f
  34 
  35 #pragma weak PMPI_Type_get_contents_f = ompi_type_get_contents_f
  36 #pragma weak PMPI_Type_get_contents_f08 = ompi_type_get_contents_f
  37 #else
  38 OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_GET_CONTENTS,
  39                            pmpi_type_get_contents,
  40                            pmpi_type_get_contents_,
  41                            pmpi_type_get_contents__,
  42                            pompi_type_get_contents_f,
  43                            (MPI_Fint *mtype, MPI_Fint *max_integers, MPI_Fint *max_addresses, MPI_Fint *max_datatypes, MPI_Fint *array_of_integers, MPI_Aint *array_of_addresses, MPI_Fint *array_of_datatypes, MPI_Fint *ierr),
  44                            (mtype, max_integers, max_addresses, max_datatypes, array_of_integers, array_of_addresses, array_of_datatypes, ierr) )
  45 #endif
  46 #endif
  47 
  48 #if OPAL_HAVE_WEAK_SYMBOLS
  49 #pragma weak MPI_TYPE_GET_CONTENTS = ompi_type_get_contents_f
  50 #pragma weak mpi_type_get_contents = ompi_type_get_contents_f
  51 #pragma weak mpi_type_get_contents_ = ompi_type_get_contents_f
  52 #pragma weak mpi_type_get_contents__ = ompi_type_get_contents_f
  53 
  54 #pragma weak MPI_Type_get_contents_f = ompi_type_get_contents_f
  55 #pragma weak MPI_Type_get_contents_f08 = ompi_type_get_contents_f
  56 #else
  57 #if ! OMPI_BUILD_MPI_PROFILING
  58 OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_GET_CONTENTS,
  59                            mpi_type_get_contents,
  60                            mpi_type_get_contents_,
  61                            mpi_type_get_contents__,
  62                            ompi_type_get_contents_f,
  63                            (MPI_Fint *mtype, MPI_Fint *max_integers, MPI_Fint *max_addresses, MPI_Fint *max_datatypes, MPI_Fint *array_of_integers, MPI_Aint *array_of_addresses, MPI_Fint *array_of_datatypes, MPI_Fint *ierr),
  64                            (mtype, max_integers, max_addresses, max_datatypes, array_of_integers, array_of_addresses, array_of_datatypes, ierr) )
  65 #else
  66 #define ompi_type_get_contents_f pompi_type_get_contents_f
  67 #endif
  68 #endif
  69 
  70 
  71 static const char FUNC_NAME[] = "MPI_TYPE_GET_CONTENTS";
  72 
  73 
  74 void ompi_type_get_contents_f(MPI_Fint *mtype, MPI_Fint *max_integers,
  75                              MPI_Fint *max_addresses, MPI_Fint *max_datatypes,
  76                              MPI_Fint *array_of_integers,
  77                              MPI_Aint *array_of_addresses,
  78                              MPI_Fint *array_of_datatypes, MPI_Fint *ierr)
  79 {
  80     MPI_Aint *c_address_array = NULL;
  81     MPI_Datatype *c_datatype_array = NULL;
  82     MPI_Datatype c_mtype = PMPI_Type_f2c(*mtype);
  83     int i, c_ierr;
  84     OMPI_ARRAY_NAME_DECL(array_of_integers);
  85 
  86     if (*max_datatypes) {
  87         c_datatype_array = (MPI_Datatype *) malloc(*max_datatypes * sizeof(MPI_Datatype));
  88         if (NULL == c_datatype_array) {
  89             c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
  90                                             FUNC_NAME);
  91             if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
  92             return;
  93         }
  94     }
  95 
  96     if (*max_addresses) {
  97         c_address_array = (MPI_Aint *) malloc(*max_addresses * sizeof(MPI_Aint));
  98         if (NULL == c_address_array) {
  99             if (NULL != c_datatype_array) {
 100               free(c_datatype_array);
 101             }
 102 
 103             c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
 104                                             FUNC_NAME);
 105             if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 106             return;
 107         }
 108     }
 109 
 110     OMPI_ARRAY_FINT_2_INT(array_of_integers, *max_integers);
 111 
 112     c_ierr = PMPI_Type_get_contents(c_mtype,
 113                                    OMPI_FINT_2_INT(*max_integers),
 114                                    OMPI_FINT_2_INT(*max_addresses),
 115                                    OMPI_FINT_2_INT(*max_datatypes),
 116                                    OMPI_ARRAY_NAME_CONVERT(array_of_integers),
 117                                    c_address_array, c_datatype_array);
 118     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 119 
 120     if (MPI_SUCCESS == c_ierr) {
 121         for (i = 0; i < *max_addresses; i++) {
 122             array_of_addresses[i] = c_address_array[i];
 123         }
 124         for (i = 0; i < *max_datatypes; i++) {
 125           array_of_datatypes[i] = PMPI_Type_c2f(c_datatype_array[i]);
 126         }
 127     }
 128     free(c_address_array);
 129     free(c_datatype_array);
 130     OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_integers);
 131 }

/* [<][>][^][v][top][bottom][index][help] */