function PGRNRM, ISEED {
      R = 1.1
      while (R >= 1) {
        X = 2 * random() - 1
        Y = 2 * random() - 1
        R = X^2 + Y^2
      }
      PGRNRM = X*sqrt(-2.0*ln(R)/R)
}

procedure PGEX0 {
//-----------------------------------------------------------------------
// This subroutine tests PGQINF and displays the information returned on
// the standard output.
//-----------------------------------------------------------------------*/
      VALUE = ""
      LENGTH = 0
      X = Y = X1 = X2 = Y1 = Y2 = 0

// Information available from PGQINF:

      pgqinf "version",  VALUE, LENGTH
      print "version=" + VALUE
      pgqinf "state",    VALUE, LENGTH
      print "state=" + VALUE
      pgqinf "user",     VALUE, LENGTH
      print "user=" + VALUE
      pgqinf "now",      VALUE, LENGTH
      print "now=" + VALUE
      pgqinf "device",   VALUE, LENGTH
      print "device=" + VALUE
      pgqinf "file",     VALUE, LENGTH
      print "file=" + VALUE
      pgqinf "type",     VALUE, LENGTH
      print "type=" + VALUE
      pgqinf "dev/type", VALUE, LENGTH
      print "dev/type=" + VALUE
      pgqinf "hardcopy", VALUE, LENGTH
      print "hardcopy=" + VALUE
      pgqinf "terminal", VALUE, LENGTH
      print "terminal=" + VALUE
      pgqinf "cursor",   VALUE, LENGTH
      print "cursor=" + VALUE

// Get view surface dimensions:

      pgqvsz 1, X1, X2, Y1, Y2
      X = X2-X1
      Y = Y2-Y1
      print " Plot dimensions (x,y; inches): " + X + ", " + Y
      print "                          (mm): " + X*25.4 + ", " + Y*25.4
}

procedure PGEX1 {
//-----------------------------------------------------------------------
// This example illustrates the use of PGENV, PGLAB, PGPT, PGLINE.
//-----------------------------------------------------------------------
      XS = [1:5]
      YS = XS^2
      XR = YR = floatarray(100)

// Call PGENV to specify the range of the axes and to draw a box, and
// PGLAB to label it. The x-axis runs from 0 to 10, and y from 0 to 20.

      pgenv 0.,10.,0.,20.,0,1
      pglab '(x)', '(y)', 'PGPLOT Example 1:  y = x\u2'

// Mark five points (coordinates in arrays XS and YS), using symbol
// number 9.

      pgpt 5,XS,YS,9

// Compute the function at 60 points, and use PGLINE to draw it.

      XR = [1:60] * .1
      YR = XR^2
      pgline 60,XR,YR
}

procedure PGEX2 {
//-----------------------------------------------------------------------
// Repeat the process for another graph. This one is a graph of the
// sinc (sin x over x) function.
//-----------------------------------------------------------------------
      XR = YR = floatarray(100)

      pgenv -2.,10.,-0.4,1.2,0,1
      pglab '(x)', 'sin(x)/x', 'PGPLOT Example 2:  Sinc Function'
      for I = 1, 100 {
          XR[I] = (I-20)/6.
          YR[I] = 1.0
          if (XR[I] != 0.0) YR[I] = sin(XR[I])/XR[I]
      }  
      pgline 100,XR,YR
}

procedure PGEX3 {
//----------------------------------------------------------------------
// This example illustrates the use of PGBOX and attribute routines to
// mix colors and line-styles.
//----------------------------------------------------------------------
      XR = YR = floatarray(360)

// Call PGENV to initialize the viewport and window; the
// AXIS argument is -2, so no frame or labels will be drawn.

      pgenv 0.,720.,-2.0,2.0,0,-2
      pgsave

// Set the color index for the axes and grid (index 5 = cyan).
// Call PGBOX to draw first a grid at low brightness, and then a
// frame and axes at full brightness. Note that as the x-axis is
// to represent an angle in degrees, we request an explicit tick 
// interval of 90 deg with subdivisions at 30 deg, as multiples of
// 3 are a more natural division than the default.

      pgsci 14
      pgbox 'G',30.0,0,'G',0.2,0
      pgsci 5
      pgbox 'ABCTSN',90.0,3,'ABCTSNV',0.0,0

// Call PGLAB to label the graph in a different color (3=green).

      pgsci 3
      pglab 'x (degrees)','f(x)','PGPLOT Example 3'

// Compute the function to be plotted: a trig function of an
// angle in degrees, computed every 2 degrees.

      for I=1,360 {
          XR[I] = 2.0*I
          ARG = XR[I]/180.0*pi()
          YR[I] = sin(ARG) + 0.5*cos(2.0*ARG) + 0.5*sin(1.5*ARG+pi()/3.0)
       }

// Change the color (6=magenta), line-style (2=dashed), and line
// width and draw the function.

      pgsci 6
      pgsls 2
      pgslw 3
      pgline 360,XR,YR

// Restore attributes to defaults.

      pgunsa
}

