diff --git a/ompi/mca/common/ompio/common_ompio_file_read.c b/ompi/mca/common/ompio/common_ompio_file_read.c index 6d6d112eb3..3203e2a697 100644 --- a/ompi/mca/common/ompio/common_ompio_file_read.c +++ b/ompi/mca/common/ompio/common_ompio_file_read.c @@ -77,6 +77,12 @@ int mca_common_ompio_file_read (ompio_file_t *fh, int i = 0; /* index into the decoded iovec of the buffer */ int j = 0; /* index into the file vie iovec */ + if (fh->f_amode & MPI_MODE_WRONLY){ +// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n"); + ret = MPI_ERR_ACCESS; + return ret; + } + if ( 0 == count ) { if ( MPI_STATUS_IGNORE != status ) { status->_ucount = 0; @@ -84,11 +90,6 @@ int mca_common_ompio_file_read (ompio_file_t *fh, return ret; } - if (fh->f_amode & MPI_MODE_WRONLY){ - printf("Improper use of FILE Mode, Using WRONLY for Read!\n"); - ret = OMPI_ERROR; - return ret; - } #if OPAL_CUDA_SUPPORT int is_gpu, is_managed; @@ -226,6 +227,12 @@ int mca_common_ompio_file_iread (ompio_file_t *fh, mca_ompio_request_t *ompio_req=NULL; size_t spc=0; + if (fh->f_amode & MPI_MODE_WRONLY){ +// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n"); + ret = MPI_ERR_ACCESS; + return ret; + } + mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_READ); if ( 0 == count ) { diff --git a/ompi/mca/common/ompio/common_ompio_file_write.c b/ompi/mca/common/ompio/common_ompio_file_write.c index fb62edf2d9..e53a1d080b 100644 --- a/ompi/mca/common/ompio/common_ompio_file_write.c +++ b/ompi/mca/common/ompio/common_ompio_file_write.c @@ -58,6 +58,13 @@ int mca_common_ompio_file_write (ompio_file_t *fh, int i = 0; /* index into the decoded iovec of the buffer */ int j = 0; /* index into the file view iovec */ + if (fh->f_amode & MPI_MODE_RDONLY){ +// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n"); + ret = MPI_ERR_READ_ONLY; + return ret; + } + + if ( 0 == count ) { if ( MPI_STATUS_IGNORE != status ) { status->_ucount = 0; @@ -194,6 +201,12 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh, mca_ompio_request_t *ompio_req=NULL; size_t spc=0; + if (fh->f_amode & MPI_MODE_RDONLY){ +// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n"); + ret = MPI_ERR_READ_ONLY; + return ret; + } + mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_WRITE); if ( 0 == count ) {