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