00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_nfs.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 void ADIOI_NFS_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code)
00032 {
00033 int err;
00034 MPI_Comm dupcommself;
00035 static char myname[] = "ADIOI_NFS_SET_SHARED_FP";
00036
00037 if (fd->shared_fp_fd == ADIO_FILE_NULL) {
00038 MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
00039 fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF, dupcommself,
00040 fd->shared_fp_fname,
00041 fd->file_system, fd->fns,
00042 ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
00043 0, MPI_BYTE, MPI_BYTE, MPI_INFO_NULL,
00044 ADIO_PERM_NULL, error_code);
00045 }
00046
00047 if (*error_code != MPI_SUCCESS) return;
00048
00049 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00050 #ifdef ADIOI_MPE_LOGGING
00051 MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
00052 #endif
00053 lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
00054 #ifdef ADIOI_MPE_LOGGING
00055 MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
00056 #endif
00057 #ifdef ADIOI_MPE_LOGGING
00058 MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
00059 #endif
00060 err = write(fd->shared_fp_fd->fd_sys, &offset, sizeof(ADIO_Offset));
00061 #ifdef ADIOI_MPE_LOGGING
00062 MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
00063 #endif
00064 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
00065
00066 if (err == -1) {
00067 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00068 myname, __LINE__, MPI_ERR_IO,
00069 "**io",
00070 "**io %s", strerror(errno));
00071 }
00072 else *error_code = MPI_SUCCESS;
00073 }
00074