program gnufor_prb ! !******************************************************************************* ! !! GNUFOR_PRB tests the GNUFOR routines. ! implicit none ! call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'GNUFOR_PRB' write ( *, '(a)' ) ' A set of tests for GNUFOR.' call test01 call test02 call test03 call test04 call test05 call test06 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'GNUFOR_PRB' write ( *, '(a)' ) ' Normal end of GNUFOR tests.' stop end subroutine test01 ! !******************************************************************************* ! !! TEST01 demonstrates the plotting of Y(X) data. ! implicit none ! integer, parameter :: n = 101 ! real angle real area character ( len = 100 ) :: command_file_name = 'test01_commands.txt' character ( len = 100 ) :: data_file_name = 'test01_data.txt' integer i integer ierror real x(n) real, parameter :: xmin = 0.0+00 real, parameter :: xmax = 20.0E+00 real y(n) ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' To plot a simple set of (X,Y) data,' write ( *, '(a)' ) ' WRITE_XY_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_XY_PLOT writes the plot command file.' do i = 1, n x(i) = ( real ( n - i ) * xmin + real ( i - 1 ) * xmax ) / real ( n - 1 ) y(i) = sin ( x(i) ) * sin ( 4.0 * x(i) ) end do call write_xy_data ( data_file_name, n, x, y, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a,i6)' ) ' WRITE_XY_DATA returned IERROR = ', ierror end if call write_xy_plot ( command_file_name, data_file_name, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a,i6)' ) ' WRITE_XY_PLOT returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end subroutine test02 ! !******************************************************************************* ! !! TEST02 demonstrates the plotting of a table of data. ! implicit none ! integer, parameter :: nrow = 101 integer, parameter :: ncol = 4 ! integer, parameter :: lda = nrow ! real angle real area character ( len = 100 ) :: command_file_name = 'test02_commands.txt' character ( len = 100 ) :: data_file_name = 'test02_data.txt' real height integer i integer ierror real, parameter :: r = 50.0E+00 real width real x(lda,ncol) ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a)' ) ' To plot X versus multiple sets of Y data,' write ( *, '(a)' ) ' WRITE_XYY_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_XYY_PLOT writes the plot command file.' do i = 1, nrow height = 2.0E+00 * r * real ( i - 1 ) / real ( nrow - 1 ) width = 2.0E+00 * sqrt ( r**2 - ( r - height )**2 ) angle = acos ( ( r - height ) / r ) area = 0.5E+00 * r**2 * 2.0E+00 * acos ( ( r - height ) / r ) & - ( r - height ) * sqrt ( height * ( 2.0E+00 * r - height ) ) x(i,1) = height x(i,2) = width x(i,3) = angle x(i,4) = area end do call write_xyy_data ( data_file_name, lda, nrow, ncol, x, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a,i6)' ) ' WRITE_XYY_DATA returned IERROR = ', ierror end if call write_xyy_plots ( command_file_name, data_file_name, ncol, & ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a,i6)' ) ' WRITE_XYY_PLOTS returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end subroutine test03 ! !******************************************************************************* ! !! TEST03 plots parameter (X,Y,Z) data. ! implicit none ! integer, parameter :: n = 101 ! character ( len = 100 ) :: command_file_name = 'test03_commands.txt' character ( len = 100 ) :: data_file_name = 'test03_data.txt' integer i integer ierror integer, parameter :: nturn = 5 real pi real, parameter :: r = 5.0E+00 real theta real x(n) real y(n) real z(n) real, parameter :: zmax = 10.0E+00 ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST03' write ( *, '(a)' ) ' To plot a (parametric) set of (X,Y,Z) data,' write ( *, '(a)' ) ' WRITE_XYZ_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_XYZ_PLOT writes the plot command file.' do i = 1, n z(i) = zmax * real ( i - 1 ) / real ( n - 1 ) theta = ( 2.0E+00 * pi() ) * z(i) * real ( nturn ) / zmax x(i) = r * cos ( theta ) y(i) = r * sin ( theta ) end do call write_xyz_data ( data_file_name, n, x, y, z, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST03' write ( *, '(a,i6)' ) ' WRITE_XYZ_DATA returned IERROR = ', ierror end if call write_xyz_plot ( command_file_name, data_file_name, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST03' write ( *, '(a,i6)' ) ' WRITE_XYZ_PLOT returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end subroutine test04 ! !******************************************************************************* ! !! TEST04 plots vector data. ! implicit none ! integer, parameter :: nx = 21 integer, parameter :: ny = 21 integer, parameter :: n = nx * ny ! character ( len = 100 ) :: command_file_name = 'test04_commands.txt' character ( len = 100 ) :: data_file_name = 'test04_data.txt' real dx(n) real dy(n) integer i integer ierror integer j integer k real x(n) real, parameter :: xmax = 1.0E+00 real, parameter :: xmin = -1.0E+00 real xx real y(n) real, parameter :: ymax = 1.0E+00 real, parameter :: ymin = -1.0E+00 real yy ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST04' write ( *, '(a)' ) ' To plot a vector field,' write ( *, '(a)' ) ' WRITE_VECTOR_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_VECTOR_PLOT writes the plot command file.' k = 0 do i = 1, nx do j = 1, ny k = k + 1 xx = ( real ( nx - i ) * xmin + real ( i - 1 ) * xmax ) / real ( nx - 1 ) yy = ( real ( ny - j ) * ymin + real ( j - 1 ) * ymax ) / real ( ny - 1 ) dx(k) = - 0.10E+00 * yy dy(k) = 0.10E+00 * xx x(k) = xx - 0.5E+00 * dx(k) y(k) = yy - 0.5E+00 * dy(k) end do end do call write_vector_data ( data_file_name, n, x, y, dx, dy, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST04' write ( *, '(a,i6)' ) ' WRITE_VECTOR_DATA returned IERROR = ', ierror end if call write_vector_plot ( command_file_name, data_file_name, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST04' write ( *, '(a,i6)' ) ' WRITE_VECTOR_PLOT returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end subroutine test05 ! !******************************************************************************* ! !! TEST05 plots Z(X,Y) grid data as a surface. ! implicit none ! integer, parameter :: nx = 21 integer, parameter :: ny = 21 integer, parameter :: nrow = nx * ny ! character ( len = 100 ) :: command_file_name = 'test05_commands.txt' character ( len = 100 ) :: data_file_name = 'test05_data.txt' integer i integer ierror integer j real x real, parameter :: xmax = 1.0E+00 real, parameter :: xmin = 0.0E+00 real xyz(3,nx,ny) real y real, parameter :: ymax = 1.0E+00 real, parameter :: ymin = 0.0E+00 real z ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST05' write ( *, '(a)' ) ' To plot a gridded set of Z(X,Y) data as a surface,' write ( *, '(a)' ) ' WRITE_XYZGRID_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_XYZGRID_SURFACE writes the plot command file.' do i = 1, nx x = ( real ( nx - i ) * xmin + real ( i - 1 ) * xmax ) / real ( nx - 1 ) do j = 1, ny y = ( real ( ny - j ) * ymin + real ( j - 1 ) * ymax ) / real ( ny - 1 ) z = sin ( 64.0E+00 * ( x - 0.5E+00 )**2 * ( y - 0.5E+00 )**2 ) xyz(1,i,j) = x xyz(2,i,j) = y xyz(3,i,j) = z end do end do call write_xyzgrid_data ( data_file_name, nx, ny, xyz, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST05' write ( *, '(a,i6)' ) ' WRITE_XYZGRID_DATA returned IERROR = ', ierror end if call write_xyzgrid_surface ( command_file_name, data_file_name, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST05' write ( *, '(a,i6)' ) ' WRITE_XYZGRID_SURFACE returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end subroutine test06 ! !******************************************************************************* ! !! TEST06 plots Z(X,Y) grid data as contours. ! implicit none ! integer, parameter :: nx = 41 integer, parameter :: ny = 41 ! character ( len = 100 ) :: command_file_name = 'test06_commands.txt' character ( len = 100 ) :: data_file_name = 'test06_data.txt' integer i integer ierror integer j real x real, parameter :: xmax = 1.0E+00 real, parameter :: xmin = 0.0E+00 real xyz(3,nx,ny) real y real, parameter :: ymax = 1.0E+00 real, parameter :: ymin = 0.0E+00 real z ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST06' write ( *, '(a)' ) ' To plot gridded Z(X,Y) data as contours,' write ( *, '(a)' ) ' WRITE_XYZGRID_DATA writes the data file,' write ( *, '(a)' ) ' WRITE_XYZGRID_CONTOUR writes the plot command file.' do i = 1, nx x = ( real ( nx - i ) * xmin + real ( i - 1 ) * xmax ) / real ( nx - 1 ) do j = 1, ny y = ( real ( ny - j ) * ymin + real ( j - 1 ) * ymax ) / real ( ny - 1 ) z = sin ( 64.0E+00 * ( x - 0.5E+00 )**2 * ( y - 0.5E+00 )**2 ) xyz(1,i,j) = x xyz(2,i,j) = y xyz(3,i,j) = z end do end do call write_xyzgrid_data ( data_file_name, nx, ny, xyz, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST06' write ( *, '(a,i6)' ) ' WRITE_XYZGRID_DATA returned IERROR = ', ierror end if call write_xyzgrid_contour ( command_file_name, data_file_name, ierror ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST06' write ( *, '(a,i6)' ) ' WRITE_XYZGRID_CONTOUR returned IERROR = ', ierror end if call run_gnuplot ( command_file_name ) return end