From a8dfeeb7429cd8818b7332ef2aa4bc88cf1497a6 Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 19 Dec 2023 15:27:13 +0000 Subject: [PATCH] Allow user to specify output data file --- gprMax/config.py | 16 ++++++---------- gprMax/gprMax.py | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gprMax/config.py b/gprMax/config.py index 4896028b..3617c794 100644 --- a/gprMax/config.py +++ b/gprMax/config.py @@ -168,17 +168,13 @@ class ModelConfig: outputdir: string of output file directory given by input file command. """ - if not outputdir: - try: - self.output_file_path = Path(self.args.outputfile) - except AttributeError: - self.output_file_path = sim_config.input_file_path.with_suffix("") + if outputdir is not None: + Path(outputdir).mkdir(exist_ok=True) + self.output_file_path = Path(outputdir, sim_config.input_file_path.stem) + elif sim_config.args.outputfile is not None: + self.output_file_path = Path(sim_config.args.outputfile).with_suffix("") else: - try: - Path(outputdir).mkdir(exist_ok=True) - self.output_file_path = Path(outputdir, sim_config.input_file_path.stem) - except AttributeError: - self.output_file_path = sim_config.input_file_path.with_suffix("") + self.output_file_path = sim_config.input_file_path.with_suffix("") parts = self.output_file_path.parts self.output_file_path = Path(*parts[:-1], parts[-1] + self.appendmodelnumber) diff --git a/gprMax/gprMax.py b/gprMax/gprMax.py index 197ed91a..089955f8 100644 --- a/gprMax/gprMax.py +++ b/gprMax/gprMax.py @@ -165,6 +165,7 @@ def cli(): # Parse command line arguments parser = argparse.ArgumentParser(prog="gprMax", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("inputfile", help=help_msg["inputfile"]) + parser.add_argument("-outputfile", "-o", help=help_msg["outputfile"]) parser.add_argument("-n", default=args_defaults["n"], type=int, help=help_msg["n"]) parser.add_argument("-i", type=int, help=help_msg["i"]) parser.add_argument("-mpi", action="store_true", default=args_defaults["mpi"], help=help_msg["mpi"])