Blame test/mpi/f90/ext/c2f90mult.c

Packit 0848f5
/* This file created from test/mpi/f77/ext/c2fmult.c with f77tof90 */
Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2001 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
/*
Packit 0848f5
  Check that MPI_xxxx_c2f, applied to the same object several times,
Packit 0848f5
  yields the same handle.  We do this because when MPI handles in
Packit 0848f5
  C are a different length than those in Fortran, care needs to
Packit 0848f5
  be exercised to ensure that the mapping from one to another is unique.
Packit 0848f5
  (Test added to test a potential problem in ROMIO for handling MPI_File
Packit 0848f5
  on 64-bit systems)
Packit 0848f5
*/
Packit 0848f5
#include "mpi.h"
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include "mpitest.h"
Packit 0848f5
Packit 0848f5
int main(int argc, char *argv[])
Packit 0848f5
{
Packit 0848f5
    MPI_Fint handleA, handleB;
Packit 0848f5
    int rc;
Packit 0848f5
    int errs = 0;
Packit 0848f5
    int buf[1];
Packit 0848f5
    MPI_Request cRequest;
Packit 0848f5
    MPI_Status st;
Packit 0848f5
    int tFlag;
Packit 0848f5
Packit 0848f5
    MTest_Init(&argc, &argv);
Packit 0848f5
Packit 0848f5
    /* Request */
Packit 0848f5
    rc = MPI_Irecv(buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &cRequest);
Packit 0848f5
    if (rc) {
Packit 0848f5
        errs++;
Packit 0848f5
        printf("Unable to create request\n");
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
        handleA = MPI_Request_c2f(cRequest);
Packit 0848f5
        handleB = MPI_Request_c2f(cRequest);
Packit 0848f5
        if (handleA != handleB) {
Packit 0848f5
            errs++;
Packit 0848f5
            printf("MPI_Request_c2f does not give the same handle twice on the same MPI_Request\n");
Packit 0848f5
        }
Packit 0848f5
    }
Packit 0848f5
    MPI_Cancel(&cRequest);
Packit 0848f5
    MPI_Test(&cRequest, &tFlag, &st);
Packit 0848f5
    MPI_Test_cancelled(&st, &tFlag);
Packit 0848f5
    if (!tFlag) {
Packit 0848f5
        errs++;
Packit 0848f5
        printf("Unable to cancel MPI_Irecv request\n");
Packit 0848f5
    }
Packit 0848f5
    /* Using MPI_Request_free should be ok, but some MPI implementations
Packit 0848f5
     * object to it imediately after the cancel and that isn't essential to
Packit 0848f5
     * this test */
Packit 0848f5
Packit 0848f5
    MTest_Finalize(errs);
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}