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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_type_hindexed_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_HINDEXED = ompi_type_hindexed_f
  31 #pragma weak pmpi_type_hindexed = ompi_type_hindexed_f
  32 #pragma weak pmpi_type_hindexed_ = ompi_type_hindexed_f
  33 #pragma weak pmpi_type_hindexed__ = ompi_type_hindexed_f
  34 
  35 #pragma weak PMPI_Type_hindexed_f = ompi_type_hindexed_f
  36 #pragma weak PMPI_Type_hindexed_f08 = ompi_type_hindexed_f
  37 #else
  38 OMPI_GENERATE_F77_BINDINGS (PMPI_TYPE_HINDEXED,
  39                            pmpi_type_hindexed,
  40                            pmpi_type_hindexed_,
  41                            pmpi_type_hindexed__,
  42                            pompi_type_hindexed_f,
  43                            (MPI_Fint *count, MPI_Fint *array_of_blocklengths, MPI_Fint *array_of_displacements, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr),
  44                            (count, array_of_blocklengths, array_of_displacements, oldtype, newtype, ierr) )
  45 #endif
  46 #endif
  47 
  48 #if OPAL_HAVE_WEAK_SYMBOLS
  49 #pragma weak MPI_TYPE_HINDEXED = ompi_type_hindexed_f
  50 #pragma weak mpi_type_hindexed = ompi_type_hindexed_f
  51 #pragma weak mpi_type_hindexed_ = ompi_type_hindexed_f
  52 #pragma weak mpi_type_hindexed__ = ompi_type_hindexed_f
  53 
  54 #pragma weak MPI_Type_hindexed_f = ompi_type_hindexed_f
  55 #pragma weak MPI_Type_hindexed_f08 = ompi_type_hindexed_f
  56 #else
  57 #if ! OMPI_BUILD_MPI_PROFILING
  58 OMPI_GENERATE_F77_BINDINGS (MPI_TYPE_HINDEXED,
  59                            mpi_type_hindexed,
  60                            mpi_type_hindexed_,
  61                            mpi_type_hindexed__,
  62                            ompi_type_hindexed_f,
  63                            (MPI_Fint *count, MPI_Fint *array_of_blocklengths, MPI_Fint *array_of_displacements, MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr),
  64                            (count, array_of_blocklengths, array_of_displacements, oldtype, newtype, ierr) )
  65 #else
  66 #define ompi_type_hindexed_f pompi_type_hindexed_f
  67 #endif
  68 #endif
  69 
  70 
  71 static const char FUNC_NAME[] = "MPI_TYPE_HINDEXED";
  72 
  73 
  74 void ompi_type_hindexed_f(MPI_Fint *count, MPI_Fint *array_of_blocklengths,
  75                          MPI_Fint *array_of_displacements,
  76                          MPI_Fint *oldtype, MPI_Fint *newtype, MPI_Fint *ierr)
  77 {
  78     MPI_Datatype c_old = PMPI_Type_f2c(*oldtype);
  79     MPI_Datatype c_new;
  80     MPI_Aint *c_disp_array;
  81     int i, c_ierr;
  82     OMPI_ARRAY_NAME_DECL(array_of_blocklengths);
  83 
  84     c_disp_array = (MPI_Aint *) malloc(*count * sizeof(MPI_Aint));
  85     if (NULL == c_disp_array) {
  86         c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
  87                                         FUNC_NAME);
  88         if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
  89         return;
  90     }
  91     for (i = 0; i < *count; i++) {
  92         c_disp_array[i] = (MPI_Aint) array_of_displacements[i];
  93     }
  94 
  95     OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);
  96 
  97     c_ierr = PMPI_Type_hindexed(OMPI_FINT_2_INT(*count),
  98                                OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths),
  99                                c_disp_array, c_old, &c_new);
 100     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 101 
 102     free(c_disp_array);
 103     OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
 104 
 105     if (MPI_SUCCESS == c_ierr) {
 106         *newtype = PMPI_Type_c2f(c_new);
 107     }
 108 }

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