00001
00002
00003
00009
00010
00011
00012
00013
00014
00015 #include "ad_bgl.h"
00016
00017
00018
00019
00020
00021
00022 void ADIOI_BGL_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
00023 int *error_code)
00024 {
00025 ADIO_Offset new_fp;
00026 int err;
00027 MPI_Comm dupcommself;
00028 static char myname[] = "ADIOI_BGL_GET_SHARED_FP";
00029
00030 if (fd->shared_fp_fd == ADIO_FILE_NULL) {
00031 MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
00032 fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF,
00033 dupcommself,
00034 fd->shared_fp_fname,
00035 fd->file_system,
00036 fd->fns,
00037 ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
00038 0,
00039 MPI_BYTE,
00040 MPI_BYTE,
00041 MPI_INFO_NULL,
00042 ADIO_PERM_NULL,
00043 error_code);
00044 if (*error_code != MPI_SUCCESS) return;
00045 *shared_fp = 0;
00046 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00047 err = read(fd->shared_fp_fd->fd_sys, shared_fp, sizeof(ADIO_Offset));
00048
00049
00050
00051 }
00052 else {
00053 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00054
00055 err = lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
00056 if (err == 0) {
00057 err = read(fd->shared_fp_fd->fd_sys, shared_fp,
00058 sizeof(ADIO_Offset));
00059 }
00060 if (err == -1) {
00061 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00062 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00063 MPIR_ERR_RECOVERABLE, myname,
00064 __LINE__, MPI_ERR_IO, "**io",
00065 "**io %s", strerror(errno));
00066 return;
00067 }
00068 }
00069
00070 new_fp = *shared_fp + incr;
00071
00072 err = lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
00073 if (err == 0) {
00074 err = write(fd->shared_fp_fd->fd_sys, &new_fp, sizeof(ADIO_Offset));
00075 }
00076 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00077 if (err == -1) {
00078 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00079 myname, __LINE__, MPI_ERR_IO,
00080 "**io",
00081 "**io %s", strerror(errno));
00082 }
00083 else *error_code = MPI_SUCCESS;
00084 }