free_unit Function

public function free_unit(n) result(unit_)

Arguments

Type IntentOptional Attributes Name
integer, optional :: n

Return Value integer


Called by

proc~~free_unit~~CalledByGraph proc~free_unit free_unit interface~newunit newunit interface~newunit->proc~free_unit

Source Code

  function free_unit(n) result(unit_)
    integer,optional :: n
    integer          :: unit_,ios
    logical          :: opened
    unit_=100
    do 
       unit_=unit_+1
       INQUIRE(unit=unit_,OPENED=opened,iostat=ios)
       if(.not.opened.AND.ios==0)exit 
       if(unit_>900) stop "ERROR free_unit: no unit free smaller than 900. Possible BUG"
    enddo
    if(present(n))n=unit_
  end function free_unit