From 424f26f6973aec06e009df558d6fca0fab989581 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 11 Jan 2022 19:06:39 -0600 Subject: [PATCH] Get starting time in Model.run based on filesystem. Closes #1939 --- openmc/model/model.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openmc/model/model.py b/openmc/model/model.py index 998992c90..c03c151c6 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -1,10 +1,11 @@ from collections.abc import Iterable +from contextlib import contextmanager from functools import lru_cache import os from pathlib import Path from numbers import Integral +from tempfile import NamedTemporaryFile import time -from contextlib import contextmanager import h5py @@ -528,8 +529,11 @@ class Model: """ # Setting tstart here ensures we don't pick up any pre-existing - # statepoint files in the output directory - tstart = time.time() + # statepoint files in the output directory -- just in case there are + # differences between the system clock and the filesystem, we get the + # time of a just-created temporary file + with NamedTemporaryFile() as fp: + tstart = Path(fp.name).stat().st_mtime last_statepoint = None # Operate in the provided working directory