1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2001 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
8 * This file contains the C routines used in testing the c2f and f2c
9 * handle conversion functions for MPI_Win
11 * The tests follow this pattern:
13 * Fortran main program
14 * calls c routine with each handle type, with a prepared
15 * and valid handle (often requires constructing an object)
17 * C routine uses xxx_f2c routine to get C handle, checks some
18 * properties (i.e., size and rank of communicator, contents of datatype)
20 * Then the Fortran main program calls a C routine that provides
21 * a handle, and the Fortran program performs similar checks.
23 * We also assume that a C int is a Fortran integer. If this is not the
24 * case, these tests must be modified.
27 /* style: allow:fprintf:1 sig:0 */
30 #include "../../include/mpitestconf.h"
34 Name mapping. All routines are created with names that are lower case
35 with a single trailing underscore. This matches many compilers.
36 We use #define to change the name for Fortran compilers that do
37 not use the lowercase/underscore pattern
41 #define c2fwin_ C2FWIN
42 #define f2cwin_ F2CWIN
44 #elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
45 /* Mixed is ok because we use lowercase in all uses */
46 #define c2fwin_ c2fwin
47 #define f2cwin_ f2cwin
49 #elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) || \
50 defined(F77_NAME_MIXED_USCORE)
51 /* Else leave name alone (routines have no underscore, so both
52 of these map to a lowercase, single underscore) */
54 #error 'Unrecognized Fortran name mapping'
57 /* Prototypes to keep compilers happy */
59 void f2cwin_( int * );
61 int c2fwin_( int *win )
63 MPI_Win cWin = MPI_Win_f2c( *win );
64 MPI_Group group, wgroup;
67 MPI_Win_get_group( cWin, &group );
68 MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
70 MPI_Group_compare( group, wgroup, &result );
71 if (result != MPI_IDENT) {
72 fprintf( stderr, "Win: did not get expected group\n" );
76 MPI_Group_free( &group );
77 MPI_Group_free( &wgroup );
83 * The following routines provide handles to the calling Fortran program
85 void f2cwin_( int *win )
88 MPI_Win_create( 0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin );
89 *win = MPI_Win_c2f( cWin );