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

« back to all changes in this revision

Viewing changes to examples/f95/x11f.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: x11f.f90,v 1.1 2006/05/16 20:24:12 airwin Exp $
 
2
!      Mesh plot demo
 
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
      integer i, j, k, ifshade, xpts, ypts
 
25
      parameter (xpts=35, ypts=46)
 
26
 
 
27
      real(kind=plflt) x(xpts), y(ypts), z(xpts,ypts), xx, yy, r
 
28
 
 
29
      character*80 title(2)
 
30
      real(kind=plflt) alt(2),az(2)
 
31
      integer opt(2)
 
32
      data alt /33.0_plflt,17.0_plflt/
 
33
      data az  /24.0_plflt,115.0_plflt/
 
34
!      DRAW_LINEXY
 
35
      data opt /2*3/
 
36
      data title /'#frPLplot Example 11 - Alt=33, Az=24, Opt=3', &
 
37
                  '#frPLplot Example 11 - Alt=17, Az=115, Opt=3'/
 
38
      integer nlevel
 
39
      parameter (nlevel = 10)
 
40
      real(kind=plflt) zmin, zmax, step, clevel(nlevel)
 
41
!      Plotting options for 3d plots, see plplot.h for the C definitions
 
42
!      of these options.
 
43
      integer DRAW_LINEX, DRAW_LINEY, DRAW_LINEXY, MAG_COLOR, &
 
44
        BASE_CONT, TOP_CONT, SURF_CONT, DRAW_SIDES, FACETED, MESH
 
45
      parameter(DRAW_LINEX = 1)
 
46
      parameter(DRAW_LINEY = 2)
 
47
      parameter(DRAW_LINEXY = 3)
 
48
      parameter(MAG_COLOR = 4)
 
49
      parameter(BASE_CONT = 8)
 
50
      parameter(TOP_CONT = 16)
 
51
      parameter(SURF_CONT = 32)
 
52
      parameter(DRAW_SIDES = 64)
 
53
      parameter(FACETED = 128)
 
54
      parameter(MESH = 256)
 
55
!      Process command-line arguments
 
56
      call plparseopts(PL_PARSE_FULL)
 
57
 
 
58
 
 
59
      do i = 1,xpts
 
60
        x(i) = 3._plflt*dble(i-1-(xpts/2))/dble (xpts/2)
 
61
      enddo
 
62
      do j = 1,ypts
 
63
        y(j) = 3._plflt*dble(j-1-(ypts/2))/dble (ypts/2)
 
64
      enddo
 
65
 
 
66
      do i=1,xpts
 
67
        xx = x(i)
 
68
        do j=1,ypts
 
69
          yy = y(j)
 
70
          z(i,j) = 3._plflt * (1._plflt-xx)*(1._plflt-xx) * &
 
71
            exp(-(xx*xx) - (yy+1._plflt)*(yy+1._plflt)) - &
 
72
            10._plflt * (xx/5._plflt - xx**3 - yy**5) * exp(-xx*xx-yy*yy) - &
 
73
            1._plflt/3._plflt * exp(-(xx+1._plflt)*(xx+1._plflt) - (yy*yy))
 
74
          if(.false.) then
 
75
!            Jungfraujoch/Interlaken
 
76
            if(z(i,j).lt.-1._plflt) z(i,j) = -1._plflt
 
77
          endif
 
78
        enddo
 
79
      enddo
 
80
      call a2mnmx(z, xpts, ypts, zmin, zmax)
 
81
      step = (zmax-zmin)/(nlevel+1)
 
82
      do i = 1, nlevel
 
83
        clevel(i) = zmin + step*i
 
84
      enddo
 
85
 
 
86
      call plinit()
 
87
      call cmap1_init(0)
 
88
      do k=1,2
 
89
        do ifshade = 0, 3
 
90
          call pladv(0)
 
91
          call plcol0(1)
 
92
          call plvpor(0.0_plflt, 1.0_plflt, 0.0_plflt, 0.9_plflt )
 
93
          call plwind(-1.0_plflt, 1.0_plflt, -1.0_plflt, 1.5_plflt )
 
94
          call plw3d(1.0_plflt, 1.0_plflt, 1.2_plflt, -3.0_plflt, &
 
95
            3.0_plflt, -3.0_plflt, 3.0_plflt, zmin, zmax, alt(k),az(k))
 
96
          call plbox3('bnstu','x axis', 0.0_plflt, 0, &
 
97
            'bnstu', 'y axis', 0.0_plflt, 0, &
 
98
            'bcdmnstuv','z axis', 0.0_plflt, 0)
 
