00001 /* -*- Mode: C; c-basic-offset:4 ; -*- */ 00002 /* 00003 * 00004 * Copyright (C) 2007 UChicago/Argonne LLC 00005 * See COPYRIGHT notice in top-level directory. 00006 */ 00007 00008 #include "adio.h" 00009 00010 /* 00011 * Scalable open: for file systems capable of having one process 00012 * create/open a file and broadcast the result to everyone else. 00013 * - Does not need one process to create the file 00014 * - Does not need special handling for CREATE|EXCL 00015 */ 00016 void ADIOI_SCALEABLE_OpenColl(ADIO_File fd, int rank, 00017 int access_mode, int *error_code) 00018 { 00019 int orig_amode_wronly; 00020 00021 /* if we are doing deferred open, non-aggregators should return now */ 00022 if (fd->hints->deferred_open ) { 00023 if (fd->agg_comm == MPI_COMM_NULL) { 00024 *error_code = MPI_SUCCESS; 00025 return; 00026 } 00027 } 00028 00029 /* For writing with data sieving, a read-modify-write is needed. If 00030 the file is opened for write_only, the read will fail. Therefore, 00031 if write_only, open the file as read_write, but record it as 00032 write_only in fd, so that get_amode returns the right answer. */ 00033 00034 orig_amode_wronly = access_mode; 00035 if (access_mode & ADIO_WRONLY) { 00036 access_mode = access_mode ^ ADIO_WRONLY; 00037 access_mode = access_mode | ADIO_RDWR; 00038 } 00039 fd->access_mode = access_mode; 00040 00041 (*(fd->fns->ADIOI_xxx_Open))(fd, error_code); 00042 00043 /* if error, may be it was due to the change in amode above. 00044 therefore, reopen with access mode provided by the user.*/ 00045 fd->access_mode = orig_amode_wronly; 00046 if (*error_code != MPI_SUCCESS) 00047 (*(fd->fns->ADIOI_xxx_Open))(fd, error_code); 00048 00049 /* for deferred open: this process has opened the file (because if we are 00050 * not an aggregaor and we are doing deferred open, we returned earlier)*/ 00051 fd->is_open = 1; 00052 00053 } 00054 00055 /* 00056 * vim: ts=8 sts=4 sw=4 noexpandtab 00057 */