Initialize ascii output format. initialize spatial reduction if reduction is active
Type | Intent | Optional | 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 |
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