Here is a bug report I have just submitted to Silverfrost, which should be of interest to anyone using the automatic mode of access to SIMPLEPLOT. 'This is by far the easiest way to access the SIMPLEPLOT library from ClearWin+', says the manual, and whilst I can't argue with that as a literal statement, I will note only that accessing it and getting it to work correctly are not at all the same thing, as I have spent the last few days finding out ...
Hello again Robert,
I have been wrestling with Simpleplot the last few days, and getting strange results, so I set out to see if I could reproduce any of the problems in a short segment of code. It turned out to be surprisingly easy to isolate and illustrate a couple of misbehaviours.
Bug report code 1 is a cunning basis for plotting more than one graph when the x values are different for each graph (at the cost of being increasingly wasteful of storage as the number of graphs increases). Unfortunately, it invariably plots the last point of the first series as the first point of the second series. Click Plot a few times to see that this is so. I have not investigated what happens with more than two graphs.
To get to this stage, I had to simplify a feature of the code that I had not expected to be of importance. When I started writing this little illustration, x, y1 and y2 were allocatable, and n1 and n2 could be changed in the UI, to give two graphs each with a different number of points every time. However, this proved unexpectedly troublesome, and so I simplified to static arrays, not because I thought it was the problem, simply in order to achieve simpler illustrative code. However, I have now revisited this aspect, and am able to illustrate additional latent problems with the %pl format code.
Bug report code 2 is expanded from bug report code 1. The only difference is that the arrays are allocatable rather than static. As submitted below, if the code is built and run, the /RELEASE build gives a runtime error, whereas the /DEBUG and /CHECKMATE builds give an access violation. Judging by the runtime error traceback, the underlying problem is related to the one associated with the %sh format code which I reported at the start of this week. Once again, I can not isolate the line of code that triggers the problem.
This problem can be made to go away by uncommenting the three commented-out lines of code in the main program. However, this introduces other problems, particularly interesting because all of the /RELEASE, /DEBUG and /CHECKMATE builds now behave incorrectly in a different way! One feature they all have in common is that when they do plot the data apparently correctly, in fact the plots have the same problem as bug report code 1. I'll call this 'correct' for short.
- The /RELEASE build initial plot has the x axis incorrect, and the wrong number of points. The first replot is 'correct'. Subsequent replots alternate between these two modes.
- The /DEBUG build initial plot is 'correctly'. The first attempt to replot causes the debugger to highlight the call to simpleplot_redraw@ and declare an invalid floating point operation.
- The /CHECKMATE build initial plot has the x axis scaled incorrectly, but in a different way to the /RELEASE build. It also has just a single spurious data point at the origin. This plot does not change as it is repeatedly redrawn.
Small wonder I have been having problems getting my real code to work considering that it features multiple sheets with a %pl region on each that is trying to plot allocatable arrays ...
Andy
Bug report code 1
program multpltest
use callbax
character (len = 100) chapel
integer iodial
chapel = '%pl[n_graphs=2,style=1,colour=black,style=1,colour=red,x_array,y_min=0.0,y_max=1.0]&'
iodial = winio@ ('%ca[Testing multiple plots]&')
iodial = winio@ ('%sc&', plotme)
iodial = winio@ (trim (chapel), 400, 400, n1 + n2, x, y1, y2)
iodial = winio@ ('%ff%nl%cn%^bt[Plot]%`bt[OK]', plotme)
stop
end program multpltest
module callbax
use clrwin
integer, parameter :: n1 = 5, n2 = 5
double precision x (n1 + n2), y1 (n1 + n2), y2 (n1 + n2)
contains
integer function plotme ()
integer n
plotme = 2
do n = 1, n1
call random_number (x (n))
call random_number (y1 (n))
y2 (n) = - 1.0d+0
end do
do n = 1, n2
call random_number (x (n1 + n))
call random_number (y2 (n1 + n))
y1 (n1 + n) = - 1.0d+0
end do
call simpleplot_redraw@
return
end function plotme
end module callbax
Bug report code 2
program multpltest
use callbax
character (len = 100) chapel
integer iodial
n1 = 5
n2 = 5
! allocate (x (n1 + n2))
! allocate (y1 (n1 + n2))
! allocate (y2 (n1 + n2))
chapel = '%pl[n_graphs=2,style=1,colour=black,style=1,colour=red,x_array,y_min=0.0,y_max=1.0]&'
iodial = winio@ ('%ca[Testing multiple plots]&')
iodial = winio@ ('%sc&', plotme)
iodial = winio@ ('%ff%nl&')
iodial = winio@ (trim (chapel), 400, 400, n1 + n2, x, y1, y2)
iodial = winio@ ('%ff%nl%cn%^bt[Plot]%`bt[OK]', plotme)
stop
end program multpltest
module callbax
use clrwin
integer n1, n2
double precision, allocatable :: x (:), y1 (:), y2 (:)
contains
integer function plotme ()
integer n
plotme = 2
if (allocated (x)) deallocate (x)
if (allocated (y1)) deallocate (y1)
if (allocated (y2)) deallocate (y2)
allocate (x (n1 + n2))
allocate (y1 (n1 + n2))
allocate (y2 (n1 + n2))
do n = 1, n1
call random_number (x (n))
call random_number (y1 (n))
y2 (n) = - 1.0d+0
end do
do n = 1, n2
call random_number (x (n1 + n))
call random_number (y2 (n1 + n))
y1 (n1 + n) = - 1.0d+0
end do
call simpleplot_redraw@
return
end function plotme
end module callbax