The DEMO program

Next: A user function Up: Fortran interface Previous: The QDP program

# The DEMO program

The file XANADU:[PLOT.QDP]DEMO.FOR contains a simple Fortran program that creates the necessary arrays and then calls the PLT subroutine. The complete source code for the DEMO.FOR program is:

```C---
C DEMO.FOR demonstrates how to call PLT from a Fortran program.
C---
C [AFT]
C---
INTEGER   MXROW, MXCOL, MXVEC, MXCMD
PARAMETER (MXROW=200, MXCOL=3, MXVEC=2, MXCMD=10)
CHARACTER CMD(MXCMD)*72
REAL      Y(MXROW, MXCOL)
INTEGER   IERY(MXVEC), NVEC, NPTS, NCMD, IER
INTEGER   I
C---
C Create two vectors.  The first vector will contain the X locations
C and a symmetric error (with constant value of 0.5).  The second
C vector will contain X*X and no error.
NVEC=2
IERY(1)=1
IERY(2)=0
NPTS=100
DO 190 I=1,NPTS
Y(I,1)=I
Y(I,2)=.5
Y(I,3)=Y(I,1)*Y(I,1)
190 CONTINUE
C---
C Now add a couple of commands, to make plot look nicer.
CMD(1)='LAB X Time (sec)'
CMD(2)='LAB Y Distance (m)'
CMD(4)='LINE STEP 2'
NCMD=4
C---
C Call the PLT subroutine.
CALL PLT(Y, IERY, MXROW, NPTS, NVEC, CMD, NCMD, IER)
END```

`DEMO.FOR` was written as an example to show how the various parameters are initialized before calling PLT. In the program NVEC=2 tells PLT to expect two vectors; IERY(1)=1 tells PLT that the first vector contains symmetric errors and, hence, is composed of two columns; and IERY(2)=0 tells PLT that the second vector does not have errors. The DO 190 loop fills 100 points of these two vectors. The `Y` array is large enough to contain up to 200 points. The first column of the `Y` array contains the x-value, which run from 1 to 100; the second column contains the errors (constant value 0.5); and the third column contains x2. After the `Y` array is initialized, the `CMD` array is initialized with four PLT commands. The first three commands define labels, and the last command creates a stepped-line plot.

The file XANADU:[PLOT.QDP]DEMO.COM will compile and link the DEMO.FOR program on a VMS system. This file can be used as an example for linking other routines that call PLT. It is necessary to link with both the XANLIB library and also the PGPLOT graphics library.

Web Page Maintained by: Dr. Lawrence E. Brown elwin@redshift.gsfc.nasa.gov