procedure PGEX4 {
//-----------------------------------------------------------------------
// Demonstration program for PGPLOT: draw histograms.
//-----------------------------------------------------------------------
      X = Y = floatarray(620)
      DATA = floatarray(1000)

// Call PGRNRM to obtain 1000 samples from a normal distribution.

      ISEED = -5678921
      for I=1,1000 DATA[I] = PGRNRM(ISEED)

// Draw a histogram of these values.

      pgsave
      pghist 1000,DATA,-3.1,3.1,31,0

// Samples from another normal distribution.

      for I=1,200 DATA[I] = 1.0*0.5*PGRNRM(ISEED)

// Draw another histogram (filled) on same axes.

      pgsci 15
      pghist 200,DATA,-3.1,3.1,31,3
      pgsci 0
      pghist 200,DATA,-3.1,3.1,31,1
      pgsci 1

// Redraw the box which may have been clobbered by the histogram.

      pgbox 'BST', 0.0, 0, ' ', 0.0, 0

// Label the plot.

      pglab 'Variate', ' ', 'PGPLOT Example 4:  Histograms (Gaussian)'

// Superimpose the theoretical distribution.

      for I=1,620 {
          X[I] = -3.1 + 0.01*(I-1)
          Y[I] = 0.2*1000./sqrt(2.0*pi())*exp(-0.5*X[I]*X[I])
      }
      pgline 620,X,Y
      pgunsa
}

procedure PGEX5 {
//----------------------------------------------------------------------
// Demonstration program for the PGPLOT plotting package.  This example
// illustrates how to draw a log-log plot.
// PGPLOT subroutines demonstrated:
//    PGENV, PGERRY, PGLAB, PGLINE, PGPT, PGSCI.
//----------------------------------------------------------------------
      RED=2
      GREEN=3
      CYAN=5
      NP=15
      YLO = YHI = floatarray(NP)
      XP = YP = floatarray(100)
      FREQ = [26., 38., 80., 160., 178., 318., 365., 408., 750., 1400., 2695., 2700., 5000., 10695., 14900.]
      FLUX = [38.0, 66.4, 89.0, 69.8, 55.9, 37.4, 46.8, 42.4, 27.0, 15.8, 9.09, 9.17, 5.35, 2.56, 1.73]
      ERR = [6.0, 6.0, 13.0, 9.1, 2.9, 1.4, 2.7, 3.0, 0.34, 0.8, 0.2, 0.46, 0.15, 0.08, 0.01]

// Call PGENV to initialize the viewport and window; the AXIS argument 
// is 30 so both axes will be logarithmic. The X-axis (frequency) runs 
// from 0.01 to 100 GHz, the Y-axis (flux density) runs from 0.3 to 300
// Jy. Note that it is necessary to specify the logarithms of these
// quantities in the call to PGENV. We request equal scales in x and y
// so that slopes will be correct.  Use PGLAB to label the graph.

      pgsave
      pgsci CYAN
      pgenv -2.0,2.0,-0.5,2.5,1,30
      pglab 'Frequency, \gn (GHz)', 'Flux Density, S\d\gn\u (Jy)', 'PGPLOT Example 5:  Log-Log plot'

// Draw a fit to the spectrum (don't ask how this was chosen). This 
// curve is drawn before the data points, so that the data will write 
// over the curve, rather than vice versa.

      for I=1,100 {
          X = 1.3 + I*0.03
          XP[I] = X-3.0
          YP[I] = 5.18 - 1.15*X -7.72*exp(-X)
      }
      pgsci RED
      pgline 100,XP,YP

// Plot the measured flux densities: here the data are installed with a
// DATA statement; in a more general program, they might be read from a
// file. We first have to take logarithms (the -3.0 converts MHz to GHz).

      for I=1,NP {
          XP[I] = log(FREQ[I])-3.0
          YP[I] = log(FLUX[I])
      }
      pgsci GREEN
      pgpt NP, XP, YP, 17

// Draw +/- 2 sigma error bars: take logs of both limits.

      for I=1,NP {
          YHI[I] = log(FLUX[I]+2.*ERR[I])
          YLO[I] = log(FLUX[I]-2.*ERR[I])
      }
      pgerry NP,XP,YLO,YHI,1.0
      pgunsa
}

