00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009
00010
00011
00012
00013
00014
00015 void ADIOI_FAILSAFE_OpenColl(ADIO_File fd, int rank,
00016 int access_mode, int *error_code)
00017 {
00018 int orig_amode_excl, orig_amode_wronly;
00019
00020 orig_amode_excl = access_mode;
00021 if ((access_mode & ADIO_CREATE) && (access_mode & ADIO_EXCL)) {
00022
00023
00024
00025
00026 if(rank == fd->hints->ranklist[0]) {
00027 fd->access_mode = access_mode;
00028 (*(fd->fns->ADIOI_xxx_Open))(fd, error_code);
00029 MPI_Bcast(error_code, 1, MPI_INT, \
00030 fd->hints->ranklist[0], fd->comm);
00031
00032 if (*error_code == MPI_SUCCESS)
00033 (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
00034 }
00035 else MPI_Bcast(error_code, 1, MPI_INT,
00036 fd->hints->ranklist[0], fd->comm);
00037 if (*error_code != MPI_SUCCESS) {
00038 return;
00039 }
00040 else {
00041
00042 access_mode = access_mode ^ ADIO_EXCL;
00043 }
00044 }
00045
00046 if (fd->hints->deferred_open ) {
00047 if (fd->agg_comm == MPI_COMM_NULL) {
00048
00049
00050
00051 fd->access_mode = orig_amode_excl;
00052 *error_code = MPI_SUCCESS;
00053 return;
00054 }
00055 }
00056
00057
00058
00059
00060
00061
00062 orig_amode_wronly = access_mode;
00063 if (access_mode & ADIO_WRONLY) {
00064 access_mode = access_mode ^ ADIO_WRONLY;
00065 access_mode = access_mode | ADIO_RDWR;
00066 }
00067 fd->access_mode = access_mode;
00068
00069 (*(fd->fns->ADIOI_xxx_Open))(fd, error_code);
00070
00071
00072
00073 fd->access_mode = orig_amode_wronly;
00074 if (*error_code != MPI_SUCCESS)
00075 (*(fd->fns->ADIOI_xxx_Open))(fd, error_code);
00076
00077
00078 if (fd->access_mode != orig_amode_excl) fd->access_mode = orig_amode_excl;
00079
00080
00081
00082 fd->is_open = 1;
00083 }
00084
00085
00086
00087
00088
00089