root/ompi/mca/io/romio321/romio/mpi-io/close.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "mpioimpl.h"
   9 
  10 #ifdef HAVE_WEAK_SYMBOLS
  11 
  12 #if defined(HAVE_PRAGMA_WEAK)
  13 #pragma weak MPI_File_close = PMPI_File_close
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_close MPI_File_close
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_close as PMPI_File_close
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_close(MPI_File *fh) __attribute__((weak,alias("PMPI_File_close")));
  21 #endif
  22 
  23 /* Include mapping from MPI->PMPI */
  24 #define MPIO_BUILD_PROFILING
  25 #include "mpioprof.h"
  26 #endif
  27 
  28 /*@
  29     MPI_File_close - Closes a file
  30 
  31 Input Parameters:
  32 . fh - file handle (handle)
  33 
  34 .N fortran
  35 @*/
  36 int MPI_File_close(MPI_File *fh)
  37 {
  38     int error_code;
  39     ADIO_File adio_fh;
  40     static char myname[] = "MPI_FILE_CLOSE";
  41 #ifdef MPI_hpux
  42     int fl_xmpi;
  43 
  44     HPMP_IO_WSTART(fl_xmpi, BLKMPIFILECLOSE, TRDTBLOCK, *adio_fh);
  45 #endif /* MPI_hpux */
  46 
  47     ROMIO_THREAD_CS_ENTER();
  48 
  49     adio_fh = MPIO_File_resolve(*fh);
  50 
  51     /* --BEGIN ERROR HANDLING-- */
  52     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  53     /* --END ERROR HANDLING-- */
  54 
  55     if (ADIO_Feature(adio_fh, ADIO_SHARED_FP))
  56     {
  57         ADIOI_Free((adio_fh)->shared_fp_fname);
  58         /* POSIX semantics say a deleted file remains available until all
  59          * processes close the file.  But since when was NFS posix-compliant?
  60          */
  61         /* this used to be gated by the lack of the UNLINK_AFTER_CLOSE feature,
  62          * but a race condition in GPFS necessated this.  See ticket #2214 */
  63         MPI_Barrier((adio_fh)->comm);
  64         if ((adio_fh)->shared_fp_fd != ADIO_FILE_NULL) {
  65             MPI_File *fh_shared = &(adio_fh->shared_fp_fd);
  66             ADIO_Close((adio_fh)->shared_fp_fd, &error_code);
  67             MPIO_File_free(fh_shared);
  68             /* --BEGIN ERROR HANDLING-- */
  69             if (error_code != MPI_SUCCESS) goto fn_fail;
  70             /* --END ERROR HANDLING-- */
  71         }
  72     }
  73 
  74     /* Because ROMIO expects the MPI library to provide error handler management
  75      * routines but it doesn't ever participate in MPI_File_close, we have to
  76      * somehow inform the MPI library that we no longer hold a reference to any
  77      * user defined error handler.  We do this by setting the errhandler at this
  78      * point to MPI_ERRORS_RETURN. */
  79 /* Open MPI: The call to PMPI_File_set_errhandler has to be done in romio/src/io_romio_file_open.c
  80    in routine mca_io_romio_file_close()
  81 */
  82 #if 0
  83     error_code = PMPI_File_set_errhandler(*fh, MPI_ERRORS_RETURN);
  84     if (error_code != MPI_SUCCESS) goto fn_fail;
  85 #endif
  86 
  87     ADIO_Close(adio_fh, &error_code);
  88     MPIO_File_free(fh);
  89     /* --BEGIN ERROR HANDLING-- */
  90     if (error_code != MPI_SUCCESS) goto fn_fail;
  91     /* --END ERROR HANDLING-- */
  92 
  93 #ifdef MPI_hpux
  94     HPMP_IO_WEND(fl_xmpi);
  95 #endif /* MPI_hpux */
  96 
  97 fn_exit:
  98     ROMIO_THREAD_CS_EXIT();
  99     return error_code;
 100 fn_fail:
 101     /* --BEGIN ERROR HANDLING-- */
 102     error_code = MPIO_Err_return_file(adio_fh, error_code);
 103     goto fn_exit;
 104     /* --END ERROR HANDLING-- */
 105 }

/* [<][>][^][v][top][bottom][index][help] */