/usr/share/doc/libplplot12/examples/f95/x22f.f90 is in libplplot-dev 5.10.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | ! $Id: x22f.f90 12827 2013-12-09 13:20:01Z andrewross $
! Vector plot demo.
!
! Copyright (C) 2004 Alan W. Irwin
! Copyright (C) 2004 Andrew Ross
!
! 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
! Does several contour plots using different coordinate mappings.
use plplot
implicit none
integer narr
logical fill
parameter (narr=6)
real(kind=plflt) arrow_x(narr),arrow_y(narr), &
arrow2_x(narr),arrow2_y(narr)
data arrow_x/-0.5_plflt, 0.5_plflt, 0.3_plflt, 0.5_plflt, 0.3_plflt, 0.5_plflt/
data arrow_y/0._plflt, 0._plflt, 0.2_plflt, 0._plflt, -0.2_plflt, 0._plflt/
data arrow2_x/-0.5_plflt, 0.3_plflt, 0.3_plflt, 0.5_plflt, 0.3_plflt, 0.3_plflt/
data arrow2_y/0._plflt, 0._plflt, 0.2_plflt, 0._plflt, -0.2_plflt, 0._plflt/
! Process command-line arguments
call plparseopts(PL_PARSE_FULL)
call plinit
call circulation
fill = .false.
! Set arrow style using arrow_x and arrow_y the
! plot using these arrows
call plsvect(arrow_x, arrow_y, fill)
call constriction( 1 )
! Set arrow style using arrow_x and arrow_y the
! plot using these arrows
fill = .true.
call plsvect(arrow2_x, arrow2_y, fill)
call constriction( 2 )
call constriction2
call plsvect
call potential
call plend
end
! vector plot of the circulation around the origin
subroutine circulation()
use plplot
implicit none
integer i, j, nx, ny
parameter (nx=20, ny=20)
real(kind=plflt) u(nx, ny), v(nx, ny), xg(nx,ny), yg(nx,ny)
real(kind=plflt) dx, dy, xmin, xmax, ymin, ymax
real(kind=plflt) xx, yy, scaling
dx = 1.0_plflt
dy = 1.0_plflt
xmin = -dble(nx)/2.0_plflt*dx
xmax = dble(nx)/2.0_plflt*dx
ymin = -dble(ny)/2.0_plflt*dy
ymax = dble(ny)/2.0_plflt*dy
do i=1,nx
xx = (dble(i)-nx/2.0_plflt-0.5_plflt)*dx
do j=1,ny
yy = (dble(j)-ny/2.0_plflt-0.5_plflt)*dy
xg(i,j) = xx
yg(i,j) = yy
u(i,j) = yy
v(i,j) = -xx
enddo
enddo
call plenv(xmin, xmax, ymin, ymax, 0, 0)
call pllab('(x)', '(y)', &
'#frPLplot Example 22 - circulation')
call plcol0(2)
scaling = 0.0_plflt
call plvect(u,v,scaling,xg,yg)
call plcol0(1)
end
! vector plot of the flow through a constricted pipe
subroutine constriction( astyle )
use plplot, PI => PL_PI
implicit none
integer i, j, nx, ny, astyle
parameter (nx=20, ny=20)
character(len=80) :: title
real(kind=plflt) u(nx, ny), v(nx, ny), xg(nx,ny), yg(nx,ny)
real(kind=plflt) dx, dy, xmin, xmax, ymin, ymax
real(kind=plflt) xx, yy, Q, b, dbdx, scaling
dx = 1.0_plflt
dy = 1.0_plflt
xmin = -dble(nx)/2.0_plflt*dx
xmax = dble(nx)/2.0_plflt*dx
ymin = -dble(ny)/2.0_plflt*dy
ymax = dble(ny)/2.0_plflt*dy
Q = 2.0_plflt
do i=1,nx
xx = (dble(i)-dble(nx)/2.0_plflt-0.5_plflt)*dx
do j=1,ny
yy = (dble(j)-dble(ny)/2.0_plflt-0.5_plflt)*dy
xg(i,j) = xx
yg(i,j) = yy
b = ymax/4.0_plflt*(3.0_plflt-cos(PI*xx/xmax))
if (abs(yy).lt.b) then
dbdx = ymax/4.0_plflt*sin(PI*xx/xmax)*PI/xmax*yy/b
u(i,j) = Q*ymax/b
v(i,j) = u(i,j)*dbdx
else
u(i,j) = 0.0_plflt
v(i,j) = 0.0_plflt
endif
enddo
enddo
call plenv(xmin, xmax, ymin, ymax, 0, 0)
write(title,'(A,I0,A)') '#frPLplot Example 22 - constriction (arrow style ', astyle,')'
call pllab('(x)', '(y)', title)
call plcol0(2)
scaling = -1.0_plflt
call plvect(u,v,scaling,xg,yg)
call plcol0(1)
end
! Global transform function for a constriction using data passed in
! This is the same transformation used in constriction.
subroutine transform( x, y, xt, yt )
use plplot, PI => PL_PI
implicit none
real(kind=plflt) x, y, xt, yt
real(kind=plflt) xmax
common /transform_data/ xmax
xt = x
yt = y / 4.0_plflt * ( 3.0_plflt - cos( PI * x / xmax ) )
end subroutine transform
! Vector plot of flow through a constricted pipe
! with a coordinate transform
subroutine constriction2()
use plplot, PI => PL_PI
implicit none
integer i, j, nx, ny, nc, nseg
parameter (nx=20, ny=20, nc=11, nseg=20)
real(kind=plflt) dx, dy, xx, yy
real(kind=plflt) xmin, xmax, ymin, ymax
real(kind=plflt) Q, b, scaling
real(kind=plflt) u(nx, ny), v(nx, ny), xg(nx,ny), yg(nx,ny)
real(kind=plflt) clev(nc);
common /transform_data/ ymax
character(len=1) defined
external transform
dx = 1.0_plflt
dy = 1.0_plflt
xmin = -dble(nx)/2.0_plflt*dx
xmax = dble(nx)/2.0_plflt*dx
ymin = -dble(ny)/2.0_plflt*dy
ymax = dble(ny)/2.0_plflt*dy
call plstransform( transform )
Q = 2.0_plflt
do i=1,nx
xx = (dble(i)-dble(nx)/2.0_plflt-0.5_plflt)*dx
do j=1,ny
yy = (dble(j)-dble(ny)/2.0_plflt-0.5_plflt)*dy
xg(i,j) = xx
yg(i,j) = yy
b = ymax/4.0_plflt*(3.0_plflt-cos(PI*xx/xmax))
u(i,j) = Q*ymax/b
v(i,j) = 0.0_plflt
enddo
enddo
do i=1,nc
clev(i) = Q + dble(i-1) * Q / ( dble(nc) - 1.0_plflt )
enddo
call plenv(xmin, xmax, ymin, ymax, 0, 0)
call pllab('(x)', '(y)', &
'#frPLplot Example 22 - constriction with plstransform')
call plcol0(2)
call plshades(u, defined, xmin + dx / 2.0_plflt, &
xmax - dx / 2.0_plflt, &
ymin + dy / 2.0_plflt, ymax - dy / 2.0_plflt, &
clev, 0.0_plflt, 1, 1.0_plflt, .false. )
scaling = -1.0_plflt
call plvect(u,v,scaling,xg,yg)
call plpath(nseg, xmin, ymax, xmax, ymax)
call plpath(nseg, xmin, ymin, xmax, ymin)
call plcol0(1)
call plstransform
end subroutine constriction2
subroutine potential()
use plplot, PI => PL_PI
implicit none
integer i, j, nr, ntheta, nper, nlevel
parameter (nr=20, ntheta=20, nper=100, nlevel=10)
real(kind=plflt) u(nr, ntheta), v(nr, ntheta), z(nr, ntheta)
real(kind=plflt) xg(nr,ntheta), yg(nr,ntheta)
real(kind=plflt) clevel(nlevel), px(nper), py(nper)
real(kind=plflt) xmin, xmax, ymin, ymax, zmin, zmax, rmax
real(kind=plflt) xx, yy, r, theta, scaling, dz
real(kind=plflt) eps, q1, d1, q1i, d1i, q2, d2, q2i, d2i
real(kind=plflt) div1, div1i, div2, div2i
rmax = dble(nr)
eps = 2.0_plflt
q1 = 1.0_plflt
d1 = rmax/4.0_plflt
q1i = - q1*rmax/d1
d1i = rmax**2.0_plflt/d1
q2 = -1.0_plflt
d2 = rmax/4.0_plflt
q2i = - q2*rmax/d2
d2i = rmax**2.0_plflt/d2
do i = 1, nr
r = 0.5 + dble(i-1)
do j = 1, ntheta
theta = 2.*PI/dble(ntheta-1)*(dble(j)-0.5)
xx = r*cos(theta)
yy = r*sin(theta)
xg(i,j) = xx
yg(i,j) = yy
div1 = sqrt((xg(i,j)-d1)**2 + (yg(i,j)-d1)**2 + eps**2)
div1i = sqrt((xg(i,j)-d1i)**2 + (yg(i,j)-d1i)**2 + eps**2)
div2 = sqrt((xg(i,j)-d2)**2 + (yg(i,j)+d2)**2 + eps**2)
div2i = sqrt((xg(i,j)-d2i)**2 + (yg(i,j)+d2i)**2 + eps**2)
z(i,j) = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i
u(i,j) = -q1*(xx-d1)/div1**3 - q1i*(xx-d1i)/div1i**3 - &
q2*(xx-d2)/div2**3 - q2i*(xx-d2i)/div2i**3
v(i,j) = -q1*(yy-d1)/div1**3 - q1i*(yy-d1i)/div1i**3 - &
q2*(yy+d2)/div2**3 - q2i*(yy+d2i)/div2i**3
enddo
enddo
call a2mnmx(xg, nr, ntheta, xmin, xmax, nr)
call a2mnmx(yg, nr, ntheta, ymin, ymax, nr)
call a2mnmx(z, nr, ntheta, zmin, zmax, nr)
call plenv(xmin, xmax, ymin, ymax, 0, 0)
call pllab('(x)', '(y)', &
'#frPLplot Example 22 - potential gradient vector plot')
! plot contours of the potential
dz = abs(zmax - zmin)/dble (nlevel)
do i = 1, nlevel
clevel(i) = zmin + (i-0.5_plflt)*dz
enddo
call plcol0(3)
call pllsty(2)
call plcont(z,1,nr,1,ntheta,clevel,xg,yg)
call pllsty(1)
call plcol0(1)
call plcol0(2)
scaling = 25.0_plflt
call plvect(u,v,scaling,xg,yg)
call plcol0(1)
do i=1,nper
theta = 2.0_plflt*PI/dble(nper-1)*dble(i)
px(i) = rmax*cos(theta)
py(i) = rmax*sin(theta)
enddo
call plline(px,py)
end
!----------------------------------------------------------------------------
! Subroutine a2mnmx
! Minimum and the maximum elements of a 2-d array.
subroutine a2mnmx(f, nx, ny, fmin, fmax, xdim)
use plplot
implicit none
integer i, j, nx, ny, xdim
real(kind=plflt) f(xdim, ny), fmin, fmax
fmax = f(1, 1)
fmin = fmax
do j = 1, ny
do i = 1, nx
fmax = max(fmax, f(i, j))
fmin = min(fmin, f(i, j))
enddo
enddo
end
|