aot_out_open Subroutine

public subroutine aot_out_open(put_conf, filename, outUnit, indentation, outstat)

Open the file to write to and return a handle (put_conf) to it.

This will overwrite the given file, if it already exists. Either filename of outUnit has to be specified, use outUnit to write to a pre-connected file. If both are given, the file will be opened and connected to a new unit, outUnit is ignored in this case.

Arguments

Type IntentOptional AttributesName
type(aot_out_type), intent(out) :: put_conf

Handle for the file

character(len=*), intent(in), optional :: filename

File to open

integer, intent(in), optional :: outUnit

Pre-connected unit to write to

integer, intent(in), optional :: indentation

Spacer per indentation level

integer, intent(out), optional :: outstat

IO status of the open operation for the given filename or an indication whether the given outUnit is actually connected to an open file.

This returns 0 if the the returned unit has properly been properly connected to the file.


Calls

proc~~aot_out_open~~CallsGraph proc~aot_out_open aot_out_open proc~newunit newunit proc~aot_out_open->proc~newunit

Contents

Source Code


Source Code

  subroutine aot_out_open(put_conf, filename, outUnit, indentation, outstat)
    !------------------------------------------------------------------------
    type(aot_out_type), intent(out) :: put_conf !! Handle for the file
    character(len=*), optional, intent(in) :: filename !! File to open
    integer, optional, intent(in) :: outUnit !! Pre-connected unit to write to
    integer, optional, intent(in) :: indentation !! Spacer per indentation level

    !> IO status of the open operation for the given filename or an indication
    !! whether the given outUnit is actually connected to an open file.
    !!
    !! This returns 0 if the the returned unit has properly been properly
    !! connected to the file.
    integer, optional, intent(out) :: outstat
    !------------------------------------------------------------------------
    integer :: iError
    logical :: isOpen
    !------------------------------------------------------------------------

    if (present(indentation)) then
      put_conf%in_step = indentation
    else
      put_conf%in_step = 4
    end if

    if (present(filename)) then
      put_conf%outunit = newunit()
      open(unit = put_conf%outunit, file = trim(filename), action = 'write', &
        &  status='replace', recl = 360, iostat=iError)
      put_conf%externalOpen = .false.
    else if (present(outUnit)) then
      inquire(unit=outUnit, opened=isOpen)
      if (isOpen) then
        iError = 0
      else
        iError = -10
      end if
      put_conf%externalOpen = .true.
      put_conf%outunit = outUnit
    end if

    if (present(outstat)) outstat = iError

    put_conf%indent = 0
    put_conf%stack(:) = 0
    put_conf%level = 0

  end subroutine aot_out_open