diff --git a/python/damask/_result.py b/python/damask/_result.py index 0f69c4c5f..d502969a1 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1766,13 +1766,16 @@ class Result: Defaults to False. """ - with h5py.File(self.fname,'r') as f_in: - for out in _match(output,f_in['setup'].keys()): - description = f_in['/'.join(('setup',out))].attrs['description'] - if not h5py3: description = description.decode() - if not Path(out).exists() or overwrite: - with open(out,'w') as f_out: - f_out.write(f_in['/'.join(('setup',out))][()].decode()) - print(f"exported {description} to '{out}'") + def export(name,obj,output,overwrite): + if type(obj) == h5py.Dataset and _match(output,[name]): + d = obj.attrs['description'] if h5py3 else obj.attrs['description'].decode() + if not Path(name).exists() or overwrite: + with open(name,'w') as f_out: f_out.write(obj[()].decode()) + print(f"Exported {d} to '{name}'.") else: - print(f"'{out}' exists, {description} not exported") + print(f"'{name}' exists, {d} not exported.") + elif type(obj) == h5py.Group: + os.makedirs(name, exist_ok=True) + + with h5py.File(self.fname,'r') as f_in: + f_in['setup'].visititems(partial(export,output=output,overwrite=overwrite)) diff --git a/src/config.f90 b/src/config.f90 index c460ce7c5..ecde0831c 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -84,7 +84,7 @@ subroutine parse_numerics() print*, 'reading numerics.yaml'; flush(IO_STDOUT) fileContent = IO_read('numerics.yaml') call results_openJobFile(parallel=.false.) - call results_writeDataset_str(fileContent,'setup','numerics.yaml','numerics configuration (optional)') + call results_writeDataset_str(fileContent,'setup','numerics.yaml','numerics configuration') call results_closeJobFile endif call parallelization_bcast_str(fileContent) @@ -114,7 +114,7 @@ subroutine parse_debug() print*, 'reading debug.yaml'; flush(IO_STDOUT) fileContent = IO_read('debug.yaml') call results_openJobFile(parallel=.false.) - call results_writeDataset_str(fileContent,'setup','debug.yaml','debug configuration (optional)') + call results_writeDataset_str(fileContent,'setup','debug.yaml','debug configuration') call results_closeJobFile endif call parallelization_bcast_str(fileContent) diff --git a/src/results.f90 b/src/results.f90 index 5553a883a..f6bc4a045 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -94,10 +94,10 @@ subroutine results_init(restart) call get_command(commandLine) call results_addAttribute('call (restart at '//date//')',trim(commandLine)) call h5gmove_f(resultsFile,'setup','tmp',hdferr) - call results_addAttribute('description','input data used to run the simulation (backup from restart at '//date//')','tmp') + call results_addAttribute('description','input data used to run the simulation up to restart at '//date,'tmp') call results_closeGroup(results_addGroup('setup')) call results_addAttribute('description','input data used to run the simulation','setup') - call h5gmove_f(resultsFile,'tmp','setup/backup',hdferr) + call h5gmove_f(resultsFile,'tmp','setup/previous',hdferr) endif call results_closeJobFile