program main !*****************************************************************************80 ! !! QUICKPLOT_SCATTER demonstrates the DISLIN quickplot command QPLOT. ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 26 February 2014 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Helmut Michels, ! The Data Plotting Software DISLIN - version 10.4, ! Shaker Media GmbH, January 2010, ! ISBN13: 978-3-86858-517-9. ! use dislin implicit none integer ( kind = 4 ), parameter :: n = 100 integer ( kind = 4 ) i integer ( kind = 4 ) j real ( kind = 8 ) r8_uniform_01 real ( kind = 8 ) s real ( kind = 8 ) seed real ( kind = 8 ) xvec(n) real ( kind = 8 ) yvec(n) call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'QUICKPLOT_SCATTER:' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Demonstrate the DISLIN "quickplot" command QPLSCA' write ( *, '(a)' ) ' to make a scatter plot.' ! ! Generate the data. ! We average 4 random values to get data that tends to cluster ! near (0.5,0.5). ! seed = 123456789 do i = 1, n s = 0.0D+00 do j = 1, 4 s = s + r8_uniform_01 ( seed ) end do xvec(i) = s / 4.0D+00 end do do i = 1, n s = 0.0D+00 do j = 1, 4 s = s + r8_uniform_01 ( seed ) end do yvec(i) = s / 4.0D+00 end do ! ! Specify the format of the output file. ! call metafl ( 'png' ) ! ! Indicate that new data overwrites old data. ! call filmod ( 'delete' ) ! ! Specify the name of the output graphics file. ! call setfil ( 'quickplot_scatter.png' ) ! ! Choose the page size and orientation. ! call setpag ( 'usal' ) ! ! For PNG output, reverse the default black background to white. ! call scrmod ( 'reverse' ) ! ! Open DISLIN. ! call disini ( ) ! ! Label the axes and the plot. ! call name ( '<-- X -->', 'X' ) call name ( '<-- Y -->', 'Y' ) call titlin ( 'Quick plot by QPLSCA', 2 ) ! ! Draw the curve. ! call qplsca ( xvec, yvec, n ) ! ! Close DISLIN. ! call disfin ( ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'QUICKPLOT_SCATTER:' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop end function r8_uniform_01 ( seed ) !*****************************************************************************80 ! !! R8_UNIFORM_01 returns a unit pseudorandom R4. ! ! Discussion: ! ! An R4 is a real ( kind = 4 ) value. ! ! This routine implements the recursion ! ! seed = 16807 * seed mod ( 2^31 - 1 ) ! r8_uniform_01 = seed / ( 2^31 - 1 ) ! ! The integer arithmetic never requires more than 32 bits, ! including a sign bit. ! ! If the initial seed is 12345, then the first three computations are ! ! Input Output R8_UNIFORM_01 ! SEED SEED ! ! 12345 207482415 0.096616 ! 207482415 1790989824 0.833995 ! 1790989824 2035175616 0.947702 ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 11 August 2004 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Paul Bratley, Bennett Fox, Linus Schrage, ! A Guide to Simulation, ! Springer Verlag, pages 201-202, 1983. ! ! Pierre L'Ecuyer, ! Random Number Generation, ! in Handbook of Simulation, ! edited by Jerry Banks, ! Wiley Interscience, page 95, 1998. ! ! Bennett Fox, ! Algorithm 647: ! Implementation and Relative Efficiency of Quasirandom ! Sequence Generators, ! ACM Transactions on Mathematical Software, ! Volume 12, Number 4, pages 362-376, 1986. ! ! Peter Lewis, Allen Goodman, James Miller ! A Pseudo-Random Number Generator for the System/360, ! IBM Systems Journal, ! Volume 8, pages 136-143, 1969. ! ! Parameters: ! ! Input/output, integer ( kind = 4 ) SEED, the "seed" value, which ! should NOT be 0. On output, SEED has been updated. ! ! Output, real ( kind = 8 ) R8_UNIFORM_01, a new pseudorandom variate, ! strictly between 0 and 1. ! implicit none integer ( kind = 4 ), parameter :: i4_huge = 2147483647 integer ( kind = 4 ) k integer ( kind = 4 ) seed real ( kind = 8 ) r8_uniform_01 if ( seed == 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'R8_UNIFORM_01 - Fatal error!' write ( *, '(a)' ) ' Input value of SEED = 0.' stop end if k = seed / 127773 seed = 16807 * ( seed - k * 127773 ) - k * 2836 if ( seed < 0 ) then seed = seed + i4_huge end if r8_uniform_01 = real ( seed, kind = 8 ) * 4.656612875D-10 return end subroutine timestamp ( ) !*****************************************************************************80 ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none character ( len = 8 ) ampm integer ( kind = 4 ) d integer ( kind = 4 ) h integer ( kind = 4 ) m integer ( kind = 4 ) mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer ( kind = 4 ) n integer ( kind = 4 ) s integer ( kind = 4 ) values(8) integer ( kind = 4 ) y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end