~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to examples/f95/x03f.f90

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
!      $Id: x03f.f90,v 1.1 2006/05/16 20:24:12 airwin Exp $
 
2
!      Generates polar plot with, 1-1 scaling
 
3
!
 
4
!      Copyright (C) 2004  Alan W. Irwin
 
5
!
 
6
!      This file is part of PLplot.
 
7
!
 
8
!      PLplot is free software; you can redistribute it and/or modify
 
9
!      it under the terms of the GNU General Library Public License as
 
10
!      published by the Free Software Foundation; either version 2 of the
 
11
!      License, or (at your option) any later version.
 
12
!
 
13
!      PLplot is distributed in the hope that it will be useful,
 
14
!      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
!      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
!      GNU Library General Public License for more details.
 
17
!
 
18
!      You should have received a copy of the GNU Library General Public
 
19
!      License along with PLplot; if not, write to the Free Software
 
20
!      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
21
 
 
22
      use plplot, PI => PL_PI
 
23
      implicit none
 
24
 
 
25
      character*3 text
 
26
      real(kind=plflt) x0(0:360), y0(0:360)
 
27
      real(kind=plflt) x(0:360), y(0:360), dtr, theta, dx, dy, r
 
28
      integer i, j, nsp
 
29
!      Process command-line arguments
 
30
      call plparseopts(PL_PARSE_FULL)
 
31
 
 
32
 
 
33
      dtr = PI/180.0_plflt
 
34
      do i=0,360
 
35
        x0(i) = cos(dtr * dble (i))
 
36
        y0(i) = sin(dtr * dble (i))
 
37
      enddo
 
38
 
 
39
!      Initialize PLplot
 
40
 
 
41
      call plinit()
 
42
 
 
43
!      Set up viewport and window, but do not draw box
 
44
 
 
45
      call plenv(-1.3_plflt, 1.3_plflt, -1.3_plflt, 1.3_plflt, 1, -2)
 
46
      do i = 1,10
 
47
        do j = 0,360
 
48
          x(j) = 0.1_plflt*i*x0(j)
 
49
          y(j) = 0.1_plflt*i*y0(j)
 
50
        enddo
 
51
!        Draw circles for polar grid
 
52
 
 
53
        call plline(x,y)
 
54
      enddo
 
55
      call plcol0(2)
 
56
      do i = 0,11
 
57
        theta = 30.0_plflt*i
 
58
        dx = cos(dtr*theta)
 
59
        dy = sin(dtr*theta)
 
60
 
 
61
!        Draw radial spokes for polar grid
 
62
 
 
63
        call pljoin(0.0_plflt, 0.0_plflt, dx, dy)
 
64
        write (text,'(i3)') nint(theta)
 
65
 
 
66
!        Write labels for angle
 
67
 
 
68
        text = text(nsp(text):)
 
69
!        Slightly off zero to avoid floating point logic flips at
 
70
!        90 and 270 deg.
 
71
        if (dx.ge.-0.00001_plflt) then
 
72
          call plptex(dx, dy, dx, dy, -0.15_plflt, text)
 
73
        else
 
74
          call plptex(dx, dy, -dx, -dy, 1.15_plflt, text)
 
75
        end if
 
76
      enddo
 
77
!      Draw the graph
 
78
 
 
79
      do i=0,360
 
80
        r = sin(dtr*dble (5*i))
 
81
        x(i) = x0(i) * r
 
82
        y(i) = y0(i) * r
 
83
      enddo
 
84
      call plcol0(3)
 
85
      call plline(x,y)
 
86
 
 
87
      call plcol0(4)
 
88
      call plmtex('t', 2.0_plflt, 0.5_plflt, 0.5_plflt, &
 
89
        '#frPLplot Example 3 - r(#gh)=sin 5#gh')
 
90
 
 
91
!      Close the plot at end
 
92
 
 
93
      call plend
 
94
      end
 
95
 
 
96
      integer function nsp(text)
 
97
!      ==================
 
98
 
 
99
!      Find first non-space character
 
100
      use plplot
 
101
      implicit none
 
102
 
 
103
      character*(*) text
 
104
      integer l, len
 
105
 
 
106
      l = len(text)
 
107
      nsp = 1
 
108
      do while(text(nsp:nsp).eq.' ' .and. nsp.lt.l)
 
109
        nsp = nsp+1
 
110
      enddo
 
111
      end