hvs_ascii_open Subroutine

public subroutine hvs_ascii_open(ascii, outProc, varSys, varPos, nDofs)

open the ascii transient output unit

Arguments

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

ascii output type

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

Parallel environment to use for the output.

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

solver-provided variable systems

integer, intent(in) :: varPos(:)

Position of variables to dump in varSys

integer, intent(in) :: nDofs

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


Calls

proc~~hvs_ascii_open~~CallsGraph proc~hvs_ascii_open hvs_ascii_open proc~tem_open tem_open proc~hvs_ascii_open->proc~tem_open proc~getheader getHeader proc~hvs_ascii_open->proc~getheader 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 proc~getheader->proc~tem_abort mpi_abort mpi_abort proc~tem_abort->mpi_abort

Called by

proc~~hvs_ascii_open~~CalledByGraph proc~hvs_ascii_open hvs_ascii_open proc~hvs_ascii_init hvs_ascii_init proc~hvs_ascii_init->proc~hvs_ascii_open 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_open( ascii, outProc, varSys, varPos, nDofs )
    ! ---------------------------------------------------------------------------
    !> ascii output type
    type(hvs_ascii_type ), intent(inout) :: ascii
    !> Parallel environment to use for  the output.
    type(tem_comm_env_type ), intent(in)    :: outProc
    !> solver-provided variable systems
    type(tem_varSys_type), intent(in)       :: varSys
    !> Position of variables to dump in varSys
    integer, intent(in) :: varPos(:)
    !> The number of dofs for each scalar variable of the equation system
    integer, intent(in) :: nDofs
    ! ---------------------------------------------------------------------------
    character(len=labelLen)  :: logName
    character(len=1500) :: buffer
    logical             :: nUnitOpened
    logical             :: file_exists
    integer             :: UnitNumber
    ! ---------------------------------------------------------------------------
    file_exists = .false.
    nUnitOpened = .false.

    write(buffer,'(i5.5)') outProc%rank
     ! Include the rank name in the file name to avoid overwriting of files
     ! by different processes
    write(logName,'(a)') trim(ascii%basename)//'_p'//trim(buffer)//'.res'

    ! check if the file exists
    inquire( file = trim(logName), exist = file_exists )
    if( file_exists )then
      ! \todo: SZ: before simply appending check if header lua exists, open
      !            it, read the varSys and compare it with the one requested
      !            by this tracking object.
      !            if equal     -> appened file_exists
      !            if not equal -> put a new behind the filename and open
      !                            a new file

      ! in case the file exists, check wether it is already opened somewhere
      ! else (dyn load balancing)
      inquire( file=trim(logName), opened=nUnitOpened, number=UnitNumber )
      if (nUNitOpened) then
        ! if it is opened, use the corresponding unit
        ascii%outunit = UnitNumber
      else
        ! get a new unit and reopen the file
        call tem_open( newunit  = ascii%outunit, &
          &            file     = trim(logName), &
          &            action   = 'WRITE',       &
          &            position = 'APPEND',      &
          &            status   = 'OLD'          )
      end if
    else
      ! in case the file does not exist, get a new unit and open a new file
      ! and write the header
      call tem_open( newunit  = ascii%outunit, &
        &            file     = trim(logName), &
        &            action   = 'WRITE',       &
        &            status   = 'NEW'          )
      write ( ascii%outunit , '(a,i7)' ) '# Rank of the process: ',         &
        &                                 outProc%rank
    end if

    if (.not. file_exists .and. .not. nUnitOpened) then
      write( buffer, '(a)' ) '#'
      write( buffer, '(a,a23)' ) trim(buffer),'time'
      buffer = trim(buffer)                                    &
        &    //trim(getHeader( varSys, varPos, nDofs, ascii%isReduce ))
      ! ... and write the header row to the file
      write ( ascii%outunit , '(a)' ) trim(buffer)
    end if

  end subroutine hvs_ascii_open