00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_pfs.h"
00009
00010 void ADIOI_PFS_IwriteContig(ADIO_File fd, void *buf, int count,
00011 MPI_Datatype datatype, int file_ptr_type,
00012 ADIO_Offset offset, ADIO_Request *request, int *error_code)
00013 {
00014 long *id_sys;
00015 ADIO_Offset off;
00016 int len, typesize, err;
00017 static char myname[] = "ADIOI_PFS_IWRITECONTIG";
00018
00019 *request = ADIOI_Malloc_request();
00020 (*request)->optype = ADIOI_WRITE;
00021 (*request)->fd = fd;
00022 (*request)->datatype = datatype;
00023
00024 MPI_Type_size(datatype, &typesize);
00025 len = count * typesize;
00026
00027 id_sys = (long *) ADIOI_Malloc(sizeof(long));
00028 (*request)->handle = (void *) id_sys;
00029
00030 off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind : offset;
00031
00032 lseek(fd->fd_sys, off, SEEK_SET);
00033 *id_sys = _iwrite(fd->fd_sys, buf, len);
00034
00035 if ((*id_sys == -1) && (errno == EQNOMID)) {
00036
00037
00038
00039
00040
00041 ADIOI_Complete_async(error_code);
00042 if (error_code != MPI_SUCCESS) return;
00043
00044
00045 *id_sys = _iwrite(fd->fd_sys, buf, len);
00046
00047 if ((*id_sys == -1) && (errno == EQNOMID)) {
00048 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00049 MPIR_ERR_RECOVERABLE, myname,
00050 __LINE__, MPI_ERR_IO, "**io",
00051 "**io %s", strerror(errno));
00052 return;
00053 }
00054 }
00055 else if (*id_sys == -1) {
00056 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00057 myname, __LINE__, MPI_ERR_IO,
00058 "**io",
00059 "**io %s", strerror(errno));
00060 return;
00061 }
00062
00063 if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind += len;
00064
00065 (*request)->queued = 1;
00066 (*request)->nbytes = len;
00067 ADIOI_Add_req_to_list(request);
00068 fd->async_count++;
00069
00070 fd->fp_sys_posn = -1;
00071
00072 if (*id_sys == -1) {
00073 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00074 myname, __LINE__, MPI_ERR_IO,
00075 "**io",
00076 "**io %s", strerror(errno));
00077 }
00078 else *error_code = MPI_SUCCESS;
00079 }