From 3b06498c2f1b3d9d563e7675a7f25ab9032b87bf Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 27 Jul 2021 07:28:35 +0200 Subject: [PATCH] make results self-contained for reproducibility ToDo: same functionality for load and geom --- src/config.f90 | 45 ++++++++++++++++++++++++++++++++++----------- src/results.f90 | 2 ++ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/config.f90 b/src/config.f90 index 7d75cb444..8ee25182f 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -8,7 +8,8 @@ module config use IO use YAML_parse use YAML_types - + use results + use parallelization implicit none private @@ -31,6 +32,7 @@ subroutine config_init print'(/,a)', ' <<<+- config init -+>>>'; flush(IO_STDOUT) + call parse_material call parse_numerics call parse_debug @@ -41,14 +43,21 @@ end subroutine config_init !-------------------------------------------------------------------------------------------------- !> @brief Read material.yaml or .yaml. !-------------------------------------------------------------------------------------------------- -subroutine parse_material +subroutine parse_material() logical :: fileExists + character(len=:), allocatable :: fileContent inquire(file='material.yaml',exist=fileExists) if(.not. fileExists) call IO_error(100,ext_msg='material.yaml') print*, 'reading material.yaml'; flush(IO_STDOUT) + fileContent = IO_read('material.yaml') + if (worldrank == 0) then + call results_openJobFile(parallel=.false.) + call results_writeDataset_str(fileContent,'setup','material.yaml','DAMASK main configuration') + call results_closeJobFile + endif config_material => YAML_parse_file('material.yaml') end subroutine parse_material @@ -57,15 +66,22 @@ end subroutine parse_material !-------------------------------------------------------------------------------------------------- !> @brief Read numerics.yaml. !-------------------------------------------------------------------------------------------------- -subroutine parse_numerics +subroutine parse_numerics() - logical :: fexist + logical :: fileExists + character(len=:), allocatable :: fileContent config_numerics => emptyDict - inquire(file='numerics.yaml', exist=fexist) - if (fexist) then + inquire(file='numerics.yaml', exist=fileExists) + if (fileExists) then print*, 'reading numerics.yaml'; flush(IO_STDOUT) + fileContent = IO_read('numerics.yaml') + if (worldrank == 0) then + call results_openJobFile(parallel=.false.) + call results_writeDataset_str(fileContent,'setup','numerics.yaml','numerics configuration (optional)') + call results_closeJobFile + endif config_numerics => YAML_parse_file('numerics.yaml') endif @@ -75,17 +91,24 @@ end subroutine parse_numerics !-------------------------------------------------------------------------------------------------- !> @brief Read debug.yaml. !-------------------------------------------------------------------------------------------------- -subroutine parse_debug +subroutine parse_debug() - logical :: fexist + logical :: fileExists + character(len=:), allocatable :: fileContent config_debug => emptyDict - inquire(file='debug.yaml', exist=fexist) - fileExists: if (fexist) then + inquire(file='debug.yaml', exist=fileExists) + if (fileExists) then print*, 'reading debug.yaml'; flush(IO_STDOUT) + fileContent = IO_read('debug.yaml') + if (worldrank == 0) then + call results_openJobFile(parallel=.false.) + call results_writeDataset_str(fileContent,'setup','debug.yaml','debug configuration (optional)') + call results_closeJobFile + endif config_debug => YAML_parse_file('debug.yaml') - endif fileExists + endif end subroutine parse_debug diff --git a/src/results.f90 b/src/results.f90 index ef6298151..8b04800ef 100644 --- a/src/results.f90 +++ b/src/results.f90 @@ -82,6 +82,8 @@ subroutine results_init(restart) call results_addAttribute('call',trim(commandLine)) call results_closeGroup(results_addGroup('cell_to')) call results_addAttribute('description','mappings to place data in space','cell_to') + call results_closeGroup(results_addGroup('setup')) + call results_addAttribute('description','input data used to run the simulation','setup') call results_closeJobFile endif