procedure PGEX6 {
//----------------------------------------------------------------------
// Demonstration program for the PGPLOT plotting package.  This example
// illustrates the use of PGPOLY, PGCIRC, and PGRECT using SOLID, 
// OUTLINE, HATCHED, and CROSS-HATCHED fill-area attributes.
//----------------------------------------------------------------------
      PI = pi()
      TWOPI = 2 * pi()
      NPOL=6
      X = Y = floatarray(10)
      N1 = [3, 4, 5, 5, 6, 8]
      N2 = [1, 1, 1, 2, 1, 3]
      LAB = stringarray(0)
      LAB += "Fill style 1 (solid)"
      LAB += "Fill style 2 (outline)"
      LAB += "Fill style 3 (hatched)"
      LAB += "Fill style 4 (cross-hatched)"

// Initialize the viewport and window.

      pgbbuf
      pgsave
      pgpage
      pgsvp 0.0, 1.0, 0.0, 1.0
      pgwnad 0.0, 10.0, 0.0, 10.0

// Label the graph.

      pgsci 1
      pgmtxt "T", -2.0, 0.5, 0.5,  "PGPLOT fill area: routines PGPOLY, PGCIRC, PGRECT"

// Draw assorted polygons.

      for K=1,4 {
         pgsci 1
         Y0 = 10.0 - 2.0*K
         pgtext 0.2, Y0+0.6, LAB[K]
         pgsfs K
         for I=1,NPOL {
            pgsci I
            for J=1,N1[I] {
               ANGLE = N2[I]*TWOPI*(J-1)/N1[I]
               X[J] = I + 0.5*cos(ANGLE)
               Y[J] = Y0 + 0.5*sin(ANGLE)
            }
            pgpoly int(N1[I]),X,Y
         }
         pgsci 7
         pgcirc 7.0, Y0, 0.5
         pgsci 8
         pgrect 7.8, 9.5, Y0-0.5, Y0+0.5
      }

      pgunsa
      pgebuf
}

procedure PGEX7 {
//-----------------------------------------------------------------------
// A plot with a large number of symbols; plus test of PGERR1.
//-----------------------------------------------------------------------
      XS = YS = floatarray(300)
      XR = YR = floatarray(101)

// Window and axes.

      pgbbuf
      pgsave
      pgsci 1
      pgenv 0.,5.,-0.3,0.6,0,1
      pglab '\fix', '\fiy', 'PGPLOT Example 7: scatter plot'

// Random data points.

      ISEED = -45678921
      for I=1,300 {
          XS[I] = 5.0*random()
          YS[I] = XS[I]*exp(-XS[I]) + 0.05*PGRNRM(ISEED)
      }
      pgsci 3
      pgpt 100,XS,YS,3
      pgpt 100,XS[101:200],YS[101:200],17
      pgpt 100,XS[201:300],YS[201:300],21

// Curve defining parent distribution.

      for I=1,101 {
          XR[I] = 0.05*(I-1)
          YR[I] = XR[I]*exp(-XR[I])
      }
      pgsci 2
      pgline 101,XR,YR

// Test of PGERR1/PGPT1.

      XP = XS[101]
      YP = YS[101]
      XSIG = 0.2
      YSIG = 0.1
      pgsci 5
      pgsch 3.0
      pgerr1 5, XP, YP, XSIG, 1.0
      pgerr1 6, XP, YP, YSIG, 1.0
      pgpt1 XP,YP,21

      pgunsa
      pgebuf
}

