root/ompi/mca/io/romio321/romio/adio/ad_hfs/ad_hfs_read.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_HFS_ReadContig

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "ad_hfs.h"
   9 
  10 #ifndef HAVE_LSEEK64
  11 #define lseek64 lseek
  12 #endif
  13 
  14 void ADIOI_HFS_ReadContig(ADIO_File fd, void *buf, int count, 
  15                      MPI_Datatype datatype, int file_ptr_type,
  16                      ADIO_Offset offset, ADIO_Status *status, int *error_code)
  17 {
  18     MPI_Count err=-1, datatype_size, len;
  19 #ifndef PRINT_ERR_MSG
  20     static char myname[] = "ADIOI_HFS_READCONTIG";
  21 #endif
  22 
  23     MPI_Type_size_x(datatype, &datatype_size);
  24     len = datatype_size * count;
  25 
  26 #ifdef SPPUX
  27     fd->fp_sys_posn = -1; /* set it to null, since we are using pread */
  28 
  29     if (file_ptr_type == ADIO_EXPLICIT_OFFSET) 
  30         err = pread64(fd->fd_sys, buf, len, offset);
  31     else {    /* read from curr. location of ind. file pointer */
  32         err = pread64(fd->fd_sys, buf, len, fd->fp_ind);
  33         fd->fp_ind += err;
  34     }
  35 #endif
  36 
  37 #ifdef HPUX
  38     if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
  39         if (fd->fp_sys_posn != offset)
  40             lseek64(fd->fd_sys, offset, SEEK_SET);
  41         err = read(fd->fd_sys, buf, len);
  42         fd->fp_sys_posn = offset + err;
  43         /* individual file pointer not updated */        
  44     }
  45     else {  /* read from curr. location of ind. file pointer */
  46         if (fd->fp_sys_posn != fd->fp_ind)
  47             lseek64(fd->fd_sys, fd->fp_ind, SEEK_SET);
  48         err = read(fd->fd_sys, buf, len);
  49         fd->fp_ind += err; 
  50         fd->fp_sys_posn = fd->fp_ind;
  51     }         
  52 #endif
  53 
  54 #ifdef HAVE_STATUS_SET_BYTES
  55     if (err != -1) MPIR_Status_set_bytes(status, datatype, err);
  56 #endif
  57 
  58         if (err == -1 ) {
  59 #ifdef MPICH
  60             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  61                 "**io %s", strerror(errno));
  62 #elif defined(PRINT_ERR_MSG)
  63             *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
  64 #else /* MPICH-1 */
  65         *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  66                               myname, "I/O Error", "%s", strerror(errno));
  67         ADIOI_Error(fd, *error_code, myname);       
  68 #endif
  69     }
  70     else *error_code = MPI_SUCCESS;
  71 }

/* [<][>][^][v][top][bottom][index][help] */