1
1
openmpi/src/mpi/f77/attr_get_f.c

98 строки
3.6 KiB
C
Исходник Обычный вид История

/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "mpi/f77/bindings.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER
#pragma weak PMPI_ATTR_GET = mpi_attr_get_f
#pragma weak pmpi_attr_get = mpi_attr_get_f
#pragma weak pmpi_attr_get_ = mpi_attr_get_f
#pragma weak pmpi_attr_get__ = mpi_attr_get_f
#elif OMPI_PROFILE_LAYER
OMPI_GENERATE_F77_BINDINGS (PMPI_ATTR_GET,
pmpi_attr_get,
pmpi_attr_get_,
pmpi_attr_get__,
pmpi_attr_get_f,
2004-09-22 18:49:52 +04:00
(MPI_Fint *comm, MPI_Fint *keyval, MPI_Fint *attribute_val, MPI_Fint *flag, MPI_Fint *ierr),
(comm, keyval, attribute_val, flag, ierr) )
#endif
#if OMPI_HAVE_WEAK_SYMBOLS
#pragma weak MPI_ATTR_GET = mpi_attr_get_f
#pragma weak mpi_attr_get = mpi_attr_get_f
#pragma weak mpi_attr_get_ = mpi_attr_get_f
#pragma weak mpi_attr_get__ = mpi_attr_get_f
#endif
#if ! OMPI_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER
OMPI_GENERATE_F77_BINDINGS (MPI_ATTR_GET,
mpi_attr_get,
mpi_attr_get_,
mpi_attr_get__,
mpi_attr_get_f,
(MPI_Fint *comm, MPI_Fint *keyval, MPI_Fint *attribute_val, MPI_Fint *flag, MPI_Fint *ierr),
(comm, keyval, attribute_val, flag, ierr) )
#endif
#if OMPI_PROFILE_LAYER && ! OMPI_HAVE_WEAK_SYMBOLS
#include "mpi/f77/profile/defines.h"
#endif
void mpi_attr_get_f(MPI_Fint *comm, MPI_Fint *keyval,
MPI_Fint *attribute_val, MPI_Fint *flag, MPI_Fint *ierr)
{
int c_err, c_flag;
MPI_Comm c_comm;
ompi_attribute_fortran_ptr_t value;
c_comm = MPI_Comm_f2c(*comm);
/* This stuff is very confusing. Be sure to see MPI-2 4.12.7. */
/* Didn't use all the FINT macros that could have prevented a few
extra variables in this function, but I figured that the
clarity of code, and the fact that this is not expected to be a
high-performance function, was worth it */
/* Note that this function deals with attribute values that are
the size of Fortran INTEGERS; the C function MPI_Attr_get deals
with attribute values that are the size of address integers.
Hence, it is possible that you'll lose some precision upon the
cast. Per MPI-2 4.12.7, use MPI_xxx_GET/SET_ATTR when you need
lossless conversion. */
c_err = MPI_Attr_get(c_comm, OMPI_FINT_2_INT(*keyval),
&value.c_ptr, &c_flag);
*ierr = OMPI_INT_2_FINT(c_err);
*flag = OMPI_INT_2_FINT(c_flag);
/* Note that MPI-2 4.12.7 specifically says that Fortran's
ATTR_GET function will take the address returned from C and
"convert it to an integer". This compliments ATTR_PUT, who,
since we need to save Fortran attributes by value, saves only
the MPI_Fint (regardless of the size of the back-end attribute
storeage). So here we simply extract that MPI_Fint and get the
value back. */
if (MPI_SUCCESS == c_err && 1 == c_flag) {
*attribute_val = value.f_integer;
}
}