The following code runs correctly with the 32 bit compiler.
A run time access violation occurs when compiled and run with the 64 bit compiler.
module test_mod
implicit none
contains
function nextfreeunit() result( iunit )
! Returns the next available Fortran I/O unit in the range 10 to 99
integer :: i, ios, iunit
logical :: lopen
iunit = 0
do i = 10, 99
inquire ( unit = i, opened = lopen, iostat = ios )
if ( ios .eq. 0 ) then
if ( .not. lopen ) then
iunit = i
return
end if
end if
end do
end function nextfreeunit
function isfree(i) result (yes)
integer, intent(in) :: i
integer :: ios
logical :: lopen, yes
inquire ( unit = i, opened = lopen, iostat = ios )
if ( ios .eq. 0 .and. .not. lopen) then
yes = .true.
else
yes = .false.
end if
end function isfree
end module test_mod
program p
use test_mod
implicit none
print*, nextfreeunit()
print*, isfree(10)
end program p