00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_hfs.h"
00009
00010 #ifndef HAVE_LSEEK64
00011 #define lseek64 lseek
00012 #endif
00013
00014 void ADIOI_HFS_ReadContig(ADIO_File fd, void *buf, int count,
00015 MPI_Datatype datatype, int file_ptr_type,
00016 ADIO_Offset offset, ADIO_Status *status, int *error_code)
00017 {
00018 int err=-1, datatype_size, len;
00019 #ifndef PRINT_ERR_MSG
00020 static char myname[] = "ADIOI_HFS_READCONTIG";
00021 #endif
00022
00023 MPI_Type_size(datatype, &datatype_size);
00024 len = datatype_size * count;
00025
00026 #ifdef SPPUX
00027 fd->fp_sys_posn = -1;
00028
00029 if (file_ptr_type == ADIO_EXPLICIT_OFFSET)
00030 err = pread64(fd->fd_sys, buf, len, offset);
00031 else {
00032 err = pread64(fd->fd_sys, buf, len, fd->fp_ind);
00033 fd->fp_ind += err;
00034 }
00035 #endif
00036
00037 #ifdef HPUX
00038 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00039 if (fd->fp_sys_posn != offset)
00040 lseek64(fd->fd_sys, offset, SEEK_SET);
00041 err = read(fd->fd_sys, buf, len);
00042 fd->fp_sys_posn = offset + err;
00043
00044 }
00045 else {
00046 if (fd->fp_sys_posn != fd->fp_ind)
00047 lseek64(fd->fd_sys, fd->fp_ind, SEEK_SET);
00048 err = read(fd->fd_sys, buf, len);
00049 fd->fp_ind += err;
00050 fd->fp_sys_posn = fd->fp_ind;
00051 }
00052 #endif
00053
00054 #ifdef HAVE_STATUS_SET_BYTES
00055 if (err != -1) MPIR_Status_set_bytes(status, datatype, err);
00056 #endif
00057
00058 if (err == -1 ) {
00059 #ifdef MPICH2
00060 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
00061 "**io %s", strerror(errno));
00062 #elif defined(PRINT_ERR_MSG)
00063 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00064 #else
00065 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00066 myname, "I/O Error", "%s", strerror(errno));
00067 ADIOI_Error(fd, *error_code, myname);
00068 #endif
00069 }
00070 else *error_code = MPI_SUCCESS;
00071 }