|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
arctica
Joined: 10 Sep 2006 Posts: 105 Location: United Kingdom
|
Posted: Sun Dec 24, 2023 5:15 pm Post subject: Extension to iso_fortran_env |
|
|
Hello.
There does not appear to be support for ieee_arithmetic in the current ftn95 e.g.
Code: |
program ieee
use, intrinsic :: iso_fortran_env, only: wp=>real64
use, intrinsic :: ieee_arithmetic
implicit none
print *, ieee_value(1.0_wp, ieee_positive_inf)
print *, ieee_value(1.0_wp, ieee_negative_inf)
end program ieee
|
This might be handy to have in a future release to deal better with coding infinity into mathematical functions. For infinity I just set a very large number as a break point.
Lester |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8040 Location: Salford, UK
|
Posted: Wed Dec 27, 2023 9:23 am Post subject: |
|
|
Lester
Thank you for the feedback. I have made a note of your suggestion.
This is a part of the 2003 Standard that has not yet been implemented in FTN95.
At the moment computing z = 0.0 then v = 1.0/z will raise a runtime time exception as will v = z/z. This default exception handling will need to be changed when implementing the ieee_arithmetic module and this could be unsafe if the programmer is not fully aware if the implications. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8040 Location: Salford, UK
|
Posted: Mon May 13, 2024 8:15 am Post subject: |
|
|
The next release of FTN95 and its associated DLLs will provide support for the Fortran 2003 intrinsic IEEE_ARITHMETIC module.
This is particularly for x64, with some support for Win32.
A new routine TRAP_FP_EXCEPTIONS@ will be released for x64 but not for Win32.
-------------------------------------------------------------------------------------------------------------------
SUBROUTINE TRAP_FP_EXCEPTIONS@(trap)
INTEGER trap
A trap value of zero masks all floating point runtime exceptions. A non-zero value restores the default state where
floating point exceptions lead to a runtime failure.
This routine is not provided for Win32 because the the existing TRAP_EXCEPTION@ function does not enable
progression (i.e. the CONTINUE_EXECUTION return state) after handling a floating point exception.
--------------------------------------------------------------------------------------------------------------------
1) TRAP_FP_EXCEPTIONS@ is implemented independently of the IEEE_ARITHMETIC module.
2) Standard PRINT and WRITE statements will display "NaN", "Infinity", or "-Infinity" where appropiate (depending on the
field width) and this is independent of IEEE_ARITHMETIC. The current output is "????....".
3) Users who want to mask floating point exceptions must use x64 and must call TRAP_FP_EXCEPTIONS@(0) for related sections
of their code.
Example
---------
real t,z,v(6)
z = 0.0
t = tiny(z)
call trap_fp_exceptions@(0)
v = [z/z,z/1.0,-z/1.0,1.0/z,-1.0/z,t/10]
call trap_fp_exceptions@(1)
do i = 1,6; print*, v(i); end do
end
Output:
--------
NaN
0.00000
0.00000
Infinity
-Infinity
0.00000 |
|
Back to top |
|
|
|
|
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
|