|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Sep 04, 2018 8:18 am Post subject: |
|
|
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. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Tue Sep 04, 2018 10:05 am Post subject: |
|
|
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. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Tue Sep 04, 2018 11:28 am Post subject: |
|
|
Quote: | but I need bug free code to work on. |
... except for 'THE' bug of course ! _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Tue Sep 04, 2018 11:36 am Post subject: |
|
|
Dan, have you got a couple or so screenshots so we can visualize what your program is trying to do/update ? Thanks _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Tue Sep 04, 2018 1:13 pm Post subject: |
|
|
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),
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Sep 04, 2018 1:52 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Sun Sep 09, 2018 3:40 pm Post subject: |
|
|
Dan, just an observation.
On the plot you posted above the 2 radio buttons appear to BOTH be selected. Is this possible ? Is it relevant ? _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sun Sep 09, 2018 4:53 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sun Oct 14, 2018 12:00 pm Post subject: |
|
|
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
Code: | 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 |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Oct 15, 2018 7:31 am Post subject: |
|
|
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@. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Mon Oct 15, 2018 10:55 am Post subject: |
|
|
Ken,
An excellent example (9.5/10); and multi facetted:
- how to use a module to define global parameters;
- a double natíve %pl plot;
- implementation of full mouse inout;
- and of course the illustration of encountering the potential problem with get_plot_data ,
... one which would be merited for a db of examples in the ftn95 documentation (suggested by many over a long period but not yet initiated).
With alongside Paul's tip of course, and the modified lines of code (tbd) to implement the tip (hence why only the 9.5 ! )
Thanks for sharing it Ken. _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Oct 16, 2018 6:15 am Post subject: |
|
|
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 ?? Code: | 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 |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Oct 16, 2018 7:16 am Post subject: |
|
|
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. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Oct 16, 2018 7:54 am Post subject: |
|
|
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.
Code: | 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 |
|
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Wed Oct 17, 2018 1:05 am Post subject: |
|
|
Well done Ken !
Paul, what would be exremely useful to avoid this type of mishap would be a table in the documentation giving for all the various controls concerned a summary of the different declarations required for the various handles (both user-defined as here and windows defined.
The quite recent post when the subject matter was again discussed only goes towards the pudding.
You could do that after kicking off the 'Users Exampls Database' with Ken's example _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " |
|
Back to top |
|
|
|
|
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
|