!______________________________________________________________________________ ! This program demonstrates how to use the Graphics module to plot 2D curves ! It plots the function y=x^2 exactly and with random deviations. ! The function Plot3D is used identically, but with x,y and z data. !______________________________________________________________________________ PROGRAM DISLIN_test USE Graphics IMPLICIT NONE INTEGER, PARAMETER :: N=10 INTEGER :: i REAL, DIMENSION(N) :: X,Y,Z,DELTA,Y_,Z_ INTEGER, EXTERNAL :: MyGraphics X=REAL((/(i,i=1,N)/))/N Y=X**2 CALL RANDOM_NUMBER(DELTA) DELTA=(DELTA-0.5)/5 Y_=Y+DELTA ! This is an example of using Plot2D plot: CALL InitGraphics("2D_test_plot.tif","TIFF",(/"Example of 2D plot"/),"x","y=x^2",my_func=MyGraphics) CALL Plot2D(X,Y,"L-R",X,Y_,"STB",X,Y_,"L|G",my_func=MyGraphics) CALL EndGraphics(my_func=MyGraphics) Z=SQRT(X) Z_=Z+DELTA ! This is an example of using Plot3D: CALL InitGraphics("3D_test_plot.tif","TIFF",(/"Example of 3D plot"/),"x","y=x^2","z=sqrt(x)",my_func=MyGraphics) CALL Plot3D(X,Y,Z,"L-R",X,Y_,Z_,"STB",X,Y_,Z_,"L|G",my_func=MyGraphics) CALL EndGraphics(my_func=MyGraphics) END PROGRAM DISLIN_test !______________________________________________________________________________ ! This subroutine is an example of what can be passed to 2DPlot ! to perform functions not in the routine, like making a legend ! and performing a spline fit to the data points: !______________________________________________________________________________ INTEGER FUNCTION MyGraphics(level) USE DISLIN IMPLICIT NONE CHARACTER*60 Leg INTEGER :: level SELECT CASE(level) CASE(-1) CALL LEGCLR CALL LEGEND(Leg,3) CASE(0) CASE(1) CALL LEGINI(Leg,3,20) CALL LEGLIN(Leg,"Fitted parabola",1) CALL LEGLIN(Leg,"Experimental points",2) CALL LEGLIN(Leg,"Fitted spline",3) CASE(2) CALL POLCRV("SPLINE") CASE(3) END SELECT MyGraphics=1 END FUNCTION MyGraphics