00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_pfs.h"
00009
00010 void ADIOI_PFS_WriteContig(ADIO_File fd, void *buf, int count,
00011 MPI_Datatype datatype, int file_ptr_type,
00012 ADIO_Offset offset, ADIO_Status *status,
00013 int *error_code)
00014 {
00015 int err=-1, datatype_size, len;
00016 static char myname[] = "ADIOI_PFS_WRITECONTIG";
00017
00018 MPI_Type_size(datatype, &datatype_size);
00019 len = datatype_size * count;
00020
00021 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00022 if (fd->fp_sys_posn != offset) {
00023 lseek(fd->fd_sys, offset, SEEK_SET);
00024 }
00025 err = _cwrite(fd->fd_sys, buf, len);
00026 fd->fp_sys_posn = offset + err;
00027
00028 }
00029 else {
00030 if (fd->fp_sys_posn != fd->fp_ind) {
00031 lseek(fd->fd_sys, fd->fp_ind, SEEK_SET);
00032 }
00033 err = _cwrite(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) MPIR_Status_set_bytes(status, datatype, err);
00040 #endif
00041
00042 if (err == -1) {
00043 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00044 myname, __LINE__, MPI_ERR_IO,
00045 "**io",
00046 "**io %s", strerror(errno));
00047 }
00048 else *error_code = MPI_SUCCESS;
00049 }