1
! $Id: x22f.f90,v 1.3 2006/05/19 17:15:15 airwin Exp $
4
! Copyright (C) 2004 Alan W. Irwin
5
! Copyright (C) 2004 Andrew Ross
7
! This file is part of PLplot.
9
! PLplot is free software; you can redistribute it and/or modify
10
! it under the terms of the GNU General Library Public License as
11
! published by the Free Software Foundation; either version 2 of the
12
! License, or (at your option) any later version.
14
! PLplot is distributed in the hope that it will be useful,
15
! but WITHOUT ANY WARRANTY; without even the implied warranty of
16
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
! GNU Library General Public License for more details.
19
! You should have received a copy of the GNU Library General Public
20
! License along with PLplot; if not, write to the Free Software
21
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
! Does several contour plots using different coordinate mappings.
30
real(kind=plflt) arrow_x(narr),arrow_y(narr), &
31
arrow2_x(narr),arrow2_y(narr)
33
data arrow_x/-0.5_plflt, 0.5_plflt, 0.3_plflt, 0.5_plflt, 0.3_plflt, 0.5_plflt/
34
data arrow_y/0._plflt, 0._plflt, 0.2_plflt, 0._plflt, -0.2_plflt, 0._plflt/
35
data arrow2_x/-0.5_plflt, 0.3_plflt, 0.3_plflt, 0.5_plflt, 0.3_plflt, 0.3_plflt/
36
data arrow2_y/0._plflt, 0._plflt, 0.2_plflt, 0._plflt, -0.2_plflt, 0._plflt/
38
! Process command-line arguments
39
call plparseopts(PL_PARSE_FULL)
48
! Set arrow style using arrow_x and arrow_y the
49
! plot using these arrows
50
call plsvect(arrow_x, arrow_y, fill)
53
! Set arrow style using arrow_x and arrow_y the
54
! plot using these arrows
56
call plsvect(arrow2_x, arrow2_y, fill)
65
! vector plot of the circulation around the origin
66
subroutine circulation()
71
parameter (nx=20, ny=20)
73
real(kind=plflt) u(nx, ny), v(nx, ny), xg(nx,ny), yg(nx,ny)
75
real(kind=plflt) dx, dy, xmin, xmax, ymin, ymax
76
real(kind=plflt) xx, yy, scaling
81
xmin = -dble(nx)/2.0_plflt*dx
82
xmax = dble(nx)/2.0_plflt*dx
83
ymin = -dble(ny)/2.0_plflt*dy
84
ymax = dble(ny)/2.0_plflt*dy
87
xx = (dble(i)-nx/2.0_plflt-0.5_plflt)*dx
89
yy = (dble(j)-ny/2.0_plflt-0.5_plflt)*dy
97
call plenv(xmin, xmax, ymin, ymax, 0, 0)
98
call pllab('(x)', '(y)', &
99
'#frPLplot Example 22 - circulation')
102
call plvect(u,v,scaling,xg,yg)
107
! vector plot of the flow through a constricted pipe
108
subroutine constriction()
109
use plplot, PI => PL_PI
113
parameter (nx=20, ny=20)
115
real(kind=plflt) u(nx, ny), v(nx, ny), xg(nx,ny), yg(nx,ny)
117
real(kind=plflt) dx, dy, xmin, xmax, ymin, ymax
118
real(kind=plflt) xx, yy, Q, b, dbdx, scaling
123
xmin = -dble(nx)/2.0_plflt*dx
124
xmax = dble(nx)/2.0_plflt*dx
125
ymin = -dble(ny)/2.0_plflt*dy
126
ymax = dble(ny)/2.0_plflt*dy
130
xx = (dble(i)-dble(nx)/2.0_plflt-0.5_plflt)*dx
132
yy = (dble(j)-dble(ny)/2.0_plflt-0.5_plflt)*dy
135
b = ymax/4.0_plflt*(3.0_plflt-cos(PI*xx/xmax))
136
if (abs(yy).lt.b) then
137
dbdx = ymax/4.0_plflt*sin(PI*xx/xmax)*yy/b
147
call plenv(xmin, xmax, ymin, ymax, 0, 0)
148
call pllab('(x)', '(y)', &
149
'#frPLplot Example 22 - constriction')
152
call plvect(u,v,scaling,xg,yg)
158
subroutine potential()
159
use plplot, PI => PL_PI
162
integer i, j, nr, ntheta, nper, nlevel
163
parameter (nr=20, ntheta=20, nper=100, nlevel=10)
165
real(kind=plflt) u(nr, ntheta), v(nr, ntheta), z(nr, ntheta)
166
real(kind=plflt) xg(nr,ntheta), yg(nr,ntheta)
167
real(kind=plflt) clevel(nlevel), px(nper), py(nper)
169
real(kind=plflt) xmin, xmax, ymin, ymax, zmin, zmax, rmax
170
real(kind=plflt) xx, yy, r, theta, scaling, dz
172
real(kind=plflt) eps, q1, d1, q1i, d1i, q2, d2, q2i, d2i
173
real(kind=plflt) div1, div1i, div2, div2i
183
d1i = rmax**2.0_plflt/d1;
189
d2i = rmax**2.0_plflt/d2;
194
theta = 2.*PI/dble(ntheta-1)*(dble(j)-0.5)
199
div1 = sqrt((xg(i,j)-d1)**2 + (yg(i,j)-d1)**2 + eps**2)
200
div1i = sqrt((xg(i,j)-d1i)**2 + (yg(i,j)-d1i)**2 + eps**2)
202
div2 = sqrt((xg(i,j)-d2)**2 + (yg(i,j)+d2)**2 + eps**2)
203
div2i = sqrt((xg(i,j)-d2i)**2 + (yg(i,j)+d2i)**2 + eps**2)
205
z(i,j) = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i
206
u(i,j) = -q1*(xx-d1)/div1**3 - q1i*(xx-d1i)/div1i**3 - &
207
q2*(xx-d2)/div2**3 - q2i*(xx-d2i)/div2i**3
208
v(i,j) = -q1*(yy-d1)/div1**3 - q1i*(yy-d1i)/div1i**3 - &
209
q2*(yy+d2)/div2**3 - q2i*(yy+d2i)/div2i**3
213
call a2mnmx(xg, nr, ntheta, xmin, xmax, nr)
214
call a2mnmx(yg, nr, ntheta, ymin, ymax, nr)
215
call a2mnmx(z, nr, ntheta, zmin, zmax, nr)
217
call plenv(xmin, xmax, ymin, ymax, 0, 0)
218
call pllab('(x)', '(y)', &
219
'#frPLplot Example 22 - potential gradient vector plot')
221
! plot contours of the potential
222
dz = abs(zmax - zmin)/dble (nlevel)
224
clevel(i) = zmin + (i-0.5_plflt)*dz
228
call plcont(z,1,nr,1,ntheta,clevel,xg,yg)
234
call plvect(u,v,scaling,xg,yg)
238
theta = 2.0_plflt*PI/dble(nper-1)*dble(i)
239
px(i) = rmax*cos(theta)
240
py(i) = rmax*sin(theta)
247
!----------------------------------------------------------------------------
249
! Minimum and the maximum elements of a 2-d array.
251
subroutine a2mnmx(f, nx, ny, fmin, fmax, xdim)
255
integer i, j, nx, ny, xdim
256
real(kind=plflt) f(xdim, ny), fmin, fmax
262
fmax = max(fmax, f(i, j))
263
fmin = min(fmin, f(i, j))