@@ -167,11 +167,13 @@ TEST(CifParserTest, ReadSimpleTest)
167167 ofs.close ();
168168#ifdef __MPI
169169 }
170+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is written
170171#endif
171172 std::map<std::string, std::vector<std::string>> data;
172173 ModuleIO::CifParser::read (" mp-2516584.cif" , data);
173174 // delete the file
174175#ifdef __MPI
176+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is already read
175177 if (rank == 0 )
176178 {
177179#endif
@@ -241,11 +243,13 @@ TEST(CifParserTest, ReadMediumTest)
241243 ofs.close ();
242244#ifdef __MPI
243245 }
246+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is written
244247#endif
245248 std::map<std::string, std::vector<std::string>> data;
246249 ModuleIO::CifParser::read (" cod-1000065.cif" , data);
247250 // delete the file
248251#ifdef __MPI
252+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is already read
249253 if (rank == 0 )
250254 {
251255#endif
@@ -316,7 +320,6 @@ TEST(CifParserTest, WriteTest)
316320 MPI_Comm_rank (MPI_COMM_WORLD, &rank);
317321#endif
318322 const std::string fcif = " test.cif" ;
319- std::ofstream ofs (fcif);
320323 const std::vector<double > abc_angles = {2.46637620 , 2.46637620 , 24.84784531 , 90.0 , 90.0 , 120.0 };
321324 const int natom = 4 ;
322325 const std::vector<std::string> atom_site_labels = {" C" , " C" , " C" , " C" };
@@ -325,16 +328,21 @@ TEST(CifParserTest, WriteTest)
325328 0.333333 , 0.666667 , 0.75 ,
326329 0.666667 , 0.333333 , 0.25 };
327330 ModuleIO::CifParser::write (fcif,
328- abc_angles.data (),
329- natom,
330- atom_site_labels.data (),
331- atom_site_fract.data (),
332- " # Generated during unittest of function ModuleIO::CifParser::write" ,
333- " data_test" );
331+ abc_angles.data (),
332+ natom,
333+ atom_site_labels.data (),
334+ atom_site_fract.data (),
335+ " # Generated during unittest of function ModuleIO::CifParser::write" ,
336+ " data_test" ,
337+ rank);
338+ #ifdef __MPI
339+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is written
340+ #endif
334341 std::map<std::string, std::vector<std::string>> data;
335- ModuleIO::CifParser::read (fcif, data);
342+ ModuleIO::CifParser::read (fcif, data, rank );
336343 // delete the file
337344#ifdef __MPI
345+ MPI_Barrier (MPI_COMM_WORLD); // make sure the file is already read
338346 if (rank == 0 )
339347 {
340348#endif
0 commit comments