unified code

This commit is contained in:
Martin Diehl 2023-07-10 20:05:17 +02:00
parent 3af61233c9
commit 4a1c6e7b4f
2 changed files with 31 additions and 61 deletions

View File

@ -185,11 +185,8 @@ subroutine CLI_init()
CLI_geomFile = getPathRelCWD(geomArg,'geometry') CLI_geomFile = getPathRelCWD(geomArg,'geometry')
CLI_loadFile = getPathRelCWD(loadArg,'load case') CLI_loadFile = getPathRelCWD(loadArg,'load case')
CLI_materialFile = getPathRelCWD(materialArg,'material configuration') CLI_materialFile = getPathRelCWD(materialArg,'material configuration')
if (allocated(numericsArg)) then if (allocated(numericsArg)) &
CLI_numericsFile = getPathRelCWD(numericsArg,'numerics configuration') CLI_numericsFile = getPathRelCWD(numericsArg,'numerics configuration')
else
CLI_numericsFile = ''
endif
if (.not. allocated(solverJobname)) then if (.not. allocated(solverJobname)) then
solverJobname = jobname(CLI_geomFile,CLI_loadFile,CLI_materialFile,CLI_numericsFile) solverJobname = jobname(CLI_geomFile,CLI_loadFile,CLI_materialFile,CLI_numericsFile)
@ -295,11 +292,12 @@ end function getSolverJobname
function jobname(geomFile,LoadFile,materialsFile,numericsFile) function jobname(geomFile,LoadFile,materialsFile,numericsFile)
character(len=:), allocatable :: jobname character(len=:), allocatable :: jobname
character(len=*), intent(in) :: geomFile,loadFile,materialsFile,numericsFile character(len=*), intent(in) :: geomFile,loadFile,materialsFile
character(len=:), allocatable, intent(in) :: numericsFile
jobname = stem(geomFile)//'_'//stem(loadFile)//'_'//stem(materialsFile) jobname = stem(geomFile)//'_'//stem(loadFile)//'_'//stem(materialsFile)
if (len_trim(numericsFile) > 0) jobname = jobname//'_'//stem(numericsFile) if (allocated(numericsFile)) jobname = jobname//'_'//stem(numericsFile)
contains contains

View File

@ -34,8 +34,23 @@ subroutine config_init()
print'(/,1x,a)', '<<<+- config init -+>>>'; flush(IO_STDOUT) print'(/,1x,a)', '<<<+- config init -+>>>'; flush(IO_STDOUT)
call parse_material() #if defined(MESH) || defined(GRID)
call parse_numerics() config_material => parse(CLI_materialFile,'material configuration')
#else
config_material => parse('material.yaml','material configuration')
#endif
config_numerics => emptyDict
#if defined(MESH) || defined(GRID)
if (allocated(CLI_numericsFile)) &
config_numerics => parse(CLI_numericsFile,'numerics configuration')
#else
MSCMarc: block
logical :: exists
inquire(file='numerics.yaml',exist=exists)
if (exists) config_numerics => parse('numerics.yaml','numerics configuration')
end block MSCMarc
#endif
end subroutine config_init end subroutine config_init
@ -92,70 +107,27 @@ end function config_listReferences
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Read material.yaml. !> @brief Read configuration, spread over all processes, and add to DADF5.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine parse_material() function parse(fname,description)
character(len=:), allocatable :: & character(len=*), intent(in) :: fname, description
fileContent, fname type(tDict), pointer :: parse
character(len=:), allocatable :: fileContent
if (worldrank == 0) then if (worldrank == 0) then
print'(/,1x,a)', 'reading material configuration'; flush(IO_STDOUT) print'(/,1x,a)', 'reading '//description; flush(IO_STDOUT)
#if defined(MESH) || defined(GRID)
fname = CLI_materialFile
#else
fname = 'material.yaml'
#endif
fileContent = IO_read(fname) fileContent = IO_read(fname)
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
call result_openJobFile(parallel=.false.) call result_openJobFile(parallel=.false.)
call result_writeDataset_str(fileContent,'setup',fname,'material configuration') call result_writeDataset_str(fileContent,'setup',fname(scan(fname,'/',.true.)+1:),description)
call result_closeJobFile() call result_closeJobFile()
end if end if
call parallelization_bcast_str(fileContent) call parallelization_bcast_str(fileContent)
config_material => YAML_parse_str_asDict(fileContent) parse => YAML_parse_str_asDict(fileContent)
end subroutine parse_material end function parse
!--------------------------------------------------------------------------------------------------
!> @brief Read numerics.yaml.
!--------------------------------------------------------------------------------------------------
subroutine parse_numerics()
character(len=:), allocatable :: &
fileContent, fname
logical :: parse
config_numerics => emptyDict
#if defined(MESH) || defined(GRID)
fname = CLI_numericsFile
parse = len_trim(CLI_numericsFile) > 0
#else
fname = 'numerics.yaml'
inquire(file=fname, exist=parse)
#endif
if (parse) then
if (worldrank == 0) then
print'(1x,a)', 'reading numerics configuration'; flush(IO_STDOUT)
fileContent = IO_read(fname)
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:)
call result_openJobFile(parallel=.false.)
call result_writeDataset_str(fileContent,'setup',fname,'numerics configuration')
call result_closeJobFile()
end if
call parallelization_bcast_str(fileContent)
config_numerics => YAML_parse_str_asDict(fileContent)
end if
end subroutine parse_numerics
end module config end module config