Skip to content

Commit

Permalink
Added try/except to wrap os.remove('state.cpt')
Browse files Browse the repository at this point in the history
  • Loading branch information
wehs7661 committed Aug 29, 2023
1 parent b6a96b8 commit 13efc15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ensemble_md/ensemble_EXE.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,12 @@ def run_mdrun(self, n):
if returncode != 0:
print(f'Error on rank {rank} (return code: {returncode}):\n{stderr}')
if self.rm_cpt is True:
os.remove('state.cpt')
# if the simulation went wrong, there would be no checkpoint file
try:
os.remove('state.cpt')
except Exception:
print('\n--------------------------------------------------------------------------\n')
MPI.COMM_WORLD.Abort(1)
os.chdir('../../')

# gather return codes at rank 0
Expand Down

0 comments on commit 13efc15

Please sign in to comment.