-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/romio/mpi-io/open.c
-: 0:Graph:open.gcno
-: 0:Data:open.gcda
-: 0:Runs:224
-: 0:Programs:67
-: 1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
-: 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_open = PMPI_File_open
-: 14:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
-: 15:#pragma _HP_SECONDARY_DEF PMPI_File_open MPI_File_open
-: 16:#elif defined(HAVE_PRAGMA_CRI_DUP)
-: 17:#pragma _CRI duplicate MPI_File_open as PMPI_File_open
-: 18:/* end of weak pragmas */
-: 19:#endif
-: 20:
-: 21:/* Include mapping from MPI->PMPI */
-: 22:#define MPIO_BUILD_PROFILING
-: 23:#include "mpioprof.h"
-: 24:#endif
-: 25:
-: 26:extern int ADIO_Init_keyval;
-: 27:
-: 28:/*@
-: 29: MPI_File_open - Opens a file
-: 30:
-: 31:Input Parameters:
-: 32:. comm - communicator (handle)
-: 33:. filename - name of file to open (string)
-: 34:. amode - file access mode (integer)
-: 35:. info - info object (handle)
-: 36:
-: 37:Output Parameters:
-: 38:. fh - file handle (handle)
-: 39:
-: 40:.N fortran
-: 41:@*/
-: 42:int MPI_File_open(MPI_Comm comm, char *filename, int amode,
-: 43: MPI_Info info, MPI_File *fh)
3099: 44:{
-: 45: int error_code, file_system, flag, /* tmp_amode, */rank;
-: 46: char *tmp;
-: 47: MPI_Comm dupcomm;
-: 48: ADIOI_Fns *fsops;
-: 49: static char myname[] = "MPI_FILE_OPEN";
3099: 50: MPIU_THREADPRIV_DECL;
-: 51:#ifdef MPI_hpux
-: 52: int fl_xmpi;
-: 53:
-: 54: HPMP_IO_OPEN_START(fl_xmpi, comm);
-: 55:#endif /* MPI_hpux */
-: 56:
3099: 57: MPIU_THREAD_CS_ENTER(ALLFUNC,);
3099: 58: MPIR_Nest_incr();
-: 59:
|
-: 60: /* --BEGIN ERROR HANDLING-- */
3099: 61: if (comm == MPI_COMM_NULL)
-: 62: {
#####: 63: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 64: myname, __LINE__, MPI_ERR_COMM,
-: 65: "**comm", 0);
#####: 66: goto fn_fail;
-: 67: }
-: 68: /* --END ERROR HANDLING-- */
-: 69:
|
3099: 70: MPI_Comm_test_inter(comm, &flag);
|
-: 71: /* --BEGIN ERROR HANDLING-- */
3099: 72: if (flag)
-: 73: {
#####: 74: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 75: myname, __LINE__, MPI_ERR_COMM,
-: 76: "**commnotintra", 0);
#####: 77: goto fn_fail;
-: 78: }
-: 79:
3099: 80: if ( ((amode&MPI_MODE_RDONLY)?1:0) + ((amode&MPI_MODE_RDWR)?1:0) +
-: 81: ((amode&MPI_MODE_WRONLY)?1:0) != 1 )
-: 82: {
#####: 83: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 84: myname, __LINE__, MPI_ERR_AMODE,
-: 85: "**fileamodeone", 0);
#####: 86: goto fn_fail;
-: 87: }
-: 88:
3099: 89: if ((amode & MPI_MODE_RDONLY) &&
-: 90: ((amode & MPI_MODE_CREATE) || (amode & MPI_MODE_EXCL)))
-: 91: {
#####: 92: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 93: myname, __LINE__, MPI_ERR_AMODE,
-: 94: "**fileamoderead", 0);
#####: 95: goto fn_fail;
-: 96: }
-: 97:
3099: 98: if ((amode & MPI_MODE_RDWR) && (amode & MPI_MODE_SEQUENTIAL))
-: 99: {
#####: 100: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 101: myname, __LINE__, MPI_ERR_AMODE,
-: 102: "**fileamodeseq", 0);
#####: 103: goto fn_fail;
-: 104: }
-: 105: /* --END ERROR HANDLING-- */
-: 106:
-: 107:/* check if amode is the same on all processes */
|
3099: 108: MPI_Comm_dup(comm, &dupcomm);
-: 109:
-: 110:/*
-: 111: Removed this check because broadcast is too expensive.
-: 112: tmp_amode = amode;
-: 113: MPI_Bcast(&tmp_amode, 1, MPI_INT, 0, dupcomm);
-: 114: if (amode != tmp_amode) {
-: 115: FPRINTF(stderr, "MPI_File_open: amode must be the same on all processes\n");
-: 116: MPI_Abort(MPI_COMM_WORLD, 1);
-: 117: }
-: 118:*/
-: 119:
-: 120:/* check if ADIO has been initialized. If not, initialize it */
3099: 121: MPIR_MPIOInit(&error_code);
|
3099: 122: if (error_code != MPI_SUCCESS) goto fn_fail;
-: 123:
|
3099: 124: file_system = -1;
-: 125:
-: 126: /* resolve file system type from file name; this is a collective call */
3099: 127: ADIO_ResolveFileType(dupcomm, filename, &file_system, &fsops, &error_code);
|
-: 128: /* --BEGIN ERROR HANDLING-- */
3099: 129: if (error_code != MPI_SUCCESS)
-: 130: {
-: 131: /* ADIO_ResolveFileType() will print as informative a message as it
-: 132: * possibly can or call MPIO_Err_setmsg. We just need to propagate
-: 133: * the error up.
-: 134: */
#####: 135: goto fn_fail;
-: 136: }
-: 137:
-: 138: /* --END ERROR HANDLING-- */
-: 139:
-: 140: /* strip off prefix if there is one, but only skip prefixes
-: 141: * if they are greater than length one to allow for windows
-: 142: * drive specifications (e.g. c:\...) */
-: 143:
|
3099: 144: tmp = strchr(filename, ':');
3099: 145: if (tmp > filename + 1) {
|
#####: 146: filename = tmp + 1;
-: 147: }
-: 148:
-: 149:/* use default values for disp, etype, filetype */
-: 150:
|
3099: 151: *fh = ADIO_Open(comm, dupcomm, filename, file_system, fsops, amode, 0,
-: 152: MPI_BYTE, MPI_BYTE, info, ADIO_PERM_NULL, &error_code);
-: 153:
|
-: 154: /* --BEGIN ERROR HANDLING-- */
3099: 155: if (error_code != MPI_SUCCESS) {
16: 156: MPI_Comm_free(&dupcomm);
16: 157: goto fn_fail;
-: 158: }
-: 159: /* --END ERROR HANDLING-- */
-: 160:
-: 161: /* if MPI_MODE_SEQUENTIAL requested, file systems cannot do explicit offset
-: 162: * or independent file pointer accesses, leaving not much else aside from
-: 163: * shared file pointer accesses. */
|
3083: 164: if ( !ADIO_Feature((*fh), ADIO_SHARED_FP) && (amode & MPI_MODE_SEQUENTIAL))
-: 165: {
|
#####: 166: error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
-: 167: myname, __LINE__,
-: 168: MPI_ERR_UNSUPPORTED_OPERATION,
-: 169: "**iosequnsupported", 0);
#####: 170: ADIO_Close(*fh, &error_code);
|
#####: 171: goto fn_fail;
-: 172: }
-: 173:
-: 174: /* determine name of file that will hold the shared file pointer */
-: 175: /* can't support shared file pointers on a file system that doesn't
-: 176: support file locking. */
|
3083: 177: if ((error_code == MPI_SUCCESS) &&
-: 178: ADIO_Feature((*fh), ADIO_SHARED_FP)) {
3083: 179: MPI_Comm_rank(dupcomm, &rank);
3083: 180: ADIOI_Shfp_fname(*fh, rank);
-: 181:
-: 182: /* if MPI_MODE_APPEND, set the shared file pointer to end of file.
-: 183: indiv. file pointer already set to end of file in ADIO_Open.
-: 184: Here file view is just bytes. */
3083: 185: if ((*fh)->access_mode & MPI_MODE_APPEND) {
|
#####: 186: if (rank == (*fh)->hints->ranklist[0]) /* only one person need set the sharedfp */
#####: 187: ADIO_Set_shared_fp(*fh, (*fh)->fp_ind, &error_code);
#####: 188: MPI_Barrier(dupcomm);
-: 189: }
-: 190: }
-: 191:
-: 192:#ifdef MPI_hpux
-: 193: HPMP_IO_OPEN_END(fl_xmpi, *fh, comm);
-: 194:#endif /* MPI_hpux */
-: 195:
|
3083: 196: MPIR_Nest_decr();
-: 197:
3099: 198:fn_exit:
3099: 199: MPIU_THREAD_CS_EXIT(ALLFUNC,);
3099: 200: return error_code;
|
16: 201:fn_fail:
-: 202: /* --BEGIN ERROR HANDLING-- */
16: 203: MPIR_Nest_decr();
16: 204: error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code);
16: 205: goto fn_exit;
-: 206: /* --END ERROR HANDLING-- */
-: 207:}
|