soccer jersey forums.silverfrost.com :: View topic - Extension to iso_fortran_env
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 

Extension to iso_fortran_env

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



Joined: 10 Sep 2006
Posts: 105
Location: United Kingdom

PostPosted: Sun Dec 24, 2023 5:15 pm    Post subject: Extension to iso_fortran_env Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Dec 27, 2023 9:23 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon May 13, 2024 8:15 am    Post subject: Reply with quote

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 all
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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions 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