This source file includes following definitions.
- MPIO_File_create
- MPIO_File_resolve
- MPIO_File_free
- MPIO_File_f2c
- MPIO_File_c2f
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 #include "mpioimpl.h"
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 MPI_File MPIO_File_create(int size)
  21 {
  22     MPI_File mpi_fh;
  23 
  24     mpi_fh = (MPI_File) ADIOI_Calloc(size,1);
  25     return mpi_fh;
  26 }
  27 
  28 ADIO_File MPIO_File_resolve(MPI_File mpi_fh)
  29 {
  30     return mpi_fh;
  31 }
  32 
  33 void MPIO_File_free(MPI_File *mpi_fh)
  34 {
  35     ADIOI_Free(*mpi_fh);
  36     *mpi_fh = MPI_FILE_NULL;
  37 }
  38 
  39 extern ADIO_File *ADIOI_Ftable;
  40 extern int ADIOI_Ftable_ptr;
  41 extern int ADIOI_Ftable_max;
  42 
  43 MPI_File MPIO_File_f2c(MPI_Fint fh)
  44 {
  45 #ifndef INT_LT_POINTER
  46     return (MPI_File) ((void *) fh);  
  47     
  48 
  49 
  50 
  51 #else
  52     if (!fh) return MPI_FILE_NULL;
  53     if ((fh < 0) || (fh > ADIOI_Ftable_ptr)) {
  54         FPRINTF(stderr, "MPI_File_f2c: Invalid file handle\n");
  55         
  56         return MPI_FILE_NULL;
  57     }
  58     return ADIOI_Ftable[fh];
  59 #endif
  60 }
  61 
  62 MPI_Fint MPIO_File_c2f(MPI_File fh)
  63 {
  64 #ifndef INT_LT_POINTER
  65     return (MPI_Fint) fh;
  66 #else
  67     int i;
  68 
  69     if ((fh == NULL) || (fh->cookie != ADIOI_FILE_COOKIE))
  70         return (MPI_Fint) 0;
  71     if (!ADIOI_Ftable) {
  72         ADIOI_Ftable_max = 1024;
  73         ADIOI_Ftable = (MPI_File *)
  74             ADIOI_Malloc(ADIOI_Ftable_max*sizeof(MPI_File)); 
  75         ADIOI_Ftable_ptr = 0;  
  76 
  77         for (i=0; i<ADIOI_Ftable_max; i++) ADIOI_Ftable[i] = MPI_FILE_NULL;
  78     }
  79     if (ADIOI_Ftable_ptr == ADIOI_Ftable_max-1) {
  80         ADIOI_Ftable = (MPI_File *) ADIOI_Realloc(ADIOI_Ftable, 
  81                            (ADIOI_Ftable_max+1024)*sizeof(MPI_File));
  82         for (i=ADIOI_Ftable_max; i<ADIOI_Ftable_max+1024; i++) 
  83             ADIOI_Ftable[i] = MPI_FILE_NULL;
  84         ADIOI_Ftable_max += 1024;
  85     }
  86     ADIOI_Ftable_ptr++;
  87     ADIOI_Ftable[ADIOI_Ftable_ptr] = fh;
  88     return (MPI_Fint) ADIOI_Ftable_ptr;
  89 #endif
  90 }