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

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PFS_IwriteContig

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

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