|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2004 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#include "create_f90_util.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#include "mpiimpl.h"
|
|
Packit |
0848f5 |
#ifdef HAVE_FC_TYPE_ROUTINES
|
|
Packit |
0848f5 |
#include "mpif90model.h"
|
|
Packit |
0848f5 |
#else
|
|
Packit |
0848f5 |
/* Assume only 4 and 8 byte IEEE reals available */
|
|
Packit |
0848f5 |
#define MPIR_F90_REAL_MODEL 6, 37
|
|
Packit |
0848f5 |
#define MPIR_F90_DOUBLE_MODEL 15, 307
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* -- Begin Profiling Symbol Block for routine MPI_Type_create_f90_real */
|
|
Packit |
0848f5 |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit |
0848f5 |
#pragma weak MPI_Type_create_f90_real = PMPI_Type_create_f90_real
|
|
Packit |
0848f5 |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit |
0848f5 |
#pragma _HP_SECONDARY_DEF PMPI_Type_create_f90_real MPI_Type_create_f90_real
|
|
Packit |
0848f5 |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit |
0848f5 |
#pragma _CRI duplicate MPI_Type_create_f90_real as PMPI_Type_create_f90_real
|
|
Packit |
0848f5 |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit |
0848f5 |
int MPI_Type_create_f90_real(int precision, int range, MPI_Datatype *newtype) __attribute__((weak,alias("PMPI_Type_create_f90_real")));
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
/* -- End Profiling Symbol Block */
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit |
0848f5 |
the MPI routines. You can use USE_WEAK_SYMBOLS to see if MPICH is
|
|
Packit |
0848f5 |
using weak symbols to implement the MPI routines. */
|
|
Packit |
0848f5 |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit |
0848f5 |
#define MPI_Type_create_f90_real PMPI_Type_create_f90_real
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
typedef struct realModel {
|
|
Packit |
0848f5 |
int digits, exponent;
|
|
Packit |
0848f5 |
MPI_Datatype dtype;
|
|
Packit |
0848f5 |
} realModel;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#undef FUNCNAME
|
|
Packit |
0848f5 |
#define FUNCNAME MPI_Type_create_f90_real
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*@
|
|
Packit |
0848f5 |
MPI_Type_create_f90_real - Return a predefined type that matches
|
|
Packit |
0848f5 |
the specified range
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Input Parameters:
|
|
Packit |
0848f5 |
+ precision - Number of decimal digits in mantissa
|
|
Packit |
0848f5 |
- range - Decimal exponent range desired
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Output Parameters:
|
|
Packit |
0848f5 |
. newtype - A predefine MPI Datatype that matches the range.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
Notes:
|
|
Packit |
0848f5 |
If there is no corresponding type for the specified range, the call is
|
|
Packit |
0848f5 |
erroneous. This implementation sets 'newtype' to 'MPI_DATATYPE_NULL' and
|
|
Packit |
0848f5 |
returns an error of class 'MPI_ERR_ARG'.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
.N Fortran
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
.N Errors
|
|
Packit |
0848f5 |
.N MPI_SUCCESS
|
|
Packit |
0848f5 |
.N MPI_ERR_ARG
|
|
Packit |
0848f5 |
@*/
|
|
Packit |
0848f5 |
int MPI_Type_create_f90_real( int precision, int range, MPI_Datatype *newtype )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
static const char FCNAME[] = "MPI_Type_create_f90_real";
|
|
Packit |
0848f5 |
int i;
|
|
Packit |
0848f5 |
int mpi_errno = MPI_SUCCESS;
|
|
Packit |
0848f5 |
MPI_Datatype basetype;
|
|
Packit |
0848f5 |
static int setupPredefTypes = 1;
|
|
Packit |
0848f5 |
static realModel f90_real_model[2] = {
|
|
Packit |
0848f5 |
{ MPIR_F90_REAL_MODEL, MPI_REAL},
|
|
Packit |
0848f5 |
{ MPIR_F90_DOUBLE_MODEL, MPI_DOUBLE_PRECISION } };
|
|
Packit |
0848f5 |
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_CREATE_F90_REAL);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit |
0848f5 |
MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_TYPE_CREATE_F90_REAL);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* ... body of routine ... */
|
|
Packit |
0848f5 |
/* MPI 2.1, Section 16.2, page 473 lines 12-27 make it clear that
|
|
Packit |
0848f5 |
these types must returned the combiner version. */
|
|
Packit |
0848f5 |
if (setupPredefTypes) {
|
|
Packit |
0848f5 |
setupPredefTypes = 0;
|
|
Packit |
0848f5 |
for (i=0; i<2; i++) {
|
|
Packit |
0848f5 |
MPI_Datatype oldType = f90_real_model[i].dtype;
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Create_unnamed_predefined( oldType,
|
|
Packit |
0848f5 |
MPI_COMBINER_F90_REAL,
|
|
Packit |
0848f5 |
f90_real_model[i].digits,
|
|
Packit |
0848f5 |
f90_real_model[i].exponent,
|
|
Packit |
0848f5 |
&f90_real_model[i].dtype );
|
|
Packit |
0848f5 |
if (mpi_errno) MPIR_ERR_POP(mpi_errno);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
basetype = MPI_DATATYPE_NULL;
|
|
Packit |
0848f5 |
for (i=0; i<2; i++) {
|
|
Packit |
0848f5 |
if (f90_real_model[i].digits >= precision &&
|
|
Packit |
0848f5 |
f90_real_model[i].exponent >= range) {
|
|
Packit |
0848f5 |
basetype = f90_real_model[i].dtype;
|
|
Packit |
0848f5 |
break;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (basetype == MPI_DATATYPE_NULL) {
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
|
|
Packit |
0848f5 |
"MPI_Type_create_f90_real",
|
|
Packit |
0848f5 |
__LINE__, MPI_ERR_OTHER,
|
|
Packit |
0848f5 |
"**f90typerealnone",
|
|
Packit |
0848f5 |
"**f90typerealnone %d %d",
|
|
Packit |
0848f5 |
precision, range );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Create_unnamed_predefined( basetype,
|
|
Packit |
0848f5 |
MPI_COMBINER_F90_REAL, range, precision, newtype );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
if (mpi_errno) MPIR_ERR_POP(mpi_errno);
|
|
Packit |
0848f5 |
/* ... end of body of routine ... */
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
fn_exit:
|
|
Packit |
0848f5 |
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit |
0848f5 |
MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_TYPE_CREATE_F90_REAL);
|
|
Packit |
0848f5 |
return mpi_errno;
|
|
Packit |
0848f5 |
fn_fail:
|
|
Packit |
0848f5 |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit |
0848f5 |
# ifdef HAVE_ERROR_CHECKING
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Err_create_code(
|
|
Packit |
0848f5 |
mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_type_create_f90_real",
|
|
Packit |
0848f5 |
"**mpi_type_create_f90_real %d %d", precision, range );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
# endif
|
|
Packit |
0848f5 |
mpi_errno = MPIR_Err_return_comm( 0, FCNAME, mpi_errno );
|
|
Packit |
0848f5 |
goto fn_exit;
|
|
Packit |
0848f5 |
/* --END ERROR HANDLING-- */
|
|
Packit |
0848f5 |
}
|