The module provides several routines for plotting graphs of FUNCTIONs. The routines allocate and calculate the arrays needed by the corresponding routines in SimpleGraphics using a function that the user provides. Here I give their interface and an explanation of how they are used. The examples given after that will make everything much clearer:
SUBROUTINE FunPlot2D(f_x,x_range,num_points,plot_spec,axis) INTERFACE FUNCTION f_x(x) RESULT(y) REAL, INTENT(IN) :: x REAL :: y END FUNCTION f_x END INTERFACE REAL, DIMENSION(2), INTENT(IN) :: x_range INTEGER, OPTIONAL, INTENT(IN) :: num_points CHARACTER(LEN=3), DIMENSION(:), OPTIONAL, INTENT(IN) :: plot_spec REAL, DIMENSION(4), OPTIONAL, INTENT(IN) :: axis END SUBROUTINE FunPlot2DThe function f_x is the function f(x) that we want to plot. It should accept a single precision value of x and return f(x) in single precision. The range x_range gives the interval of x values to plot f(x) on, using num_points points (default value is 10). The optional single-precision vector of 4 values axis gives the axis limits. If it is not present, the routine will choose the axis limits so as to fit the whole range of x and y values. For example, use axis=(/x_min,x_max,y_min,y_max/).
SUBROUTINE FunPlot3D(f_xy,xy_range,num_points,plot_spec,axis,view) INTERFACE FUNCTION f_xy(x,y) RESULT(z) REAL, INTENT(IN) :: x,y REAL :: z END FUNCTION f_xy END INTERFACE REAL, DIMENSION(4), INTENT(IN) :: xy_range INTEGER, DIMENSION(2), OPTIONAL, INTENT(IN) :: num_points CHARACTER(LEN=3), OPTIONAL, INTENT(IN) :: plot_spec REAL, DIMENSION(6), OPTIONAL, INTENT(IN) :: axis REAL, DIMENSION(3), OPTIONAL, INTENT(IN) :: view END SUBROUTINE FunPlot3DIt accepts almost the same kind of arguments as FunPlot3D, except that now the user-supplied function f_xy accepts two arguments, x and y, the range gives ranges for both x and y axes, in the form (/x_min,x_max,y_min,y_max/) and num_points is an array giving the number of grid points in the x and y directions respectively (default is (/10,10/)). The specification plot_spec is the same as in SurfPlot. There are additional optional 2/3 element arrays specifying the camera position view (in polar (phi,theta,r) coordinates--angles as degrees, not radians!), which are usually chosen well automatically.
SUBROUTINE FunPlotContour(f_xy,xyz_range,num_points,plot_spec,axis) INTERFACE FUNCTION f_xy(x,y) RESULT(z) REAL, INTENT(IN) :: x,y REAL :: z END FUNCTION f_xy END INTERFACE REAL, DIMENSION(6), INTENT(IN) :: xyz_range INTEGER, DIMENSION(3), OPTIONAL, INTENT(IN) :: num_points CHARACTER(LEN=3), OPTIONAL, INTENT(IN) :: plot_spec REAL, DIMENSION(4), OPTIONAL, INTENT(IN) :: axis END SUBROUTINE FunPlotContourAlmost everything is as usual. Now, however, the user also needs to supply a range for the z direction as well in xyz_range. The routine will plot num_points(3) contour lines of the function f_xy with levels spaced uniformly over the range [xyz_range(5),xyz_range(6)]. The rest of the arguments are the same as in all routines. A typical basic call to this routine is given below.
SUBROUTINE FunVectorPlot2D(f_xy,xy_range,num_points,plot_spec,axis,zoom) INTERFACE FUNCTION f_xy(x,y) RESULT(z) REAL, INTENT(IN) :: x,y REAL, DIMENSION(2) :: z END FUNCTION f_xy END INTERFACE REAL, DIMENSION(4), INTENT(IN) :: xy_range INTEGER, DIMENSION(2), OPTIONAL, INTENT(IN) :: num_points CHARACTER(LEN=3), OPTIONAL, INTENT(IN) :: plot_spec REAL, DIMENSION(6), OPTIONAL, INTENT(IN) :: axis REAL, OPTIONAL, INTENT(IN) :: zoomThe function f_xy is the function f(x,y) that we want to plot. It should return a vector of two values in the form [f_{x }, f_{y}]. The rest of the algorithms are like in the routines above. Note that axis(5:6) in this instance specifies the minimal and maximal length of the vectors to be plotted. This is useful in avoiding plotting very small vectors and very large vectors, which look ugly. The optional real argument zoom determines the scaling factor for the vectors. Since the scale of the vector magnitudes is no way related to the axis (different units) the zoom factor can be changed to make the plot look nicer without affecting the meaning of the plot. Color is used to denote magnitude. The three-character specification string plot_spec has the following meaning: The first and second characters are digits 1-9 determining the size and width of the arrow while the last character determines the color pallette and is the same as in the other routines. The default "11g" usually produces best results! For examples on how to use these routines, take a look at this Fortran 90 code which plots a surface and contour plot of the function z=sin(x)sin(y). Here is the output of this file for the surface and for the contour plot. There is no example for the field plotting routine, but the above has enough clues to guide you.