00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009
00010 #ifdef HAVE_WEAK_SYMBOLS
00011
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_File_close = PMPI_File_close
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_close MPI_File_close
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_close as PMPI_File_close
00018
00019 #endif
00020
00021
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 int MPI_File_close(MPI_File *mpi_fh)
00035 {
00036 int error_code;
00037 ADIO_File fh;
00038 static char myname[] = "MPI_FILE_CLOSE";
00039 #ifdef MPI_hpux
00040 int fl_xmpi;
00041
00042 HPMP_IO_WSTART(fl_xmpi, BLKMPIFILECLOSE, TRDTBLOCK, *fh);
00043 #endif
00044
00045 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00046
00047 fh = MPIO_File_resolve(*mpi_fh);
00048
00049
00050 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00051
00052
00053 if (ADIO_Feature(fh, ADIO_SHARED_FP))
00054 {
00055 ADIOI_Free((fh)->shared_fp_fname);
00056
00057
00058
00059 if (!ADIO_Feature(fh, ADIO_UNLINK_AFTER_CLOSE)) {
00060 MPI_Barrier((fh)->comm);
00061 }
00062 if ((fh)->shared_fp_fd != ADIO_FILE_NULL) {
00063 MPI_File *mpi_fh_shared = &(fh->shared_fp_fd);
00064 ADIO_Close((fh)->shared_fp_fd, &error_code);
00065 MPIO_File_free(mpi_fh_shared);
00066
00067 if (error_code != MPI_SUCCESS) goto fn_fail;
00068
00069 }
00070 }
00071
00072
00073
00074
00075
00076
00077
00078 #if 0
00079 error_code = PMPI_File_set_errhandler(*mpi_fh, MPI_ERRORS_RETURN);
00080 if (error_code != MPI_SUCCESS) goto fn_fail;
00081 #endif
00082
00083 ADIO_Close(fh, &error_code);
00084 MPIO_File_free(mpi_fh);
00085
00086 if (error_code != MPI_SUCCESS) goto fn_fail;
00087
00088
00089 #ifdef MPI_hpux
00090 HPMP_IO_WEND(fl_xmpi);
00091 #endif
00092
00093 fn_exit:
00094 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00095 return error_code;
00096 fn_fail:
00097
00098 error_code = MPIO_Err_return_file(fh, error_code);
00099 goto fn_exit;
00100
00101 }