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/mpi/fortran/base/constants.h"
26 
27 #if OMPI_BUILD_MPI_PROFILING
28 #if OPAL_HAVE_WEAK_SYMBOLS
29 #pragma weak PMPI_TEST_CANCELLED = ompi_test_cancelled_f
30 #pragma weak pmpi_test_cancelled = ompi_test_cancelled_f
31 #pragma weak pmpi_test_cancelled_ = ompi_test_cancelled_f
32 #pragma weak pmpi_test_cancelled__ = ompi_test_cancelled_f
33 
34 #pragma weak PMPI_Test_cancelled_f = ompi_test_cancelled_f
35 #pragma weak PMPI_Test_cancelled_f08 = ompi_test_cancelled_f
36 #else
37 OMPI_GENERATE_F77_BINDINGS (PMPI_TEST_CANCELLED,
38                            pmpi_test_cancelled,
39                            pmpi_test_cancelled_,
40                            pmpi_test_cancelled__,
41                            pompi_test_cancelled_f,
42                            (MPI_Fint *status, ompi_fortran_logical_t *flag, MPI_Fint *ierr),
43                            (status, flag, ierr) )
44 #endif
45 #endif
46 
47 #if OPAL_HAVE_WEAK_SYMBOLS
48 #pragma weak MPI_TEST_CANCELLED = ompi_test_cancelled_f
49 #pragma weak mpi_test_cancelled = ompi_test_cancelled_f
50 #pragma weak mpi_test_cancelled_ = ompi_test_cancelled_f
51 #pragma weak mpi_test_cancelled__ = ompi_test_cancelled_f
52 
53 #pragma weak MPI_Test_cancelled_f = ompi_test_cancelled_f
54 #pragma weak MPI_Test_cancelled_f08 = ompi_test_cancelled_f
55 #else
56 #if ! OMPI_BUILD_MPI_PROFILING
57 OMPI_GENERATE_F77_BINDINGS (MPI_TEST_CANCELLED,
58                            mpi_test_cancelled,
59                            mpi_test_cancelled_,
60                            mpi_test_cancelled__,
61                            ompi_test_cancelled_f,
62                            (MPI_Fint *status, ompi_fortran_logical_t *flag, MPI_Fint *ierr),
63                            (status, flag, ierr) )
64 #else
65 #define ompi_test_cancelled_f pompi_test_cancelled_f
66 #endif
67 #endif
68 
69 
ompi_test_cancelled_f(MPI_Fint * status,ompi_fortran_logical_t * flag,MPI_Fint * ierr)70 void ompi_test_cancelled_f(MPI_Fint *status, ompi_fortran_logical_t *flag, MPI_Fint *ierr)
71 {
72     int c_ierr;
73     MPI_Status c_status;
74     OMPI_LOGICAL_NAME_DECL(flag);
75 
76     /* This seems silly, but someone will do it */
77 
78     if (OMPI_IS_FORTRAN_STATUS_IGNORE(status)) {
79         *flag = OMPI_INT_2_LOGICAL(0);
80         c_ierr = MPI_SUCCESS;
81     } else {
82         c_ierr = PMPI_Status_f2c( status, &c_status );
83 
84         if (MPI_SUCCESS == c_ierr) {
85             c_ierr = PMPI_Test_cancelled(&c_status,
86                                         OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag));
87 
88             OMPI_SINGLE_INT_2_LOGICAL(flag);
89         }
90     }
91     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
92 }
93