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 

Behavior of system function EXP with very low parameter

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



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Jul 01, 2012 10:50 am    Post subject: Behavior of system function EXP with very low parameter Reply with quote

Have anyone ever noticed that strange (sorry, not reproducible yet in small code though i am trying) behavior of the compiler and SDBG debugger when you get single precision EXP(X) with very small X, say X<-70?

Since it is not overflow but underflow the code still should work as if EXP=0. And it mostly works fine. But sometimes the code starts to behave irrationally as if it was corrupted. The debugger may stop (or may not) on the line with such small EXP, debugging will not go to the next line and control returned to main program, Clearwin+ GUI starts to hiccup - callbacks are not called, %dd freezes - but closing window and opening again makes the code work again. The code generally may still continue to work (or may freeze).

Workaround is in using IF and not letting EXP to take such small values of X.
Getting that for 20+ years ones in a while since FTN77. Could be some other hidden error in my code though but i suspect here some old devilry with the underflow handling.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Jul 02, 2012 1:38 am    Post subject: Reply with quote

Dan,

I compiled the following example as "ftn95 exp /check /link", then ran using SDBG. Using F7, I stepped past i=88 where "Y" underflowed to 0 and did not produce any other error report.
Not sure if this excludes the problem from SDBG?

John
Code:
integer i
real    x,y
!
do i = -85,-100,-1
   x = i
   y = exp(x)
   write (*,*) i,x,y
end do
end


ps, Dan, the following example fails with overflow, but not underflow. This shows a different type of result, where underflow is treated differently to overflow, in the default error response.
Code:
integer i, k
real two, x, y
!
two = 2
do i = 120,130
  k = -i
  y = two**i
  x = two**k
  write (*,*) k,x,y
end do
end
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Jul 02, 2012 9:46 am    Post subject: Reply with quote

Yea, this thing is not reproducible. We are hunting for something very rear. Here could be some other error or corruption, of course.

Similar corruptions when debugger stops on legitimate line and does not go further for example happen when you exceed allocatable limits beyond 3GB (and you probably know that better then anybody else!), but right now with this specific case i am not that aggressive and leave a lot of free space.

Searching for reasons, i look for patterns of happening similar things in different places at different times each with very small probabilities. EXP was one such painful rear instances. Let's wait some time may be someone experienced similar symptoms. Damn thing in the code killed three days of life searching just for simple bug...

Another possible suspicion (also based on coincidence for similarly rear things in different places) is with %^rd with spinning wheel and callback like this one

i=winio@('%`bg[white]%dd%il%4^rd%`il&', 1, 1, Nl, i0dLowLevel, AtConstRenewal)

The CWP GUI where it happen is large. Seems it's really good practice to keep it small and simple...but Clearwin+ is addictive..it's a crack cocaine of Fortran programmers Smile ( i do not understand why authors are not expanding it to Linux and Android and Windows Mobile and iOS, the phones and tablets...). Same things caused by some kind of corruption happened in another place in the code with its own large CWP GUI where i've tried to change some variable the way above but no matter what i have done i miserably failed and backed off... It takes decades to be a Pro with CWP, clearly i'm still an apprentice !
So did anyone see sometimes something unusual with %dd%^rd ?
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 -> General 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