procedure PGEX8 {
//-----------------------------------------------------------------------
// Demonstration program for PGPLOT. This program shows some of the
// possibilities for overlapping windows and viewports.
// T. J. Pearson  1986 Nov 28
//-----------------------------------------------------------------------
      XR = YR = floatarray(720)
//-----------------------------------------------------------------------
// Color index:
      BLACK=0
      WHITE=1
      RED=2
      GREEN=3
      BLUE=4
      CYAN=5
      MAGENT=6
      YELLOW=7
// Line style:
      FULL=1
      DASHED=2
      DOTDSH=3
      DOTTED=4
      FANCY=5
// Character font:
      NORMAL=1
      ROMAN=2
      ITALIC=3
      SCRIPT=4
// Fill-area style:
      SOLID=1
      HOLLOW=2
//-----------------------------------------------------------------------
      
      pgpage
      pgbbuf
      pgsave

// Define the Viewport

      pgsvp 0.1,0.6,0.1,0.6

// Define the Window

      pgswin 0.0, 630.0, -2.0, 2.0

// Draw a box

      pgsci CYAN
      pgbox "ABCTS", 90.0, 3, "ABCTSV", 0.0, 0

// Draw labels

      pgsci RED
      pgbox "N",90.0, 3, "VN", 0.0, 0

// Draw SIN line

      XR = [1:360] * 2
      YR = sin(XR / 57.29577951)
      pgsci MAGENT
      pgsls DASHED
      pgline 360,XR,YR

// Draw COS line by redefining the window

      pgswin 90.0, 720.0, -2.0, 2.0
      pgsci YELLOW
      pgsls DOTTED
      pgline 360,XR,YR
      pgsls FULL

// Re-Define the Viewport

      pgsvp 0.45,0.85,0.45,0.85

// Define the Window, and erase it

      pgswin 0.0, 180.0, -2.0, 2.0
      pgsci 0
      pgrect 0.0, 180., -2.0, 2.0

// Draw a box

      pgsci BLUE
      pgbox "ABCTSM", 60.0, 3, "VABCTSM", 1.0, 2

// Draw SIN line

      pgsci WHITE
      pgsls DASHED
      pgline 360,XR,YR

      pgunsa
      pgebuf
}

procedure PGEX9 {
//----------------------------------------------------------------------
// Demonstration program for the PGPLOT plotting package.  This example
// illustrates curve drawing with PGFUNT; the parametric curve drawn is
// a simple Lissajous figure.
//                              T. J. Pearson  1983 Oct 5
//----------------------------------------------------------------------
      PI=pi()
      TWOPI=2.0*PI

// Call PGFUNT to draw the function (autoscaling).

      pgbbuf
      pgsave
      pgsci 5
      X = [0:360] * pi() / 180
      pgenv -1, 1, -1, 1, 1, 0
      pgline 361, sin(X * 5), sin(X * 4)
//      CALL PGFUNT(FX,FY,360,0.0,TWOPI,0)

// Call PGLAB to label the graph in a different color.

      pgsci 3
      pglab "x","y","PGPLOT Example 9:  routine PGFUNT"
      pgunsa
      pgebuf
}

procedure PGEX10 {
//----------------------------------------------------------------------
// Demonstration program for the PGPLOT plotting package.  This example
// illustrates curve drawing with PGFUNX.
//                              T. J. Pearson  1983 Oct 5
//----------------------------------------------------------------------
      PI = pi()
// The following define mnemonic names for the color indices and
// linestyle codes.
      BLACK=0
      WHITE=1
      RED=2
      GREEN=3
      BLUE=4
      CYAN=5
      MAGENT=6
      YELLOW=7
      FULL=1
      DASH=2
      DOTD=3


// Call PGFUNX twice to draw two functions (autoscaling the first time).

      pgbbuf
      pgsave
      pgsci YELLOW
      X = [0:500] / 500 * 10 * pi()
      Y = X
      for i=1, 501 Y[i] = bessel(X[i], 1, 0)
      pgenv 0, 10*pi(), min(Y), max(Y), 0, 0
      pgline 501, X, Y
//      CALL PGFUNX(PGBSJ0,500,0.0,10.0*PI,0)
      pgsci RED
      pgsls DASH
      for i=1, 501 Y[i] = bessel(X[i], 1, 1)
      pgline 501, X, Y
//      CALL PGFUNX(PGBSJ1,500,0.0,10.0*PI,1)

// Call PGLAB to label the graph in a different color. Note the
// use of "\f" to change font.  Use PGMTXT to write an additional
// legend inside the viewport.

      pgsci GREEN
      pgsls FULL
      pglab "\fix", "\fiy","\frPGPLOT Example 10: routine PGFUNX"
      pgmtxt "T", -4.0, 0.5, 0.5,"\frBessel Functions"

// Call PGARRO to label the curves.

      pgarro 8.0, 0.7, 1.0, bessel(1.0, 1, 0)
      pgarro 12.0, 0.5, 9.0, bessel(9.0, 1, 1)
      pgstbg GREEN
      pgsci 0
      pgptxt 8.0, 0.7, 0.0, 0.0, " \fiy = J\d0\u(x)"
      pgptxt 12.0, 0.5, 0.0, 0.0, " \fiy = J\d1\u(x)"
      pgunsa
      pgebuf
}

