
      FUNCTION FGRAPH(IFN,P,X)
*
* Fortran source FGRAPH.for v1.0          Copyright (C) D.I. Hoyer, 1988 
*
* The list of functions for plotting on IGRAPH.
* This list can be added to as required.
*
* FNUM = Function number
* P    = Array of parameters to be passed to the selected function
* X    = X-value at which the function is to be evaluated
*
      DIMENSION P(*)
* To add more functions, add labels to the following statement:
      GOTO (1,2,3,4,5,6,7,8) IFN 
*
* Function 1. Polynomial (to n-th order). n+2 parameters.
*             P(1)=n,  P(2) to P(n+2) = coeffecients a0, a1, a2, ... an.
*                      [ f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n ]
*
   1  N = INT(P(1)+0.5)
      POLY = P(N+2)
      DO 100 I=N+1, 2, -1
        POLY = X*POLY + P(I)
 100  CONTINUE
      FGRAPH = POLY
      RETURN
*
*  Function 2. Exponential, 3 parameters.
*              f(x) = a + b.exp(c.x)
*
   2  FGRAPH = P(1) + P(2)*EXP(P(3)*X)
      RETURN
*
*  Function 3. Power function, 3 parameters.
*              f(x) = a + b.x^c
*
   3  FGRAPH = P(1) + P(2)*X**P(3)
      RETURN
*
*  Function 4. Logarithmic, 4 parameters.
*              f(x) = a + b.ln(c.x+d)
*
   4  FGRAPH = P(1) + P(2)*ALOG(P(3)*X + P(4))
      RETURN
*
*  Function 5. Base 10 Logarithmic, 4 parameters.
*              f(x) = a + b.log(c.x+d)
*
   5  FGRAPH = P(1) + P(2)*ALOG10(P(3)*X + P(4))
      RETURN
*
*  Function 6. Inverse function, 3 parameters.
*              f(x) = a + b/(c+x)
   6  FGRAPH = P(1) + P(2)/(P(3)+X)
      RETURN
*
*  Function 7. Circle.    4 Parameters.
*              P(1) = 1 for top half of circle, -1 for bottom half.
*              P(2) = radius
*              P(3) = x coordinate of centre of circle
*              P(4) = y coordinate of centre of circle
*
   7  XXX = P(2)*P(2) - (X-P(3))**2.
      IF(XXX.LT.0) XXX = 0.
      FGRAPH = P(1)*SQRT(XXX) + P(4)
      RETURN
*
*  Function 8. Ellipse.    5 Parameters.
*              P(1) = 1 for top half of ellipse, -1 for bottom half.
*              P(2) = max radius in x direction 
*              P(3) = max radius in y direction 
*              P(4) = x coordinate of centre of ellipse
*              P(5) = y coordinate of centre of ellipse
*
   8  XXX = 1.- ((X-P(4))/P(2))**2.
      IF(XXX.LT.0) XXX = 0.
      FGRAPH = P(1)*P(3)*SQRT(XXX) + P(5)
      RETURN
      END

*---------------------------------------------------------------------------
