@@ -90,11 +90,12 @@ ncmpio_create(MPI_Comm comm,
9090 * nc_num_aggrs_per_node: number of processes per node to be the INA
9191 * aggregators.
9292 *
93- * ncp->fstype will be set in ncmpio_hint_extract().
93+ * ncp->fstype will be initialized in ncmpio_hint_extract(), and set in
94+ * PNCIO_FileSysType().
9495 */
9596 ncmpio_hint_extract (ncp , user_info );
9697
97- if (ncp -> fstype == PNCIO_FSTYPE_CHECK )
98+ if (ncp -> fstype == PNCIO_FSTYPE_CHECK && rank == 0 )
9899 /* Check file system type. If the given file does not exist, check its
99100 * folder. Currently PnetCDF's PNCIO drivers support Lustre
100101 * (PNCIO_LUSTRE) and Unix File System (PNCIO_UFS).
@@ -159,13 +160,20 @@ if (rank == 0) printf("%s at %d fstype=%s\n", __func__,__LINE__,(ncp->fstype ==
159160 * NC_NOCLOBBER mode is set in ncmpi_create.
160161 */
161162#ifdef HAVE_ACCESS
162- if (nprocs > 1 )
163- TRACE_COMM (MPI_Bcast )(& file_exist , 1 , MPI_INT , 0 , comm );
163+ if (nprocs > 1 ) {
164+ int msg [2 ] = {file_exist , ncp -> fstype };
165+ TRACE_COMM (MPI_Bcast )(msg , 2 , MPI_INT , 0 , comm );
166+ file_exist = msg [0 ];
167+ ncp -> fstype = msg [1 ];
168+ }
164169 if (file_exist ) {
165170 NCI_Free (ncp );
166171 DEBUG_RETURN_ERROR (NC_EEXIST )
167172 }
168173#else
174+ if (nprocs > 1 )
175+ TRACE_COMM (MPI_Bcast )(& ncp -> fstype , 1 , MPI_INT , 0 , comm );
176+
169177 /* Add MPI_MODE_EXCL mode for MPI_File_open, so it can error out, if
170178 * the file exists.
171179 */
@@ -183,8 +191,10 @@ if (rank == 0) printf("%s at %d fstype=%s\n", __func__,__LINE__,(ncp->fstype ==
183191 if (rank == 0 && file_exist ) {
184192 if (!use_trunc ) { /* delete the file */
185193#ifdef HAVE_UNLINK
186- /* unlink() is likely faster then truncate(), but may be still
187- * expensive
194+ /* unlink() is likely faster then truncate(). However, unlink()
195+ * can be expensive when the file size is large. For example,
196+ * it taook 1.1061 seconds to delete a file of size 27.72 GiB
197+ * on Perlmutter at NERSC.
188198 */
189199 err = unlink (filename );
190200 if (err < 0 && errno != ENOENT )
@@ -283,12 +293,11 @@ if (rank == 0) printf("%s at %d fstype=%s\n", __func__,__LINE__,(ncp->fstype ==
283293 * when the file to be clobbered is a symbolic link.
284294 */
285295 if (nprocs > 1 ) {
286- int msg [2 ];
287- msg [0 ] = err ;
288- msg [1 ] = mpiomode ;
289- TRACE_COMM (MPI_Bcast )(& msg , 2 , MPI_INT , 0 , comm );
290- err = msg [0 ];
291- mpiomode = msg [1 ];
296+ int msg [3 ] = {err , mpiomode , ncp -> fstype };
297+ TRACE_COMM (MPI_Bcast )(& msg , 3 , MPI_INT , 0 , comm );
298+ err = msg [0 ];
299+ mpiomode = msg [1 ];
300+ ncp -> fstype = msg [2 ];
292301 }
293302 if (err != NC_NOERR ) return err ;
294303 }
0 commit comments