root/ompi/mca/io/romio321/romio/mpi-io/glue/openmpi/mpio_file.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPIO_File_create
  2. MPIO_File_resolve
  3. MPIO_File_free
  4. MPIO_File_f2c
  5. MPIO_File_c2f

   1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
   2 /*
   3  *
   4  *   Copyright (C) 2004 University of Chicago.
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "mpioimpl.h"
   9 
  10 #include "adio_extern.h"
  11 
  12 /* Hooks for allocation of MPI_File handles.
  13  *
  14  * Three functions are used in ROMIO for allocation/deallocation
  15  * of MPI_File structures:
  16  * - MPIO_File_create(size)
  17  * - MPIO_File_resolve(mpi_fh)
  18  * - MPIO_File_free(mpi_fh)
  19  *
  20  */
  21 
  22 MPI_File MPIO_File_create(int size)
  23 {
  24     MPI_File mpi_fh;
  25 
  26     mpi_fh = (MPI_File) ADIOI_Calloc(size, 1);
  27     return mpi_fh;
  28 }
  29 
  30 ADIO_File MPIO_File_resolve(MPI_File mpi_fh)
  31 {
  32     return mpi_fh;
  33 }
  34 
  35 void MPIO_File_free(MPI_File * mpi_fh)
  36 {
  37     ADIOI_Free(*mpi_fh);
  38     *mpi_fh = MPI_FILE_NULL;
  39 }
  40 
  41 /* these functions aren't needed with the way Open MPI uses ROMIO */
  42 #if 0
  43 
  44 
  45 MPI_File MPIO_File_f2c(MPI_Fint fh)
  46 {
  47 #ifndef INT_LT_POINTER
  48     return (MPI_File) ((void *) fh);
  49     /* the extra cast is to get rid of a compiler warning on Exemplar.
  50      * The warning is because MPI_File points to a structure containing
  51      * longlongs, which may be 8-byte aligned. But MPI_Fint itself
  52      * may not be 8-byte aligned. */
  53 #else
  54     if (!fh)
  55         return MPI_FILE_NULL;
  56     if ((fh < 0) || (fh > ADIOI_Ftable_ptr)) {
  57         FPRINTF(stderr, "MPI_File_f2c: Invalid file handle\n");
  58         MPI_Abort(MPI_COMM_WORLD, 1);
  59     }
  60     return ADIOI_Ftable[fh];
  61 #endif
  62 }
  63 
  64 MPI_Fint MPIO_File_c2f(MPI_File fh)
  65 {
  66 #ifndef INT_LT_POINTER
  67     return (MPI_Fint) fh;
  68 #else
  69     int i;
  70 
  71     if ((fh == NULL) || (fh->cookie != ADIOI_FILE_COOKIE))
  72         return (MPI_Fint) 0;
  73     if (!ADIOI_Ftable) {
  74         ADIOI_Ftable_max = 1024;
  75         ADIOI_Ftable = (MPI_File *)
  76             ADIOI_Malloc(ADIOI_Ftable_max * sizeof(MPI_File));
  77         ADIOI_Ftable_ptr = 0;   /* 0 can't be used though, because
  78                                  * MPI_FILE_NULL=0 */
  79         for (i = 0; i < ADIOI_Ftable_max; i++)
  80             ADIOI_Ftable[i] = MPI_FILE_NULL;
  81     }
  82     if (ADIOI_Ftable_ptr == ADIOI_Ftable_max - 1) {
  83         ADIOI_Ftable = (MPI_File *) ADIOI_Realloc(ADIOI_Ftable,
  84                                                   (ADIOI_Ftable_max + 1024) * sizeof(MPI_File));
  85         for (i = ADIOI_Ftable_max; i < ADIOI_Ftable_max + 1024; i++)
  86             ADIOI_Ftable[i] = MPI_FILE_NULL;
  87         ADIOI_Ftable_max += 1024;
  88     }
  89     ADIOI_Ftable_ptr++;
  90     ADIOI_Ftable[ADIOI_Ftable_ptr] = fh;
  91     return (MPI_Fint) ADIOI_Ftable_ptr;
  92 #endif
  93 }
  94 
  95 #endif /* #if 0 */

/* [<][>][^][v][top][bottom][index][help] */