replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - asin of angle
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 

asin of angle

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



Joined: 02 Sep 2008
Posts: 229

PostPosted: Wed Dec 18, 2024 11:37 pm    Post subject: asin of angle Reply with quote

Note: in Silverfrost Fortran, 64 bit with Win11, when calling the function ASIN(A) and A=1.D0, get "invalid floating point operation". The limits for A, per the mathematical functions for Silverfrost Fortran, are stated as -1.D0 <= A <= 1.D0. Should this not be an "invalid floating point operation? As a minimum, I would think that Silverfrost Fortran should be checking this limit to make sure that it is not stated as invalid. Sid Kraft
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2611
Location: Sydney

PostPosted: Thu Dec 19, 2024 1:03 am    Post subject: Reply with quote

My test on Win 10
Code:
      use iso_fortran_env
      real*8 :: a
      write (*,*) compiler_version ()
      write (*,*) compiler_options ()
      a = asin (1.0d0)
      write (*,*) a
      end

  FTN95 v9.04.0
 64;ECHO_OPTIONS;ERROR_NUMBERS;IMPLICIT_NONE;INTL;LINK;LOGL;NO_BANNER;UNLIMITED_ERRORS;VS7;
           1.57079632679


I would check SET PATH
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 19, 2024 8:59 am    Post subject: Reply with quote

Sid

I have tested John's code under Windows 11 (both 23 H2 and 24 H2).
I have also tested with /checkmate etc.
I have not been able to reproduce your error report.

Please supply a sample program that demonstrates the fault together with details of the FTN95 version that you are using.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Thu Dec 19, 2024 11:25 am    Post subject: Reply with quote

Consider this simple example:

Code:
program p
implicit none
real*8 :: y
y = 1.d0
print*, y
print*, asin(y)
y = 1.d0 + epsilon(1.d0)   ! Y is now ever so slighty greater than 1
                           ! (as may happen in a real calculation where
                           ! the expect value is exactly 1.d0)
print*, y                  ! Not obvious when you print the value.
print*, asin(y)          ! Invalid float error!
end program p


One way around this problem is to do the following:

Code:
program p
implicit none
real*8 :: y
y = 1.d0
print*, y
print*, asin(y)
y = 1.d0 + epsilon(1.d0)    ! Y is now ever so slighty greater than 1
                            ! (as may happen in a real calculation where
                            ! the expect value is exactly 1.d0)
print*, y                   ! Not obvious when you print the value.
print*, limited_arg_asin(y) ! Call a function which truncates y to valid
                            ! valid range and then returns the arcsine

contains

function limited_arg_asin(x) result (x1)
real*8, intent(in) :: x
real*8 :: x1
  if(x .gt. 1.d0) then
    x1 = 1.d0
  else if (x .lt. -1.d0) then
    x1 = -1.d0
  else
    x1 = x
  end if
  x1 = asin(x1)
end function limited_arg_asin

end program p
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Thu Dec 19, 2024 12:11 pm    Post subject: Reply with quote

Alternative function without block ifs:
Code:
program p
implicit none
real*8 :: y
y = 1.d0
print*, y
print*, asin(y)
y = 1.d0 + epsilon(1.d0)
print*, y
print*, Dasin_t(y)

contains

  function Dasin_t (y) result (asiny)
  real*8 :: asiny
  real*8, intent(in) :: y
  real*8 :: x
    x = max(y,-1.d0)
    x = min(x, 1.d0)
    asiny = asin(x)
  end function Dasin_t

end program p
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Thu Dec 19, 2024 12:39 pm    Post subject: Reply with quote

FTN95 has now been fixed for the next release so that an argument that is out of bounds will give a meaningful runtime failure message (as already occurs for Win32).
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