1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ 2 /* 3 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana 4 * University Research and Technology 5 * Corporation. All rights reserved. 6 * Copyright (c) 2004-2005 The University of Tennessee and The University 7 * of Tennessee Research Foundation. All rights 8 * reserved. 9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10 * University of Stuttgart. All rights reserved. 11 * Copyright (c) 2004-2005 The Regents of the University of California. 12 * All rights reserved. 13 * Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved. 14 * Copyright (c) 2013 Los Alamos National Security, LLC. All rights 15 * reserved. 16 * Copyright (c) 2015 Research Organization for Information Science 17 * and Technology (RIST). All rights reserved. 18 * $COPYRIGHT$ 19 * 20 * Additional copyrights may follow 21 * 22 * $HEADER$ 23 */ 24 #include "ompi_config.h" 25 26 #include "ompi/mpi/c/bindings.h" 27 #include "ompi/runtime/params.h" 28 #include "ompi/communicator/communicator.h" 29 #include "ompi/errhandler/errhandler.h" 30 #include "ompi/mpi/fortran/base/fint_2_int.h" 31 #include "ompi/mpi/fortran/base/constants.h" 32 33 #if OMPI_BUILD_MPI_PROFILING 34 #if OPAL_HAVE_WEAK_SYMBOLS 35 #pragma weak MPI_Status_f2c = PMPI_Status_f2c 36 #endif 37 #define MPI_Status_f2c PMPI_Status_f2c 38 #endif 39 40 static const char FUNC_NAME[] = "MPI_Status_f2c"; 41 42 43 int MPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status) 44 { 45 int i, *c_ints; 46 47 OPAL_CR_NOOP_PROGRESS(); 48 49 if (MPI_PARAM_CHECK) { 50 OMPI_ERR_INIT_FINALIZE(FUNC_NAME); 51 52 /* MPI-2:4.12.5 says that if you pass in 53 MPI_STATUS[ES]_IGNORE, it's erroneous */ 54 55 if (NULL == f_status || 56 #if OMPI_BUILD_FORTRAN_BINDINGS 57 /* This section is #if'ed out if we are not building the 58 fortran bindings because these macros check values 59 against constants that only exist if the fortran 60 bindings exist. */ 61 OMPI_IS_FORTRAN_STATUS_IGNORE(f_status) || 62 OMPI_IS_FORTRAN_STATUSES_IGNORE(f_status) || 63 #endif 64 NULL == c_status) { 65 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, 66 MPI_ERR_IN_STATUS, FUNC_NAME); 67 } 68 } 69 70 /* ***NOTE*** See huge comment in status_c2f.c (yes, I know 71 there's a size_t member in the C MPI_Status -- go 72 read that comment for an explanation why copying 73 everything as a bunch of int's is ok). 74 75 We can't use OMPI_FINT_2_INT here because of some complications 76 with include files. :-( So just do the casting manually. */ 77 c_ints = (int*)c_status; 78 for( i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int)); i++ ) 79 c_ints[i] = (int)f_status[i]; 80 81 return MPI_SUCCESS; 82 }