GetLUN Subroutine

public subroutine GetLUN(LUN, RC)

The routine GetLUN finds a valid logical unit number in the range 1-100. IMPORTANT: This is the minimal-effort version of this routine, and extremely slow!

History

  • 09 Jan 2016 - S. D. Eastham - Initial version

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: LUN
integer, optional :: RC

Called by

proc~~getlun~~CalledByGraph proc~getlun GetLUN proc~readinput ReadInput proc~readinput->proc~getlun proc~readtilefile readTileFile proc~readtilefile->proc~getlun

Source Code

      Subroutine GetLUN(LUN,RC)
!
! !USES:
!

!      Use Precision_Mod, Only: f4

!
! !INPUT PARAMETERS:
!
!
! !OUTPUT PARAMETERS:
!
      Integer, Intent(Out)                 :: LUN
      Integer, Optional                    :: RC
!
!-----------------------------------------------------------------------
!BOC
!
! !LOCAL VARIABLES:
!
      Integer :: I, RC_
      Logical :: isOpen

      !=================================================================
      ! GetLUN starts here!
      !=================================================================

      isOpen = .True.
      LUN = -1
      RC_ = 0
      Do I = 8,100
         Inquire(Unit=I,Opened=isOpen)
         If (.not.isOpen) Then
            LUN = I
            Exit
         End If
      End Do
      If (isOpen) RC_ = -1
      If (Present(RC)) RC = RC_

      End Subroutine GetLUN