tem_restart_writeHeader Subroutine

public subroutine tem_restart_writeHeader(me, tree, varSys, subTree, timing, lastHeader, suffix)

This subroutine closes the restart dump file and writes the last header.


Type IntentOptional AttributesName
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!!!!)


proc~~tem_restart_writeheader~~CallsGraph proc~tem_restart_writeheader tem_restart_writeHeader proc~aot_out_close_table aot_out_close_table proc~tem_restart_writeheader->proc~aot_out_close_table proc~aot_out_open_table aot_out_open_table proc~tem_restart_writeheader->proc~aot_out_open_table interface~aot_out_val aot_out_val proc~tem_restart_writeheader->interface~aot_out_val proc~aot_out_close aot_out_close proc~tem_restart_writeheader->proc~aot_out_close proc~newunit newunit proc~tem_restart_writeheader->proc~newunit proc~tem_mesh_out tem_mesh_out proc~tem_restart_writeheader->proc~tem_mesh_out proc~tem_time_out tem_time_out proc~tem_restart_writeheader->proc~tem_time_out proc~aot_out_open aot_out_open proc~tem_restart_writeheader->proc~aot_out_open interface~tem_varsys_out tem_varSys_out proc~tem_restart_writeheader->interface~tem_varsys_out proc~tem_mesh_out->proc~aot_out_close_table proc~tem_mesh_out->proc~aot_out_open_table proc~tem_mesh_out->interface~aot_out_val proc~tem_time_out->proc~aot_out_close_table proc~tem_time_out->proc~aot_out_open_table proc~tem_time_out->interface~aot_out_val proc~tem_varsys_out_vector tem_varSys_out_vector interface~tem_varsys_out->proc~tem_varsys_out_vector proc~tem_varsys_out_single tem_varSys_out_single interface~tem_varsys_out->proc~tem_varsys_out_single proc~tem_varsys_out_vector->proc~aot_out_close_table proc~tem_varsys_out_vector->proc~aot_out_open_table proc~tem_varsys_out_vector->proc~tem_varsys_out_single proc~tem_varsys_out_single->proc~aot_out_close_table proc~tem_varsys_out_single->proc~aot_out_open_table proc~tem_varsys_out_single->interface~aot_out_val

Called by

proc~~tem_restart_writeheader~~CalledByGraph proc~tem_restart_writeheader tem_restart_writeHeader proc~tem_restart_closewrite tem_restart_closeWrite proc~tem_restart_closewrite->proc~tem_restart_writeheader proc~tem_restart_openwrite tem_restart_openWrite proc~tem_restart_openwrite->proc~tem_restart_writeheader proc~hvs_output_close hvs_output_close proc~hvs_output_close->proc~tem_restart_closewrite proc~hvs_output_open hvs_output_open proc~hvs_output_open->proc~tem_restart_openwrite proc~tem_tracker tem_tracker proc~tem_tracker->proc~hvs_output_close proc~tem_tracker->proc~hvs_output_open


Source Code

  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
      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'
        if ( present(suffix) ) then
          filename = trim( me%header%headerPrefix )//'_header_' &
            &      // trim(suffix)//'.lua'
          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()
      open(unit = 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
        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
           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


    end if

  end subroutine tem_restart_writeHeader