00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "adio.h"
00010
00011
00012
00013
00014
00015
00016 void ADIO_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
00017 int *error_code)
00018 {
00019 ADIO_Status status;
00020 ADIO_Offset new_fp;
00021 MPI_Comm dupcommself;
00022
00023 #ifdef NFS
00024 if (fd->file_system == ADIO_NFS) {
00025 ADIOI_NFS_Get_shared_fp(fd, incr, shared_fp, error_code);
00026 return;
00027 }
00028 #endif
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, dupcommself,
00033 fd->shared_fp_fname,
00034 fd->file_system,
00035 ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
00036 0, MPI_BYTE, MPI_BYTE, M_ASYNC,
00037 MPI_INFO_NULL,
00038 ADIO_PERM_NULL, error_code);
00039 if (*error_code != MPI_SUCCESS) return;
00040 *shared_fp = 0;
00041 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00042 ADIO_ReadContig(fd->shared_fp_fd, shared_fp, sizeof(ADIO_Offset),
00043 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00044
00045
00046
00047 }
00048 else {
00049 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00050 ADIO_ReadContig(fd->shared_fp_fd, shared_fp, sizeof(ADIO_Offset),
00051 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00052 if (*error_code != MPI_SUCCESS) {
00053 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00054 return;
00055 }
00056 }
00057
00058 new_fp = *shared_fp + incr;
00059
00060 ADIO_WriteContig(fd->shared_fp_fd, &new_fp, sizeof(ADIO_Offset),
00061 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00062 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00063 }