00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "ad_nfs.h"
00010
00011
00012
00013
00014 void ADIOI_NFS_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code)
00015 {
00016 int err;
00017 MPI_Comm dupcommself;
00018 #ifndef PRINT_ERR_MSG
00019 static char myname[] = "ADIOI_NFS_SET_SHARED_FP";
00020 #endif
00021
00022 if (fd->shared_fp_fd == ADIO_FILE_NULL) {
00023 MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
00024 fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF, dupcommself, fd->shared_fp_fname,
00025 fd->file_system, ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
00026 0, MPI_BYTE, MPI_BYTE, M_ASYNC, MPI_INFO_NULL,
00027 ADIO_PERM_NULL, error_code);
00028 }
00029
00030 if (*error_code != MPI_SUCCESS) return;
00031
00032 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00033 lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
00034 err = write(fd->shared_fp_fd->fd_sys, &offset, sizeof(ADIO_Offset));
00035 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00036
00037 #ifdef PRINT_ERR_MSG
00038 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00039 #else
00040 if (err == -1) {
00041 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00042 myname, "I/O Error", "%s", strerror(errno));
00043 ADIOI_Error(fd, *error_code, myname);
00044 }
00045 else *error_code = MPI_SUCCESS;
00046 #endif
00047 }
00048