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