procedure PGEX11 {
//-----------------------------------------------------------------------
// Test routine for PGPLOT: draws a skeletal dodecahedron.
//-----------------------------------------------------------------------
      NVERT=20
      T=1.618
      T1=1.0+T
      T2=-1.0*T
      T3=-1.0*T1
      VERT = floatarray(3,NVERT)
      X = Y = floatarray(2)

// Cartesian coordinates of the 20 vertices.

     VERT[*,1] = [T, T, T]
     VERT[*,2] = [T, T,T2]
     VERT[*,3] = [T,T2, T]
     VERT[*,4] = [T,T2,T2]
     VERT[*,5] = [T2, T, T]
     VERT[*,6] = [T2, T,T2]
     VERT[*,7] = [T2,T2, T]
     VERT[*,8] = [T2,T2,T2]
     VERT[*,9] = [T1,1.0,0.0]
     VERT[*,10]= [T1,-1.0,0.0]
     VERT[*,11]= [T3,1.0,0.0]
     VERT[*,12]= [T3,-1.0,0.0]
     VERT[*,13]= [0.0,T1,1.0]
     VERT[*,14]= [0.0,T1,-1.0]
     VERT[*,15]= [0.0,T3,1.0]
     VERT[*,16]= [0.0,T3,-1.0]
     VERT[*,17]= [1.0,0.0,T1]
     VERT[*,18]= [-1.0,0.0,T1]
     VERT[*,19]= [1.0,0.0,T3]
     VERT[*,20]= [-1.0,0.0,T3]

// Initialize the plot (no labels).

      pgbbuf
      pgsave
      pgenv -4.,4.,-4.,4.,1,-2
      pgsci 2
      pgsls 1
      pgslw 1

// Write a heading.

      pglab " "," ","PGPLOT Example 11:  Dodecahedron"

// Mark the vertices.

      for I=1,NVERT {
          ZZ = VERT[3,I]
          pgpt1  VERT[1,I]+0.2*ZZ,VERT[2,I]+0.3*ZZ,9
      }

// Draw the edges - test all vertex pairs to find the edges of the 
// correct length.

      pgslw 3
      for I=2,NVERT {
          for J=1,I-1 {
              R = 0.
              for K=1,3 {
                  R = R + (VERT[K,I]-VERT[K,J])^2
              }
              R = sqrt(R)
              if (abs(R-2.0) <= 0.1) {
                ZZ = VERT[3,I]
                X[1] = VERT[1,I]+0.2*ZZ
                Y[1] = VERT[2,I]+0.3*ZZ
                ZZ = VERT[3,J]
                X[2] = VERT[1,J]+0.2*ZZ
                Y[2] = VERT[2,J]+0.3*ZZ
                pgline 2, X, Y
              }
          }
      }
      pgunsa
      pgebuf
}

procedure PGEX12 {
//-----------------------------------------------------------------------
// Test routine for PGPLOT: draw arrows with PGARRO.
//-----------------------------------------------------------------------

// Number of arrows.

      NV =16

// Select a square viewport.

      pgbbuf
      pgsave
      pgsch 0.7
      pgsci 2
      pgenv -1.05,1.05,-1.05,1.05,1,-1
      pgsci 2
      pglab " ", " ", "PGPLOT Example 12: PGARRO"
      pgsci 1

// Draw the arrows

      K = 1
      D = 360.0/57.29577951/NV
      A = -D
      for I=1,NV {
          A = A+D
          X = cos(A)
          Y = sin(A)
          XT = 0.2*cos(A-D)
          YT = 0.2*sin(A-D)
          pgsah K, 80.0-3.0*I, 0.5*I/NV
          pgsch 0.25*I
          pgarro XT, YT, X, Y
          K = K+1
          if (K > 2) K=1
      }

      pgunsa
      pgebuf
}

