00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009 #include "adio_extern.h"
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 MPI_File MPIO_File_create(int size)
00022 {
00023 MPI_File mpi_fh;
00024
00025 mpi_fh = (MPI_File) ADIOI_Malloc(size);
00026 return mpi_fh;
00027 }
00028
00029 ADIO_File MPIO_File_resolve(MPI_File mpi_fh)
00030 {
00031 return mpi_fh;
00032 }
00033
00034 void MPIO_File_free(MPI_File *mpi_fh)
00035 {
00036 ADIOI_Free(*mpi_fh);
00037 *mpi_fh = MPI_FILE_NULL;
00038 }
00039
00040 MPI_File MPIO_File_f2c(MPI_Fint fh)
00041 {
00042 #ifndef INT_LT_POINTER
00043 return (MPI_File) ((void *) fh);
00044
00045
00046
00047
00048 #else
00049 if (!fh) return MPI_FILE_NULL;
00050
00051
00052 if ((fh < 0) || (fh > ADIOI_Ftable_ptr)) {
00053
00054 return MPI_FILE_NULL;
00055 }
00056
00057 return ADIOI_Ftable[fh];
00058 #endif
00059 }
00060
00061 MPI_Fint MPIO_File_c2f(MPI_File fh)
00062 {
00063 #ifndef INT_LT_POINTER
00064 return (MPI_Fint) fh;
00065 #else
00066 int i;
00067
00068 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE))
00069 return (MPI_Fint) 0;
00070
00071 if (fh->fortran_handle != -1)
00072 return fh->fortran_handle;
00073
00074 if (!ADIOI_Ftable) {
00075 ADIOI_Ftable_max = 1024;
00076 ADIOI_Ftable = (MPI_File *)
00077 ADIOI_Malloc(ADIOI_Ftable_max*sizeof(MPI_File));
00078 ADIOI_Ftable_ptr = 0;
00079
00080 for (i=0; i<ADIOI_Ftable_max; i++) ADIOI_Ftable[i] = MPI_FILE_NULL;
00081 }
00082 if (ADIOI_Ftable_ptr == ADIOI_Ftable_max-1) {
00083 ADIOI_Ftable = (MPI_File *) ADIOI_Realloc(ADIOI_Ftable,
00084 (ADIOI_Ftable_max+1024)*sizeof(MPI_File));
00085 for (i=ADIOI_Ftable_max; i<ADIOI_Ftable_max+1024; i++)
00086 ADIOI_Ftable[i] = MPI_FILE_NULL;
00087 ADIOI_Ftable_max += 1024;
00088 }
00089 ADIOI_Ftable_ptr++;
00090 ADIOI_Ftable[ADIOI_Ftable_ptr] = fh;
00091 fh->fortran_handle = ADIOI_Ftable_ptr;
00092 return (MPI_Fint) ADIOI_Ftable_ptr;
00093 #endif
00094 }