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