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