GETFILEUNIT Function

public function GETFILEUNIT(Name, RC)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: Name
integer, intent(out), optional :: RC

Return Value integer


Source Code

  INTEGER FUNCTION GETFILEUNIT(name,  RC )
    IMPLICIT NONE
    character(LEN=*), intent(in   )           :: Name
    integer         , intent(  out), OPTIONAL :: RC

    integer :: i
    logical :: found

    found = .false.
    do i = 2, last_unit
       if(name==Mname(i)) then
          found = .true.
          exit
       end if
    end do

    if (.not. found) then
       do i = 2,last_unit
          if(.not.MTAKEN(i)) then
             found = .true.
             exit
          endif
       enddo
    end if

    if (.not. found) then
       if(present(rc)) rc = 1
       return
    endif

    mname(i)   = name
    mtaken(i)  = .true.
    getfileunit = i

    if(present(rc)) rc = 0
    return
  end function getfileunit