hvs_ascii_init Subroutine

public subroutine hvs_ascii_init(ascii, varsys, varpos, basename, globProc, outProc, solver, geometry, nElems, glob_nElems, timeControl, useGetPoint, nPoints, glob_nPoints, nDofs)

Initialize ascii output format. initialize spatial reduction if reduction is active

Arguments

Type IntentOptional Attributes Name
type(hvs_ascii_type), intent(inout) :: ascii

Ascii output file settings It must be intent inout since ascii%redSpatial are loaded in tem_load_trackingHeader

type(tem_varSys_type), intent(in) :: varsys

Description of the available variable system to get the given varnames from.

integer, intent(in) :: varpos(:)

List of variable positions that should be written in the output.

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

An extension to the output basename.

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

Global communicator type for global rank information

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

Process description to use.

type(tem_solveHead_type), intent(in) :: solver

Global solver information

type(tem_shape_type), intent(in), optional :: geometry(:)

shape defined for this ascii output

integer, intent(in) :: nElems

Number of elements to output by local process

integer(kind=long_k), intent(in) :: glob_nElems

Total number of elements across process on this output

type(tem_timeControl_type), intent(in), optional :: timeControl

output timeControl

logical, intent(in) :: useGetPoint

if get_point is to be used to track the point

integer, intent(in) :: nPoints

Number of points to output by local process

integer(kind=long_k), intent(in) :: glob_nPoints

Total number of points across process on this output

integer, intent(in) :: nDofs

The number of dofs for each scalar variable of the equation system


Calls

proc~~hvs_ascii_init~~CallsGraph proc~hvs_ascii_init hvs_ascii_init proc~tem_abort tem_abort proc~hvs_ascii_init->proc~tem_abort proc~hvs_ascii_write_header hvs_ascii_write_header proc~hvs_ascii_init->proc~hvs_ascii_write_header proc~hvs_ascii_open hvs_ascii_open proc~hvs_ascii_init->proc~hvs_ascii_open mpi_abort mpi_abort proc~tem_abort->mpi_abort interface~tem_shape_out tem_shape_out proc~hvs_ascii_write_header->interface~tem_shape_out proc~aot_out_close aot_out_close proc~hvs_ascii_write_header->proc~aot_out_close proc~tem_timecontrol_out tem_timeControl_out proc~hvs_ascii_write_header->proc~tem_timecontrol_out proc~tem_solvertag tem_solverTag proc~hvs_ascii_write_header->proc~tem_solvertag proc~aot_out_val aot_out_val proc~hvs_ascii_write_header->proc~aot_out_val proc~aot_out_open aot_out_open proc~hvs_ascii_write_header->proc~aot_out_open interface~tem_varsys_out tem_varSys_out proc~hvs_ascii_write_header->interface~tem_varsys_out proc~getheader getHeader proc~hvs_ascii_open->proc~getheader proc~tem_open tem_open proc~hvs_ascii_open->proc~tem_open proc~tem_shape_out_vec tem_shape_out_vec interface~tem_shape_out->proc~tem_shape_out_vec proc~tem_shape_out_scal tem_shape_out_scal interface~tem_shape_out->proc~tem_shape_out_scal proc~getheader->proc~tem_abort proc~tem_timecontrol_out->proc~aot_out_val proc~aot_out_open_table aot_out_open_table proc~tem_timecontrol_out->proc~aot_out_open_table proc~aot_out_close_table aot_out_close_table proc~tem_timecontrol_out->proc~aot_out_close_table proc~tem_time_out tem_time_out proc~tem_timecontrol_out->proc~tem_time_out 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_open->proc~tem_abort proc~upper_to_lower upper_to_lower proc~tem_open->proc~upper_to_lower proc~newunit newunit proc~tem_open->proc~newunit proc~tem_shape_out_vec->proc~aot_out_open_table proc~tem_shape_out_vec->proc~aot_out_close_table proc~tem_shape_out_vec->proc~tem_shape_out_scal proc~tem_varsys_out_vector->proc~aot_out_open_table proc~tem_varsys_out_vector->proc~aot_out_close_table proc~tem_varsys_out_vector->proc~tem_varsys_out_single proc~tem_shape_out_scal->proc~aot_out_val proc~tem_shape_out_scal->proc~aot_out_open_table proc~tem_shape_out_scal->proc~aot_out_close_table interface~tem_canonicalnd_out tem_canonicalND_out proc~tem_shape_out_scal->interface~tem_canonicalnd_out interface~tem_cylinder_out tem_cylinder_out proc~tem_shape_out_scal->interface~tem_cylinder_out proc~tem_shape_bclabel_out tem_shape_bcLabel_out proc~tem_shape_out_scal->proc~tem_shape_bclabel_out interface~tem_ellipsoid_out tem_ellipsoid_out proc~tem_shape_out_scal->interface~tem_ellipsoid_out proc~tem_shape_proplabel_out tem_shape_propLabel_out proc~tem_shape_out_scal->proc~tem_shape_proplabel_out interface~tem_triangle_out tem_triangle_out proc~tem_shape_out_scal->interface~tem_triangle_out interface~tem_stlhead_out tem_stlHead_out proc~tem_shape_out_scal->interface~tem_stlhead_out interface~tem_sphere_out tem_sphere_out proc~tem_shape_out_scal->interface~tem_sphere_out proc~tem_shape_level_out tem_shape_level_out proc~tem_shape_out_scal->proc~tem_shape_level_out proc~tem_time_out->proc~aot_out_val proc~tem_time_out->proc~aot_out_open_table proc~tem_time_out->proc~aot_out_close_table proc~tem_varsys_out_single->proc~aot_out_val proc~tem_varsys_out_single->proc~aot_out_open_table proc~tem_varsys_out_single->proc~aot_out_close_table

