read file only once (per process)
This commit is contained in:
parent
367c088b16
commit
812b0f07f5
|
@ -14,7 +14,7 @@ module YAML_parse
|
|||
|
||||
public :: &
|
||||
YAML_parse_init, &
|
||||
YAML_parse_file
|
||||
YAML_parse_str
|
||||
|
||||
contains
|
||||
|
||||
|
@ -29,16 +29,16 @@ end subroutine YAML_parse_init
|
|||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief Parse a YAML file into a a structure of nodes.
|
||||
!> @brief Parse a YAML string into a a structure of nodes.
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
function YAML_parse_file(fname) result(node)
|
||||
function YAML_parse_str(str) result(node)
|
||||
|
||||
character(len=*), intent(in) :: fname
|
||||
character(len=*), intent(in) :: str
|
||||
class (tNode), pointer :: node
|
||||
|
||||
node => parse_flow(to_flow(IO_read(fname)))
|
||||
node => parse_flow(to_flow(str))
|
||||
|
||||
end function YAML_parse_file
|
||||
end function YAML_parse_str
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -51,14 +51,17 @@ subroutine parse_material()
|
|||
|
||||
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')
|
||||
|
||||
config_material => YAML_parse_str(fileContent)
|
||||
|
||||
end subroutine parse_material
|
||||
|
||||
|
@ -73,16 +76,21 @@ subroutine parse_numerics()
|
|||
|
||||
|
||||
config_numerics => emptyDict
|
||||
|
||||
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')
|
||||
|
||||
config_numerics => YAML_parse_str(fileContent)
|
||||
|
||||
endif
|
||||
|
||||
end subroutine parse_numerics
|
||||
|
@ -98,16 +106,21 @@ subroutine parse_debug()
|
|||
|
||||
|
||||
config_debug => emptyDict
|
||||
|
||||
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')
|
||||
|
||||
config_debug => YAML_parse_str(fileContent)
|
||||
|
||||
endif
|
||||
|
||||
end subroutine parse_debug
|
||||
|
|
|
@ -129,13 +129,13 @@ program DAMASK_grid
|
|||
if (stagItMax < 0) call IO_error(301,ext_msg='maxStaggeredIter')
|
||||
if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack')
|
||||
|
||||
fileContent = IO_read(interface_loadFile)
|
||||
if (worldrank == 0) then
|
||||
fileContent = IO_read(interface_loadFile)
|
||||
call results_openJobFile(parallel=.false.)
|
||||
call results_writeDataset_str(fileContent,'setup',interface_loadFile,'load case definition (grid solver)')
|
||||
call results_closeJobFile
|
||||
endif
|
||||
config_load => YAML_parse_file(trim(interface_loadFile))
|
||||
config_load => YAML_parse_str(fileContent)
|
||||
solver => config_load%get('solver')
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue