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.

Arguments

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


Calls

proc~~tem_restart_writeheader~~CallsGraph proc~tem_restart_writeheader tem_restart_writeHeader aot_out_close aot_out_close proc~tem_restart_writeheader->aot_out_close aot_out_close_table aot_out_close_table proc~tem_restart_writeheader->aot_out_close_table aot_out_open aot_out_open proc~tem_restart_writeheader->aot_out_open aot_out_open_table aot_out_open_table proc~tem_restart_writeheader->aot_out_open_table aot_out_val aot_out_val proc~tem_restart_writeheader->aot_out_val interface~tem_varsys_out tem_varSys_out proc~tem_restart_writeheader->interface~tem_varsys_out 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_open tem_open proc~tem_restart_writeheader->proc~tem_open proc~tem_time_out tem_time_out proc~tem_restart_writeheader->proc~tem_time_out proc~tem_varsys_out_single tem_varSys_out_single interface~tem_varsys_out->proc~tem_varsys_out_single proc~tem_varsys_out_vector tem_varSys_out_vector interface~tem_varsys_out->proc~tem_varsys_out_vector proc~tem_mesh_out->aot_out_close_table proc~tem_mesh_out->aot_out_open_table proc~tem_mesh_out->aot_out_val proc~tem_open->proc~newunit proc~tem_abort tem_abort proc~tem_open->proc~tem_abort proc~upper_to_lower upper_to_lower proc~tem_open->proc~upper_to_lower proc~tem_time_out->aot_out_close_table proc~tem_time_out->aot_out_open_table proc~tem_time_out->aot_out_val mpi_abort mpi_abort proc~tem_abort->mpi_abort proc~tem_varsys_out_single->aot_out_close_table proc~tem_varsys_out_single->aot_out_open_table proc~tem_varsys_out_single->aot_out_val proc~tem_varsys_out_vector->aot_out_close_table proc~tem_varsys_out_vector->aot_out_open_table proc~tem_varsys_out_vector->proc~tem_varsys_out_single

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
    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