procedure PGEX35 {
//-----------------------------------------------------------------------
// Program to demonstrate the use of PGVECT along with
// PGCONB by illustrating the flow around a cylinder with circulation.
//
//          NX      total # of axial stations
//          NY      total # of grid pts in y (or r) direction
//-----------------------------------------------------------------------
      MAXX=101
      MAXY=201
      CP = floatarray(MAXX,MAXY)
      X = floatarray(MAXX)
      Y = floatarray(MAXY)
      U = floatarray(MAXX,MAXY)
      V = floatarray(MAXX,MAXY)
      PSI = floatarray(MAXX,MAXY)
      TR = floatarray(6)
      C = floatarray(10)
      PI = pi()
      BLANK = -1e10
//
// compute the flow about a cylinder with circulation
//
// define various quantities

// number of points in the x and y directions
      NX = 31
      NY = 31
// cylinder radius
      A = 1.
// circulation strength
      GAMMA = 2.
// freestream velocity
      VINF = 1.
// max and min x and y
      XMAX = 3.*A
      XMIN = -3.*A
      YMAX = 3.*A
      YMIN = -3.*A
// point spacing
      DX = (XMAX-XMIN)/(NX-1)
      DY = (YMAX-YMIN)/(NY-1)
// compute the stream function, Cp, and u and v velocities
      CPMIN =1e10
      for I=1,NX {
         X[I] = XMIN+DX*(I-1)
         for J=1,NY {
            Y[J] = YMIN+DY*(J-1)
            R2 = X[I]^2+Y[J]^2
            if (R2 > 0.) {
               PSI[I,J] = VINF*Y[J]*(1.-A^2/R2)+GAMMA/(2.*PI)*0.5*log(R2/A)
               U[I,J] = VINF*(1.+A^2/R2-2.*A^2*X[I]^2/R2^2)+GAMMA/(2.*PI)*Y[J]/R2
               V[I,J] = VINF*X[I]*(-2.*A^2*Y[J]/R2^2)+GAMMA/(2.*PI)*X[I]/R2
               CP[I,J] = 1.-(U[I,J]^2+V[I,J]^2)/VINF^2
            } else {
               PSI[I,J] = 0.
               U[I,J] = 0.
               V[I,J] = 0.
               CP[I,J] = 0.
            }
            if (R2 < A^2) {
               U[I,J] = BLANK
               V[I,J] = BLANK
            } else {
               CPMIN = min(CPMIN,CP[I,J])
            }
        }
      }
//
// grid to world transformation
//
      TR[1]=X[1]-DX
      TR[2]=DX
      TR[3]=0.0
      TR[4]=Y[1]-DY
      TR[5]=0.0
      TR[6]=DY

      pgenv X[1],X[NX],Y[1],Y[NY],1,0
      pgiden
      pglab "X","Y","Flow About a Cylinder with Circulation"
//
// contour plot of the stream function (streamlines)
//
      NC=5
      C[1]=1.
      C[2]=.5
      C[3]=0.
      C[4]=-.5
      C[5]=-1.
      pgcont PSI,MAXX,MAXY,1,NX,1,NY,C,NC,TR
//
// draw cylinder
//
      pgbbuf
      pgsci 0
      pgsfs 1
      pgcirc 0.,0.,A*1.1
      pgsfs 2
      pgsci 14
      pgcirc 0.0, 0., A
      pgsci 1
      pgebuf
//
// vector plot
//
      pgsah 2, 45.0, 0.7
      pgsch 0.3
      pgvect U,V,MAXX,MAXY,2,NX-1,2,NY-1,0.0,0,TR,-1e10
      pgsch 1.0
//
// finished
//
}

//C-----------------------------------------------------------------------
//C Demonstration program for PGPLOT vector field plot.
//C-----------------------------------------------------------------------
      print " Demonstration of routine PGVECT"
//C
//C Call PGBEG to initiate PGPLOT and open the output device; PGBEG
//C will prompt the user to supply the device name and type.
//C
      if (pgopen(plotdevice) <= 0) break
      PGEX35
      pgend


