@@ -114,7 +114,6 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
114114 /* No need to duplicate the communicator if the file_open is called
115115 from the sharedfp component, since the comm used as an input
116116 is already a dup of the user level comm. */
117- ompio_fh -> f_flags |= OMPIO_SHAREDFP_IS_SET ;
118117 ompio_fh -> f_comm = comm ;
119118 }
120119
@@ -195,26 +194,9 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
195194 ** function will return an error code.
196195 */
197196 }
198-
199- /* open the file once more for the shared file pointer if required.
200- ** Can be disabled by the user if no shared file pointer operations
201- ** are used by his application.
202- */
203- if ( NULL != ompio_fh -> f_sharedfp &&
204- true == use_sharedfp &&
205- (!mca_io_ompio_sharedfp_lazy_open ||
206- !strcmp (ompio_fh -> f_sharedfp_component -> mca_component_name ,
207- "addproc" ) )) {
208- ret = ompio_fh -> f_sharedfp -> sharedfp_file_open (comm ,
209- filename ,
210- amode ,
211- info ,
212- ompio_fh );
213-
214- if ( OMPI_SUCCESS != ret ) {
215- goto fn_fail ;
216- }
217- }
197+ }
198+ else {
199+ ompio_fh -> f_flags |= OMPIO_SHAREDFP_IS_SET ;
218200 }
219201
220202 /*Determine topology information if set*/
@@ -231,15 +213,31 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
231213 info ,
232214 ompio_fh );
233215
234-
235-
236-
237216 if ( OMPI_SUCCESS != ret ) {
238217 ret = MPI_ERR_FILE ;
239218 goto fn_fail ;
240219 }
241220
242221
222+ if ( true == use_sharedfp ) {
223+ /* open the file once more for the shared file pointer if required.
224+ ** Can be disabled by the user if no shared file pointer operations
225+ ** are used by his application.
226+ */
227+ if ( NULL != ompio_fh -> f_sharedfp &&
228+ !mca_io_ompio_sharedfp_lazy_open ) {
229+ ret = ompio_fh -> f_sharedfp -> sharedfp_file_open (comm ,
230+ filename ,
231+ amode ,
232+ info ,
233+ ompio_fh );
234+
235+ if ( OMPI_SUCCESS != ret ) {
236+ goto fn_fail ;
237+ }
238+ }
239+ }
240+
243241 /* If file has been opened in the append mode, move the internal
244242 file pointer of OMPIO to the very end of the file. */
245243 if ( ompio_fh -> f_amode & MPI_MODE_APPEND ) {
@@ -251,16 +249,14 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
251249 ompi_io_ompio_set_explicit_offset (ompio_fh , current_size );
252250 if ( true == use_sharedfp ) {
253251 if ( NULL != ompio_fh -> f_sharedfp &&
254- (!mca_io_ompio_sharedfp_lazy_open ||
255- !strcmp (ompio_fh -> f_sharedfp_component -> mca_component_name ,
256- "addproc" ) )) {
252+ !mca_io_ompio_sharedfp_lazy_open ) {
257253
258254 shared_fp_base_module = ompio_fh -> f_sharedfp ;
259255 ret = shared_fp_base_module -> sharedfp_seek (ompio_fh ,current_size , MPI_SEEK_SET );
260256 }
261257 else {
262258 opal_output (1 , "mca_common_ompio_file_open: Could not adjust position of "
263- "shared file pointer whith MPI_MODE_APPEND\n" );
259+ "shared file pointer with MPI_MODE_APPEND\n" );
264260 ret = MPI_ERR_OTHER ;
265261 goto fn_fail ;
266262 }
@@ -412,7 +408,7 @@ ompio_io_ompio_file_close (mca_io_ompio_file_t *ompio_fh)
412408 }
413409
414410
415- if (MPI_COMM_NULL != ompio_fh -> f_comm && (ompio_fh -> f_flags & OMPIO_SHAREDFP_IS_SET ) ) {
411+ if (MPI_COMM_NULL != ompio_fh -> f_comm && ! (ompio_fh -> f_flags & OMPIO_SHAREDFP_IS_SET ) ) {
416412 ompi_comm_free (& ompio_fh -> f_comm );
417413 }
418414
0 commit comments