00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009
00010 #ifdef HAVE_UNISTD_H
00011 #include <unistd.h>
00012 #endif
00013
00014
00015
00016 void ADIOI_GEN_Close(ADIO_File fd, int *error_code)
00017 {
00018 int err, derr=0;
00019 static char myname[] = "ADIOI_GEN_CLOSE";
00020
00021 #ifdef ADIOI_MPE_LOGGING
00022 MPE_Log_event( ADIOI_MPE_close_a, 0, NULL );
00023 #endif
00024 err = close(fd->fd_sys);
00025 #ifdef ADIOI_MPE_LOGGING
00026 MPE_Log_event( ADIOI_MPE_close_b, 0, NULL );
00027 #endif
00028 if (fd->fd_direct >= 0) {
00029 #ifdef ADIOI_MPE_LOGGING
00030 MPE_Log_event( ADIOI_MPE_close_a, 0, NULL );
00031 #endif
00032 derr = close(fd->fd_direct);
00033 #ifdef ADIOI_MPE_LOGGING
00034 MPE_Log_event( ADIOI_MPE_close_b, 0, NULL );
00035 #endif
00036 }
00037
00038 fd->fd_sys = -1;
00039 fd->fd_direct = -1;
00040
00041 if (err == -1 || derr == -1) {
00042 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00043 myname, __LINE__, MPI_ERR_IO,
00044 "**io",
00045 "**io %s", strerror(errno));
00046 }
00047 else *error_code = MPI_SUCCESS;
00048 }