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 

Floating Point Stack Fault

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



Joined: 20 Jan 2007
Posts: 3
Location: Tennessee, USA

PostPosted: Tue Jan 23, 2007 5:51 am    Post subject: Floating Point Stack Fault Reply with quote

Hello,
First, thanks to Silverfrost for making a free version of their software available. I had Fortran77 in college last century and I’ve enjoyed refreshing my (limited) skills. I especially like Clearwin+ and the ability to make GUI’s fairly easily.
Speaking of which, I’m having a problem with code I’ve written. It calculates various quantities relevant to stocks. Very simple math but when I enter a number in the second field of any of the 5 options, I get a “floating point stack fault”. I take that to mean that the number created is beyond the allocated memory. But the numbers are no larger than 10^5 or no smaller than 10^-3 and I'm using Real*8 values. And the error occurs before I even compute the value. Twice I got the “Blue Screen of Death” because of this.
I upgraded from version 4.9 to 5.01 but it didn't help as well as trying to debug. The worst part is that it’s an intermittent problem. Sometimes it works fine.
It may be a computer problem but I’ve written numerous programs including some with thousands of iterations with few problems. The only thing different is with this program I’m using the paneled radio button format within a parent window.
I’ve searched the forum and haven’t found a similar problem. I keep thinking I may be overlooking something simple but I just don't know.
Partial Code below. The module is a separate file. I use XP and Pentium chip.
Thanks for any help.
Tom
!****************************************
Code:

Module Stocks_Mod
Implicit None
Character TenPercentStr*10,TenPercentPhrase*35,FivePercentStr*10,
Character FivePercentPhrase*35,PercentChangePhrase*35
Character PercentPhrase*30, PercentChangeStr*7
Character TotalSharePhrase*45,PercentStr*8
Character SharePhrase*35, TotalSharesStr*15, PricePhrase*26, TotalPriceStr*15, TotalPricePhrase*45   
Real*8 TenPercent,FivePercent
Real*8 PercentChange,TotalShares, TotalPrice, Price_p_Share
Real*8 Price_p_Share_Final, Price_p_Share_Int
Integer*4 i, winio@, lwo, r(10) 
End Module Stocks_Mod
!*****************************************
WINAPP
Use MSWIN
Use Stocks_Mod
External Shares, Price, PercentChange_Func, Five_Per, Ten_Per
r(1)=0
r(2)=0
r(3)=0
r(4)=0
r(5)=0
i=winio@('%ca[Stocks]%lw&',lwo)
i=winio@('%pv%fr',425,450)
i=winio@('%ww[no_frame,no_caption,no_border]&')
i=winio@('%5ga&',r(1),r(2),r(3),r(4),r(5))
i=winio@('%3.2ob[panelled]%^rb[Number of Shares]%cb&',r(1),Shares)
i=winio@('%^rb[Total Price]%cb&',r(2),Price)
i=winio@('%^rb[Percent Change]%cb&',r(3),PercentChange_Func)
i=winio@('%^rb[5%]%cb&',r(4),Five_Per)
i=winio@('%^rb[10%]%cb&',r(5),Ten_Per)
i=winio@('%aw%cb',lwo)
End
!************************************
Real*8 Function Price()
Use Stocks_Mod
External CalculatePrice, Z
TotalShares=0
Price_p_Share=0.01d0
TotalPricePhrase=' '
i=winio@('%ca[Price Calculator]&')
i=winio@('%cnEnter the share price: %nl%cn%rf&',Price_p_Share)
i=winio@('%2nl%cnEnter the number of shares: %2nl%cn%rf&', TotalShares)
i=winio@('%nl%cn%`^bt[Compute]%ta%^bt[Clear]&',CalculatePrice,Z)
i=winio@('%5nl%cn%ob%45st%cb&', TotalPricePhrase)
i=winio@('%aw',lwo)
Call window_update@(lwo)
Price=1
End Price
!***************
Real*8 Function CalculatePrice()
Use Stocks_Mod
PricePhrase='The total stock value is $'
TotalPrice=TotalShares*Price_p_Share
Write(TotalPriceStr,'(f10.2)')TotalPrice
Call trim@(TotalPriceStr)
TotalPricePhrase=PricePhrase//TotalPriceStr
Call window_update@(TotalPricePhrase)
CalculatePrice=1
End CalculatePrice
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jan 23, 2007 9:55 am    Post subject: Reply with quote

I have had a quick look at this but there are missing routines TEN_PER etc.

All callbacks should return an INTEGER and should be declared as such in the calling main program or routine.
Back to top
View user's profile Send private message AIM Address
meso x



Joined: 20 Jan 2007
Posts: 3
Location: Tennessee, USA

PostPosted: Wed Jan 24, 2007 6:08 am    Post subject: Reply with quote

Sorry about that. I stuffed as much code as I could onto the board. Is there a way to get it all on the board? There are 5 more functions.

Thanks for the feedback. This isn't urgent.

Tom Light
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jan 24, 2007 9:19 am    Post subject: Reply with quote

I should have made my comment clearer...

The main reason for failure is almost certainly that

Real*8 Function CalculatePrice()

should be

integer Function CalculatePrice()

etc (i.e. the same for other callbacks)

and you should put

integer CalculatePrice

in the code that calls the function.
Back to top
View user's profile Send private message AIM Address
meso x



Joined: 20 Jan 2007
Posts: 3
Location: Tennessee, USA

PostPosted: Fri Jan 26, 2007 5:05 am    Post subject: Re: Reply with quote

OK, thanks. I was thinking you had to match the function type with the argument/ variable type. So, ALL callback functions from winio@ because they return an integer, have to be integer functions. That makes sense.

Not exactly sure what you mean by this:


PaulLaidler wrote:
and you should put

integer CalculatePrice

in the code that calls the function.


If I define CalculatePrice as an integer in the module I get a run-time error, “argument corrupt”. But if I define it as an integer in the calling function it seems to work. I have no idea why the difference or why it matters.

I’ve probably missed the point again but I’m sure I’ll get it soon enough. Smile

Thanks for your time.

Tom
Back to top
View user's profile Send private message
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Fri Jan 26, 2007 11:04 am    Post subject: Reply with quote

Quote:
... integer Function CalculatePrice()

etc (i.e. the same for other callbacks)

and you should put

integer CalculatePrice

in the code that calls the function.


Now I'm worried! I've never done this. I mean, my callbacks are all declared as argumentless integer functions, but I've never declared their return values separately as integers in the code that uses them.

I have /IMPLICIT_NONE in my ftn95.cfg file, so how am I getting away with it?

I think I must not be the only one that's missing a point somewhere Confused

Andy
Back to top
View user's profile Send private message Send e-mail
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Thu Feb 01, 2007 3:05 pm    Post subject: Re: Reply with quote

sparge wrote:
... so how am I getting away with it?


So how am I getting away with it?
Back to top
View user's profile Send private message Send e-mail
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