Merge pull request #169 from archerc/master

Add an input file command '#output_dir' to allow user to specify the directory of output files other than the directory of the input files.
这个提交包含在:
Craig Warren
2018-08-30 19:46:08 +01:00
提交者 GitHub
当前提交 aec1c54406
共有 5 个文件被更改,包括 36 次插入3 次删除

查看文件

@@ -153,6 +153,18 @@ Allows you to control the amount of information displayed on screen when gprMax
where ``c1`` can be either y (yes) or n (no) which turns on or off the messages on the screen. The default value is y. When messages are on, gprMax will display on the screen information the translation of space and time values to cell coordinates, iteration number, material parameters etc... This information can be useful for error checking.
#output_dir:
----------
Allows you to control the directory of output files. The syntax of the command is:
.. code-block:: none
#output_dir: str1
where ``str1`` can be either the absolute path of the output directory or relative to the directory of the input files. The default value is the same as the directory of the input files.
#num_threads:
-----------------

查看文件

@@ -86,6 +86,7 @@ class FDTDGrid(Grid):
def __init__(self):
self.inputfilename = ''
self.inputdirectory = ''
self.outputdirectory = ''
self.title = ''
self.messages = True
self.tqdmdisable = False

查看文件

@@ -192,7 +192,7 @@ def check_cmd_names(processedlines, checkessential=True):
essentialcmds = ['#domain', '#dx_dy_dz', '#time_window']
# Commands that there should only be one instance of in a model
singlecmds = dict.fromkeys(['#domain', '#dx_dy_dz', '#time_window', '#title', '#messages', '#num_threads', '#time_step_stability_factor', '#pml_cells', '#excitation_file', '#src_steps', '#rx_steps', '#taguchi', '#end_taguchi'], None)
singlecmds = dict.fromkeys(['#domain', '#dx_dy_dz', '#time_window', '#title', '#messages', '#num_threads', '#time_step_stability_factor', '#pml_cells', '#excitation_file', '#src_steps', '#rx_steps', '#taguchi', '#end_taguchi', '#output_dir'], None)
# Commands that there can be multiple instances of in a model - these will be lists within the dictionary
multiplecmds = {key: [] for key in ['#geometry_view', '#geometry_objects_write', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#rx', '#rx_array', '#snapshot', '#pml_cfs', '#include_file']}

查看文件

@@ -312,3 +312,9 @@ def process_singlecmds(singlecmds, G):
print('User waveform {} created using {} and, if required, interpolation parameters (kind: {}, fill value: {}).'.format(w.ID, timestr, kwargs['kind'], kwargs['fill_value']))
G.waveforms.append(w)
# set output dir
cmd = '#output_dir'
if singlecmds[cmd] is not None:
output_dir = singlecmds[cmd]
G.outputdirectory = output_dir

查看文件

@@ -332,8 +332,22 @@ def run_model(args, currentmodelrun, modelend, numbermodelruns, inputfile, usern
# Run simulation
else:
# Output filename
inputfileparts = os.path.splitext(os.path.join(G.inputdirectory, G.inputfilename))
outputfile = inputfileparts[0] + appendmodelnumber + '.out'
inputdirectory, inputfilename = os.path.split(os.path.join(G.inputdirectory, G.inputfilename))
if G.outputdirectory is None:
output_dir = inputdirectory
else:
output_dir = G.outputdirectory
# save current directory
curdir = os.getcwd()
os.chdir(inputdirectory)
output_dir = os.path.abspath(output_dir)
if not os.path.isdir(output_dir):
os.mkdir(output_dir)
print('\nmaking outputdirectory: {}'.format(output_dir))
# restore current directory
os.chdir(curdir)
basename, ext = os.path.splitext(inputfilename)
outputfile = os.path.join(output_dir, basename + appendmodelnumber + '.out')
print('\nOutput file: {}\n'.format(outputfile))
# Main FDTD solving functions for either CPU or GPU