Hi Alan, On 2011-10-19 19:39, Alan W. Irwin wrote: > Hi Arjen: > > Now that you have put in a notice in README.release about the future > deprecation of our f77 bindings and examples, and Andrew has done such > great work making our f95 bindings and examples much more compliant > with the Fortran 95 standard, I think our next obvious Fortran step is > to follow up by using more of the power of Fortran 95 in our f95 > examples. > > For example, I understand that intrinsic functions like sin, cos, > etc., can take array arguments and return the corresponding array > results (just like the corresponding numpy Python capability that is > used in examples/python/xw??.py) so using this Fortran 95 capability > should eliminate many of the do loops in our examples. >
I have reworked example x01 with this in mind. Some more changes are possible, but what do you think of it? The implied do-loops to get data into the arrays are perhaps a bit overdone, but that is where I want your opinion about. Other things: indentation - I will back on that, no time right now. Regards, Arjen --------- ! $Id: x01f.f90 11680 2011-03-27 17:57:51Z airwin $ ! Simple line plot and multiple windows demo. ! ! Copyright (C) 2004 Alan W. Irwin ! ! This file is part of PLplot. ! ! PLplot is free software; you can redistribute it and/or modify ! it under the terms of the GNU Library General Public License as ! published by the Free Software Foundation; either version 2 of the ! License, or (at your option) any later version. ! ! PLplot is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with PLplot; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA program x01f95 use plplot, PI => PL_PI implicit none real(plflt) :: xscale, yscale, xoff, yoff character(len=80) :: version integer :: digmax ! Process command-line arguments call plparseopts(PL_PARSE_FULL) ! Print plplot version call plgver(version) write (*,'(a,a)') 'PLplot library version: ', trim(version) ! Initialize plplot ! Divide page into 2x2 plots call plstar(2,2) ! Set up the data ! Original case xscale = 6._plflt yscale = 1._plflt xoff = 0._plflt yoff = 0._plflt ! Do a plot call plot1() ! Set up the data xscale = 1._plflt yscale = 0.0014_plflt yoff = 0.0185_plflt ! Do a plot digmax = 5 call plsyax(digmax, 0) call plot1() call plot2() call plot3() ! Don't forget to call PLEND to finish off! call plend() contains !====================================================================== subroutine plot1() real(plflt), dimension(1:60) :: x, y real(plflt), dimension(1:6) :: xs, ys real(plflt) :: xmin, xmax, ymin, ymax integer :: i x = (/ ( xoff + xscale * dble(i)/60.0_plflt, i = 1,size(x) ) /) y = yoff + yscale * x**2 xmin = minval(x) xmax = maxval(x) ymin = minval(y) ymax = maxval(y) xs = x(4::10) ys = y(4::10) ! Set up the viewport and window using PLENV. The range in X is ! 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are ! scaled separately (just = 0), and we just draw a labelled ! box (axis = 0). call plcol0(1) call plenv( xmin, xmax, ymin, ymax, 0, 0 ) call plcol0(2) call pllab( '(x)', '(y)', '#frPLplot Example 1 - y=x#u2' ) ! Plot the data points call plcol0(4) call plpoin( xs, ys, 9 ) ! Draw the line through the data call plcol0(3) call plline( x, y ) end subroutine plot1 !====================================================================== subroutine plot2() real(plflt), dimension(1:100) :: x, y integer :: i ! ! Set up the viewport and window using PLENV. The range in X is ! -2.0 to 10.0, and the range in Y is -0.4 to 2.0. The axes are ! scaled separately (just = 0), and we draw a box with axes ! (axis = 1). call plcol0(1) call plenv(-2.0_plflt, 10.0_plflt, -0.4_plflt, 1.2_plflt, 0, 1 ) call plcol0(2) call pllab( '(x)', 'sin(x)/x', '#frPLplot Example 1 - Sinc Function' ) ! Fill up the arrays x = (/ ( (i-20.0_plflt)/6.0_plflt, i = 1,size(x) ) /) y = merge( sin(x) / x, 1.0_plflt, x /= 0.0_plflt ) ! Draw the line call plcol0(3) call plwid(2) call plline( x, y ) call plwid(1) end subroutine plot2 !====================================================================== subroutine plot3() ! ! For the final graph we wish to override the default tick intervals, ! and so do not use_ PLENV real(plflt), dimension(1:101) :: x, y integer :: i call pladv(0) ! Use_ standard viewport, and define X range from 0 to 360 degrees, ! Y range from -1.2 to 1.2. call plvsta() call plwind( 0.0_plflt, 360.0_plflt, -1.2_plflt, 1.2_plflt ) ! Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y. call plcol0(1) call plbox( 'bcnst', 60.0_plflt, 2, 'bcnstv', 0.2_plflt, 2 ) ! Superimpose a dashed line grid, with 1.5 mm marks and spaces. With ! only a single mark and space element, we do not need arrays call plstyl( 1, 1500, 1500 ) call plcol0(2) call plbox( 'g', 30.0_plflt, 0, 'g', 0.2_plflt, 0 ) call plstyl( 0, 0, 0 ) call plcol0(3) call pllab( 'Angle (degrees)', 'sine', '#frPLplot Example 1 - Sine function' ) x = (/ ( 3.6_plflt * (i-1), i = 1,size(x) ) /) y = sin( x * PI/180.0_plflt ) call plcol0(4) call plline( x, y ) end subroutine plot3 end program x01f95 DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail. ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel