Skip to content

Commit 00f059c

Browse files
committed
Check if mesh file exists and fall back on restart stream
If neither the file in the mesh stream nor the first file matching the pattern for the restart file exists, raise an error.
1 parent 75ee729 commit 00f059c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

mpas_analysis/shared/analysis_task.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import time
2020
import traceback
2121
import logging
22+
import os
2223
import sys
2324

2425
from mpas_analysis.shared.io import NameList, StreamsFile
@@ -506,11 +507,23 @@ def get_mesh_filename(self):
506507

507508
meshStream = self.config.get(self.componentName, 'meshStream')
508509
try:
509-
return self.runStreams.readpath(meshStream)[0]
510+
meshFilename = self.runStreams.readpath(meshStream)[0]
510511
except ValueError:
512+
meshFilename = None
513+
514+
if meshFilename is None or not os.path.exists(meshFilename):
515+
# try again with "restart" stream
516+
try:
517+
meshFilename = self.runStreams.readpath('restart')[0]
518+
except ValueError:
519+
meshFilename = None
520+
521+
if meshFilename is None or not os.path.exists(meshFilename):
511522
raise IOError(
512-
f'The MPAS mesh file could not be found: needed to '
513-
f'run {self.componentName} analysis')
523+
f'The MPAS mesh file could not be found via either '
524+
f'"{meshStream}" or "restart" streams')
525+
526+
return meshFilename
514527

515528
# }}}
516529

0 commit comments

Comments
 (0)