Skip to content

Commit 6207798

Browse files
authored
Fix: std::out_of_range of map when out_mat_t with multi-core (#6090)
1 parent bbf41aa commit 6207798

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/module_io/write_HS_sparse.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,15 @@ void ModuleIO::save_sparse(
765765
}
766766
}
767767

768-
output_single_R(ofs, smat.at(R_coor), sparse_thr, binary, pv, reduce);
768+
if (smat.count(R_coor))
769+
{
770+
output_single_R(ofs, smat.at(R_coor), sparse_thr, binary, pv, reduce);
771+
}
772+
else
773+
{
774+
std::map<size_t, std::map<size_t, Tdata>> empty_map;
775+
output_single_R(ofs, empty_map, sparse_thr, binary, pv, reduce);
776+
}
769777
++count;
770778
}
771779
if (!reduce || GlobalV::DRANK == 0) {

0 commit comments

Comments
 (0)