Provide for a free unit, from here John Burkardt website
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4), | intent(out) | :: | iunit |
free unit to use |
subroutine get_unit(iunit) !! Provide for a free unit, from here [John Burkardt website](https://people.sc.fsu.edu/~jburkardt/f_src) implicit none integer(kind=I4), intent(out) :: iunit !! free unit to use integer(kind=I4) :: i integer(kind=I4) :: ios logical(kind=I4) :: lopen iunit = 0 do i = 10, 99 if (i /= OPU .and. i /= IPU .and. i /= ERU) then inquire (unit = i, opened = lopen, iostat = ios) if (ios == 0) then if ( .not. lopen ) then iunit = i return endif endif endif enddo return endsubroutine get_unit