/*@ MPI_File_set_view - Sets the file view Input Parameters: . fh - file handle (handle) . disp - displacement (nonnegative integer) . etype - elementary datatype (handle) . filetype - filetype (handle) . datarep - data representation (string) . info - info object (handle) .N fortran @*/ int MPI_File_set_view(MPI_File mpi_fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, char *datarep, MPI_Info info) { int filetype_size, etype_size, error_code; static char myname[] = "MPI_FILE_SET_VIEW"; ADIO_Offset shared_fp, byte_off; ADIO_File fh; MPIU_THREAD_SINGLE_CS_ENTER("io"); MPIR_Nest_incr(); fh = MPIO_File_resolve(mpi_fh); /* --BEGIN ERROR HANDLING-- */ MPIO_CHECK_FILE_HANDLE(fh, myname, error_code); if ((disp < 0) && (disp != MPI_DISPLACEMENT_CURRENT)) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iobaddisp", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } /* rudimentary checks for incorrect etype/filetype.*/ if (etype == MPI_DATATYPE_NULL) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**ioetype", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } if (filetype == MPI_DATATYPE_NULL) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iofiletype", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } if ((fh->access_mode & MPI_MODE_SEQUENTIAL) && (disp != MPI_DISPLACEMENT_CURRENT)) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iodispifseq", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } if ((disp == MPI_DISPLACEMENT_CURRENT) && !(fh->access_mode & MPI_MODE_SEQUENTIAL)) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iodispifseq", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ MPI_Type_size(filetype, &filetype_size); MPI_Type_size(etype, &etype_size); /* --BEGIN ERROR HANDLING-- */ if (filetype_size % etype_size != 0) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iofiletype", 0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } if (strcmp(datarep, "native") && strcmp(datarep, "NATIVE")) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_UNSUPPORTED_DATAREP, "**unsupporteddatarep",0); error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ if (disp == MPI_DISPLACEMENT_CURRENT) { MPI_Barrier(fh->comm); ADIO_Get_shared_fp(fh, 0, &shared_fp, &error_code); /* TODO: check error code */ MPI_Barrier(fh->comm); ADIOI_Get_byte_offset(fh, shared_fp, &byte_off); /* TODO: check error code */ disp = byte_off; } ADIO_Set_view(fh, disp, etype, filetype, info, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) { error_code = MPIO_Err_return_file(fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ /* reset shared file pointer to zero */ if ((fh->file_system != ADIO_PIOFS) && (fh->file_system != ADIO_PVFS) && (fh->file_system != ADIO_PVFS2) && (fh->shared_fp_fd != ADIO_FILE_NULL)) { /* only one process needs to set it to zero, but I don't want to create the shared-file-pointer file if shared file pointers have not been used so far. Therefore, every process that has already opened the shared-file-pointer file sets the shared file pointer to zero. If the file was not opened, the value is automatically zero. Note that shared file pointer is stored as no. of etypes relative to the current view, whereas indiv. file pointer is stored in bytes. */ ADIO_Set_shared_fp(fh, 0, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) error_code = MPIO_Err_return_file(fh, error_code); /* --END ERROR HANDLING-- */ } if ((fh->file_system != ADIO_PIOFS) && (fh->file_system != ADIO_PVFS) && (fh->file_system != ADIO_PVFS2 )) { MPI_Barrier(fh->comm); /* for above to work correctly */ } fn_exit: MPIR_Nest_decr(); MPIU_THREAD_SINGLE_CS_EXIT("io"); return error_code; }
/*@ MPI_File_seek_shared - Updates the shared file pointer Input Parameters: . fh - file handle (handle) . offset - file offset (integer) . whence - update mode (state) .N fortran @*/ int MPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence) { int error_code=MPI_SUCCESS, tmp_whence, myrank; static char myname[] = "MPI_FILE_SEEK_SHARED"; MPI_Offset curr_offset, eof_offset, tmp_offset; ADIO_File adio_fh; MPIU_THREAD_CS_ENTER(ALLFUNC,); adio_fh = MPIO_File_resolve(fh); /* --BEGIN ERROR HANDLING-- */ MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code); MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code); MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code); /* --END ERROR HANDLING-- */ tmp_offset = offset; MPI_Bcast(&tmp_offset, 1, ADIO_OFFSET, 0, adio_fh->comm); /* --BEGIN ERROR HANDLING-- */ if (tmp_offset != offset) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**notsame", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ tmp_whence = whence; MPI_Bcast(&tmp_whence, 1, MPI_INT, 0, adio_fh->comm); /* --BEGIN ERROR HANDLING-- */ if (tmp_whence != whence) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iobadwhence", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ ADIOI_TEST_DEFERRED(adio_fh, "MPI_File_seek_shared", &error_code); MPI_Comm_rank(adio_fh->comm, &myrank); if (!myrank) { switch(whence) { case MPI_SEEK_SET: /* --BEGIN ERROR HANDLING-- */ if (offset < 0) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iobadoffset", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ break; case MPI_SEEK_CUR: /* get current location of shared file pointer */ ADIO_Get_shared_fp(adio_fh, 0, &curr_offset, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, myname, __LINE__, MPI_ERR_INTERN, "**iosharedfailed", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ offset += curr_offset; /* --BEGIN ERROR HANDLING-- */ if (offset < 0) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**ionegoffset", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ break; case MPI_SEEK_END: /* find offset corr. to end of file */ ADIOI_Get_eof_offset(adio_fh, &eof_offset); offset += eof_offset; /* --BEGIN ERROR HANDLING-- */ if (offset < 0) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**ionegoffset", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ break; default: /* --BEGIN ERROR HANDLING-- */ error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**iobadwhence", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; /* --END ERROR HANDLING-- */ } ADIO_Set_shared_fp(adio_fh, offset, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL, myname, __LINE__, MPI_ERR_INTERN, "**iosharedfailed", 0); error_code = MPIO_Err_return_file(adio_fh, error_code); goto fn_exit; } /* --END ERROR HANDLING-- */ } /* FIXME: explain why the barrier is necessary */ MPI_Barrier(adio_fh->comm); error_code = MPI_SUCCESS; fn_exit: MPIU_THREAD_CS_EXIT(ALLFUNC,); return error_code; }
/*@ MPI_File_open - Opens a file Input Parameters: . comm - communicator (handle) . filename - name of file to open (string) . amode - file access mode (integer) . info - info object (handle) Output Parameters: . fh - file handle (handle) .N fortran @*/ int MPI_File_open(MPI_Comm comm, ROMIO_CONST char *filename, int amode, MPI_Info info, MPI_File *fh) { int error_code = MPI_SUCCESS, file_system, flag, tmp_amode=0, rank; char *tmp; MPI_Comm dupcomm = MPI_COMM_NULL; ADIOI_Fns *fsops; static char myname[] = "MPI_FILE_OPEN"; #ifdef MPI_hpux int fl_xmpi; HPMP_IO_OPEN_START(fl_xmpi, comm); #endif /* MPI_hpux */ MPIU_THREAD_CS_ENTER(ALLFUNC,); /* --BEGIN ERROR HANDLING-- */ MPIO_CHECK_COMM(comm, myname, error_code); MPIO_CHECK_INFO_ALL(info, error_code, comm); /* --END ERROR HANDLING-- */ error_code = MPI_Comm_test_inter(comm, &flag); /* --BEGIN ERROR HANDLING-- */ if (error_code || flag) { error_code = MPIO_Err_create_code(error_code, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_COMM, "**commnotintra", 0); goto fn_fail; } if ( ((amode&MPI_MODE_RDONLY)?1:0) + ((amode&MPI_MODE_RDWR)?1:0) + ((amode&MPI_MODE_WRONLY)?1:0) != 1 ) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_AMODE, "**fileamodeone", 0); goto fn_fail; } if ((amode & MPI_MODE_RDONLY) && ((amode & MPI_MODE_CREATE) || (amode & MPI_MODE_EXCL))) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_AMODE, "**fileamoderead", 0); goto fn_fail; } if ((amode & MPI_MODE_RDWR) && (amode & MPI_MODE_SEQUENTIAL)) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_AMODE, "**fileamodeseq", 0); goto fn_fail; } MPI_Comm_dup(comm, &dupcomm); /* check if ADIO has been initialized. If not, initialize it */ MPIR_MPIOInit(&error_code); if (error_code != MPI_SUCCESS) goto fn_fail; /* check if amode is the same on all processes: at first glance, one might try * to use a built-in operator like MPI_BAND, but we need every mpi process to * agree the amode was not the same. Consider process A with * MPI_MODE_CREATE|MPI_MODE_RDWR, and B with MPI_MODE_RDWR: MPI_BAND yields * MPI_MODE_RDWR. A determines amodes are different, but B proceeds having not * detected an error */ MPI_Allreduce(&amode, &tmp_amode, 1, MPI_INT, ADIO_same_amode, dupcomm); if (tmp_amode == ADIO_AMODE_NOMATCH) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_NOT_SAME, "**fileamodediff", 0); goto fn_fail; } /* --END ERROR HANDLING-- */ file_system = -1; /* resolve file system type from file name; this is a collective call */ ADIO_ResolveFileType(dupcomm, filename, &file_system, &fsops, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) { /* ADIO_ResolveFileType() will print as informative a message as it * possibly can or call MPIO_Err_setmsg. We just need to propagate * the error up. */ goto fn_fail; } /* --END ERROR HANDLING-- */ /* strip off prefix if there is one, but only skip prefixes * if they are greater than length one to allow for windows * drive specifications (e.g. c:\...) */ tmp = strchr(filename, ':'); if (tmp > filename + 1) { filename = tmp + 1; } /* use default values for disp, etype, filetype */ *fh = ADIO_Open(comm, dupcomm, filename, file_system, fsops, amode, 0, MPI_BYTE, MPI_BYTE, info, ADIO_PERM_NULL, &error_code); /* --BEGIN ERROR HANDLING-- */ if (error_code != MPI_SUCCESS) { goto fn_fail; } /* --END ERROR HANDLING-- */ /* if MPI_MODE_SEQUENTIAL requested, file systems cannot do explicit offset * or independent file pointer accesses, leaving not much else aside from * shared file pointer accesses. */ if ( !ADIO_Feature((*fh), ADIO_SHARED_FP) && (amode & MPI_MODE_SEQUENTIAL)) { error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_UNSUPPORTED_OPERATION, "**iosequnsupported", 0); ADIO_Close(*fh, &error_code); goto fn_fail; } /* determine name of file that will hold the shared file pointer */ /* can't support shared file pointers on a file system that doesn't support file locking. */ if ((error_code == MPI_SUCCESS) && ADIO_Feature((*fh), ADIO_SHARED_FP)) { MPI_Comm_rank(dupcomm, &rank); ADIOI_Shfp_fname(*fh, rank, &error_code); if (error_code != MPI_SUCCESS) goto fn_fail; /* if MPI_MODE_APPEND, set the shared file pointer to end of file. indiv. file pointer already set to end of file in ADIO_Open. Here file view is just bytes. */ if ((*fh)->access_mode & MPI_MODE_APPEND) { if (rank == (*fh)->hints->ranklist[0]) /* only one person need set the sharedfp */ ADIO_Set_shared_fp(*fh, (*fh)->fp_ind, &error_code); MPI_Barrier(dupcomm); } } #ifdef MPI_hpux HPMP_IO_OPEN_END(fl_xmpi, *fh, comm); #endif /* MPI_hpux */ fn_exit: MPIU_THREAD_CS_EXIT(ALLFUNC,); return error_code; fn_fail: /* --BEGIN ERROR HANDLING-- */ if (dupcomm != MPI_COMM_NULL) MPI_Comm_free(&dupcomm); error_code = MPIO_Err_return_file(MPI_FILE_NULL, error_code); goto fn_exit; /* --END ERROR HANDLING-- */ }
/*@ MPI_File_open - Opens a file Input Parameters: . comm - communicator (handle) . filename - name of file to open (string) . amode - file access mode (integer) . info - info object (handle) Output Parameters: . fh - file handle (handle) .N fortran @*/ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh) { int error_code, file_system, flag, tmp_amode, rank, orig_amode; #ifndef PRINT_ERR_MSG static char myname[] = "MPI_FILE_OPEN"; #endif int err, min_code; char *tmp; MPI_Comm dupcomm, dupcommself; #ifdef MPI_hpux int fl_xmpi; HPMP_IO_OPEN_START(fl_xmpi, comm); #endif /* MPI_hpux */ error_code = MPI_SUCCESS; if (comm == MPI_COMM_NULL) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: Invalid communicator\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_COMM, MPIR_ERR_COMM_NULL, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } MPI_Comm_test_inter(comm, &flag); if (flag) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: Intercommunicator cannot be passed to MPI_File_open\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_COMM, MPIR_ERR_COMM_INTER, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } if ( ((amode&MPI_MODE_RDONLY)?1:0) + ((amode&MPI_MODE_RDWR)?1:0) + ((amode&MPI_MODE_WRONLY)?1:0) != 1 ) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: Exactly one of MPI_MODE_RDONLY, MPI_MODE_WRONLY, or MPI_MODE_RDWR must be specified\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_AMODE, 3, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } if ((amode & MPI_MODE_RDONLY) && ((amode & MPI_MODE_CREATE) || (amode & MPI_MODE_EXCL))) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: It is erroneous to specify MPI_MODE_CREATE or MPI_MODE_EXCL with MPI_MODE_RDONLY\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_AMODE, 5, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } if ((amode & MPI_MODE_RDWR) && (amode & MPI_MODE_SEQUENTIAL)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: It is erroneous to specify MPI_MODE_SEQUENTIAL with MPI_MODE_RDWR\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_AMODE, 7, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } /* check if amode is the same on all processes */ MPI_Comm_dup(comm, &dupcomm); tmp_amode = amode; /* Removed this check because broadcast is too expensive. MPI_Bcast(&tmp_amode, 1, MPI_INT, 0, dupcomm); if (amode != tmp_amode) { FPRINTF(stderr, "MPI_File_open: amode must be the same on all processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); } */ /* check if ADIO has been initialized. If not, initialize it */ if (ADIO_Init_keyval == MPI_KEYVAL_INVALID) { /* check if MPI itself has been initialized. If not, flag an error. Can't initialize it here, because don't know argc, argv */ MPI_Initialized(&flag); if (!flag) { FPRINTF(stderr, "Error: MPI_Init() must be called before using MPI-IO\n"); MPI_Abort(MPI_COMM_WORLD, 1); } MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_End_call, &ADIO_Init_keyval, (void *) 0); /* put a dummy attribute on MPI_COMM_WORLD, because we want the delete function to be called when MPI_COMM_WORLD is freed. Hopefully the MPI library frees MPI_COMM_WORLD when MPI_Finalize is called, though the standard does not mandate this. */ MPI_Attr_put(MPI_COMM_WORLD, ADIO_Init_keyval, (void *) 0); /* initialize ADIO */ ADIO_Init( (int *)0, (char ***)0, &error_code); } file_system = -1; tmp = strchr(filename, ':'); #ifdef WIN32 // Unfortunately Windows uses ':' behind the drive letter. // So we check if there is only one letter before the ':' // Please do not use a single letter filesystem name! if(tmp && ((tmp-filename) == 1)) tmp = 0; #endif if (!tmp) { ADIO_FileSysType(filename, &file_system, &err); if (err != MPI_SUCCESS) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: Can't determine the file-system type. Check the filename/path you provided and try again. Otherwise, prefix the filename with a string to indicate the type of file sytem (piofs:, pfs:, nfs:, ufs:, hfs:, xfs:, sfs:, pvfs:, svm:).\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_FSTYPE, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } MPI_Allreduce(&file_system, &min_code, 1, MPI_INT, MPI_MIN, dupcomm); if (min_code == ADIO_NFS) file_system = ADIO_NFS; } #ifndef PFS if (!strncmp(filename, "pfs:", 4) || !strncmp(filename, "PFS:", 4) || (file_system == ADIO_PFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the PFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PFS, myname, (char *) 0, (char *) 0,"PFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef PIOFS if (!strncmp(filename, "piofs:", 6) || !strncmp(filename, "PIOFS:", 6) || (file_system == ADIO_PIOFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the PIOFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PIOFS, myname, (char *) 0, (char *) 0,"PIOFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef UFS if (!strncmp(filename, "ufs:", 4) || !strncmp(filename, "UFS:", 4) || (file_system == ADIO_UFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the UFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_UFS, myname, (char *) 0, (char *) 0,"UFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef NFS if (!strncmp(filename, "nfs:", 4) || !strncmp(filename, "NFS:", 4) || (file_system == ADIO_NFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the NFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_NFS, myname, (char *) 0, (char *) 0,"NFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef HFS if (!strncmp(filename, "hfs:", 4) || !strncmp(filename, "HFS:", 4) || (file_system == ADIO_HFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the HFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_HFS, myname, (char *) 0, (char *) 0,"HFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef XFS if (!strncmp(filename, "xfs:", 4) || !strncmp(filename, "XFS:", 4) || (file_system == ADIO_XFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the XFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_XFS, myname, (char *) 0, (char *) 0,"XFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef SFS if (!strncmp(filename, "sfs:", 4) || !strncmp(filename, "SFS:", 4) || (file_system == ADIO_SFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the SFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_SFS, myname, (char *) 0, (char *) 0,"SFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef PVFS if (!strncmp(filename, "pvfs:", 5) || !strncmp(filename, "PVFS:", 5) || (file_system == ADIO_PVFS)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the PVFS file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_PVFS, myname, (char *) 0, (char *) 0,"PVFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef SVM if (!strncmp(filename, "svm:", 4) || !strncmp(filename, "SVM:", 4) || (file_system == ADIO_SVM)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the SVM file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_SVM, myname, (char *) 0, (char *) 0,"SVM"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif #ifndef NTFS if (!strncmp(filename, "svm:", 4) || !strncmp(filename, "NTFS:", 4) || (file_system == ADIO_SVM)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: ROMIO has not been configured to use the SVM file system\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ERR_NO_NTFS, myname, (char *) 0, (char *) 0,"NTFS"); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } #endif if (!strncmp(filename, "pfs:", 4) || !strncmp(filename, "PFS:", 4)) { file_system = ADIO_PFS; filename += 4; } else if (!strncmp(filename, "piofs:", 6) || !strncmp(filename, "PIOFS:", 6)) { file_system = ADIO_PIOFS; filename += 6; } else if (!strncmp(filename, "ufs:", 4) || !strncmp(filename, "UFS:", 4)) { file_system = ADIO_UFS; filename += 4; } else if (!strncmp(filename, "nfs:", 4) || !strncmp(filename, "NFS:", 4)) { file_system = ADIO_NFS; filename += 4; } else if (!strncmp(filename, "hfs:", 4) || !strncmp(filename, "HFS:", 4)) { file_system = ADIO_HFS; filename += 4; } else if (!strncmp(filename, "xfs:", 4) || !strncmp(filename, "XFS:", 4)) { file_system = ADIO_XFS; filename += 4; } else if (!strncmp(filename, "sfs:", 4) || !strncmp(filename, "SFS:", 4)) { file_system = ADIO_SFS; filename += 4; } else if (!strncmp(filename, "pvfs:", 5) || !strncmp(filename, "PVFS:", 5)) { file_system = ADIO_PVFS; filename += 5; } else if (!strncmp(filename, "svm:", 4) || !strncmp(filename, "SVM:", 4)) { file_system = ADIO_SVM; filename += 4; } else if (!strncmp(filename, "ntfs:", 4) || !strncmp(filename, "NTFS:", 4)) { file_system = ADIO_NTFS; filename += 5; } if (((file_system == ADIO_PIOFS) || (file_system == ADIO_PVFS)) && (amode & MPI_MODE_SEQUENTIAL)) { #ifdef PRINT_ERR_MSG FPRINTF(stderr, "MPI_File_open: MPI_MODE_SEQUENTIAL not supported on PIOFS and PVFS\n"); MPI_Abort(MPI_COMM_WORLD, 1); #else error_code = MPIR_Err_setmsg(MPI_ERR_UNSUPPORTED_OPERATION, MPIR_ERR_NO_MODE_SEQ, myname, (char *) 0, (char *) 0); return ADIOI_Error(MPI_FILE_NULL, error_code, myname); #endif } orig_amode = amode; MPI_Comm_rank(dupcomm, &rank); if ((amode & MPI_MODE_CREATE) && (amode & MPI_MODE_EXCL)) { /* the open should fail if the file exists. Only process 0 should check this. Otherwise, if all processes try to check and the file does not exist, one process will create the file and others who reach later will return error. */ if (!rank) { MPI_Comm_dup(MPI_COMM_SELF, &dupcommself); /* this dup is freed either in ADIO_Open if the open fails, or in ADIO_Close */ *fh = ADIO_Open(dupcommself, filename, file_system, amode, 0, MPI_BYTE, MPI_BYTE, M_ASYNC, info, ADIO_PERM_NULL, &error_code); /* broadcast the error code to other processes */ MPI_Bcast(&error_code, 1, MPI_INT, 0, dupcomm); /* if no error, close the file. It will be reopened normally below. */ if (error_code == MPI_SUCCESS) ADIO_Close(*fh, &error_code); } else MPI_Bcast(&error_code, 1, MPI_INT, 0, dupcomm); if (error_code != MPI_SUCCESS) { MPI_Comm_free(&dupcomm); *fh = MPI_FILE_NULL; #ifdef MPI_hpux HPMP_IO_OPEN_END(fl_xmpi, *fh, comm); #endif /* MPI_hpux */ return error_code; } else amode = amode ^ MPI_MODE_EXCL; /* turn off MPI_MODE_EXCL */ } /* use default values for disp, etype, filetype */ /* set iomode=M_ASYNC. It is used to implement the Intel PFS interface on top of ADIO. Not relevant for MPI-IO implementation */ *fh = ADIO_Open(dupcomm, filename, file_system, amode, 0, MPI_BYTE, MPI_BYTE, M_ASYNC, info, ADIO_PERM_NULL, &error_code); /* if MPI_MODE_EXCL was removed, add it back */ if ((error_code == MPI_SUCCESS) && (amode != orig_amode)) (*fh)->access_mode = orig_amode; /* determine name of file that will hold the shared file pointer */ /* can't support shared file pointers on a file system that doesn't support file locking, e.g., PIOFS, PVFS */ if ((error_code == MPI_SUCCESS) && ((*fh)->file_system != ADIO_PIOFS) && ((*fh)->file_system != ADIO_PVFS)) { ADIOI_Shfp_fname(*fh, rank); /* if MPI_MODE_APPEND, set the shared file pointer to end of file. indiv. file pointer already set to end of file in ADIO_Open. Here file view is just bytes. */ if ((*fh)->access_mode & MPI_MODE_APPEND) { if (!rank) ADIO_Set_shared_fp(*fh, (*fh)->fp_ind, &error_code); MPI_Barrier(dupcomm); } } #ifdef MPI_hpux HPMP_IO_OPEN_END(fl_xmpi, *fh, comm); #endif /* MPI_hpux */ return error_code; }