00001
00002
00003
00004
00005
00006
00007 #include "adio.h"
00008
00009
00010
00011
00012
00013
00014 void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
00015 int *error_code);
00016
00017 void ADIO_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
00018 int *error_code)
00019 {
00020 ADIO_Status status;
00021 ADIO_Offset new_fp;
00022 MPI_Comm dupcommself;
00023
00024 #ifdef ROMIO_NFS
00025 if (fd->file_system == ADIO_NFS) {
00026 ADIOI_NFS_Get_shared_fp(fd, incr, shared_fp, error_code);
00027 return;
00028 }
00029 #endif
00030
00031 #ifdef ROMIO_BGL
00032
00033 if (fd->file_system == ADIO_BGL) {
00034 ADIOI_BGL_Get_shared_fp(fd, incr, shared_fp, error_code);
00035 return;
00036 }
00037 #endif
00038
00039 if (fd->shared_fp_fd == ADIO_FILE_NULL) {
00040 MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
00041 fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF, dupcommself,
00042 fd->shared_fp_fname,
00043 fd->file_system,
00044 fd->fns,
00045 ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
00046 0, MPI_BYTE, MPI_BYTE,
00047 MPI_INFO_NULL,
00048 ADIO_PERM_NULL, error_code);
00049 if (*error_code != MPI_SUCCESS) return;
00050 *shared_fp = 0;
00051 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00052 ADIO_ReadContig(fd->shared_fp_fd, shared_fp, sizeof(ADIO_Offset),
00053 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00054
00055
00056
00057 }
00058 else {
00059 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00060 ADIO_ReadContig(fd->shared_fp_fd, shared_fp, sizeof(ADIO_Offset),
00061 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00062 if (*error_code != MPI_SUCCESS) {
00063 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00064 return;
00065 }
00066 }
00067
00068 if (incr == 0) {goto done;}
00069
00070 new_fp = *shared_fp + incr;
00071
00072 ADIO_WriteContig(fd->shared_fp_fd, &new_fp, sizeof(ADIO_Offset),
00073 MPI_BYTE, ADIO_EXPLICIT_OFFSET, 0, &status, error_code);
00074 done:
00075 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00076 }