Called by

proc~~hvs_ascii_init~~CalledByGraph proc~hvs_ascii_init hvs_ascii_init proc~hvs_output_init hvs_output_init proc~hvs_output_init->proc~hvs_ascii_init proc~tem_init_tracker tem_init_tracker proc~tem_init_tracker->proc~hvs_output_init

Contents

Source Code


Source Code

  subroutine hvs_ascii_init(ascii, varSys, varPos, basename, globProc,         &
    &                       outProc, solver, geometry, nElems, glob_nElems,    &
    &                       timeControl, useGetPoint, nPoints, glob_nPoints,   &
    &                       nDofs)
    ! --------------------------------------------------------------------------!
    !> Ascii output file settings
    !! It must be intent inout since ascii%redSpatial
    !! are loaded in tem_load_trackingHeader
    type(hvs_ascii_type), intent(inout) :: ascii

    !> Description of the available variable system to get the given varnames
    !! from.
    type(tem_varSys_type), intent(in) :: varsys

    !> List of variable positions that should be written in the output.
    integer, intent(in) :: varpos(:)

    !> An extension to the output basename.
    character(len=*), intent(in) :: basename

    !> Global communicator type for global rank information
    type(tem_comm_env_type ), intent(in) :: globProc

    !> Process description to use.
    type(tem_comm_env_type), intent(in) :: outProc

    !> The number of dofs for each scalar variable of the equation system
    integer, intent(in) :: nDofs

    !> Number of elements to output by local process
    integer, intent(in) :: nElems

    !> Total number of elements across process on this output
    integer(kind=long_k), intent(in) :: glob_nElems

    !> Global solver information
    type(tem_solveHead_type ),intent(in) :: solver

    !> shape defined for this ascii output
    type(tem_shape_type), optional, intent(in) :: geometry(:)

    !> output timeControl
    type(tem_timeControl_type), optional, intent(in) :: timeControl

    !> if get_point is to be used to track the point
    logical, intent(in) :: useGetPoint

    !> Number of points to output by local process
    integer, intent(in) :: nPoints

    !> Total number of points across process on this output
    integer(kind=long_k), intent(in) :: glob_nPoints
    ! ----------------------------------------------------------------------!
    integer :: nVars, nScalars, chunkSize, nChunks
    ! Define limit for max number of tracking entities in ascii file
    integer, parameter :: nElemLimit_ascii = 50
    ! ----------------------------------------------------------------------!

    nVars = size(varPos)

    ! Check if there are too many entries for an ascii line
    if ( ( (nElems*nVars*nDofs > nElemLimit_ascii) &
      & .or. (nPoints*nVars > nElemLimit_ascii) )  &
      & .and. (.not. ascii%isReduce)  ) then
      write(logUnit(1),*)'Error in ascii output: '//trim(basename)
      write(logUnit(1),*)'Reduce is: ', ascii%isReduce
      if (useGetPoint) then
        write(logUnit(1),"(A,I0)")'Entities in output:', nPoints*nVars
      else
        write(logUnit(1),"(A,I0)")'Entities in output:', nElems*nVars*nDofs
      end if
      write(logUnit(1),"(A,I0)") 'Limit: ', nElemLimit_ascii
      write(logUnit(1),*)'Error: Too many entries for the tracking '//   &
        &            'entity as it is in ascii format'
      write(logUnit(1),*)'       All this information must be packed '// &
        &                'into one line.'
      write(logUnit(1),*)'Solution1: Use the Harvester format. '//       &
        &                 'It is way more efficient.'
      write(logUnit(1),*)'Solution2: reduce number of variables or '//   &
        &                'number of elements(segments)'
      call tem_abort()
    end if

    ! Compute nChunks, Abort if nChunks>1 asciiSpatial format
    ! and for ascii format abort if nChunk>1 and no reduction defined
    nScalars = sum(varSys%method%val(varPos(:))%nComponents)

    if (useGetPoint) then
      chunkSize = min(io_buffer_size/nScalars, nPoints)
    else
      chunkSize = min(io_buffer_size/(nScalars*nDofs), nElems)
    end if
    if ( (nElems > 0 .or. nPoints > 0) .and. (chunkSize == 0) ) then
      write(logUnit(0),*)'Error in ascii output: '//trim(basename)
      write(logUnit(0),*) 'The chosen io_buffer_size of ', io_buffer_size
      write(logUnit(0),*) 'is too small for outputting ', nScalars
      write(logUnit(0),*) 'scalar values'
      write(logUnit(0),*) 'Please increase the io_buffer_size to at &
        & least ', real(nScalars) / real(131072), ' MB!'
      call tem_abort()
    end if

    if (chunkSize>0) then
      if (useGetPoint) then
        nChunks = ceiling(real(nPoints, kind=rk)/real(chunkSize, kind=rk))
      else
        nChunks = ceiling(real(nElems, kind=rk)/real(chunkSize, kind=rk))
      end if
    else
      nChunks = 0
    end if

    ! abort if nChunk> 1 and reduction is not active
    if ( nChunks > 1 .and. (.not. ascii%isReduce) ) then
      write(logUnit(0),*)'Error in ascii output: '//trim(basename)
      write(logUnit(0),*)
      write(logUnit(0),*)'Number of chunks > 1'
      write(logUnit(0),*)'Solution: Define reduction of each variable to dump ',&
        &                'data in ascii format'
      call tem_abort()
    end if

    ascii%chunkSize = chunkSize
    ascii%nChunks   = nChunks
    ascii%basename  = trim(basename)

    ! write ascii header lua
    call hvs_ascii_write_header(out_format   = 'ascii',        &
      &                         basename     = trim(basename), &
      &                         varSys       = varSys,         &
      &                         varPos       = varPos,         &
      &                         globProc     = globProc,       &
      &                         outProc      = outProc,        &
      &                         nDofs        = nDofs,          &
      &                         solver       = solver,         &
      &                         geometry     = geometry,       &
      &                         timeControl  = timeControl,    &
      &                         glob_nElems  = glob_nElems,    &
      &                         useGetPoint  = useGetPoint,    &
      &                         glob_nPoints = glob_nPoints    )

    ! If reduction is active only root of this output
    ! dumps data else all process writes their own result file
    if ( (ascii%isReduce .and. outProc%rank == 0) .or. &
        & (.not. ascii%isReduce) ) then
      ! write header for result file
      call hvs_ascii_open( ascii   = ascii,   &
        &                  outProc = outProc, &
        &                  varSys  = varSys,  &
        &                  varPos  = varPos,  &
        &                  nDofs   = nDofs    )
    end if
  end subroutine hvs_ascii_init