Added return (currently unused) from main gprMax call

这个提交包含在:
Craig Warren
2022-11-19 20:31:42 +00:00
父节点 e5f9e51b61
当前提交 f3c9cfc01e
共有 2 个文件被更改,包括 33 次插入12 次删除

查看文件

@@ -45,7 +45,13 @@ class Context:
self.tsimstart = None
def run(self):
"""Run the simulation in the correct context."""
"""Run the simulation in the correct context.
Returns:
results: dict that can contain useful results/data from simulation.
"""
results = {}
self.tsimstart = timer()
self.print_logo_copyright()
print_host_info(config.sim_config.hostinfo)
@@ -80,6 +86,8 @@ class Context:
self.tsimend = timer()
self.print_time_report()
return results
def print_logo_copyright(self):
"""Prints gprMax logo, version, and copyright/licencing information."""
logo_copyright = logo(__version__ + ' (' + codename + ')')
@@ -134,7 +142,12 @@ class MPIContext(Context):
model.solve(solver)
def run(self):
"""Specialise how the models are run."""
"""Specialise how the models are run.
Returns:
results: dict that can contain useful results/data from simulation.
"""
if self.rank == 0:
self.tsimstart = timer()
self.print_logo_copyright()
@@ -173,3 +186,4 @@ class MPIContext(Context):
if executor.is_master():
self.tsimend = timer()
self.print_time_report()
return results

查看文件

@@ -96,9 +96,8 @@ def run(scenes=args_defaults['scenes'],
write_processed=args_defaults['write_processed'],
log_level=args_defaults['log_level'],
log_file=args_defaults['log_file']):
"""This is the main function for gprMax when entering using application
programming interface (API). Run the simulation for the given list of
scenes.
"""Entry point for application programming interface (API). Runs the
simulation for the given list of scenes.
"""
args = argparse.Namespace(**{'scenes': scenes,
@@ -121,9 +120,7 @@ def run(scenes=args_defaults['scenes'],
def cli():
"""Main function for gprMax when entering using the command line interface
(CLI).
"""
"""Entry point for command line interface (CLI)."""
# Parse command line arguments
parser = argparse.ArgumentParser(prog='gprMax',
@@ -154,16 +151,24 @@ def cli():
help=help_msg['log_file'])
args = parser.parse_args()
run_main(args)
results = run_main(args)
return results
def run_main(args):
"""Called by either run (API) or main (CLI).
"""Runs simulation contexts. Called by either API or CLI.
Args:
args: namespace with arguments from either API or CLI.
Returns:
results: dict that can contain useful results/data from simulation.
Enables these to be propagated to calling script.
"""
results = {}
logging_config(level=args.log_level, log_file=args.log_file)
config.sim_config = config.SimulationConfig(args)
@@ -171,8 +176,10 @@ def run_main(args):
# MPI running with (OpenMP/CUDA/OpenCL)
if config.sim_config.args.mpi:
context = MPIContext()
context.run()
results = context.run()
# Standard running (OpenMP/CUDA/OpenCL)
else:
context = Context()
context.run()
results = context.run()
return results