Silverfrost Forums

Welcome to our forums

More Diagnostics for %pl of Simpleplot

14 Mar 2013 4:07 #11751

Well, this is about Simpleplot's %pl function again. This function is very handy but not many users seems use it and not all bugs are hunted down there.

If you make declaration in %pl[Y_MIN=1.d-7] or Y_MAX=1.d-3 expect to lose a day hunting the unexplainable behavior or the graph scales. This is because you naturally expect it to accept only double precision values but things here are exactly opposite, counterintuitive to general design of CWP.

Suggestion is for compiler to warn user that form of double precision is not accepted here or make it acceptable.

Another suggestion is to warn user when %pl can not use LOG scale user required due to zeros so the %pl switches to linear scale explaining why.

14 Mar 2013 6:45 #11752

Thanks for the input but realistically work on %pl is way down on the agenda.

14 Mar 2013 3:40 #11759

%pl is only usefull when you have to do some very simple plots. I used Simpleplot a lot from the very beginning (when BUSS was still alive in the 90') and I would advise to program specific subroutines for making graphics using the proper subroutines of Simpleplot. Manuals are in the Silverfrost web site, and yes, that requires more work but in the end you will find that you have better control of your graphs (and lots of other facilities). It is a pitty that the development of Simpleplot has been frozen but one get graph facilities for free....and that's good....at least for me...

Agustin

14 Mar 2013 6:08 #11761

Is the axis tics issue fixed in the package? If yes, i might be interested

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

14 Mar 2013 6:22 #11764

well...to tell you the truth...no

This still existing bug and the lack of update or upgrade of some features of Simpleplot is a natural consequence of the dissapearance of BUSS software company.....I guess the last version of Simpleplot is now 12 years old....maybe too old for the today software standars, but it still works 'almost' fine and free....but of course, if you need a better and bug-free solution, you then have to look at Gino, for example....as I use fortran for personal use, I can accept Simpleplot as it is...

Agustin

14 Mar 2013 8:21 #11766

Is it really free? Where is Simpleplot LIB? Also can you show here small Fortran text for the simplest plot, say, for parabola, and show how do you compile?

17 Mar 2013 11:41 #11810

Sorry for the delay but I was out for a couple of days and with no access to my computer.

First point: I said it is free because it comes with the fortran compiler, so you do not need to buy it apart like Gino or other graphic packages, although I do not know what happens if you want to use the routines in programs for commercial use.

Second point: there is no Simpleplot LIB (although there was one when BUSS was developing and selling the software, first for FTN77 and then for FTN90 and FTN95, among other compilers). Today you have just a DLL that comes with the distribution of FTN95. Manuals and help files (i.e. FSimpleplot.chm) are available in the Silverfrost web site.

Third point: here is an example of fortran code using the proper Simpleplot subroutines instead of %pl. You have to compile this code with Simpleplot.dll in order to run properly. I guess the Module SPwin is explained in the manuals.

MODULE  SPWIN      ! Contains definition of values to pass to DDDATA
INTEGER,PARAMETER  :: SIMPLE_WINDOWS_WINDOW=1,SIMPLE_WINDOWS_PRINTER=2,  &
&SIMPLE_WINDOWS_DIB=4,SIMPLE_WINDOWS_METAFILE=8,SIMPLE_PERCENT=0,SIMPLE_PIXELS=1,SIMPLE_MM=2
TYPE  SIMPLE_WINDOWS_DATA_STRUCT_T
INTEGER  ::  iOpc        !  Corresponds  to  C++  long  int
INTEGER  ::  iPtr        !  Address  of  OpCode  specific  data
END  TYPE  SIMPLE_WINDOWS_DATA_STRUCT_T
TYPE  SIMPLE_WINDOWS_HDC_DATA_T
INTEGER  ::  hDC                    !  device  context  handle
INTEGER  ::  iWidth,  iHeight    !  plotting  area
END  TYPE  SIMPLE_WINDOWS_HDC_DATA_T
TYPE  SIMPLE_WINDOWS_SIZE_T
INTEGER  ::  iUnits   !  SIMPLE_PERCENT,  ..._PIXELS,  ..._MM
INTEGER  ::  iWidth,  iHeight,  iDepth
END  TYPE  SIMPLE_WINDOWS_SIZE_T
TYPE  SIMPLE_WINDOWS_ORIGIN_T
INTEGER  ::  iUnits   !  SIMPLE_PERCENT,  ..._PIXELS,  ..._MM
INTEGER  ::  iX, iY
END  TYPE  SIMPLE_WINDOWS_ORIGIN_T
TYPE HDC_DIM_TYPE
INTEGER*4 iBitmapDC, iWidth, iHeight
END TYPE HDC_DIM_TYPE
TYPE (HDC_DIM_TYPE) :: HDC_DIM
INTEGER, PARAMETER :: SIMPLE_WINDOWS_END_LIST = 0
INTEGER, PARAMETER :: SIMPLE_WINDOWS_SET_WINDOWNAME = 6
INTEGER, PARAMETER :: SIMPLE_WINDOWS_SET_HDC_DIM = 7

! Useful definition of data structure to hold BitmapDC to pass to SIMPLEPLOT

Contains

SUBROUTINE SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
! Set up a Static (SAVEd) array of OpCodes. Each OpCode consists of an
! OpCode ID followed by an optional address of a data structure.
! The parameter block address is passed to SIMPLEPLOT by SUBROUTINE DDDATA.
!
! In this example:
!   SIMPLE_WINDOWS_SET_HDC_DIM specifies that the next integer is the address
!     of a data structure consisting of a Bitmap DC followed by its dimensions
!   SIMPLE_WINDOWS_END_LIST is the mandatory end of list item which does not
!     require the address of a structure
TYPE(SIMPLE_WINDOWS_DATA_STRUCT_T), DIMENSION(2) :: OpCodes
SAVE OpCodes
OpCodes(1)%iOpc = SIMPLE_WINDOWS_SET_HDC_DIM   ! hDC + dimensions
OpCodes(1)%iPtr = LOC(HDC_DIM)                 ! See definition of SPWIN above
OpCodes(2)%iOpc = SIMPLE_WINDOWS_END_LIST! End of list
CALL DDDATA(LOC(OpCodes))! Notify SIMPLEPLOT
CALL DEVNAM('WINDOW')   ! Select Window
CALL OWNNEW(.TRUE.)     ! Inhibit 'Continue' button
END subroutine SP_SupplyBitmap

!this subroutine is needed if the content of the graph window changes during the program run
SUBROUTINE UpdateWin
CALL OUTBUF  ! Flush buffers
CALL WINDOW_UPDATE@(HDC_DIM%iBitmapDC) ! Copy Bitmap to window
END subroutine UpdateWin
END MODULE SPWIN

program Simpleplot_plots
!requires simpleplot.dll
use mswin
use spwin
implicit none
real*4,dimension(100) ::xarr,yarr
integer*4 :: narr,ltype,xscale,yscale,nstep=1,mtype=5
integer*4 :: ctype,i,ans
character(8) :: xlabel='x',ylabel='y',ptype
real*4 :: minx,maxx,miny,maxy

narr=0
do i=1,100
  xarr(i)=2*i
  yarr(i)=i*i
  narr=narr+1
end do  

HDC_DIM%iWidth = 600
HDC_DIM%iHeight = 800
HDC_DIM%iBitmapDC = GET_Bitmap_DC@(HDC_DIM%iWidth, HDC_DIM%iHeight)
CALL SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
call initsp
call pgfull(.true.)
!scale factor for text in graph
call textmg(1.5)
!characters set
call chset(0)
!direction of ticks: in, out
call axsbtk('XC','I')
call axsbtk('YC','O')
!line thickness
call thckmg('L',2.0)
!location of labels in the axes
CALL AXLBJS('**', 'Centre')
minx=minval(xarr)
maxx=maxval(xarr)
miny=minval(yarr)
maxy=maxval(yarr)
!define the graph scales: max and min values of x and y and the type of scales: 1-linear, 2-log
xscale=1;yscale=1
CALL SCALES(minx,maxx,xscale,miny,maxy,yscale)
!pen color 1...for axes
call pen(4)
!cross point of x and y
call axcrss('YC',minx)
! labels of axes
CALL AXES7(xlabel, ylabel)    
!pen color for data  
call pen(2)
!full line or dashed? 
!ltype=0, full line,ltype=1, dashed
ltype=0
!ptype='scatter'
ptype='curve'
if(ptype=='curve') then
!cvtype=1 -> smooth
!cvtype=3 -> straight lines  
ctype=3
call cvtype(ctype)
CALL BRKNCV(real(xarr,1),real(yarr,1),narr,ltype)
else !scatter
CALL MKSET(1) !set of markers 1,2,3......
CALL MARKCV(real(xarr,1),real(yarr,1),narr,mtype,nstep)
endif
ans=winio@('%ca[A Simple Plot with Simpleplot]%bg[grey]&')
ans=winio@('%dw&',HDC_DIM%iBitmapDC) ! Pass bitmapDC to ClearWin
ans=winio@('%ff%nl%cn%6bt[Close]')
end program simpleplot_plots

Hope this help.

Agustin

18 Mar 2013 6:55 #11812

I think the text was cut as usually due to too small size limits for forum post...

18 Mar 2013 1:25 #11816

yes!...it's funny because the 'preview' of the message showed the whole text....here goes the part of the program:

program Simpleplot_plots
!requires simpleplot.dll
use mswin
use spwin
implicit none
real*4,dimension(100) ::xarr,yarr
integer*4 :: narr,ltype,xscale,yscale,nstep=1,mtype=5
integer*4 :: ctype,i,ans
character(8) :: xlabel='x',ylabel='y',ptype
real*4 :: minx,maxx,miny,maxy

narr=0
do i=1,100
  xarr(i)=2*i
  yarr(i)=i*i
  narr=narr+1
end do  

HDC_DIM%iWidth = 600
HDC_DIM%iHeight = 800
HDC_DIM%iBitmapDC = GET_Bitmap_DC@(HDC_DIM%iWidth, HDC_DIM%iHeight)
CALL SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
call initsp
call pgfull(.true.)
!scale factor for text in graph
call textmg(1.5)
!characters set
call chset(0)
!direction of ticks: in, out
call axsbtk('XC','I')
call axsbtk('YC','O')
!line thickness
call thckmg('L',2.0)
!location of labels in the axes
CALL AXLBJS('**', 'Centre')
minx=minval(xarr)
maxx=maxval(xarr)
miny=minval(yarr)
maxy=maxval(yarr)
!define the graph scales: max and min values of x and y and the type of scales: 1-linear, 2-log
xscale=1;yscale=1
CALL SCALES(minx,maxx,xscale,miny,maxy,yscale)
!pen color 1...for axes
call pen(4)
!cross point of x and y
call axcrss('YC',minx)
! labels of axes
CALL AXES7(xlabel, ylabel)    
!pen color for data  
call pen(2)
!full line or dashed? 
!ltype=0, full line,ltype=1, dashed
ltype=0
ptype='scatter'
ptype='curve'
if(ptype=='curve') then
!cvtype=1 -> smooth
!cvtype=3 -> straight lines  
ctype=3
call cvtype(ctype)
CALL BRKNCV(real(xarr,1),real(yarr,1),narr,ltype)
else !scatter
CALL MKSET(1) !set of markers 1,2,3......
CALL MARKCV(real(xarr,1),real(yarr,1),narr,mtype,nstep)
endif
ans=winio@('%ca[A Simple Plot with Simpleplot]%bg[grey]&')
ans=winio@('%dw&',HDC_DIM%iBitmapDC) ! Pass bitmapDC to ClearWin
ans=winio@('%ff%nl%cn%6bt[Close]')
end program simpleplot_plots

Agustin

18 Mar 2013 2:13 #11817

I feel helplessly lost here. I always assumed that you got a stripped down minimal version with the FTN95.

Is it the case that SIMPLE.DLL contains the entirety of SimplePlot? (it is about 1/3 the size of Salflibc.dll, so there's a lot in it!).

Eddie

18 Mar 2013 3:10 #11818

As far as I tested simpleplot.dll, it contains the whole set of graphic subroutines, even those related to maps, 3D visualisation, etc. So, for taking full advantage of what Simpleplot can do, one needs to read carefully the help file (well, the sections corresponding to the type of graph one wants to program).

There is apparently a 'minimal' version of Simpleplot in FTN95: it's the one that use %pl......but if you use directly Simpleplot trough a %dw window, you have quite a lot of possibilities. Simpleplot offers linear regressions, iso surfaces, drawing an iso surface in slices, contour maps, etc.

Agustin

P.D. by the way, the minimal example could be even more minimalistic (appart from the simpleplot module):

program Simpleplot_plots
!requires simpleplot.dll
use mswin
use spwin
implicit none
real*4,dimension(100) ::xarr,yarr
integer*4 :: narr,ltype,xscale,yscale,ctype,i,ans
character(8) :: xlabel='x',ylabel='y'
real*4 :: minx,maxx,miny,maxy
narr=0
do i=1,100
  xarr(i)=2*i
  yarr(i)=i*i
  narr=narr+1
end do  
HDC_DIM%iWidth = 600
HDC_DIM%iHeight = 800
HDC_DIM%iBitmapDC = GET_Bitmap_DC@(HDC_DIM%iWidth, HDC_DIM%iHeight)
CALL SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
minx=minval(xarr)
maxx=maxval(xarr)
miny=minval(yarr)
maxy=maxval(yarr)
xscale=1;yscale=1
CALL SCALES(minx,maxx,xscale,miny,maxy,yscale)
CALL AXES7(xlabel, ylabel)    
ltype=0
CALL BRKNCV(real(xarr,1),real(yarr,1),narr,ltype)
ans=winio@('%ca[A Simple Plot with Simpleplot]%bg[grey]&')
ans=winio@('%dw&',HDC_DIM%iBitmapDC) ! Pass bitmapDC to ClearWin
ans=winio@('%ff%nl%cn%6bt[Close]')
end program simpleplot_plots
18 Mar 2013 3:27 #11819

Hi Augustin,

So it's a %dw window, is it. My first encounters with Clearwin were trying to use a %dw window to replace the old DBOS graphics. I didn't make much headway for some years. The trick to make better progress is to use a %gr window. Perhaps it is worth revisiting %dw!

Thanks for the advice

Eddie

18 Mar 2013 4:07 #11820

The confusion about what simpleplot.dll is likely comes from what the Ftn95 Help says: 'ClearWin+ provides access to SIMPLEPLOT via a dynamic link library (simple.dll) that is distributed with Salford compilers. Access to this library is available by using the winio@ function together with the %pl format code. %pl is designed to be similar to %gr.'

In fact, one can directly use Simpleplot.dll. The difference is that one uses %dw (with its limitations) instead of %gr (i.e. %pl). %pl was set to provide fortran users the possibility to make rather simple plots with minimal efforts. But Simpleplot is far more than that. It is far from perfect (rather old, the problem with ticks in the y-axes, fonts are far from the best ones, etc.)...but it works....

Agustin

19 Mar 2013 7:41 #11827

Augustin

I have noted your SimplePlot example above and the MODULE spwin. I would be interested to know where this code comes from and if you know of a module or header file for the whole library.

19 Mar 2013 1:00 #11830

When Ftn90 (not FTN95!) was still in the very beginning, David Butland from BUSS sent me the first directives for creating a module that allowed one to use SIMPLEPLOT with Clearwin+ through a %dw window. Then, they added it in the printed manuals that used to come with the installation disks. Today you can find these instructions in the document 'Using SimplePlot with FTN95' in this address: http://www.silverfrost.com/23/ftn95/support/documentation.aspx.

With this module you can use the whole library (v. 2-16), even those related to maps. The only problem is that the manual for maps is not available in the Silverfrost site. I know that you can use maps because I checked it some time ago with some old examples, but I have no manuals at all because when I bought Simpleplot in the 90' the map library was a set that was sold apart at a different price.

Agustin

Update!!!: maps examples are available in the help file FSimpleplot.chm, also available at Silverfrost....interesting is that no information about the module for using Simpleplot with FNT90/95 is available there...

19 Mar 2013 2:27 #11831

Thank you. I will give it a try and, if successful, add the module to the FTN95 release.

19 Mar 2013 3:16 #11832

Subroutines CALL DDDATA, CALL DEVNAM, CALL OWNNEW, CALL OUTBUF and CALL WINDOW_UPDATE@ are described in FSimpleplot.chm. I still have a hardcopy of the manuals but I do not find the description of the module. It is quite possible that David Butland sent me that...looong time ago when we used to use a fax for comunications. Apparently the installation guide of Simpleplot for FTN77/90/95 came appart from the manuals.

In the examples that appear in the CHM file you can see that they include a 'use spmodule' statement ....as far as I remember the spmodule was automatically created by the instalation disks of the distribution of Simpleplot provided by BUSS. I guess that that module was the same as the one I use today. I have now in front of me, the distribution disks of version 2.15 (not much different that the one coming with FTN95 today) dated...1998....it says...for Win95/NT....I have to find a PC were one can read a 1.44 disk nowadays!.....

Best wishes,

Agustin

19 Mar 2013 9:49 #11841

Thanks Agustin. Tics versus numbering displacements here are not that bad as in %pl, and on X axis all looks just perfect. Have you tried to find how to use modern fonts instead of default ones? Changing just the fonts would blow outdated look and feel of the plots. I've tried contacting author several times over past decade or so but besides just the first one all emails bounced back or were not answered. If he still alive may be our UK folks can try to find him and ask if he can fix those small but important issues or give out the sources.

I am not super-interested with this package because over decades of using this compiler i developed my own graphics programs (written purely in this Fortran) but i know that to make them perfect takes a lot of time and i am not yet finished (see some in User's Examples below), so others may look at just improving existing resources.

Just will comment if others will want to try: compilation is with the SIMPLE.DLL not simpleplot.dll (you probably still keep original DLL from the developer!) and by some reason compiler does not find this DLL in default FTN95 own dir so it should be in the same dir as your code.

Are there other Fortran examples of , say, 2D surface plots, 3D plots? Editing existing texts is much easier then writing from zero based on the description

20 Mar 2013 8:01 #11842

A word of caution to those who are thinking of investing time in %pl or SIMPLEPLOT, if you may need to port to 64 bit in the future then direct access to simple.dll will no longer be possible.

20 Mar 2013 6:39 #11849

Caution words of Paul: are quite right!. Simpleplot is good as it is, no more no less. In fact, it uses only real4 and integer4 variables, which can bother quite a lot when one uses real8 variables along the program and they need every time to be converted to real4.

Modern fonts: fonts were always a problem with Simpleplot. I remeber that in the old good days people of Salford and BUSS used to have one (or two?) days workshops for discussing with customers the use and development of the set Salford compilers + Simpleplot. As far as I remember they thought once about using TeX fonts with Simpleplot (very nice idea for me) but for some problems that idea was abandoned very fast. There is a subroutine called CHSET(INT) that should allow to use different set of fonts (Hershey fonts among others), but I am not sure if it works fine nowadays.

Contact authors: as one day I woke up and found that 'Salford Compilers' disappeared, so did BUSS suddenly. I do not believe that it is possible to contact those people that were involved in Simpleplot (even my old e-mails with them disappeared during a change of e-mail client in my PC, so I hardly remember their names, just one or two). But I might be wrong...who knows....

Simple.dll: yes, I made a mistake in my program saying 'simpleplot.dll' instead of 'simple.dll'...sorry...

3D plots: here is a short example of a 3D plot (it needs the previous spwin module) that comes from the Simpleplot help file:

program Simpleplot_plots_3
!requires simple.dll
use mswin
use spwin
integer*4 ans
INTEGER*4, PARAMETER :: NX = 10, NY = 10
REAL*4, DIMENSION(NX, NY) :: Z2ARR
DATA Z2ARR/0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     &
             0.0, -2.6, -3.8, -1.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,  &
             0.0, -3.8, -5.9, -2.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,  &
             0.0, -1.4, -2.3, -0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,  &
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     &
             0.0, 1.5, 1.7, 1.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,     &
             1.8, 1.4, 2.3, 0.4, 1.1, 0.0, 0.0, 8.0, 8.0, 0.0,     &
             2.2, 3.8, 5.9, 2.3, 1.7, 0.0, 0.0, 8.0, 8.0, 0.0,     &
             2.1, 2.6, 3.8, 1.4, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0,     &
             1.0, 2.1, 2.2, 1.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0/
HDC_DIM%iWidth = 800
HDC_DIM%iHeight = 600
HDC_DIM%iBitmapDC = GET_Bitmap_DC@(HDC_DIM%iWidth, HDC_DIM%iHeight)
CALL SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
call chset(17)
CALL RGSURF(Z2ARR, NX, NY)            ! draw surface picture
CALL TITLE7('Top', 'Centre', 'A simple surface outline')
call UpdateWin
ans=winio@('%ca[A Simple Plot with Simpleplot]%bg[white]&')
ans=winio@('%dw&',HDC_DIM%iBitmapDC) ! Pass bitmapDC to ClearWin
ans=winio@('%ff%nl%cn%6bt[Close]')
end program simpleplot_plots_3
Please login to reply.