This subroutine closes the restart dump file and writes the last header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type) | :: | me |
the restart header info |
|||
type(treelmesh_type) | :: | tree |
mesh, provided in treelm format |
|||
type(tem_varSys_type), | intent(in) | :: | varSys |
global variable system defined in solver |
||
type(tem_subTree_type), | intent(in), | optional | :: | subTree |
optional subTree of the given tree |
|
type(tem_time_type), | intent(in) | :: | timing | |||
logical, | optional | :: | lastHeader |
is this header a last header |
||
character(len=*), | intent(in), | optional | :: | suffix |
optional suffix (if present NO timestamp will be added!!!!) |
subroutine tem_restart_writeHeader( me, tree, varSys, subTree, timing, &
& lastHeader, suffix )
! -------------------------------------------------------------------- !
!> the restart header info
type(tem_restart_type) :: me
!> mesh, provided in treelm format
type(treelmesh_type) :: tree
!> global variable system defined in solver
type(tem_varSys_type), intent(in) :: varSys
!> optional subTree of the given tree
type(tem_subTree_type), optional, intent(in) :: subTree
!>
type(tem_time_type), intent(in) :: timing
!> is this header a last header
logical, optional :: lastHeader
!> optional suffix (if present NO timestamp will be added!!!!)
character(len=*), optional, intent(in) :: suffix
! -------------------------------------------------------------------- !
character(len=1024) :: filename
character(len=320) :: solve_line
type(aot_out_type) :: conf ! aotus lua state to write output
logical :: isLast
type(tem_global_type) :: global_loc
integer(kind=long_k) :: nElems
integer :: punit
integer :: read_stat
logical :: nUnitOpened
! -------------------------------------------------------------------- !
if ( present(lastHeader) ) then
isLast = lastHeader
else
isLast = .false.
end if
! now write out the header file
! only one process (root) writes out the header file
if (me%comm%rank == 0) then
! choose the right filename
if (isLast) then
filename = trim( me%header%headerPrefix )// '_lastHeader.lua'
else
if ( present(suffix) ) then
filename = trim( me%header%headerPrefix )//'_header_' &
& // trim(suffix)//'.lua'
else
filename = trim( me%header%headerPrefix )//'_header_' &
& // trim(me%header%timestamp)//'.lua'
end if
end if
! Open up the restart header lua file, so we can write the stuff using
! the aotus library
punit = newUnit()
call tem_open( newunit = punit, &
& file = trim(filename), &
& action = 'write', &
& status = 'replace', &
& recl = 360 )
call aot_out_open(put_conf = conf, outUnit = punit)
! the binary names; for multiple schemes a list of binaries have to be
! written
call aot_out_open_table(conf, 'binary_name')
call aot_out_val( put_conf = conf, &
& val = trim(me%header%binName) )
call aot_out_close_table(conf)
! the solver config file names
call aot_out_val( put_conf = conf, &
& val = trim(me%header%solverConfigFile), &
& vname = 'solver_configFile' )
if( present( subTree ))then
global_loc = subTree%global
nElems = subTree%global%nElems
else
global_loc = tree%global
nElems = tree%global%nElems
end if
! the mesh info
call tem_mesh_out( me = global_loc, conf = conf )
call aot_out_val(conf, tree%weights_file, 'weights')
! the time stamp
!call aot_out_val( conf, trim(me%header%timestamp), 'time_point')
call tem_time_out( conf = conf, me = timing, key = 'time_point' )
! the total number of elements
call aot_out_val( conf, nElems, 'nElems')
! the number of dofs for each scalar variable of the equation system
call aot_out_val( conf, me%write_file%nDofs, 'nDofs')
! the solver tag (solver name and version)
call aot_out_val( conf, trim( me%header%solverTag), 'solver')
! the variable system, incl. the solver specific
! information from the solSpec data
call tem_varSys_out( me = varSys, &
& conf = conf, &
& dumpVarPos = me%varMap%varPos%val(:) )
! close the restart header file
call aot_out_close(conf)
! Append the solver specific data, stored in a scratch file to the header
! file, if one is provided by caller.
if ( me%solSpec_unit>0 ) then
inquire(unit=me%solSpec_unit, opened=nUnitOpened)
if (nUnitOpened) then
rewind(me%solSpec_unit)
do
read(me%solSpec_unit,'(a)', iostat=read_stat) solve_line
if (read_stat /= 0) EXIT
write(punit,'(a)') trim(solve_line)
end do
end if
end if
close(punit)
end if
end subroutine tem_restart_writeHeader