procedure PGEX13 {
//----------------------------------------------------------------------
// This example illustrates the use of PGTBOX.
//----------------------------------------------------------------------
      N=10
      X1 = [0,0,0,0,-8000.0, 100.3, 205.3, -45000.0, 0,0]
      X2 = [8000,8000,8000,8000,  8000.0, 101.3, 201.1, -100000,-100000,-100000.0]
      XOPT = ["BSTN", "BSTNZ", "BSTNZH", "BSTNZD", "BSNTZHFO", "BSTNZD", "BSTNZHI", "BSTNZHP", "BSTNZDY", "BSNTZHFOY"]

      BSL = char(92)
      pgpage
      pgsave
      pgbbuf
      pgsch 0.7
      for I=1,N {
        pgsvp 0.15, 0.85, (0.7+(N-I))/N, (0.7+(N-I+1))/N
        pgswin X1[I], X2[I], 0.0, 1.0
        pgtbox XOPT[I],0.0,0," ",0.0,0
        pglab "Option = " + XOPT[I], " ", " "
        if (I == 1) {
           pgmtxt "B", -1.0, 0.5, 0.5, BSL+"fiAxes drawn with PGTBOX"
        }
      }
      pgebuf
      pgunsa
}

procedure PGEX14 {
//-----------------------------------------------------------------------
// Test routine for PGPLOT: polygon fill and color representation.
//-----------------------------------------------------------------------
      XI = YI = XO = YO = floatarray(100)
      XT = YT = floatarray(3)
      PI = pi()

      N = 33
      M = 8
      THINC=2.0*PI/N
      for I=1,N {
        XI[I] = 0.0
        YI[I] = 0.0
      }
      pgbbuf
      pgsave
      pgenv -1.,1.,-1.,1.,1,-2
      pglab " ", " ", "PGPLOT Example 14: PGPOLY and PGSCR"
      for J=1,M {
        R = 1.0
        G = 1.0 - J/M
        B = G
        pgscr J, R, G, B
        THETA = -J*PI/N
        R = J/M
        for I=1,N {
          THETA = THETA+THINC
          XO[I] = R*cos(THETA)
          YO[I] = R*sin(THETA)
        }
        for I=1,N {
          XT[1] = XO[I]
          YT[1] = YO[I]
          XT[2] = XO[(I % N)+1]
          YT[2] = YO[(I % N)+1]
          XT[3] = XI[I]
          YT[3] = YI[I]
          pgsci J
          pgsfs 1
          pgpoly 3,XT,YT
          pgsfs 2
          pgsci 1
          pgpoly 3,XT,YT
        }
        for I=1,N {
          XI[I] = XO[I]
          YI[I] = YO[I]
        }
      }
      pgunsa
      pgebuf
}

procedure PGEX15 {
//----------------------------------------------------------------------
// This is a line-drawing test; it draws a regular n-gon joining
// each vertex to every other vertex. It is not optimized for pen
// plotters.
//----------------------------------------------------------------------
      X = Y = floatarray(100)

// Set the number of vertices, and compute the 
// coordinates for unit circumradius.

      NV = 17
      D = 360.0/NV
      A = -D
      for I=1,NV {
          A = A+D
          X[I] = cos(A/57.29577951)
          Y[I] = sin(A/57.29577951)
      }

// Select a square viewport.

      pgbbuf
      pgsave
      pgsch 0.5
      pgsci 2
      pgenv -1.05,1.05,-1.05,1.05,1,-1
      pglab " ", " ", "PGPLOT Example 15: PGMOVE and PGDRAW"
      pgscr 0,0.2,0.3,0.3
      pgscr 1,1.0,0.5,0.2
      pgscr 2,0.2,0.5,1.0
      pgsci 1

// Draw the polygon.

      for I=1,NV-1 {
          for J=I+1,NV {
            pgmove X[I], Y[I]
            pgdraw X[J], Y[J]
          }
      }

// Flush the buffer.

      pgunsa
      pgebuf
}

/*      PROGRAM PGDEM1 */
//-----------------------------------------------------------------------
// Demonstration program for PGPLOT. The main program opens the output
// device and calls a series of subroutines, one for each sample plot.
//-----------------------------------------------------------------------

// Call PGOPEN to initiate PGPLOT and open the output device; PGOPEN
// will prompt the user to supply the device name and type. Always
// check the return code from PGOPEN.

      if (pgopen(plotdevice) <= 0) break

// Print information about device.

      PGEX0

// Call the demonstration subroutines (4,5 are put on one page)


      PGEX1
      PGEX2
      PGEX3
      pgsubp 2,1
      PGEX4
      PGEX5
      pgsubp 1,1
      PGEX6
      PGEX7
      PGEX8
      PGEX9
      PGEX10
      PGEX11
      PGEX12
      PGEX13
      PGEX14
      PGEX15

// Finally, call PGCLOS to terminate things properly.

      pgclos
