Silverfrost Forums

Welcome to our forums

Native %pl

29 Jun 2018 4:52 #22282

Paul, Somehow older simpleplot_redraw@ was doing both rescaling and refresh. It probably had a restriction new simpleplot_redraw@ does not have: in multi-plot the first array always must define Y_max

As to overflow if size(array) and undefined some variable in 32bits, these seems are two bugs of FTN95. First one should be either error or zero, as the array is not yet allocated. And second error is indeed due to undefined values and 32 bit compiler catched it while /64 missed. Currently FTN95 /64 still misses a lot undefined variables. Both lines can be commented out, they are not used. There are some other undefined variables all of which can be initialized as =0. This does not change the fact that simpleplot_redraw@ crashes even in 32bits due to possibly the reason you have just mentioned.

John, Yes, the new name plot_redraw@ or pl_redraw@ has to be introduced.

29 Jun 2018 1:31 #22284

Dan

I think that a new routine is the simplest option and I have called it PLOT_REDRAW@.

30 Jun 2018 1:30 #22286

Please see...

https://forums.silverfrost.com/Forum/Topic/3403

1 Jul 2018 5:57 #22289

Thanks, Paul for the efforts. Now demo code does not crash but unfortunately also does not update the plot. The previous 'Crashing Case' has to behave the same way like 'Working Case' behaved: when you keep clicking on radiobuttons the appropriate plots have to appear or disappear. Does it work on your computer exactly this way?

1 Jul 2018 6:13 #22290

Dan

Is it possible to share your code more widely so that others might get involved in trying to work out how to fix this?

1 Jul 2018 9:12 #22292

Paul, As a hint, besides this my demo, other my codes fail to start with this new beta. One is complaining at stack overflow at second line (could be first actually as 64bit version was wrongly identified first executable line )

iSysYRES= GetSystemMetrics(SM_CYSCREEN),

and another immediately exits with not yet clear reason.

1 Jul 2018 1:00 #22293

Thanks Dan. I will await your code that demonstrates the fault.

3 Sep 2018 12:33 #22504

Paul,

I tried to simplify the demo by removing the necessity of reading big data files and processing it before plotting. Since plotted data is much smaller of course, I preliminary saved it on harddrive and when run the new demo I just loaded it right before plotting. The result was that this new demo also failed to plot the data dynamically on the simpleplot_update@ when I click on different radiobuttons but did not crash. This means that it's still better to use my older demo as it clearly has more useful 'bugged' information.

3 Sep 2018 1:52 #22505

Dan

As far as I recall, I don't have anything useful from you to work on at the moment.

4 Sep 2018 6:30 #22508

Paul, see my email on May 28.

4 Sep 2018 7:18 #22509

Dan

I think that I must have looked at that sample before.

The first two run time failures are due to undefined values at lines 2770 and 2940 in the file called crashPL.for. These may not relate to the problem that you are experiencing with %PL but I need bug free code to work on.

4 Sep 2018 9:05 #22510

Paul,

There probably still exist a lot of undefined variables, the original code was large. This part with undefined variables is doing reading of data and processing it for 1000 different purposes which are not needed for us, so i removed a lot of code but definitely not all. Removing it and scaling down took me more then a month. All still existing undefined variables have no relationship to the code which crashes, again, it just reads the data. Line 2770 for example is not used anywhere. The crashing part is very small, all is in the couple of small functions and is free of undefined things.

4 Sep 2018 12:13 #22512

Yes, John. I try to do elementary all we do many times per day: I displayed several curves on the same plotting area (like here below with just two curves shown),

https://s25.postimg.cc/fqer2li3j/Crash3.jpg

and when I click appropriate radiobutton they have to appear or disappear. Fun is that I made two versions in the demo - one works OK and another uses a bit different initial data crashes when I click radiobuttons (crash happening on the line with 'call simpleplot_update@' statement ). Also it does not allow to resize.

Older %PL by the way worked OK.

4 Sep 2018 12:52 #22513

Dan

If you can send me code that is free from Fortran bugs then I may be able to find time to work out why %pl is not doing what you expect.

9 Sep 2018 3:53 #22522

John,

