@@ -82,7 +82,6 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
82
82
/* No need to duplicate the communicator if the file_open is called
83
83
from the sharedfp component, since the comm used as an input
84
84
is already a dup of the user level comm. */
85
- ompio_fh -> f_flags |= OMPIO_SHAREDFP_IS_SET ;
86
85
ompio_fh -> f_comm = comm ;
87
86
}
88
87
@@ -149,26 +148,9 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
149
148
** function will return an error code.
150
149
*/
151
150
}
152
-
153
- /* open the file once more for the shared file pointer if required.
154
- ** Can be disabled by the user if no shared file pointer operations
155
- ** are used by his application.
156
- */
157
- if ( NULL != ompio_fh -> f_sharedfp &&
158
- true == use_sharedfp &&
159
- (!mca_io_ompio_sharedfp_lazy_open ||
160
- !strcmp (ompio_fh -> f_sharedfp_component -> mca_component_name ,
161
- "addproc" ) )) {
162
- ret = ompio_fh -> f_sharedfp -> sharedfp_file_open (comm ,
163
- filename ,
164
- amode ,
165
- info ,
166
- ompio_fh );
167
-
168
- if ( OMPI_SUCCESS != ret ) {
169
- goto fn_fail ;
170
- }
171
- }
151
+ }
152
+ else {
153
+ ompio_fh -> f_flags |= OMPIO_SHAREDFP_IS_SET ;
172
154
}
173
155
174
156
/*Determine topology information if set*/
@@ -185,15 +167,32 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
185
167
info ,
186
168
ompio_fh );
187
169
188
-
189
-
190
-
191
170
if ( OMPI_SUCCESS != ret ) {
192
171
ret = MPI_ERR_FILE ;
193
172
goto fn_fail ;
194
173
}
195
174
196
175
176
+ if ( true == use_sharedfp ) {
177
+ /* open the file once more for the shared file pointer if required.
178
+ ** Can be disabled by the user if no shared file pointer operations
179
+ ** are used by his application.
180
+ */
181
+ if ( NULL != ompio_fh -> f_sharedfp &&
182
+ !mca_io_ompio_sharedfp_lazy_open ) {
183
+ ret = ompio_fh -> f_sharedfp -> sharedfp_file_open (comm ,
184
+ filename ,
185
+ amode ,
186
+ info ,
187
+ ompio_fh );
188
+
189
+ if ( OMPI_SUCCESS != ret ) {
190
+ goto fn_fail ;
191
+ }
192
+ }
193
+ }
194
+
195
+
197
196
/* If file has been opened in the append mode, move the internal
198
197
file pointer of OMPIO to the very end of the file. */
199
198
if ( ompio_fh -> f_amode & MPI_MODE_APPEND ) {
@@ -205,16 +204,13 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
205
204
mca_common_ompio_set_explicit_offset (ompio_fh , current_size );
206
205
if ( true == use_sharedfp ) {
207
206
if ( NULL != ompio_fh -> f_sharedfp &&
208
- (!mca_io_ompio_sharedfp_lazy_open ||
209
- !strcmp (ompio_fh -> f_sharedfp_component -> mca_component_name ,
210
- "addproc" ) )) {
211
-
207
+ !mca_io_ompio_sharedfp_lazy_open ) {
212
208
shared_fp_base_module = ompio_fh -> f_sharedfp ;
213
209
ret = shared_fp_base_module -> sharedfp_seek (ompio_fh ,current_size , MPI_SEEK_SET );
214
210
}
215
211
else {
216
212
opal_output (1 , "mca_common_ompio_file_open: Could not adjust position of "
217
- "shared file pointer whith MPI_MODE_APPEND\n" );
213
+ "shared file pointer with MPI_MODE_APPEND\n" );
218
214
ret = MPI_ERR_OTHER ;
219
215
goto fn_fail ;
220
216
}
@@ -362,7 +358,7 @@ int mca_common_ompio_file_close (mca_io_ompio_file_t *ompio_fh)
362
358
}
363
359
364
360
365
- if (MPI_COMM_NULL != ompio_fh -> f_comm ) {
361
+ if (MPI_COMM_NULL != ompio_fh -> f_comm && !( ompio_fh -> f_flags & OMPIO_SHAREDFP_IS_SET ) ) {
366
362
ompi_comm_free (& ompio_fh -> f_comm );
367
363
}
368
364
0 commit comments