99
          call plcol0(2)
 
100
          if(ifshade.eq.0) then
 
101
!            wireframe plot
 
102
            call plmesh(x(:xpts), y(:ypts), z(:xpts,:ypts), &
 
103
              opt(k))
 
104
          elseif(ifshade.eq.1) then
 
105
!            magnitude colored wireframe plot
 
106
            call plmesh(x(:xpts), y(:ypts), z(:xpts,:ypts), &
 
107
              ior(opt(k), MAG_COLOR))
 
108
          elseif(ifshade.eq.2) then
 
109
!            magnitude colored wireframe plot with sides
 
110
            call plot3d(x(:xpts), y(:ypts), z(:xpts,:ypts), &
 
111
              ior(opt(k), MAG_COLOR), .true.)
 
112
          elseif(ifshade.eq.3) then
 
113
!             magnitude colored wireframe plot with base contour
 
114
            call plmeshc(x(:xpts), y(:ypts), z(:xpts,:ypts), &
 
115
              ior(opt(k), ior(MAG_COLOR, BASE_CONT)), clevel)
 
116
          else
 
117
            stop 'x11f: bad logic'
 
118
          endif
 
119
          call plcol0(3)
 
120
          call plmtex('t', 1.0_plflt, 0.5_plflt, 0.5_plflt, title(k))
 
121
        enddo
 
122
      enddo
 
123
      call plend
 
124
      end
 
125
 
 
126
!----------------------------------------------------------------------------
 
127
      subroutine cmap1_init(gray)
 
128
!      For gray.eq.1, basic grayscale variation from half-dark
 
129
!      to light.  Otherwise, hue variations around the front of the
 
130
!      colour wheel from blue to green to red with constant lightness
 
131
!      and saturation.
 
132
 
 
133
      use plplot
 
134
      implicit none
 
135
      integer gray
 
136
      real(kind=plflt) i(0:1), h(0:1), l(0:1), s(0:1)
 
137
      logical rev(0:1)
 
138
!      left boundary
 
139
      i(0) = 0._plflt
 
140
!      right boundary
 
141
      i(1) = 1._plflt
 
142
      if (gray.eq.1) then
 
143
!        hue -- low: red (arbitrary if s=0)
 
144
        h(0) = 0.0_plflt
 
145
!        hue -- high: red (arbitrary if s=0)
 
146
        h(1) = 0.0_plflt
 
147
!        lightness -- low: half-dark
 
148
        l(0) = 0.5_plflt
 
149
!        lightness -- high: light
 
150
        l(1) = 1.0_plflt
 
151
!        minimum saturation
 
152
        s(0) = 0.0_plflt
 
153
!        minimum saturation
 
154
        s(1) = 0.0_plflt
 
155
      else
 
156
!        This combination of hues ranges from blue to cyan to green to yellow
 
157
!        to red (front of colour wheel) with constant lightness = 0.6
 
158
!        and saturation = 0.8.
 
159
 
 
160
!        hue -- low: blue
 
161
        h(0) = 240._plflt
 
162
!        hue -- high: red
 
163
        h(1) = 0.0_plflt
 
164
!        lightness -- low:
 
165
        l(0) = 0.6_plflt
 
166
!        lightness -- high:
 
167
        l(1) = 0.6_plflt
 
168
!        saturation
 
169
        s(0) = 0.8_plflt
 
170
!        minimum saturation
 
171
        s(1) = 0.8_plflt
 
172
      endif
 
173
      rev(0) = .false.
 
174
      rev(1) = .false.
 
175
      call plscmap1n(256)
 
176
      call plscmap1l(.false., i, h, l, s, rev)
 
177
      end
 
178
 
 
179
!----------------------------------------------------------------------------
 
180
!      Subroutine a2mnmx
 
181
!      Minimum and the maximum elements of a 2-d array.
 
182
 
 
183
      subroutine a2mnmx(f, nx, ny, fmin, fmax)
 
184
      use plplot
 
185
      implicit none
 
186
 
 
187
      integer   i, j, nx, ny
 
188
      real(kind=plflt)    f(nx, ny), fmin, fmax
 
189
 
 
190
      fmax = f(1, 1)
 
191
      fmin = fmax
 
192
      do j = 1, ny
 
193
        do  i = 1, nx
 
194
          fmax = max(fmax, f(i, j))
 
195
          fmin = min(fmin, f(i, j))
 
196
        enddo
 
197
      enddo
 
198
      end