avoid file name clashes

This commit is contained in:
Martin Diehl 2023-07-11 20:37:21 +02:00
parent 83db176e1b
commit 0e7c9f101c
5 changed files with 43 additions and 10 deletions

View File

@ -210,9 +210,9 @@ subroutine inputRead(elem,node0_elem,connectivity_elem,materialAt)
call result_openJobFile() call result_openJobFile()
call result_writeDataset_str(IO_read(trim(getSolverJobName())//InputFileExtension), 'setup', & call result_addSetupFile(IO_read(trim(getSolverJobName())//InputFileExtension), &
trim(getSolverJobName())//InputFileExtension, & trim(getSolverJobName())//InputFileExtension, &
'MSC.Marc input deck') 'MSC.Marc input deck')
call result_closeJobFile() call result_closeJobFile()
inputFile = IO_readlines(trim(getSolverJobName())//InputFileExtension) inputFile = IO_readlines(trim(getSolverJobName())//InputFileExtension)

View File

@ -121,7 +121,7 @@ function parse(fname,description)
print'(/,1x,a)', 'reading '//description; flush(IO_STDOUT) print'(/,1x,a)', 'reading '//description; flush(IO_STDOUT)
fileContent = IO_read(fname) fileContent = IO_read(fname)
call result_openJobFile(parallel=.false.) call result_openJobFile(parallel=.false.)
call result_writeDataset_str(fileContent,'setup',fname(scan(fname,'/',.true.)+1:),description) call result_addSetupFile(fileContent,fname,description)
call result_closeJobFile() call result_closeJobFile()
end if end if
call parallelization_bcast_str(fileContent) call parallelization_bcast_str(fileContent)

View File

@ -146,7 +146,7 @@ program DAMASK_grid
fname = CLI_loadFile fname = CLI_loadFile
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:) 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,'load case definition (grid solver)') call result_addSetupFile(fileContent,fname,'load case definition (grid solver)')
call result_closeJobFile() call result_closeJobFile()
end if end if

View File

@ -89,7 +89,7 @@ subroutine discretization_grid_init(restart)
fname = CLI_geomFile fname = CLI_geomFile
if (scan(fname,'/') /= 0) fname = fname(scan(fname,'/',.true.)+1:) 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,'geometry definition (grid solver)') call result_addSetupFile(fileContent,fname,'geometry definition (grid solver)')
call result_closeJobFile() call result_closeJobFile()
else else
allocate(materialAt_global(0)) ! needed for IntelMPI allocate(materialAt_global(0)) ! needed for IntelMPI

View File

@ -62,6 +62,7 @@ module result
result_writeDataset, & result_writeDataset, &
result_writeDataset_str, & result_writeDataset_str, &
result_setLink, & result_setLink, &
result_addSetupFile, &
result_addAttribute, & result_addAttribute, &
result_removeLink, & result_removeLink, &
result_mapping_phase, & result_mapping_phase, &
@ -166,7 +167,7 @@ end subroutine result_finalizeIncrement
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief open a group from the result file !> @brief Open a group from the result file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function result_openGroup(groupName) integer(HID_T) function result_openGroup(groupName)
@ -179,7 +180,7 @@ end function result_openGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief adds a new group to the result file !> @brief Add a new group to the result file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
integer(HID_T) function result_addGroup(groupName) integer(HID_T) function result_addGroup(groupName)
@ -192,7 +193,7 @@ end function result_addGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief close a group !> @brief Close a group.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine result_closeGroup(group_id) subroutine result_closeGroup(group_id)
@ -205,7 +206,7 @@ end subroutine result_closeGroup
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief set link to object in result file !> @brief Set link to object in result file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine result_setLink(path,link) subroutine result_setLink(path,link)
@ -216,6 +217,38 @@ subroutine result_setLink(path,link)
end subroutine result_setLink end subroutine result_setLink
!--------------------------------------------------------------------------------------------------
!> @brief Add file to setup folder and ensure unique name.
!--------------------------------------------------------------------------------------------------
subroutine result_addSetupFile(content,fname,description)
character(len=*), intent(in) :: content, fname, description
integer(HID_T) :: groupHandle
character(len=:), allocatable :: fname_
integer :: i
groupHandle = result_openGroup('setup')
fname_ = fname(scan(fname,'/',.true.)+1:)
if (.not. HDF5_objectExists(groupHandle,fname_)) then
call result_writeDataset_str(content,'setup',fname_,description)
else
i = 1
do
fname_ = fname(scan(fname,'/',.true.)+1:)//'.'//IO_intAsStr(i)
if (.not. HDF5_objectExists(groupHandle,fname_)) then
call result_writeDataset_str(content,'setup',fname_,description)
exit
i = i+1
end if
end do
end if
call result_closeGroup(groupHandle)
end subroutine result_addSetupFile
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Add a string attribute to an object in the result file. !> @brief Add a string attribute to an object in the result file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------