00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_panfs.h"
00009
00010 #ifdef HAVE_UNISTD_H
00011 #include <unistd.h>
00012 #endif
00013
00014 void ADIOI_PANFS_WriteContig(ADIO_File fd, void *buf, int count,
00015 MPI_Datatype datatype, int file_ptr_type,
00016 ADIO_Offset offset, ADIO_Status *status,
00017 int *error_code)
00018 {
00019 int err = -1, datatype_size, len;
00020 static char myname[] = "ADIOI_PANFS_WRITECONTIG";
00021
00022 MPI_Type_size(datatype, &datatype_size);
00023 len = datatype_size * count;
00024
00025 if (file_ptr_type == ADIO_INDIVIDUAL) {
00026 offset = fd->fp_ind;
00027 }
00028
00029 if (fd->fp_sys_posn != offset) {
00030 err = lseek(fd->fd_sys, offset, SEEK_SET);
00031
00032 if (err == -1) {
00033 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00034 MPIR_ERR_RECOVERABLE,
00035 myname, __LINE__,
00036 MPI_ERR_IO, "**io",
00037 "**io %s", strerror(errno));
00038 fd->fp_sys_posn = -1;
00039 return;
00040 }
00041
00042 }
00043
00044 AD_PANFS_RETRY(write(fd->fd_sys, buf, len),err)
00045
00046 if (err == -1) {
00047 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00048 MPIR_ERR_RECOVERABLE,
00049 myname, __LINE__,
00050 MPI_ERR_IO, "**io",
00051 "**io %s", strerror(errno));
00052 fd->fp_sys_posn = -1;
00053 return;
00054 }
00055
00056
00057 fd->fp_sys_posn = offset + err;
00058
00059 if (file_ptr_type == ADIO_INDIVIDUAL) {
00060 fd->fp_ind += err;
00061 }
00062
00063 #ifdef HAVE_STATUS_SET_BYTES
00064 if (err != -1 && status) MPIR_Status_set_bytes(status, datatype, err);
00065 #endif
00066
00067 *error_code = MPI_SUCCESS;
00068 }