00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "mpioimpl.h"
00010
00011 #ifdef HAVE_WEAK_SYMBOLS
00012
00013 #if defined(HAVE_PRAGMA_WEAK)
00014 #pragma weak MPI_File_set_atomicity = PMPI_File_set_atomicity
00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00016 #pragma _HP_SECONDARY_DEF PMPI_File_set_atomicity MPI_File_set_atomicity
00017 #elif defined(HAVE_PRAGMA_CRI_DUP)
00018 #pragma _CRI duplicate MPI_File_set_atomicity as PMPI_File_set_atomicity
00019
00020 #endif
00021
00022
00023 #define MPIO_BUILD_PROFILING
00024 #include "mpioprof.h"
00025 #endif
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 int MPI_File_set_atomicity(MPI_File fh, int flag)
00037 {
00038 int error_code, tmp_flag;
00039 #ifndef PRINT_ERR_MSG
00040 static char myname[] = "MPI_FILE_SET_ATOMICITY";
00041 #endif
00042 ADIO_Fcntl_t *fcntl_struct;
00043
00044 #ifdef PRINT_ERR_MSG
00045 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) {
00046 FPRINTF(stderr, "MPI_File_set_atomicity: Invalid file handle\n");
00047 MPI_Abort(MPI_COMM_WORLD, 1);
00048 }
00049 #else
00050 ADIOI_TEST_FILE_HANDLE(fh, myname);
00051 #endif
00052
00053 if (flag) flag = 1;
00054
00055
00056 tmp_flag = flag;
00057 MPI_Bcast(&tmp_flag, 1, MPI_INT, 0, fh->comm);
00058 if (tmp_flag != flag) {
00059 #ifdef PRINT_ERR_MSG
00060 FPRINTF(stderr, "MPI_File_set_atomicity: flag must be the same on all processes\n");
00061 MPI_Abort(MPI_COMM_WORLD, 1);
00062 #else
00063 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_FLAG_ARG,
00064 myname, (char *) 0, (char *) 0);
00065 return ADIOI_Error(fh, error_code, myname);
00066 #endif
00067 }
00068
00069 if (fh->atomicity == flag) return MPI_SUCCESS;
00070
00071 fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
00072 fcntl_struct->atomicity = flag;
00073 ADIO_Fcntl(fh, ADIO_FCNTL_SET_ATOMICITY, fcntl_struct, &error_code);
00074 ADIOI_Free(fcntl_struct);
00075
00076 return error_code;
00077 }