Dan likes radio buttons of the round sort %rb instead of the square check boxes (%`rb) in defiance of convention, so therefore not ganged, and also (vide posts passim) likes them to be action buttons instead of a bunch of selections actioned together by a button of the %bt sort.

So yes, in Dan's universe, two radio buttons in the same group can be selected simultaneously.

Each to his own, even though perhaps I have met too many users whose Tourrette's Syndome is worsened by departure from Windows norms to plough such a convention-discarding furrow of my own!

Eddie

14 Oct 2018 11:00 #22667

One to be aware of if using multiple %pl regions and get_plot_data@.

In the example below there are two %pl regions, both with full mouse input.

Data in each plot is different and the plots have different sizes.

Moving the mouse across any of the regions and keeping an eye on the output window, it is apparent that the call back function correctly returns the pixel coordinates for each graph, however get_plot_data@ always returns the data corresponding to the last drawn plot.

Ken

module data_mod
implicit none
integer, parameter :: dp = kind(1.d0)
integer, parameter :: npts = 100
real(kind=dp) :: time(1:npts) = 0.d0, decay(1:npts) = 0.d0, rocof(1:npts) = 0.d0, time2(1:npts) = 0.d0

contains

  integer function create_data()
  real(kind=dp) :: t = 0.d0, dt = 0.10d0
  integer i
    do i = 1, npts
      time(i) = t ; decay(i) = 50.d0*(exp(-t/4.d0) ) ; t = t + dt
      if (i .gt. 1) then
        rocof(i) = ( decay(i) - decay(i-1) ) / dt
      end if
    end do
    time2 = 2.d0*time
    create_data = 1
  end function create_data

  integer function plot()
  include<windows.ins>
  integer i
    i= winio@('%bg[blue]&')
    i=winio@('%`bg[white]&')
    call winop@('%pl[native]')
    call winop@('%pl[title='Frequency (Hz)']')
    call winop@('%pl[width=2]')
    call winop@('%pl[gridlines,x_array,frame,etched]')
    call winop@('%pl[link=lines, symbol=0, colour=blue, pen_style=0]')
    call winop@('%pl[x_axis= 'Time (s)', y-axis=@]')
    call winop@('%pl[full_mouse_input]')
    i = winio@('%^pl&',600,250,npts,time,decay,plot1_cb)

    i=winio@('%ff%2nl%`bg[white]&')
    call winop@('%pl[native]')
    call winop@('%pl[title='Rate of change of frequency (Hz/s)']')
    call winop@('%pl[width=2]')
    call winop@('%pl[gridlines,x_array,frame,etched]')
    call winop@('%pl[link=lines, symbol=0, colour=blue, pen_style=0]')
    call winop@('%pl[x_axis= 'Time (s)', y-axis=@]')
    call winop@('%pl[full_mouse_input]')
    i = winio@('%^pl&',300,125,npts,time2,rocof,plot2_cb)
    i = winio@(' ')
    plot = 1
  end function plot

  integer function plot1_cb()
  include<windows.ins>
  CHARACTER(80) reason
  integer i, ix, iy
  real(kind=dp) x, y
    reason = clearwin_string@('CALLBACK_REASON')
    if (reason .eq. 'MOUSE_MOVE') then
      ix = clearwin_info@('GRAPHICS_MOUSE_X')
      iy = clearwin_info@('GRAPHICS_MOUSE_Y')
      i = get_plot_data@(ix,iy,x,y)
      write(6,*) ix, iy, x, y
    end if
    plot1_cb = 1
  end function plot1_cb

  integer function plot2_cb()
  include<windows.ins>
  CHARACTER(80) reason
  integer i, ix, iy
  real(kind=dp) x, y
    reason = clearwin_string@('CALLBACK_REASON')
    if (reason .eq. 'MOUSE_MOVE') then
      ix = clearwin_info@('GRAPHICS_MOUSE_X')
      iy = clearwin_info@('GRAPHICS_MOUSE_Y')
      i = get_plot_data@(ix,iy,x,y)
      write(6,*) ix, iy, x, y
    end if
    plot2_cb = 1
  end function plot2_cb

end module data_mod

program main
use data_mod
implicit none
integer i
i = create_data()
i = plot()
end program main
15 Oct 2018 6:31 #22673

Yes, the native %pl accesses the functionality of %gr and get_plot_data@ uses the associated 'current drawing surface'. %pl can take a grave accent together with the constant integer*4 value of an identifier provided by the programmer. This value (that you have chosen) can then be used in calls to select_graphics_object@ in order to set the 'current drawing surface' before calling get_plot_data@.

16 Oct 2018 5:15 #22683

Thanks Paul. Here's the code with Paul's suggestions. Runs OK in 32 bit, but there is a problem with 64 bit which I have yet to identify. 7th argument of the %pl should be 32 bit integer ?? module data_mod implicit none integer, parameter :: dp = kind(1.d0) ; integer, parameter :: npts = 100 real(kind=dp) :: time(1:npts) = 0.d0, decay(1:npts) = 0.d0, rocof(1:npts) = 0.d0 integer(kind=7) :: plot1_handle = 1001, plot2_handle = 1002 contains integer function create_data() real(kind=dp) :: t = 0.d0, dt = 0.10d0 ; integer i do i = 1, npts time(i) = t ; decay(i) = 50.d0*(exp(-t/4.d0) ) ; t = t + dt if (i .gt. 1) rocof(i) = ( decay(i) - decay(i-1) ) / dt end do create_data = 1 end function create_data integer function plot() include<windows.ins> integer i i= winio@('%bg&',rgb@(250,250,250) ) i=winio@('%bg[white]&') call winop@('%pl[native,title='Frequency (Hz)']') call winop@('%pl[width=2,gridlines,x_array,frame,etched,link=lines, symbol=0, colour=blue, pen_style=0]') call winop@('%pl[x_axis= 'Time (s)', y-axis=@]') call winop@('%pl[full_mouse_input]') i = winio@('%^pl&',600,250,npts,time,decay,plot1_handle,plot1_cb) i=winio@('%ff%bg[white]&') call winop@('%pl[native,title='Rate of change of frequency (Hz/s)']') call winop@('%pl[width=2,gridlines,x_array,frame,etched,link=lines, symbol=0, colour=blue, pen_style=0]') call winop@('%pl[x_axis= 'Time (s)', y-axis=@]') call winop@('%pl[full_mouse_input]') i = winio@('%^pl&',600,250,npts,time,rocof,plot2_handle,plot2_cb) i = winio@(' ') plot = 1 end function plot integer(kind=3) function plot1_cb() include<windows.ins> CHARACTER(80):: reason ; integer i, ix, iy ; real(kind=dp) x, y reason = clearwin_string@('CALLBACK_REASON') if (reason .eq. 'MOUSE_MOVE') then ix = clearwin_info@('GRAPHICS_MOUSE_X') ; iy = clearwin_info@('GRAPHICS_MOUSE_Y') i = select_graphics_object@(plot1_handle) ; i = get_plot_data@(ix,iy,x,y) if ( (x.ge.minval(time)) .and. (x.le.maxval(time)) .and. (y.ge.minval(decay)) .and. (y.lt.maxval(decay)) ) write(6,)ix,iy,x,y end if plot1_cb = 1 end function plot1_cb integer(kind=3) function plot2_cb() include<windows.ins> CHARACTER(80) reason ; integer i, ix, iy ; real(kind=dp) x, y reason = clearwin_string@('CALLBACK_REASON') if (reason .eq. 'MOUSE_MOVE') then ix = clearwin_info@('GRAPHICS_MOUSE_X') ; iy = clearwin_info@('GRAPHICS_MOUSE_Y') i = select_graphics_object@(plot2_handle) ; i = get_plot_data@(ix,iy,x,y) if ( (x.ge.minval(time)) .and. (x.le.maxval(time)) .and. (y.ge.minval(rocof)) .and. (y.lt.maxval(rocof)) ) write(6,)ix,iy,x,y end if plot2_cb = 1 end function plot2_cb end module data_mod program main use data_mod implicit none ; integer i i = create_data() ; i = plot() end program main

16 Oct 2018 6:16 #22684

plot1_handle and plot2_handle should be 32 bit integers even for 64 bits. So they should be declared as something like INTEGER(3) or INTEGER*4 or just INTEGER for the default INTEGER type.

16 Oct 2018 6:54 #22686

Thanks Paul, Problem fixed 😃 I was sure I had read some where that these were to be kind=7. Corrected code below for those who wish to experiment.

module data_mod 
 implicit none 
 integer, parameter :: dp = kind(1.d0)  ;  integer, parameter :: npts = 100 
 real(kind=dp) :: time(1:npts) = 0.d0, decay(1:npts) = 0.d0, rocof(1:npts) = 0.d0 
 integer :: plot1_handle = 1001, plot2_handle = 1002           ! DEFAULT INTEGER TYPE NOT KIND = 7 
 contains 
   integer function create_data() 
   real(kind=dp) :: t = 0.d0, dt = 0.10d0   ; integer i 
     do i = 1, npts 
       time(i) = t ; decay(i) = 50.d0*(exp(-t/4.d0) ) ; t = t + dt 
       if (i .gt. 1) rocof(i) = ( decay(i) - decay(i-1) ) / dt 
     end do 
     create_data = 1 
   end function create_data 
   integer function plot() 
   include<windows.ins> 
   integer i 
     i= winio@('%bg&',rgb@(250,250,250) ) 
     i=winio@('%`bg[white]&') 
     call winop@('%pl[native,title='Frequency (Hz)']') 
     call winop@('%pl[width=2,gridlines,x_array,frame,etched,link=lines, symbol=0, colour=blue, pen_style=0]') 
     call winop@('%pl[x_axis= 'Time (s)', y-axis=@]') 
     call winop@('%pl[full_mouse_input]') 
     i = winio@('%`^pl&',600,250,npts,time,decay,plot1_handle,plot1_cb) 
     i=winio@('%ff%`bg[white]&') 
     call winop@('%pl[native,title='Rate of change of frequency (Hz/s)']') 
     call winop@('%pl[width=2,gridlines,x_array,frame,etched,link=lines, symbol=0, colour=blue, pen_style=0]') 
     call winop@('%pl[x_axis= 'Time (s)', y-axis=@]') 
     call winop@('%pl[full_mouse_input]') 
     i = winio@('%`^pl&',600,250,npts,time,rocof,plot2_handle,plot2_cb) 
     i = winio@(' ') 
     plot = 1 
   end function plot 
   integer function plot1_cb()
   include<windows.ins> 
   CHARACTER(80):: reason  ; integer i, ix, iy  ;  real(kind=dp) x, y 
     reason = clearwin_string@('CALLBACK_REASON') 
     if (reason .eq. 'MOUSE_MOVE') then 
       ix = clearwin_info@('GRAPHICS_MOUSE_X')  ;  iy = clearwin_info@('GRAPHICS_MOUSE_Y') 
       i = select_graphics_object@(plot1_handle) ;  i = get_plot_data@(ix,iy,x,y) 
       if((x.ge.minval(time)).and.(x.le.maxval(time)).and.(y.ge.minval(decay)).and.(y.lt.maxval(decay)))write(6,*)ix,iy,x,y 
     end if 
     plot1_cb = 1 
   end function plot1_cb 
   integer function plot2_cb() 
   include<windows.ins> 
   CHARACTER(80) reason  ;  integer i, ix, iy  ;  real(kind=dp) x, y 
     reason = clearwin_string@('CALLBACK_REASON') 
     if (reason .eq. 'MOUSE_MOVE') then 
       ix = clearwin_info@('GRAPHICS_MOUSE_X')  ;  iy = clearwin_info@('GRAPHICS_MOUSE_Y') 
       i = select_graphics_object@(plot2_handle) ;  i = get_plot_data@(ix,iy,x,y) 
       if ((x.ge.minval(time)).and.(x.le.maxval(time)).and.(y.ge.minval(rocof)).and.(y.lt.maxval(rocof)))write(6,*)ix,iy,x,y 
     end if 
     plot2_cb = 1 
   end function plot2_cb 
 end module data_mod 
 program main 
 use data_mod 
 implicit none ; integer i 
 i = create_data()  ; i = plot() 
 end program main
Please login to reply.