get_unused_unit Subroutine

public subroutine get_unused_unit(unit)

Get an unused unit number for I/O.

FIXME: remove and replace with newunit in open

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: unit

A new unit not associated with an open file


Contents

Source Code


Source Code

  subroutine get_unused_unit (unit)
    implicit none
    !> A new unit not associated with an open file
    integer, intent (out) :: unit
    logical :: od
    unit = 50
    do
       inquire (unit=unit, opened=od)
       if (.not.od) return
       unit = unit + 1
    end do
  end subroutine get_unused_unit