Skip to content

2026PKUCourseHW5: Add if(!file.is_open()) check in write_restart#7066

Open
meltryllis2025 wants to merge 2 commits intodeepmodeling:developfrom
meltryllis2025:develop
Open

2026PKUCourseHW5: Add if(!file.is_open()) check in write_restart#7066
meltryllis2025 wants to merge 2 commits intodeepmodeling:developfrom
meltryllis2025:develop

Conversation

@meltryllis2025
Copy link

fix(io): prevent silent failure when writing restart file

Previously, if global_out_dir did not exist or lacked write permissions, std::ofstream would silently fail. The MD simulation would continue running without saving restart points, leading to potential loss of computational progress.
This commit adds an is_open() check in MD_base::write_restart. It now prints a clear error message to std::cerr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants