From ab0555f5de091c4dd408b5235b802a063ceacb1c Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Thu, 18 Dec 2025 20:51:18 +0100 Subject: [PATCH 1/3] Allow mcrun / mcdisplay to run / visualize without access to .c/.instr --- tools/Python/mcrun/mccode.py | 4 ++++ tools/Python/mcrun/mcrun.py | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index 064b55bb8..fbcbef0b4 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -138,6 +138,10 @@ def x_path(file): else: self.binpath = './%s.%s' % (self.name, mccode_config.platform['EXESUFFIX']) + # Check if self.path is .exe or .out binary, if so - skip ahead to execution + if options.force_compile or not pathlib.Path(self.path).suffix==mccode_config.platform['EXESUFFIX']: + return + # Check if c-code should be regenerated by comparing to instr timestamp existingC = findReusableFile(self.path, [self.cpath, x_path(self.cpath)]) diff --git a/tools/Python/mcrun/mcrun.py b/tools/Python/mcrun/mcrun.py index 28e2f4936..2e74c84ce 100644 --- a/tools/Python/mcrun/mcrun.py +++ b/tools/Python/mcrun/mcrun.py @@ -444,12 +444,7 @@ def get_parameters(options): def find_instr_file(instr): - # Remove [-mpi].out to avoid parsing a binary file instr = clean_quotes(instr) - if instr.endswith("-mpi." + mccode_config.platform['EXESUFFIX']): - instr = instr[:-(5 + len(mccode_config.platform['EXESUFFIX']))] - if instr.endswith("." + mccode_config.platform['EXESUFFIX']): - instr = instr[:-(1 + len(mccode_config.platform['EXESUFFIX']))] # Append ".instr" if needed if not isfile(instr) and isfile(instr + ".instr"): From a858c74058bdbca052adb728d0b6c95c0b4e9ddb Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Thu, 18 Dec 2025 21:07:03 +0100 Subject: [PATCH 2/3] Logic needed reversal --- tools/Python/mcrun/mccode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index fbcbef0b4..ae20abd5f 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -139,7 +139,7 @@ def x_path(file): self.binpath = './%s.%s' % (self.name, mccode_config.platform['EXESUFFIX']) # Check if self.path is .exe or .out binary, if so - skip ahead to execution - if options.force_compile or not pathlib.Path(self.path).suffix==mccode_config.platform['EXESUFFIX']: + if pathlib.Path(self.path).suffix==mccode_config.platform['EXESUFFIX']: return # Check if c-code should be regenerated by comparing to instr timestamp From 3bf12eccea30536434cbb9b29cf2982d74bd4988 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Thu, 18 Dec 2025 21:24:11 +0100 Subject: [PATCH 3/3] Another round of fixing logic, LOG.info() that we are using binary directly --- tools/Python/mcrun/mccode.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index ae20abd5f..ae217f448 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -128,10 +128,6 @@ def x_path(file): ''' Return external path (relative to self.path) for file ''' return '%s/%s' % (dirname(self.path), basename(file)) - # Copy instrument file to cwd if not already there (for compatibility) - if not isfile(basename(self.path)): - shutil.copy2(self.path, ".") # also copies stat information - # Create the path for the binary if os.name == 'nt': self.binpath = '%s.%s' % (self.name, mccode_config.platform['EXESUFFIX']) @@ -139,9 +135,14 @@ def x_path(file): self.binpath = './%s.%s' % (self.name, mccode_config.platform['EXESUFFIX']) # Check if self.path is .exe or .out binary, if so - skip ahead to execution - if pathlib.Path(self.path).suffix==mccode_config.platform['EXESUFFIX']: + if self.path==basename(self.binpath): + LOG.info('Called with binary file %s, skipping ahead to execution', self.binpath) return + # Copy instrument file to cwd if not already there (for compatibility) + if not isfile(basename(self.path)): + shutil.copy2(self.path, ".") # also copies stat information + # Check if c-code should be regenerated by comparing to instr timestamp existingC = findReusableFile(self.path, [self.cpath, x_path(self.cpath)])