1 /* This file created from test/mpi/f77/rma/c2f2cwin.c with f77tof90 */
2 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
5 * (C) 2001 by Argonne National Laboratory.
6 * See COPYRIGHT in top-level directory.
9 * This file contains the C routines used in testing the c2f and f2c
10 * handle conversion functions for MPI_Win
12 * The tests follow this pattern:
14 * Fortran main program
15 * calls c routine with each handle type, with a prepared
16 * and valid handle (often requires constructing an object)
18 * C routine uses xxx_f2c routine to get C handle, checks some
19 * properties (i.e., size and rank of communicator, contents of datatype)
21 * Then the Fortran main program calls a C routine that provides
22 * a handle, and the Fortran program performs similar checks.
24 * We also assume that a C int is a Fortran integer. If this is not the
25 * case, these tests must be modified.
28 /* style: allow:fprintf:1 sig:0 */
31 #include "../../include/mpitestconf.h"
35 Name mapping. All routines are created with names that are lower case
36 with a single trailing underscore. This matches many compilers.
37 We use #define to change the name for Fortran compilers that do
38 not use the lowercase/underscore pattern
42 #define c2fwin_ C2FWIN
43 #define f2cwin_ F2CWIN
45 #elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
46 /* Mixed is ok because we use lowercase in all uses */
47 #define c2fwin_ c2fwin
48 #define f2cwin_ f2cwin
50 #elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) || \
51 defined(F77_NAME_MIXED_USCORE)
52 /* Else leave name alone (routines have no underscore, so both
53 of these map to a lowercase, single underscore) */
55 #error 'Unrecognized Fortran name mapping'
58 /* Prototypes to keep compilers happy */
60 void f2cwin_( int * );
62 int c2fwin_( int *win )
64 MPI_Win cWin = MPI_Win_f2c( *win );
65 MPI_Group group, wgroup;
68 MPI_Win_get_group( cWin, &group );
69 MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
71 MPI_Group_compare( group, wgroup, &result );
72 if (result != MPI_IDENT) {
73 fprintf( stderr, "Win: did not get expected group\n" );
77 MPI_Group_free( &group );
78 MPI_Group_free( &wgroup );
84 * The following routines provide handles to the calling Fortran program
86 void f2cwin_( int *win )
89 MPI_Win_create( 0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin );
90 *win = MPI_Win_c2f( cWin );