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