00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "mpioimpl.h"
00009 
00010 #ifdef HAVE_WEAK_SYMBOLS
00011 
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_File_set_atomicity = PMPI_File_set_atomicity
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_set_atomicity MPI_File_set_atomicity
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_set_atomicity as PMPI_File_set_atomicity
00018 
00019 #endif
00020 
00021 
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 int MPI_File_set_atomicity(MPI_File mpi_fh, int flag)
00036 {
00037     int error_code, tmp_flag;
00038     static char myname[] = "MPI_FILE_SET_ATOMICITY";
00039     ADIO_Fcntl_t *fcntl_struct;
00040     ADIO_File fh;
00041 
00042     MPIU_THREAD_CS_ENTER(ALLFUNC,);
00043 
00044     fh = MPIO_File_resolve(mpi_fh);
00045 
00046     
00047     MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00048     
00049 
00050     ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00051 
00052     if (flag) flag = 1;  
00053 
00054 
00055     tmp_flag = flag;
00056     MPI_Bcast(&tmp_flag, 1, MPI_INT, 0, fh->comm);
00057 
00058     
00059     if (tmp_flag != flag) {
00060     error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00061                       myname, __LINE__, MPI_ERR_ARG, 
00062                       "**notsame", 0);
00063     error_code = MPIO_Err_return_file(fh, error_code);
00064     goto fn_exit;
00065     }
00066     
00067 
00068     if (fh->atomicity == flag){
00069         error_code = MPI_SUCCESS;
00070         goto fn_exit;
00071     }
00072 
00073 
00074     fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
00075     fcntl_struct->atomicity = flag;
00076     ADIO_Fcntl(fh, ADIO_FCNTL_SET_ATOMICITY, fcntl_struct, &error_code);
00077     
00078 
00079     
00080     if (error_code != MPI_SUCCESS)
00081     error_code = MPIO_Err_return_file(fh, error_code);
00082     
00083 
00084     ADIOI_Free(fcntl_struct);
00085 
00086 fn_exit:
00087     MPIU_THREAD_CS_EXIT(ALLFUNC,);
00088     return error_code;
00089 }