hvs_vtk_init Subroutine

public subroutine hvs_vtk_init(vtk_file, vtk_config, basename, proc)

Initialize the type for VTK format

Arguments

Type IntentOptional Attributes Name
type(hvs_vtk_file_type), intent(inout) :: vtk_file

The file description to open.

type(hvs_vtk_config_type), intent(in) :: vtk_config

User specified settings for the output

character(len=*), intent(in) :: basename

Basename for the output file, rank and suffix will be appended as needed.

type(tem_comm_env_type), intent(in) :: proc

Parallel environment to use for the output.


Calls

proc~~hvs_vtk_init~2~~CallsGraph proc~hvs_vtk_init~2 hvs_vtk_init proc~tem_open tem_open proc~hvs_vtk_init~2->proc~tem_open proc~upper_to_lower upper_to_lower proc~tem_open->proc~upper_to_lower proc~tem_abort tem_abort proc~tem_open->proc~tem_abort proc~newunit newunit proc~tem_open->proc~newunit mpi_abort mpi_abort proc~tem_abort->mpi_abort

Called by

proc~~hvs_vtk_init~2~~CalledByGraph proc~hvs_vtk_init~2 hvs_vtk_init proc~hvs_dump_debug_array hvs_dump_debug_array proc~hvs_dump_debug_array->proc~hvs_vtk_init~2

Contents

Source Code


Source Code

  subroutine hvs_vtk_init(vtk_file, vtk_config, basename, proc)
    ! --------------------------------------------------------------------------!
    !> The file description to open.
    type(hvs_vtk_file_type), intent(inout) :: vtk_file

    !> User specified settings for the output
    type(hvs_vtk_config_type), intent(in) :: vtk_config

    !> Basename for the output file, rank and suffix will be appended as
    !! needed.
    character(len=*), intent(in) :: basename

    !> Parallel environment to use for  the output.
    type(tem_comm_env_type), intent(in) :: proc
    ! --------------------------------------------------------------------------!
    character(len=PathLen) :: headerline
    character :: linebreak
    character(len=labelLen) :: byte_order
    logical :: pvd_opened_already
    ! --------------------------------------------------------------------------!

    ! Copy the dataform for later usage without the vtk_config.
    vtk_file%dataform = vtk_config%dataform

    ! Assume no cell data, until actual celldata has been written.
    vtk_file%has_celldata = .false.

    ! Store the basename for later retrieval.
    vtk_file%basename = basename

    if ( isLittleEndian ) then
      byte_order = 'LittleEndian'
    else
      byte_order = 'BigEndian'
    end if

    ! Write pvtu file only when nProc > 1
    vtk_file%write_pvtu = ( (proc%comm_size > 1)   &
      &                     .and. (proc%rank == 0) )

    ! Write PVD file header from root and only if it is not
    ! deactivated in output table
    vtk_file%write_pvd = (proc%rank == 0) .and. vtk_config%write_pvd

    if ( vtk_file%write_pvd ) then
      inquire( file   = trim(basename)//'.pvd', &
        &      opened = pvd_opened_already      )

      if (.not. pvd_opened_already) then
        ! Only need to open pvd file if it was not already opened
        ! before
        call tem_open( newunit = vtk_file%pvdunit,       &
          &            file    = trim(basename)//'.pvd', &
          &            action  = 'write',                &
          &            status  = 'replace',              &
          &            form    = 'unformatted',          &
          &            access  = 'stream'                )

        linebreak = new_line('x')

        write(headerline,'(a)') '<?xml version="1.0"?>'
        write(vtk_file%pvdunit) trim(headerline)//linebreak

        write(headerline,'(a)') '<VTKFile type="Collection" ' &
          &                     // 'version="0.1" byte_order="'&
          &                     //trim(byte_order)//'">'
        write(vtk_file%pvdunit) trim(headerline)//linebreak

        write(headerline,'(a)') '<Collection>'
        write(vtk_file%pvdunit) trim(headerline)//linebreak
        flush(vtk_file%pvdunit)
      else
        ! PVD file already opened, get the unit it is connected to.
        inquire( file   = trim(basename)//'.pvd', &
          &      number = vtk_file%pvdunit        )
      end if
    end if

  end subroutine hvs_vtk_init