replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Pure function - dummy argument intent(out)
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 

Pure function - dummy argument intent(out)

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



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Mon Feb 24, 2025 1:47 am    Post subject: Pure function - dummy argument intent(out) Reply with quote

The following program compiles and runs with FTN95.

However, since the function F1 is PURE its dummy arguments can only have INTENT(in).

Both iFort and gFortran complain about this code but not FTN95.

I discovered this one PURELY by accident!

Code:
module test
implicit none
contains
 
  pure function f1(a, rc) result( y )
  real, intent(in) :: a
  integer, intent(out) :: rc
  real :: y
    if (a .lt. 0.0) then
      y = 0.0
      rc = 0
    else   
      y = sqrt(a)
      rc = 1
    end if
  end function f1
 
end module test

program p
use test
implicit none
real a, b
integer rc
 a = -2.0
 b = f1(a, rc)
 print*, a, b, rc
 a = 2.0
 b = f1(a, rc)
 print*, a, b, rc
end program p
 
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Feb 25, 2025 11:37 am    Post subject: Reply with quote

Ken

Thank you for the valued feedback. This 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 -> Support 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