replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Access violation with 64 bit compiler
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Access violation with 64 bit compiler

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 818
Location: Lanarkshire, Scotland.

PostPosted: Thu Feb 27, 2025 11:38 am    Post subject: Access violation with 64 bit compiler Reply with quote

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.

Code:
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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8217
Location: Salford, UK

PostPosted: Thu Feb 27, 2025 12:50 pm    Post subject: Reply with quote

Ken

Thank you for the bug report which I have logged for investigation.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Sat Mar 01, 2025 8:42 am    Post subject: Reply with quote

The following edit removes the problem
Code:
program p
use test_mod
implicit none
 logical :: is_unit
 integer :: lu
  lu = nextfreeunit()
  is_unit = isfree(10)
  print*, lu
  print*, is_unit
!  print*, nextfreeunit()
!  print*, isfree(10)
end program p


I have also had what may be similar problems recently when using a function in a print/write statement.
Evaluating the function first removes the problem, althouigh the use of a function in a write statement is allowed.

I am not sure if it is now allowed for the function to itself perform (internal) I/O ?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8217
Location: Salford, UK

PostPosted: Tue Mar 04, 2025 4:33 pm    Post subject: Reply with quote

In general recursive IO is not permitted in FTN95. It is permitted in certain cases such as this INQUIRE and the fact that it failed is an x64 bug.

This failure has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group