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 

%pl + optimise + win32 + minimal %pl call back

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



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Jul 24, 2020 4:53 pm    Post subject: %pl + optimise + win32 + minimal %pl call back Reply with quote

The following code uses the native %pl to plot a simple two cycle sine wave.

It includes the options(optimise) flag at the beginning to the file. (This is a cut down version of a 1000 line program which would benefit from optimisation).

When compiled with the 64 bit compiler everything is as expected. But when complied with 32 bit the program fails. “The function supplied as argument 7 is corrupt”.

This appears to be related to the %pl call back. If there is no %pl call back everything runs as expected.

In this program, the %pl call back does nothing apart from return the value 2. If the pl call back does something else e.g. there is a print statement added then the program runs as expected.

I stumbled on this one by accident, as the %pl was in the code as a placeholder and I was intending to come back to add to it later. So it’s not really a bug, but it is a bit unexpected. The reference to “argument 7” is a bit unhelpful as there are no functions with 7 arguments.
Code:
options(optimise)
module problem_mod
use clrwin
implicit none
integer, parameter :: dp = kind(1.d0)
integer, parameter :: n=360*2+1
real(kind=dp), parameter :: pi = 4.d0*atan(1.d0)
real(kind=dp), parameter :: deg2rad = pi/180.d0
real(kind=dp) x1(1:n), y1(1:n)
contains
  integer function build_gui()
  integer winio@, i
  integer, save :: iw
    x1 = (/(deg2rad*i,i=1,n,1)/) ; y1 = (/(sin(deg2rad*i),i=1,n,1)/)
    iw = winio@('%mn[Exit]&','exit')
    call winop@('%pl[native, independent, x_array, n_graphs=1,gridlines,framed,y_min=-1,y_max=1, dy=0.5]')
    iw = winio@('%^pl&',600,400,n,x1,y1,pl_cb)
    iw = winio@(' ')
    build_gui =1
  end function build_gui

  integer function pl_cb()
  pl_cb = 2
  end function pl_cb
 
end module problem_mod

program main
use problem_mod
implicit none
integer i
  i = build_gui()
end program main
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Fri Jul 24, 2020 5:27 pm    Post subject: Reply with quote

Ken

I have added this to the list of things to investigate.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Sat Jul 25, 2020 5:46 am    Post subject: Reply with quote

Ken,
Compiler calls
winio@('%^pl&',600,400,n,x1,y1,pl_cb)
a function with 7 arguments. Ideally it better also display the name of the erroneous argument as i for example often gather 10 controls in one long line. Or show it using arrow like some compilers sometimes do for convenience
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jul 25, 2020 7:58 am    Post subject: Reply with quote

Dan

As soon as you switch on the optimiser you won't get detailed information about runtime failures (with any compiler).
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Jul 25, 2020 10:29 am    Post subject: Reply with quote

You are correct Dan. I was looking at this as %pl with 6 arguments, rather than winio@ with 7 arguments.

While it's easy to pick out the offending line in this sample program this is not the case in the longer program.

Easy to fix in this particular example, but the observed behaviour is not correct, so I thought it best to share this example with Silverfrost as whatever is causing the failure in this case may cause other problems with more complex codes in less obvious ways.
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Sat Jul 25, 2020 12:16 pm    Post subject: Reply with quote

This has now been fixed for the next release of FTN95.
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 -> 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