soccer jersey forums.silverfrost.com :: View topic - Failure at run-time with format F when using real KIND=3
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 

Failure at run-time with format F when using real KIND=3

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



Joined: 21 Oct 2020
Posts: 67

PostPosted: Thu Aug 01, 2024 12:12 pm    Post subject: Failure at run-time with format F when using real KIND=3 Reply with quote

The following program, compiled with FTN95 v. 9.03.0.0 Win32, raises an exception (Invalid floating point operation) at runtime for i=19.
This error doesn't occur if KIND=2 is used for the real variables or F7.3 instead of F7.2 in the 9000 FORMAT.
Am I missing an obvious pitfall in this case?
Code:
PROGRAM RUNGE
IMPLICIT NONE
INTEGER :: I, N
REAL(KIND=3) :: A, B, T
A=0.0
B=5.0
N=1000
DO I=1,N
  T=(B-A)*FLOAT(I)/FLOAT(N)
  WRITE(*,9000) I,T
END DO
9000 FORMAT(1X,I4,3X,F7.2)
END PROGRAM RUNGE
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 01, 2024 1:11 pm    Post subject: Reply with quote

There appears to be a problem with F7.2 for extended precision in this context but G7.2 seems to work OK.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2580
Location: Sydney

PostPosted: Fri Aug 02, 2024 4:01 am    Post subject: Reply with quote

This is a very strange error !
The following does not show the problem ?
Code:
  PROGRAM RUNGE
  IMPLICIT NONE
  INTEGER :: I, N
  REAL(KIND=3) :: A, B, T

  A=0.0
  B=5.0
  N=1001       !  35  !  1000
  DO I=1,N
    T=(B-A)*FLOAT(I)/FLOAT(N)
    WRITE(*,9000) I,T
  END DO
  9000 FORMAT(1X,I4,3X,F7.2)
 
  END PROGRAM RUNGE


N = 35 or N=1001 work ok, but why not N=1000 ?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2580
Location: Sydney

PostPosted: Fri Aug 02, 2024 11:09 am    Post subject: Reply with quote

This shows how unique this problem might be.
The following variant shows there is something special about N = 1000 ; i = 19 ?
Does anyone know the reason for the problem with this ?

Code:
  PROGRAM RUNGE
  IMPLICIT NONE
  INTEGER :: I, N
  REAL(KIND=3) :: A, B, T

  A=0.0
  B=5.0
  do n = 4,1004
!  N=1000       !  35  !  1000
  DO I=1,N
    T=(B-A)*FLOAT(I)/FLOAT(N)
    WRITE(*,9000) I,T
  END DO
  end do
  9000 FORMAT(1X,I4,3X,F7.2)
 
  END PROGRAM RUNGE


I am running using PLATO with Checkmate, Win32
[FTN95/x64 Ver. 9.03.0.0 Copyright (c) Silverfrost Ltd 1993-2024]

Even with Release, Win32 it crashes at i=19

The following change skips the error,
do n = 994,1004
if ( n == 1000 ) cycle

??
Back to top
View user's profile Send private message
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Fri Aug 02, 2024 11:47 am    Post subject: Reply with quote

Paul
A similar error occurs with N=10000 or 100000 or 1000000 and G7.2 at I=199
John
Thanks for confirming the bug. A similar error occurs with N=10000 and F7.2 at I=189 (not 199!).
Neither the DO loop nor the reals A and B are needed, the reproducer can be reduced to the following:
Code:
PROGRAM RUNGE
IMPLICIT NONE
INTEGER :: I, N
REAL(KIND=3) :: T
I=95
N=1000
T=FLOAT(I)/FLOAT(N)
WRITE(*,9000) I,T
9000 FORMAT(1X,I4,3X,F7.2)
END PROGRAM RUNGE
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1225
Location: Morrison, CO, USA

PostPosted: Fri Aug 02, 2024 6:55 pm    Post subject: Reply with quote

No error if you use dble(i)/dble(n).

However, the value displayed for the floating point value is still all ******'s.

The hexadecimal of this is interesting as a repeating pattern:

C28F5C28F5C28F5C
Back to top
View user's profile Send private message Visit poster's website
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Sat Aug 03, 2024 1:34 pm    Post subject: Reply with quote

Bill
I still get the same error with DBLE(I)/DBLE(N) using FTN95 version 9.03.0.0 Win32.
Do you have an easy way to get the full hexadecimal "physical" representation of a KIND=3 real (80-bit) number, since I can only use 64-bit integers (KIND=4) as targets with the TRANSFER method in FTN95?
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1225
Location: Morrison, CO, USA

PostPosted: Mon Aug 05, 2024 5:47 pm    Post subject: Reply with quote

This should work. This causes an error in both Checkmate and Release.

Code:

   PROGRAM RUNGE
   IMPLICIT NONE
   INTEGER :: I, N
        integer (KIND=4):: k=0
        integer(7):: my_loc,indx
   REAL (kind=3) :: T
   I=95
   N=1000
        t=0.0
   T=FLOAT(I)/FLOAT(N)
        my_loc = loc(t)
!        print *,my_loc ! decimal
        write(*,9002)my_loc,(core1(my_loc+indx-1),indx=1,10)
   WRITE(*,9000) I,T
9000   FORMAT(1X,I4,3X,F7.2)
9001   format(z20.20)
9002   format('Start Addr=',z8.8,': ',10z2.2)
   END PROGRAM RUNGE
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1225
Location: Morrison, CO, USA

PostPosted: Mon Aug 05, 2024 6:25 pm    Post subject: Reply with quote

FWIW: Fortran 9.02.00
Back to top
View user's profile Send private message Visit poster's website
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Tue Aug 06, 2024 12:38 pm    Post subject: Reply with quote

Bill
Thanks for the method of showing the physical representation of a 80-bit real number. I had all the knowledge to do it myself, as you kindly gave me a workaround for C_F_POINTER some time ago, but unfortunately I didn't recover the trick. Sorry for that and thanks again for your help.


Last edited by jlb on Tue Aug 20, 2024 1:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1225
Location: Morrison, CO, USA

PostPosted: Wed Aug 07, 2024 4:07 pm    Post subject: Reply with quote

No worries! That's what this forum is for, helping others!
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Aug 19, 2024 9:25 am    Post subject: Reply with quote

This failure has now been fixed for the next release of salflibc.dll.
Back to top
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Tue Aug 20, 2024 9:34 am    Post subject: Reply with quote

Paul
Thank you for this.
Back to top
View user's profile Send private message
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