root/ompi/mca/io/romio321/romio/adio/ad_pfs/ad_pfs_iread.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PFS_IreadContig

   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_pfs.h"
   9 
  10 void ADIOI_PFS_IreadContig(ADIO_File fd, void *buf, int count, 
  11                            MPI_Datatype datatype, int file_ptr_type,
  12                            ADIO_Offset offset, ADIO_Request *request,
  13                            int *error_code)
  14 {
  15     long *id_sys;
  16     int err=-1;
  17     MPI_Count len, typesize;
  18     ADIO_Offset off;
  19     static char myname[] = "ADIOI_PFS_IREADCONTIG";
  20 
  21     *request = ADIOI_Malloc_request();
  22     (*request)->optype = ADIOI_READ;
  23     (*request)->fd = fd;
  24     (*request)->datatype = datatype;
  25 
  26     MPI_Type_size_x(datatype, &typesize);
  27     len = count * typesize;
  28 
  29     id_sys = (long *) ADIOI_Malloc(sizeof(long));
  30     (*request)->handle = (void *) id_sys;
  31 
  32     off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind : offset;
  33 
  34     lseek(fd->fd_sys, off, SEEK_SET);
  35     *id_sys = _iread(fd->fd_sys, buf, len);
  36 
  37     if ((*id_sys == -1) && (errno == EQNOMID)) {
  38      /* the man pages say EMREQUEST, but in reality errno is set to EQNOMID! */
  39 
  40         /* exceeded the max. no. of outstanding requests. */
  41 
  42         /* complete all previous async. requests */
  43         /*ADIOI_Complete_async(error_code); */
  44         if (*error_code != MPI_SUCCESS) return;
  45 
  46         /* try again */
  47         *id_sys = _iread(fd->fd_sys, buf, len);
  48 
  49         if ((*id_sys == -1) && (errno == EQNOMID)) {
  50             *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  51                                                MPIR_ERR_RECOVERABLE, myname,
  52                                                __LINE__, MPI_ERR_IO, "**io",
  53                                                "**io %s", strerror(errno));
  54             return;
  55         }
  56     }
  57     else if (*id_sys == -1) {
  58         *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  59                                            myname, __LINE__, MPI_ERR_IO,
  60                                            "**io",
  61                                            "**io %s", strerror(errno));
  62         return;
  63     }
  64 
  65     if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind += len; 
  66 
  67     (*request)->queued = 1;
  68     (*request)->nbytes = len;
  69     ADIOI_Add_req_to_list(request);
  70     fd->async_count++;
  71 
  72     fd->fp_sys_posn = -1;   /* set it to null. */
  73 
  74     if (*id_sys == -1) {
  75         *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  76                                            myname, __LINE__, MPI_ERR_IO,
  77                                            "**io",
  78                                            "**io %s", strerror(errno));
  79     }
  80     else *error_code = MPI_SUCCESS;
  81 }

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