Blame test/mpi/f77/io/c2fmultio.c

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_File_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
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 rank;
Packit 0848f5
    MPI_File cFile;
Packit 0848f5
Packit 0848f5
    MPI_Init(&argc, &argv);
Packit 0848f5
    MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
Packit 0848f5
Packit 0848f5
    /* File */
Packit 0848f5
    rc = MPI_File_open(MPI_COMM_WORLD, (char *) "temp",
Packit 0848f5
                       MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
Packit 0848f5
                       MPI_INFO_NULL, &cFile);
Packit 0848f5
    if (rc) {
Packit 0848f5
        errs++;
Packit 0848f5
        printf("Unable to open file \"temp\"\n");
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
        handleA = MPI_File_c2f(cFile);
Packit 0848f5
        handleB = MPI_File_c2f(cFile);
Packit 0848f5
        if (handleA != handleB) {
Packit 0848f5
            errs++;
Packit 0848f5
            printf("MPI_File_c2f does not give the same handle twice on the same MPI_File\n");
Packit 0848f5
        }
Packit 0848f5
    }
Packit 0848f5
    MPI_File_close(&cFile);
Packit 0848f5
Packit 0848f5
    if (rank == 0) {
Packit 0848f5
        if (errs) {
Packit 0848f5
            fprintf(stderr, "Found %d errors\n", errs);
Packit 0848f5
        }
Packit 0848f5
        else {
Packit 0848f5
            printf(" No Errors\n");
Packit 0848f5
        }
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}