PG2PLplot
Aid in the conversion from PGPlot to PLplot in Fortran programs
All Namespaces Files Functions Variables Pages
pg2plplot.f90
Go to the documentation of this file.
1 !> \file pg2plplot.f90 Contains pgplot-to-plplot bindings (i.e., call PLplot from PGplot commands)
2 
3 !
4 ! LICENCE:
5 !
6 ! Copyright 2010-2017 AstroFloyd, joequant
7 !
8 ! This file is part of the PG2PLplot package.
9 !
10 ! This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published
11 ! by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
12 !
13 ! This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 !
16 ! You should have received a copy of the GNU General Public License along with this code (LICENCE). If not, see
17 ! <http://www.gnu.org/licenses/>.
18 !
19 !
20 ! PG2PLplot can be found on http://pg2plplot.sourceforge.net
21 ! Some routines are taken from libSUFR, http://libsufr.sourceforge.net
22 
23 
24 
25 !***********************************************************************************************************************************
26 !> \brief PG2PLplot module
27 
28 module pg2plplot
29  use plplot, only: plflt
30  implicit none
31  private plflt
32  save
33 
34  !> Conversion factor for the character height
35  real(plflt), parameter :: ch_fac = 0.35_plflt
36  !logical, parameter :: compatibility_warnings = .false. ! Don't warn
37  logical, parameter :: compatibility_warnings = .true. ! Do warn
38 
39  real(plflt) :: xcur=0., ycur=0.
40  integer :: save_level = 0
41  integer, parameter :: max_level = 20
42  integer, parameter :: max_open = 100
43  real(plflt), parameter :: mm_per_inch = 25.4
44  integer :: save_ffamily(max_level)
45  integer :: save_fstyle(max_level)
46  integer :: save_fweight(max_level)
47  integer :: save_lwidth(max_level)
48  integer :: save_lstyle(max_level)
49  integer :: save_color(max_level)
50  integer :: cur_lwidth=1, cur_color=1, cur_lstyle=1
51  integer :: devid=0
52  logical :: is_init
53  real(plflt) :: paper_width, paper_ratio
54 
55 contains
56 
57  !*********************************************************************************************************************************
58  subroutine do_init()
59  use plplot, only: plbop, plinit
60  implicit none
61  if(.not. is_init) then
62  call plinit()
63  call plbop()
64  is_init = .true.
65  end if
66  end subroutine do_init
67  !*********************************************************************************************************************************
68 
69 end module pg2plplot
70 !***********************************************************************************************************************************
71 
72 
73 
74 !***********************************************************************************************************************************
75 !> \brief Set line style
76 !!
77 !! \param ls Line style
78 
79 subroutine pgsls(ls)
80  use plplot, only: pllsty
81  use pg2plplot, only : cur_lstyle
82  implicit none
83  integer, intent(in) :: ls
84  integer :: ls1,ls2, styles(5)
85 
86  cur_lstyle = ls
87  styles = (/1,4,5,2,6/)
88 
89  ls1 = ls ! 1: solid, 2: dashes, 3: dash-dotted, 4: dotted, 5: dash-dot-dot-dot
90  if(ls1.lt.1.or.ls1.gt.5) ls1 = 1
91 
92 
93  ls2 = styles(ls1) ! 1: solid, 2: short dashes, 3: long dashes, 4: long dashes, short gaps, 5: long-short dashes,
94  ! 6: long-short dashes, long-short gaps, 7: ?, 8: ?
95 
96  call pllsty(ls2)
97 
98  !print*,'pgsls: ',ls,ls1,ls2
99 
100 end subroutine pgsls
101 !***********************************************************************************************************************************
102 
103 !***********************************************************************************************************************************
104 !> \brief Query line style
105 !!
106 !! \param ls Line style
107 
108 subroutine pgqls(ls)
109  use pg2plplot, only : cur_lstyle
110  implicit none
111  integer, intent(out) :: ls
112  ls = cur_lstyle
113 end subroutine pgqls
114 !***********************************************************************************************************************************
115 
116 !***********************************************************************************************************************************
117 !> \brief Set line width
118 !!
119 !! \param lw Line width
120 
121 subroutine pgslw(lw)
122  use plplot, only: plflt, plwidth
123  use pg2plplot, only : cur_lwidth
124  implicit none
125  integer, intent(in) :: lw
126  integer :: lw1
127  real(kind=plflt) :: lw2
128 
129  cur_lwidth = lw
130  lw1 = max(min(lw,201),1)
131  lw2 = real(lw1 - 1)
132 
133  call plwidth(lw2)
134 
135  !print*,'pgslw: ',lw,lw1,lw2
136 
137 end subroutine pgslw
138 !***********************************************************************************************************************************
139 
140 !***********************************************************************************************************************************
141 !> \brief Query line width
142 !!
143 !! \param lw Line width
144 
145 subroutine pgqlw(lw)
147  implicit none
148  integer, intent(out) :: lw
149 
150  lw = max(1,cur_lwidth)
151 
152 end subroutine pgqlw
153 !***********************************************************************************************************************************
154 
155 !***********************************************************************************************************************************
156 !> \brief Set character font
157 !!
158 !! \param cf Character font
159 
160 subroutine pgscf(cf)
161  use plplot, only: plfont
162  implicit none
163  integer, intent(in) :: cf
164 
165  call plfont(cf)
166 
167 end subroutine pgscf
168 !***********************************************************************************************************************************
169 
170 !***********************************************************************************************************************************
171 !> \brief Query character font
172 !!
173 !! \retval cf Character font
174 
175 subroutine pgqcf(cf)
176  use plplot, only: plgfont
177  implicit none
178  integer, intent(out) :: cf
179  integer :: family, style, weight
180 
181  call plgfont(family, style, weight)
182  if(style .eq. 1) then
183  cf = 3
184  return
185  else if(family .eq. 1) then
186  cf = 2
187  return
188  else if(family .eq. 3) then
189  cf = 4
190  return
191  end if
192  cf = 1
193 end subroutine pgqcf
194 !***********************************************************************************************************************************
195 
196 !***********************************************************************************************************************************
197 !> \brief Inquire PGPLOT general information - dummy routine
198 !!
199 !! \param item
200 !! \retval value
201 !! \retval length
202 
203 subroutine pgqinf(item, value, length)
204  implicit none
205  character, intent(in) :: item*(*)
206  character, intent(out) :: value*(*)
207  integer, intent(out) :: length
208  value = item(1:1)
209  value = 'Dummy'
210  length = 5
211 end subroutine pgqinf
212 !***********************************************************************************************************************************
213 
214 !***********************************************************************************************************************************
215 !> \brief Set colour index
216 !!
217 !! \param ci1 Colour index
218 
219 subroutine pgsci(ci1)
220  use pg2plplot, only: cur_color
221  use plplot, only: plcol0
222  implicit none
223  integer, intent(in) :: ci1
224  integer :: ci2,colours(0:15)
225  cur_color = ci1
226  ci2 = 15 ! White
227  ci2 = ci1
228  colours = (/0,15,1,3,9,7,13,2,8,12,4,11,10,5,7,7/)
229  if(ci1.ge.0.and.ci1.le.15) ci2 = colours(ci1)
230 
231  call plcol0(ci2)
232 
233  !write(6,'(A,2I6)')' pgsci: ',ci1,ci2
234 
235 end subroutine pgsci
236 !***********************************************************************************************************************************
237 
238 !***********************************************************************************************************************************
239 !> \brief Set colour representation
240 !!
241 !! \param ci1 Colour index
242 !! \param r Red colour (0-1)
243 !! \param g Green colour (0-1)
244 !! \param b Blue colour (0-1)
245 
246 subroutine pgscr(ci1, r,g,b)
247  use plplot, only: plscol0, plscmap0n
248  implicit none
249  integer, intent(in) :: ci1
250  real, intent(in) :: r,g,b
251  integer :: ci2,ri,gi,bi,colours(0:15)
252 
253  ri = nint(r*255)
254  gi = nint(g*255)
255  bi = nint(b*255)
256 
257  colours = (/0,15,1,3,9,7,13,2,8,12,4,11,10,5,7,7/)
258  ci2 = ci1
259  if(ci1.ge.0.and.ci1.le.15) ci2 = colours(ci1)
260  if(ci2.gt.15) call plscmap0n(256) ! Allows indices 0-255
261 
262  call plscol0(ci2, ri,gi,bi)
263 
264  !write(6,'(A,2I6, 5x,3F10.3, 5x,3I6)')' pgscr: ',ci1,ci2, r,g,b, ri,gi,bi
265 
266 end subroutine pgscr
267 !***********************************************************************************************************************************
268 
269 !***********************************************************************************************************************************
270 !> \brief Query colour representation
271 !!
272 !! \param ci1 Colour index
273 !! \retval r Red colour (0-1)
274 !! \retval g Green colour (0-1)
275 !! \retval b Blue colour (0-1)
276 
277 subroutine pgqcr(ci1, r,g,b)
278  use plplot, only: plgcol0
279  implicit none
280  integer, intent(in) :: ci1
281  real, intent(out) :: r,g,b
282  integer :: ci2,ri,gi,bi,colours(0:15)
283 
284  ci2 = ci1
285  colours = (/0,15,1,3,9,7,13,2,8,12,4,11,10,5,7,7/)
286  if(ci1.ge.0.and.ci1.le.15) ci2 = colours(ci1)
287 
288  call plgcol0(ci2,ri,gi,bi)
289 
290  r = real(ri)/255.
291  g = real(gi)/255.
292  b = real(bi)/255.
293 
294  !write(6,'(A,2I6,5x,3I6,5x,3F10.3)')' pgqcr: ',ci1,ci2, ri,gi,bi, r,g,b
295 
296 end subroutine pgqcr
297 !***********************************************************************************************************************************
298 
299 !***********************************************************************************************************************************
300 !> \brief Set colour-index range for pggray and pgimag - dummy routine!
301 !!
302 !! \param ci1 Lower colour index
303 !! \param ci2 Upper colour index
304 
305 subroutine pgscir(ci1,ci2)
307  implicit none
308  integer, intent(in) :: ci1,ci2
309  integer :: tmp
310  integer, save :: warn
311 
312  tmp = ci1
313  tmp = ci2
314  tmp = tmp ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
315 
316  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
317  if(warn.ne.123) call warn_dummy_routine('pgscir', '')
318  warn = 123
319 
320 end subroutine pgscir
321 !***********************************************************************************************************************************
322 
323 
324 !***********************************************************************************************************************************
325 !> \brief Query colour-index range for pggray and pgimag - dummy routine!
326 !!
327 !! \param ci1 Lower colour index
328 !! \param ci2 Upper colour index
329 
330 subroutine pgqcir(ci1,ci2)
332  implicit none
333  integer, intent(out) :: ci1,ci2
334  integer, save :: warn
335 
336  ci1 = 0
337  ci2 = 255
338 
339  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
340  if(warn.ne.123) call warn_dummy_routine('pgqcir', '')
341  warn = 123
342 
343 end subroutine pgqcir
344 !***********************************************************************************************************************************
345 
346 
347 
348 !***********************************************************************************************************************************
349 !> \brief Set fill style
350 !!
351 !! \param fs Fill style (1-4, no match for 2: outline)
352 
353 subroutine pgsfs(fs)
354  use plplot, only: plpsty
355  implicit none
356  integer, intent(in) :: fs
357  integer :: fs1,fs2, styles(4)
358 
359  fs1 = fs
360  if(fs.lt.1.or.fs.gt.4) fs1 = 1
361 
362  ! fs1: 1: solid, 2: outline, 3-hatched, 4-cross-hatched
363  ! fs2: 0: solid, 1: H lines, 2: V lines, 3: hatches 45d up, 4: hatches 45d down, 5: hatches 30d up, 6: hatches 30d down
364  ! 7: upright cross-hatces, 8: 45d cross-hatces
365 
366  styles = (/0,0,3,8/)
367 
368  fs2 = styles(fs1)
369 
370  call plpsty(fs2)
371 
372  !print*,'pgsfs: ',fs1,fs2
373 
374 end subroutine pgsfs
375 !***********************************************************************************************************************************
376 
377 !***********************************************************************************************************************************
378 !> \brief Set hash style
379 !!
380 !! \param ang Angle of the lines (deg)
381 !! \param sep Spacing (in % of view-surface size): >0!
382 !! \param ph Phase of hatching. Use e.g. 0.0 and 0.5 for double hatching - dummy variable: not used
383 
384 subroutine pgshs(ang, sep, ph)
385  use plplot, only: plpat
386  implicit none
387  real, intent(in) :: ang, sep, ph
388  integer :: inc, del, tmp
389 
390  inc = nint(ang*10.) ! Tenths of a degree
391  del = nint(sep*1000) ! Spacing in micrometers(!)
392  tmp = nint(ph)
393  tmp = tmp ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
394 
395  call plpat([inc], [del])
396 
397 end subroutine pgshs
398 !***********************************************************************************************************************************
399 
400 
401 !***********************************************************************************************************************************
402 !> \brief Set character height
403 !!
404 !! \param ch Character height
405 
406 subroutine pgsch(ch)
407  use plplot, only: plflt, plschr
408  use pg2plplot, only: ch_fac
409 
410  implicit none
411  real, intent(in) :: ch
412  real(kind=plflt) :: ch1,ch2
413 
414  ch1 = 0.0_plflt ! 0: don't change
415  ch2 = ch * ch_fac
416 
417  call plschr(ch1,ch2)
418 
419  !print*
420  !print*,'pgsch1: ',ch,ch1,ch2
421  !call plgchr(ch1,ch2)
422  !print*,'pgsch2: ',ch,ch1,ch2
423 
424 end subroutine pgsch
425 !***********************************************************************************************************************************
426 
427 !***********************************************************************************************************************************
428 !> \brief Inquire character height in a variety of units
429 !!
430 !! \param unit 0: normalized device coordinates, 1: in, 2: mm, 3: pixels, 4: world coordinates
431 !! \retval xch The character height for text written with a vertical baseline
432 !! \retval ych The character height for text written with a horizontal baseline (the usual case)
433 
434 subroutine pgqcs(unit, xch, ych)
435  use plplot, only: plflt, plgpage, plgchr
436  use pg2plplot, only: mm_per_inch
437 
438  implicit none
439  integer, intent(in) :: unit
440  real, intent(out) :: xch, ych
441  real(kind=plflt) :: ch1,ch2
442  real(kind=plflt) :: xp, yp
443  integer :: xleng, yleng, xoff, yoff
444  call plgchr(ch1,ch2)
445  if(unit.eq.2) then
446  xch = real(ch2)
447  ych = real(ch2)
448  else if(unit .eq. 1) then
449  xch = real(ch2 / mm_per_inch)
450  ych = real(ch2 / mm_per_inch)
451  else if(unit .eq. 0) then
452  call plgpage(xp, yp, xleng, yleng, xoff, yoff)
453  xch = real(ch2 / yleng)
454  ych = real(ch2 / yleng)
455  else
456  print *, 'unknown unit in pgqcs', unit
457  end if
458 
459 end subroutine pgqcs
460 !***********************************************************************************************************************************
461 
462 !***********************************************************************************************************************************
463 !> \brief Query character height
464 !!
465 !! \param ch Character height
466 
467 subroutine pgqch(ch)
468  use plplot, only: plflt, plgchr
469  use pg2plplot, only: ch_fac
470 
471  implicit none
472  real, intent(out) :: ch
473  real(kind=plflt) :: ch1,ch2
474 
475  call plgchr(ch1,ch2)
476  ch = real(ch2/(ch1*ch_fac))
477 
478  !print*,'pgqch: ',ch,ch1,ch2
479 
480 end subroutine pgqch
481 !***********************************************************************************************************************************
482 
483 
484 !***********************************************************************************************************************************
485 !> \brief Set arrow head - dummy routine!
486 !!
487 !! \param fs Fill style
488 !! \param angle Arrow-point angle
489 !! \param barb Arrow back cut
490 
491 subroutine pgsah(fs, angle, barb)
493  implicit none
494  integer, intent(in) :: fs
495  real, intent(in) :: angle, barb
496  integer :: tmp
497  integer, save :: warn
498 
499  tmp = fs
500  tmp = nint(angle)
501  tmp = nint(barb)
502  tmp = tmp ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
503 
504  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
505  if(warn.ne.123) call warn_dummy_routine('pgsah', '')
506  warn = 123
507 
508 end subroutine pgsah
509 !***********************************************************************************************************************************
510 
511 
512 !***********************************************************************************************************************************
513 !> \brief Draw a line
514 !!
515 !! \param n Number of points
516 !! \param x1 X-values of points
517 !! \param y1 Y-values of points
518 
519 subroutine pgline(n,x1,y1)
520  use plplot, only: plflt, plline
521 
522  implicit none
523  integer, intent(in) :: n
524  real, intent(in) :: x1(n),y1(n)
525  real(kind=plflt) :: x2(n),y2(n)
526 
527  x2 = x1
528  y2 = y1
529 
530  call plline(x2,y2)
531 
532  !write(6,'(A,99ES16.9)')' pgline1: ',x1(1:min(n,9)),y1(1:min(n,9))
533  !write(6,'(A,99ES16.9)')' pgline2: ',x2(1:min(n,9)),y2(1:min(n,9))
534 
535 end subroutine pgline
536 !***********************************************************************************************************************************
537 
538 !***********************************************************************************************************************************
539 !> \brief Draw an arrow - only a line is drawn, arrows not supported in PLplot!
540 !!
541 !! \param x1 X-value of start point
542 !! \param y1 Y-value of start point
543 !! \param x2 X-value of end point
544 !! \param y2 Y-value of end point
545 
546 subroutine pgarro(x1,y1, x2,y2)
547  use plplot, only: plflt, plline, plpoin
548 
549  implicit none
550  real, intent(in) :: x1,x2, y1,y2
551  real(kind=plflt) :: x(2),y(2)
552 
553  x = (/x1,x2/)
554  y = (/y1,y2/)
555 
556  call plline(x,y)
557  call plpoin((/x(2)/),(/y(2)/),2)
558 
559  !print*,'pgarro: ',x1,x2,y1,y2,' ',x,y
560 
561 end subroutine pgarro
562 !***********************************************************************************************************************************
563 
564 
565 
566 !***********************************************************************************************************************************
567 !> \brief Draw points
568 !!
569 !! \param n Number of points
570 !! \param x1 X-values of points
571 !! \param y1 Y-values of points
572 !! \param s Plot symbol to use
573 
574 subroutine pgpoint(n,x1,y1,s)
575  use plplot, only: plflt, plpoin
576 
577  implicit none
578  integer, intent(in) :: n,s
579  real, intent(in) :: x1(n),y1(n)
580  real(kind=plflt) :: x2(n),y2(n)
581 
582  x2 = x1
583  y2 = y1
584 
585  call plpoin(x2,y2,s)
586  !call plsym(1,x2,y2,143) ! Produces Hershey -> many letters, etc
587 
588 end subroutine pgpoint
589 !***********************************************************************************************************************************
590 
591 !***********************************************************************************************************************************
592 !> \brief Draw a polygone
593 !!
594 !! \param n Number of points
595 !! \param x1 X-values of points
596 !! \param y1 Y-values of points
597 
598 subroutine pgpoly(n,x1,y1)
599  use plplot, only: plflt, plfill
600 
601  implicit none
602  integer, intent(in) :: n
603  real, intent(in) :: x1(n),y1(n)
604  real(kind=plflt) :: x2(n),y2(n)
605 
606  x2 = x1
607  y2 = y1
608 
609  call plfill(x2,y2)
610 
611  !print*,'pgpoly: ',n,x1(1),x1(n),y1(1),y1(n)
612 
613 end subroutine pgpoly
614 !***********************************************************************************************************************************
615 
616 !***********************************************************************************************************************************
617 !> \brief Draw a rectangle
618 !!
619 !! \param x1 Lower x value
620 !! \param x2 Upper x value
621 !! \param y1 Lower y value
622 !! \param y2 Upper y value
623 
624 subroutine pgrect(x1,x2,y1,y2)
625  use plplot, only: plflt, plfill
626 
627  implicit none
628  real, intent(in) :: x1,x2,y1,y2
629  real(kind=plflt) :: x(4),y(4)
630 
631  x = (/x1,x1,x2,x2/)
632  y = (/y1,y2,y2,y1/)
633 
634  call plfill(x,y)
635 
636 end subroutine pgrect
637 !***********************************************************************************************************************************
638 
639 
640 !***********************************************************************************************************************************
641 !> \brief Draw a circle
642 !!
643 !! \param xc X-value of centre
644 !! \param yc Y-value of centre
645 !! \param r Radius
646 
647 subroutine pgcirc(xc, yc, r)
648  use plplot, only: plflt, plfill
649 
650  implicit none
651  real, intent(in) :: xc, yc, r
652 
653  integer, parameter :: n=100
654  integer :: i
655  real(kind=plflt) :: x(n),y(n),twopi
656 
657  twopi = 8.*atan(1.)
658 
659  do i=1,n
660  x(i) = xc + r * cos(twopi/real(n-1))
661  y(i) = yc + r * sin(twopi/real(n-1))
662  end do
663 
664  call plfill(x,y)
665 
666 end subroutine pgcirc
667 !***********************************************************************************************************************************
668 
669 
670 
671 
672 !***********************************************************************************************************************************
673 !> \brief Make a contour plot
674 !!
675 !! \param arr Data array
676 !! \param nx Dimension 1 of data array
677 !! \param ny Dimension 2 of data array
678 !! \param ix1 Start index range in dimension 1 to use from data array
679 !! \param ix2 End index range in dimension 1 to use from data array
680 !! \param iy1 Start index range in dimension 2 to use from data array
681 !! \param iy2 End index range in dimension 2 to use from data array
682 !! \param c Array with heights to draw contours for
683 !! \param nc Dimension of c
684 !! \param tr Affine transformation elements
685 
686 subroutine pgcont(arr, nx,ny, ix1,ix2, iy1,iy2, c, nc, tr)
687  use plplot, only: plflt, plcont
688 
689  implicit none
690  integer, intent(in) :: nx,ny, ix1,ix2, iy1,iy2, nc
691  real, intent(in) :: arr(nx,ny), c(*), tr(6)
692  real(kind=plflt) :: arr1(nx,ny), clevel(nc), tr1(6)
693 
694  arr1 = arr
695  clevel = c(1:nc)
696  tr1 = tr
697 
698  call plcont(arr1, ix1,ix2, iy1,iy2, clevel, tr1)
699 
700 end subroutine pgcont
701 !***********************************************************************************************************************************
702 
703 
704 !***********************************************************************************************************************************
705 !> \brief Shade a region (between contours/heights) - dummy routine!
706 !!
707 !! \param arr Data array
708 !! \param nx Dimension 1 of data array
709 !! \param ny Dimension 2 of data array
710 !! \param ix1 Start index range in dimension 1 to use from data array
711 !! \param ix2 End index range in dimension 1 to use from data array
712 !! \param iy1 Start index range in dimension 2 to use from data array
713 !! \param iy2 End index range in dimension 2 to use from data array
714 !! \param c1 Lower limit in height/contour to fill
715 !! \param c2 Upper limit in height/contour to fill
716 !! \param tr Affine transformation elements
717 
718 subroutine pgconf(arr, nx,ny, ix1,ix2, iy1,iy2, c1, c2, tr)
720  implicit none
721  integer, intent(in) :: nx,ny, ix1,ix2, iy1,iy2
722  real, intent(in) :: arr(nx,ny), c1,c2, tr(6)
723  !real(kind=plflt) :: arr1(nx,ny), clevel(nc), tr1(6)
724  integer :: tmp
725  integer, save :: warn
726 
727  tmp = nint(arr(1,1))
728  tmp = nx
729  tmp = ny
730  tmp = ix1
731  tmp = ix2
732  tmp = iy1
733  tmp = iy2
734  tmp = nint(c1)
735  tmp = nint(c2)
736  tmp = nint(tr(1))
737  tmp = tmp ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
738 
739 
740  !arr1 = arr
741  !clevel = c(1:nc)
742  !tr1 = tr
743  !
744  !call plshade1(arr1, ix1,ix2, iy1,iy2, clevel, tr1)
745 
746  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
747  if(warn.ne.123) call warn_dummy_routine('pgconf', '')
748  warn = 123
749 
750 end subroutine pgconf
751 !***********************************************************************************************************************************
752 
753 
754 
755 
756 
757 
758 
759 
760 
761 
762 
763 
764 
765 !***********************************************************************************************************************************
766 !> \brief Print text with arbitrary angle and justification
767 !!
768 !! \param x1 X-coordinate of text
769 !! \param y1 Y-coordinate of text
770 !! \param ang Angle
771 !! \param just1 Justification
772 !! \param text Text to print
773 !!
774 !! \note Angle only correct for 0,90,180,270deg or square viewport
775 
776 subroutine pgptxt(x1,y1,ang,just1,text)
777  use plplot, only: plflt, plptex, plgvpw
778 
779  implicit none
780  real, intent(in) :: x1,y1,ang,just1
781  character, intent(in) :: text*(*)
782  real :: d2r
783  real(kind=plflt) :: x2,y2,just2,dx,dy,xmin,xmax,ymin,ymax
784  character :: text1*(len(text))
785 
786  d2r = atan(1.)/45.
787  call plgvpw(xmin,xmax,ymin,ymax)
788 
789  ! Convert angle -> dy/dx
790  dx = (xmax-xmin)*0.1
791 
792  if(abs(ang).lt.1.e-5) then ! ang ~ 0 deg
793  dy = 0.0
794  else if(abs(mod(ang-90.,180.)).lt.1.e-5) then ! ang = +/-90deg
795  dx = 0.0
796  dy = -1.0 ! ang = -90deg
797  if(abs(mod(ang-90.,360.)).lt.1.e-5) dy = 1. ! ang = +90deg
798  else
799  dx = 1.0
800  dy = dx*tan(ang*d2r) * (ymax-ymin)/(xmax-xmin)
801  if(ang.gt.90. .and. ang.lt.270. .or. ang.lt.-90. .and. ang.gt.-270.) then
802  dx = -dx
803  dy = -dy
804  end if
805  end if
806 
807  x2 = x1
808  y2 = y1
809  just2 = just1
810 
811  text1 = text
812  call pg2pltext(text1)
813 
814  call plptex(x2,y2,dx,dy,just2,trim(text1))
815 
816  !write(6,'(A,4F10.3,A)')' pgptxt: ',x1,y1,ang,just1,trim(text)
817  !write(6,'(A,5F10.3,A)')' pgptxt: ',x2,y2,dx,dy,just2,trim(text1)
818 
819 end subroutine pgptxt
820 !***********************************************************************************************************************************
821 
822 !***********************************************************************************************************************************
823 !> \brief Non-standard alias for pgptxt()
824 !!
825 !! \param x X-coordinate of text
826 !! \param y Y-coordinate of text
827 !! \param ang Angle
828 !! \param just Justification
829 !! \param text Text to print
830 !!
831 !! \note Angle only right for 0,90,180,270deg or square viewport
832 
833 subroutine pgptext(x,y,ang,just,text)
834  implicit none
835  real, intent(in) :: x,y,ang,just
836  character, intent(in) :: text*(*)
837 
838  call pgptxt(x,y,ang,just,text)
839 
840 end subroutine pgptext
841 !***********************************************************************************************************************************
842 
843 
844 !***********************************************************************************************************************************
845 !> \brief Print text with default angle and justification
846 !!
847 !! \param x1 X-coordinate of text
848 !! \param y1 Y-coordinate of text
849 !! \param text Text to print
850 
851 subroutine pgtext(x1,y1,text)
852  use plplot, only: plflt, plptex
853 
854  implicit none
855  real, intent(in) :: x1,y1
856  character, intent(in) :: text*(*)
857  real(kind=plflt) :: x2,y2,just,dx,dy
858  character :: text1*(len(text))
859 
860  ! Convert angle=0deg -> dy/dx
861  dx = 1.
862  dy = 0.
863  just = 0. !Left-adjusted
864 
865  x2 = x1
866  y2 = y1
867 
868  text1 = text
869  call pg2pltext(text1)
870  call plptex(x2,y2,dx,dy,just,text1)
871 
872 end subroutine pgtext
873 !***********************************************************************************************************************************
874 
875 
876 !***********************************************************************************************************************************
877 !> \brief Print text in the margin
878 !!
879 !! \param side Side to print text on ('L','R','T','B')
880 !! \param disp1 Distance from axis
881 !! \param pos1 Position along axis
882 !! \param just1 Justification
883 !! \param text Text to print
884 
885 subroutine pgmtxt(side, disp1, pos1, just1, text)
886  use plplot, only: plflt, plmtex
887 
888  implicit none
889  real, intent(in) :: disp1,pos1,just1
890  real(kind=plflt) :: disp2,pos2,just2
891  character, intent(in) :: side*(*)
892  character, intent(in) :: text*(*)
893  character :: text1*(len(text))
894 
895  disp2 = disp1
896  pos2 = pos1
897  just2 = just1
898 
899  !write(6,'(2A,2(3F10.3,5x),A)')' pgmtxt: ',trim(side),disp1,pos1,just1,disp2,pos2,just2,trim(text)
900 
901  text1 = text
902  call pg2pltext(text1)
903  call plmtex(side, disp2, pos2, just2, text1)
904 
905 end subroutine pgmtxt
906 !***********************************************************************************************************************************
907 
908 !***********************************************************************************************************************************
909 !> \brief Alias for pgmtxt()
910 !!
911 !! \param side Side to print text on ('L','R','T','B')
912 !! \param disp
913 !! \param pos Position
914 !! \param just Justification
915 !! \param text Text to print
916 
917 subroutine pgmtext(side, disp, pos, just, text)
918  implicit none
919  real, intent(in) :: disp,pos,just
920  character, intent(in) :: side*(*)
921  character, intent(in) :: text*(*)
922  character :: text1*(len(text))
923 
924  text1 = text
925  call pg2pltext(text1)
926  call pgmtxt(side, disp, pos, just, text1)
927 
928 end subroutine pgmtext
929 !***********************************************************************************************************************************
930 
931 
932 !***********************************************************************************************************************************
933 !> \brief Interface for pglab
934 !!
935 !! \param xlbl Label for the horizontal axis
936 !! \param ylbl Label for the vertical axis
937 !! \param toplbl Plot title
938 
939 subroutine pglab(xlbl, ylbl, toplbl)
940  implicit none
941  character, intent(in) :: xlbl*(*), ylbl*(*), toplbl*(*)
942  call pgbbuf
943  call pgmtxt('T', 2.0, 0.5, 0.5, toplbl)
944  call pgmtxt('B', 3.2, 0.5, 0.5, xlbl)
945  call pgmtxt('L', 2.2, 0.5, 0.5, ylbl)
946  call pgebuf
947 end subroutine pglab
948 !***********************************************************************************************************************************
949 
950 !***********************************************************************************************************************************
951 !> \brief Alias for pglab
952 !!
953 !! \param xlbl Label for the horizontal axis
954 !! \param ylbl Label for the vertical axis
955 !! \param toplbl Plot title
956 
957 subroutine pglabel(xlbl, ylbl, toplbl)
958  implicit none
959  character, intent(in) :: xlbl*(*), ylbl*(*), toplbl*(*)
960  call pglab(xlbl, ylbl, toplbl)
961 end subroutine pglabel
962 !***********************************************************************************************************************************
963 
964 !***********************************************************************************************************************************
965 !> \brief Start a new plot
966 !!
967 !! \param pgdev PGplot device
968 !!
969 !! This function creates a new stream for each xwin request, but uses the same stream (0) for each file stream request.
970 !! Xwin streams are treated differently, since we want bufferring for smooth animations whereas the other streams are non-buffered.
971 
972 function pgopen(pgdev)
973  use plplot, only: plspause, plsfnam, plsdev, plmkstrm, plsetopt, plssub, plfontld
974  use pg2plplot, only : is_init, devid
975  implicit none
976  integer :: pgopen
977  character, intent(in) :: pgdev*(*)
978 
979  integer :: cur_stream=0, check_error, status
980  character :: pldev*(99),filename*(99)
981 
982  filename = 'plot_temp.png'
983 
984  call pg2pldev(pgdev, pldev,filename) ! Extract pldev and filename from pgdev
985  call plmkstrm(cur_stream)
986  call plssub(1, 1)
987  call plsdev(trim(pldev))
988  if(trim(pldev).ne.'xwin') then
989  if(check_error(trim(filename)).ne. 0) then
990  pgopen = -1
991  return
992  end if
993  call plsfnam(trim(filename)) ! Set output file name
994  else
995  status = plsetopt("db", "")
996  end if
997 
998  !call plscolbg(255,255,255) ! Set background colour to white
999  call plfontld(1) ! Load extended character set(?)
1000  call plspause(.false.) ! Pause at plend()
1001 
1002  pgopen = cur_stream + 1
1003  devid = pgopen
1004  is_init = .false.
1005 end function pgopen
1006 !***********************************************************************************************************************************
1007 
1008 !***********************************************************************************************************************************
1009 !> \brief Inquire current device identifier
1010 !!
1011 !! \retval Device identifier
1012 
1013 subroutine pgqid(id)
1014  use pg2plplot, only : devid
1015  implicit none
1016  integer, intent(out) :: id
1017  id = devid
1018 end subroutine pgqid
1019 !***********************************************************************************************************************************
1020 
1021 
1022 !***********************************************************************************************************************************
1023 !> \brief Begin a new plot
1024 !!
1025 !! \param i Display ID
1026 !! \param pgdev PGplot device
1027 !! \param nx Number of frames in the x-direction
1028 !! \param ny Number of frames in the y-direction
1029 !!
1030 !! This is a bit simpler than pgopen(), since I don't need to create a new stream for each request.
1031 
1032 subroutine pgbegin(i,pgdev,nx,ny)
1033  use plplot, only: plspause, plsfnam, plsetopt, plssub, plsdev, plfontld
1034  use pg2plplot, only : is_init
1035  implicit none
1036  integer, intent(in) :: i,nx,ny
1037  character, intent(in) :: pgdev*(*)
1038  integer :: i1, check_error, status
1039  character :: pldev*(99),filename*(99)
1040 
1041  ! These are ignored by pgbegin. Can't be self, since calling arguments are likely constants
1042  i1 = i
1043  i1 = nx
1044  i1 = ny
1045  i1 = i1
1046 
1047  call pg2pldev(pgdev, pldev,filename) ! Extract pldev and filename from pgdev
1048 
1049  if(trim(pldev).ne.'xwin') then
1050  if(check_error(trim(filename)).ne.0) return
1051  call plsfnam(trim(filename)) ! Set output file name
1052  else
1053  status = plsetopt("db", "")
1054  end if
1055 
1056  call plfontld(1) ! Load extended character set(?)
1057  call plssub(1, 1)
1058  call plsdev(trim(pldev))
1059  is_init = .false.
1060  call plspause(.false.) ! Pause at plend()
1061 end subroutine pgbegin
1062 !***********************************************************************************************************************************
1063 
1064 !***********************************************************************************************************************************
1065 !> \brief Alias for pgbegin
1066 !!
1067 !! \param i Display ID
1068 !! \param pgdev PGplot device
1069 !! \param nx Number of frames in the x-direction
1070 !! \param ny Number of frames in the y-direction
1071 
1072 subroutine pgbeg(i, pgdev, nx, ny)
1073  implicit none
1074  integer, intent(in) :: i,nx,ny
1075  character, intent(in) :: pgdev*(*)
1076  call pgbegin(i, pgdev, nx, ny)
1077 end subroutine pgbeg
1078 !***********************************************************************************************************************************
1079 
1080 
1081 !***********************************************************************************************************************************
1082 !> \brief End a plot
1083 !!
1084 
1085 subroutine pgend()
1086  use plplot, only: plflush, plend1
1087  implicit none
1088 
1089  call plflush()
1090  call plend1()
1091 end subroutine pgend
1092 !***********************************************************************************************************************************
1093 
1094 
1095 !***********************************************************************************************************************************
1096 !> \brief Set paper size
1097 !!
1098 !! \param width Paper width
1099 !! \param ratio Paper aspect ratio
1100 
1101 subroutine pgpap(width,ratio)
1103  use plplot, only : plflt, plspage
1104  implicit none
1105  real, intent(in) :: width, ratio
1106  integer :: xlen,ylen,xoff,yoff
1107  real(kind=plflt) :: xp,yp
1108 
1109  xp = 300. ! DPI
1110  yp = 300.
1111  paper_width = width
1112  paper_ratio = ratio
1113 
1114  xlen = nint(paper_width*xp)
1115  ylen = nint(paper_width*xp*paper_ratio)
1116 
1117  xoff = 0 ! Offset
1118  yoff = 0
1119 
1120  call plspage(xp,yp,xlen,ylen,xoff,yoff) ! Must be called before plinit()!
1121  call do_init()
1122 
1123 end subroutine pgpap
1124 !***********************************************************************************************************************************
1125 
1126 
1127 !***********************************************************************************************************************************
1128 !> \brief Set view port
1129 !!
1130 !! \param xl1 Left side of the x-axis
1131 !! \param xr1 Right side of the x-axis
1132 !! \param yb1 Bottom side of the y-axis
1133 !! \param yt1 Top side of the y-axis
1134 
1135 subroutine pgsvp(xl1,xr1,yb1,yt1)
1136  use plplot, only: plflt, plvpor
1137 
1138  implicit none
1139  real, intent(in) :: xl1,xr1,yb1,yt1
1140  real(kind=plflt) :: xl2,xr2,yb2,yt2
1141 
1142  xl2 = xl1
1143  xr2 = xr1
1144  yb2 = yb1
1145  yt2 = yt1
1146  !write(6,'(A,2(4F10.3,5x))')' pgsvp: ',xl1,xr1,yb1,yt1,xl2,xr2,yb2,yt2
1147 
1148  call plvpor(xl2,xr2,yb2,yt2)
1149 
1150 end subroutine pgsvp
1151 !***********************************************************************************************************************************
1152 
1153 
1154 !***********************************************************************************************************************************
1155 !> \brief Set window
1156 !!
1157 !! \param xmin1 Left
1158 !! \param xmax1 Right
1159 !! \param ymin1 Top
1160 !! \param ymax1 Bottom
1161 
1162 subroutine pgswin(xmin1,xmax1,ymin1,ymax1)
1163  use plplot, only: plflt, plwind
1164 
1165  implicit none
1166  real, intent(in) :: xmin1,xmax1,ymin1,ymax1
1167  real(kind=plflt) :: xmin2,xmax2,ymin2,ymax2
1168 
1169  xmin2 = xmin1
1170  xmax2 = xmax1
1171  ymin2 = ymin1
1172  ymax2 = ymax1
1173  !write(6,'(A,2(4F10.3,5x))')' pgswin: ',xmin1,xmax1,ymin1,ymax1,xmin2,xmax2,ymin2,ymax2
1174 
1175  call plwind(xmin2,xmax2,ymin2,ymax2)
1176 
1177 end subroutine pgswin
1178 !***********************************************************************************************************************************
1179 
1180 !***********************************************************************************************************************************
1181 !> \brief alias for pgswin
1182 !!
1183 !! \param xmin1 Left
1184 !! \param xmax1 Right
1185 !! \param ymin1 Top
1186 !! \param ymax1 Bottom
1187 
1188 subroutine pgwindow(xmin1,xmax1,ymin1,ymax1)
1189  use plplot, only: plflt, plwind
1190 
1191  implicit none
1192  real, intent(in) :: xmin1,xmax1,ymin1,ymax1
1193  real(kind=plflt) :: xmin2,xmax2,ymin2,ymax2
1194 
1195  xmin2 = dble(xmin1)
1196  xmax2 = dble(xmax1)
1197  ymin2 = dble(ymin1)
1198  ymax2 = dble(ymax1)
1199  call plwind(xmin2,xmax2,ymin2,ymax2)
1200 
1201 end subroutine pgwindow
1202 !***********************************************************************************************************************************
1203 
1204 
1205 !***********************************************************************************************************************************
1206 !> \brief Subdivide view surface into panels
1207 !!
1208 !! \param nxsub Number of subticks on the x-axis
1209 !! \param nysub Number of subticks on the y-axis
1210 
1211 subroutine pgsubp(nxsub, nysub)
1212  use plplot, only: plssub
1213  implicit none
1214  integer, intent(in) :: nxsub,nysub
1215 
1216  call plssub(nxsub, nysub)
1217 
1218 end subroutine pgsubp
1219 !***********************************************************************************************************************************
1220 
1221 
1222 !***********************************************************************************************************************************
1223 !> \brief Advance to the next (sub-)page
1224 !!
1225 
1226 subroutine pgpage()
1227  use plplot, only: pladv
1228  use pg2plplot, only: do_init
1229  implicit none
1230 
1231  call pladv(0)
1232  call do_init()
1233 
1234 end subroutine pgpage
1235 !***********************************************************************************************************************************
1236 
1237 !***********************************************************************************************************************************
1238 !> Alias for pgpage
1239 subroutine pgadvance()
1240  call pgpage()
1241 end subroutine pgadvance
1242 !***********************************************************************************************************************************
1243 
1244 
1245 !***********************************************************************************************************************************
1246 !> \brief Start buffering output - dummy routine!
1247 !!
1248 
1249 subroutine pgbbuf()
1251  implicit none
1252  integer, save :: warn
1253 
1254  call do_init()
1255 
1256  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1257  if(warn.ne.123) call warn_dummy_routine('pgbbuf', '')
1258  warn = 123
1259 
1260 end subroutine pgbbuf
1261 !***********************************************************************************************************************************
1262 
1263 
1264 !***********************************************************************************************************************************
1265 !> \brief End buffering output - dummy routine!
1266 !!
1267 
1268 subroutine pgebuf()
1270  implicit none
1271  integer, save :: warn
1272 
1273  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1274  if(warn.ne.123) call warn_dummy_routine('pgebuf', '')
1275  warn = 123
1276 
1277 end subroutine pgebuf
1278 !***********************************************************************************************************************************
1279 
1280 
1281 
1282 
1283 !***********************************************************************************************************************************
1284 !> \brief Draw a box (+axes) around a plot
1285 !!
1286 !! \param xopt Options for the x-axis
1287 !! \param xtick1 Distance between ticks on the x-axis
1288 !! \param nxsub Number of subticks on the x-axis
1289 !! \param yopt Options for the y-axis
1290 !! \param ytick1 Distance between ticks on the y-axis
1291 !! \param nysub Number of subticks on the y-axis
1292 
1293 subroutine pgbox(xopt, xtick1, nxsub, yopt, ytick1, nysub)
1294  use plplot, only: plflt, plbox
1295 
1296  implicit none
1297  integer, intent(in) :: nxsub,nysub
1298  real, intent(in) :: xtick1,ytick1
1299  character, intent(in) :: xopt*(*),yopt*(*)
1300  real(kind=plflt) :: xtick2,ytick2
1301 
1302  xtick2 = xtick1
1303  ytick2 = ytick1
1304  !write(6,'(A,2(2F10.3,5x))')' pgbox: ',xtick1,ytick1,xtick2,ytick2
1305 
1306  call plbox(xopt, xtick2, nxsub, yopt, ytick2, nysub)
1307 
1308 end subroutine pgbox
1309 !***********************************************************************************************************************************
1310 
1311 
1312 
1313 !***********************************************************************************************************************************
1314 !> \brief Draw a single tick mark, optionally with label - no PLplot routine found, using an ad-hoc routine
1315 !!
1316 !! \param x1 world coordinates of one endpoint of the axis
1317 !! \param y1 world coordinates of one endpoint of the axis
1318 !! \param x2 world coordinates of the other endpoint of the axis
1319 !! \param y2 world coordinates of the other endpoint of the axis
1320 !!
1321 !! \param pos draw the tick mark at fraction pos (0<=pos<=1) along the line from (X1,Y1) to (X2,Y2)
1322 !! \param tikl length of tick mark drawn to the left or bottom of the axis - drawing ticks outside the box may not be supported
1323 !! \param tikr length of major tick marks drawn to the right or top of the axis - drawing outside the box may not be supported
1324 !!
1325 !! \param disp displacement of label text from the axis
1326 !! \param orient orientation of label text, in degrees
1327 !! \param lbl text of label (may be blank)
1328 
1329 subroutine pgtick(x1, y1, x2, y2, pos, tikl, tikr, disp, orient, lbl)
1330  use plplot, only: plflt, plmtex, pljoin, plgvpw
1331 
1332  implicit none
1333  real, intent(in) :: x1, y1, x2, y2, pos, tikl, tikr, disp, orient
1334  character, intent(in) :: lbl*(*)
1335 
1336  real :: x,y,dx,dy, dpx,dpy, reldiff
1337  real(plflt) :: p_xmin,p_xmax,p_ymin,p_ymax, plx1,plx2,ply1,ply2, tlen, disp1,pos1,just
1338  character :: lbl1*(len(lbl))
1339  logical :: seq,deq
1340 
1341  disp1 = disp
1342  x = orient ! Unused
1343  x = x ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
1344  lbl1 = lbl
1345 
1346  dx = x2 - x1
1347  dy = y2 - y1
1348  x = x1 + pos*dx
1349  y = y1 + pos*dy
1350 
1351  call plgvpw(p_xmin, p_xmax, p_ymin, p_ymax)
1352 
1353  dpx = real(abs(p_xmax-p_xmin))
1354  dpy = real(abs(p_ymax-p_ymin))
1355 
1356 
1357  tlen = 0.03 ! default size of a tickmark
1358  pos1 = pos
1359  just = 0.5
1360 
1361  if(reldiff(y1,y2) .le. epsilon(y1)*10 .or. (seq(y1,0.) .and. seq(y2,0.))) then ! Want horizontal axis
1362 
1363  plx1 = x
1364  plx2 = x
1365  ply1 = y
1366 
1367  ! Plot ticks below the axis:
1368  if(tikl.gt.tiny(tikl)) then
1369  ply2 = y - dpy * tikl * tlen
1370  call pljoin(plx1,ply1,plx2,ply2)
1371  end if
1372 
1373  ! Plot ticks above the axis:
1374  if(tikr.gt.tiny(tikr)) then
1375  ply2 = y + dpy * tikr * tlen
1376  call pljoin(plx1,ply1,plx2,ply2)
1377  end if
1378 
1379  ! Print labels:
1380  if(abs(reldiff(y,real(p_ymin))) .le. epsilon(y)*10 .or. (seq(y,0.) .and. deq(p_ymin,0.0_plflt))) then
1381  call plmtex('B', disp1, pos1, just, trim(lbl1)) ! Print label below the bottom axis
1382  else
1383  call plmtex('T', disp1, pos1, just, trim(lbl1)) ! Print label above the top axis
1384  end if
1385 
1386  else if(reldiff(x1,x2) .le. epsilon(x1)*10 .or. (seq(x1,0.) .and. seq(x2,0.))) then ! Want vertical axis
1387 
1388  ply1 = y
1389  ply2 = y
1390  plx1 = x
1391 
1392  ! Plot ticks to the left of the axis:
1393  if(tikl.gt.tiny(tikl)) then
1394  plx2 = x - dpx * tikl * tlen
1395  call pljoin(plx1,ply1, plx2,ply2)
1396  end if
1397 
1398  ! Plot ticks to the right of the axis:
1399  if(tikr.gt.tiny(tikr)) then
1400  plx2 = x + dpx * tikr * tlen
1401  call pljoin(plx1,ply1, plx2,ply2)
1402  end if
1403 
1404  ! Print labels:
1405  if(abs(reldiff(x,real(p_xmin))) .le. epsilon(x)*10 .or. (seq(x,0.) .and. deq(p_xmin,0.0_plflt))) then
1406  call plmtex('L', disp1, pos1, just, trim(lbl1)) ! Print label to the left of the left-hand axis
1407  else
1408  call plmtex('R', disp1, pos1, just, trim(lbl1)) ! Print label to the right of the right-hand axis
1409  end if
1410 
1411  else
1412  write(0, '(A)') "PG2PLplot, pgtick(): x1!=x2 and y1!=y2 - I don't know which axis you want to use..."
1413  print*,'x:',x1,x2,reldiff(x1,x2)
1414  print*,'y:',y1,y2,reldiff(y1,y2)
1415  end if
1416 
1417 end subroutine pgtick
1418 !***********************************************************************************************************************************
1419 
1420 
1421 
1422 !***********************************************************************************************************************************
1423 !> \brief Read data from screen - no PLplot equivalent (yet) - dummy routine!
1424 !!
1425 !! \param maxpt Maximum number of points that may be accepted
1426 !! \param npt Number of points entered (zero on first call)
1427 !! \param x Array of x-coordinates
1428 !! \param y Array of y-coordinates
1429 !! \param symbol Code number of symbol to use for markingentered points
1430 !!
1431 !! \todo No plplot routine found yet - using dummy
1432 
1433 subroutine pgolin(maxpt, npt, x, y, symbol)
1435 
1436  implicit none
1437  integer, intent(in) :: maxpt,symbol
1438  integer, intent(out) :: npt
1439  real, intent(out) :: x(maxpt),y(maxpt)
1440 
1441  integer :: symbol1
1442  integer, save :: warn
1443 
1444  npt = maxpt
1445  x = 0.d0
1446  y = 0.d0
1447  symbol1 = symbol
1448  symbol1 = symbol1 ! Avoid 'variable is set but not used' warnings from compiler for dummy variable
1449 
1450  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1451  if(warn.ne.123) call warn_dummy_routine('pgolin', '')
1452  warn = 123
1453 
1454 end subroutine pgolin
1455 !***********************************************************************************************************************************
1456 
1457 
1458 !***********************************************************************************************************************************
1459 !> \brief Erase screen
1460 !!
1461 
1462 subroutine pgeras()
1463  use plplot, only: plclear
1464  implicit none
1465  call plclear()
1466 end subroutine pgeras
1467 !***********************************************************************************************************************************
1468 
1469 
1470 
1471 !***********************************************************************************************************************************
1472 !> \brief Replace the PGPlot escape character '\' with the PLplot escape character '#'
1473 !!
1474 !! \param string Text string to convert
1475 
1476 subroutine pg2pltext(string)
1477  implicit none
1478  character, intent(inout) :: string*(*)
1479 
1480  !print*,trim(string)
1481 
1482  call replace_substring(string, '\', '#') ! Replace the PGPlot escape character \ with the PLplot escape character # '
1483  call replace_substring(string, '#(0248)', '#(2246)') ! \approx -> \sim
1484  call replace_substring(string, '#(062', '#(212') ! alpha - gamma
1485  call replace_substring(string, '#(063', '#(213') ! delta - nu
1486  call replace_substring(string, '#(064', '#(214') ! xi - psi
1487  call replace_substring(string, '#(0650', '#(2150') ! omega
1488  call replace_substring(string, '#(0685)', '#(2185)') ! (var)theta
1489 
1490  !print*,trim(string)
1491 
1492 end subroutine pg2pltext
1493 !***********************************************************************************************************************************
1494 
1495 !***********************************************************************************************************************************
1496 !> \brief Converts PGplot device ID to PLplot device ID + file name
1497 !!
1498 !! \param pgdev PGplot device ID (includes filename: 'file.name/dev')
1499 !! \retval pldev PLplot device ID ('dev')
1500 !! \retval filename PLplot file name ('file.name')
1501 !!
1502 !!
1503 !! \note Possible values for pldev:
1504 !! - xwin:
1505 !! - wxwidgets:
1506 !! - xcairo:
1507 !! - qtwidget:
1508 !!
1509 !! - png: no anti-aliasing in lines
1510 !! - wxpng: no extended characters
1511 !! - pngcairo:
1512 !! - pngqt:
1513 
1514 subroutine pg2pldev(pgdev, pldev,filename)
1515  implicit none
1516  character, intent(in) :: pgdev*(*)
1517  character, intent(out) :: pldev*(*), filename*(*)
1518  integer :: i
1519 
1520 
1521  i = index(pgdev, '/', back=.true.)
1522 
1523  filename = ' '
1524  if(i.ne.1) filename = pgdev(1:i-1)
1525 
1526  pldev = ' '
1527  pldev = pgdev(i+1:)
1528 
1529  ! Change PGPlot ps to PLplot ps:
1530  call replace_substring(pldev,'vcps','psc')
1531  call replace_substring(pldev,'cvps','psc')
1532  call replace_substring(pldev,'cps','psc')
1533  call replace_substring(pldev,'vps','ps')
1534 
1535  ! Change PGplot ppm output tot png:
1536  call replace_substring(pldev,'ppm','png')
1537  call replace_substring(filename,'ppm','png')
1538 
1539  ! Use pngqt rather than png:
1540  !call replace_substring(pldev,'png','pngqt')
1541 
1542  ! Use pngcairo rather than png, since I get segfaults if outputing to both X11 and png which pulls in pngqt (joequant):
1543  if(pldev .eq. 'png') pldev = 'pngcairo'
1544 
1545 end subroutine pg2pldev
1546 !***********************************************************************************************************************************
1547 
1548 
1549 !***********************************************************************************************************************************
1550 !> \brief Select output stream
1551 !!
1552 !! \param pgdev stream number
1553 
1554 subroutine pgslct(pgdev)
1555  use pg2plplot, only: do_init
1556  use plplot, only : plspause, plgdev, pleop, plsstrm
1557 
1558  implicit none
1559  integer, intent(in) :: pgdev
1560  character :: pldev*(99)
1561 
1562  call do_init()
1563  call plgdev(pldev)
1564  if(trim(pldev).eq.'xwin') call pleop()
1565  call plsstrm(pgdev-1)
1566 
1567 end subroutine pgslct
1568 !***********************************************************************************************************************************
1569 
1570 
1571 !***********************************************************************************************************************************
1572 !> \brief Save parameters
1573 !!
1574 
1575 subroutine pgsave()
1579  use pg2plplot, only: cur_lstyle, cur_lwidth
1580  use plplot, only : plgfont
1581  implicit none
1582 
1583  save_level = save_level + 1
1584  if(save_level.gt.max_level) then
1585  write(0,'(/,A,/)') '*** PG2PLplot WARNING: too many save calls in pgsave()'
1586  return
1587  end if
1588 
1589  call plgfont(save_ffamily(save_level), save_fstyle(save_level), save_fweight(save_level))
1590  save_lwidth(save_level) = cur_lwidth
1591  save_color(save_level) = cur_color
1592  save_lstyle(save_level) = cur_lstyle
1593 end subroutine pgsave
1594 !***********************************************************************************************************************************
1595 
1596 
1597 !***********************************************************************************************************************************
1598 !> \brief Unsave parameters
1599 !!
1600 
1601 subroutine pgunsa()
1605  use plplot, only : plsfont
1606  implicit none
1607 
1608  if(save_level.eq.0) then
1609  write(0,'(/,A,/)') '*** PG2PLplot WARNING: no save call in stack in pgunsa()'
1610  return
1611  end if
1612 
1613  if(save_level.gt.max_level) then
1614  write(0,'(/,A,/)') '*** PG2PLplot WARNING: unsave greater than stack in pgunsa()'
1615  save_level = save_level - 1
1616  return
1617  end if
1618 
1619  call plsfont(save_ffamily(save_level), save_fstyle(save_level), save_fweight(save_level))
1620  call pgslw(save_lwidth(save_level))
1621  call pgsci(save_color(save_level))
1622  call pgsls(save_lstyle(save_level))
1623  save_level = save_level - 1
1624 
1625 end subroutine pgunsa
1626 !***********************************************************************************************************************************
1627 
1628 
1629 !***********************************************************************************************************************************
1630 !> \brief Move pen to location - for use with pgdraw() only!
1631 !!
1632 !! \param x Horizontal location
1633 !! \param y Vertical location
1634 
1635 subroutine pgmove(x, y)
1636  use pg2plplot, only: xcur, ycur
1637  implicit none
1638  real, intent(in) :: x, y
1639 
1640  xcur = x
1641  ycur = y
1642 
1643 end subroutine pgmove
1644 !***********************************************************************************************************************************
1645 
1646 
1647 !***********************************************************************************************************************************
1648 !> \brief Draw line to location
1649 !!
1650 !! \param x Horizontal location
1651 !! \param y Vertical location
1652 
1653 subroutine pgdraw(x, y)
1654  use pg2plplot, only: xcur, ycur
1655  use plplot, only: pljoin, plflt
1656  implicit none
1657  real, intent(in) :: x, y
1658  real(plflt) :: x1, y1
1659 
1660  x1 = x
1661  y1 = y
1662 
1663  call pljoin(xcur, ycur, x1, y1)
1664  call pgmove(x, y)
1665 
1666 end subroutine pgdraw
1667 !***********************************************************************************************************************************
1668 
1669 
1670 !***********************************************************************************************************************************
1671 !> \brief Draw a point
1672 !!
1673 !! \param n Number of data points to draw
1674 !! \param x Horizontal locations
1675 !! \param y Vertical locations
1676 !! \param ncode Plot symbol
1677 
1678 subroutine pgpt(n, x, y, ncode)
1679  use plplot, only: plpoin, plflt, plsym
1680 
1681  implicit none
1682  integer, intent(in) :: n, ncode
1683  real(plflt), intent(in), dimension(n) :: x, y
1684 
1685  integer :: code
1686 
1687 
1688  if(ncode == -3) then
1689  code = 7
1690  else if(ncode == -4) then
1691  code = 6
1692  else if(ncode < 0) then
1693  code = 22
1694  else
1695  code = ncode
1696  end if
1697 
1698  call plsym(x, y, code)
1699 
1700 end subroutine pgpt
1701 !***********************************************************************************************************************************
1702 
1703 
1704 !***********************************************************************************************************************************
1705 !> \brief Draw a single point
1706 !!
1707 !! \param x Horizontal location
1708 !! \param y Vertical location
1709 !! \param ncode Plot symbol
1710 
1711 subroutine pgpt1(x, y, ncode)
1712  use plplot, only: plpoin, plflt
1713  implicit none
1714  integer, intent(in) :: ncode
1715  real(plflt), intent(in) :: x, y
1716  real(plflt), dimension(1) :: xin, yin
1717 
1718  xin(1) = x
1719  yin(1) = y
1720 
1721  call pgpt(1, xin, yin, ncode)
1722 
1723 end subroutine pgpt1
1724 !***********************************************************************************************************************************
1725 
1726 
1727 !***********************************************************************************************************************************
1728 !> \brief Close stream
1729 !!
1730 
1731 subroutine pgclos()
1732  use plplot, only: plend1
1733  implicit none
1734  call plend1()
1735 end subroutine pgclos
1736 !***********************************************************************************************************************************
1737 
1738 
1739 !***********************************************************************************************************************************
1740 !> \brief Get cursor location - dummy routine!
1741 !!
1742 !! \param mode Display mode (0-7)
1743 !! \param posn If POSN=1, PGBAND tries to place the cursor at (X,Y); if POSN=0, it leaves the cursor at its current position
1744 !! \param xref World x-coordinate of the anchor point
1745 !! \param yref World y-coordinate of the anchor point
1746 !! \param x World x-coordinate of the cursor
1747 !! \retval y World y-coordinate of the cursor
1748 !! \retval ch Character typed by the user
1749 
1750 subroutine pgband(mode, posn, xref, yref, x, y, ch)
1752 
1753  implicit none
1754  integer, intent(in) :: mode, posn
1755  real, intent(in) :: xref, yref
1756  real, intent(out) :: x, y
1757  character, intent(out) :: ch*(*)
1758 
1759  integer, save :: warn
1760  integer :: i1
1761  real :: r1
1762 
1763 
1764  i1 = mode
1765  i1 = posn
1766  i1 = i1 ! Remove 'unused variable error from g95'
1767 
1768  r1 = xref
1769  r1 = yref
1770  r1 = r1 ! Remove 'unused variable error from g95'
1771 
1772  x = 0.0
1773  y = 0.0
1774  ch = char(0)
1775 
1776  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1777  if(warn.ne.123) call warn_dummy_routine('pgband', '')
1778  warn = 123
1779 
1780 end subroutine pgband
1781 !***********************************************************************************************************************************
1782 
1783 
1784 !***********************************************************************************************************************************
1785 !> \brief Get colour range - dummy routine!
1786 !!
1787 !! \param c1 Lower colour index
1788 !! \param c2 Upper colour index
1789 
1790 subroutine pgqcol(c1, c2)
1792 
1793  implicit none
1794  integer, intent(out) :: c1, c2
1795  integer, save :: warn
1796 
1797 
1798  c1 = 0
1799  c2 = 255
1800 
1801  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1802  if(warn.ne.123) call warn_dummy_routine('pgqcir','using a default colour range')
1803  warn = 123
1804 
1805 end subroutine pgqcol
1806 !***********************************************************************************************************************************
1807 
1808 
1809 
1810 !***********************************************************************************************************************************
1811 !> \brief Get current colour index - dummy routine!
1812 !!
1813 !! \retval ci Colour index
1814 
1815 subroutine pgqci(ci)
1817 
1818  implicit none
1819  integer, intent(out) :: ci
1820  integer, save :: warn
1821 
1822  ci = 0
1823 
1824  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1825  if(warn.ne.123) call warn_dummy_routine('pgqcir','using a default colour index')
1826  warn = 123
1827 
1828 end subroutine pgqci
1829 !***********************************************************************************************************************************
1830 
1831 
1832 !***********************************************************************************************************************************
1833 !> \brief Get viewport size
1834 !!
1835 !! \param units specify the units of the output parameters:
1836 !! - 0 : normalized device coordinates
1837 !! - 1 : inches
1838 !! - 2 : millimeters
1839 !! - 3 : pixels
1840 !!
1841 !! \retval x1 Left
1842 !! \retval x2 Right
1843 !! \retval y1 Bottom
1844 !! \retval y2 Top
1845 
1846 subroutine pgqvp(units, x1, x2, y1, y2)
1847  use plplot, only: plflt, plgpage, plgvpd
1848  use pg2plplot, only : mm_per_inch
1849  implicit none
1850  integer, intent(in) :: units
1851  real, intent(out) :: x1, x2, y1, y2
1852  real(kind=plflt) :: x1d, x2d, y1d, y2d
1853  real(kind=plflt) :: xp, yp
1854  integer :: xleng, yleng, xoff, yoff
1855 
1856  call plgvpd(x1d, x2d, y1d, y2d)
1857  if(units .ne. 0) then
1858  call plgpage(xp, yp, xleng, yleng, xoff, yoff)
1859  x1 = real(x1d * xleng - xoff)
1860  x2 = real(x2d * xleng - xoff)
1861  y1 = real(y1d * yleng - yoff)
1862  y2 = real(y2d * yleng - yoff)
1863  if(units .eq. 3) then
1864  return
1865  else if(units .eq. 2) then
1866  x1 = x1 / real(xp * mm_per_inch)
1867  x2 = x2 / real(xp* mm_per_inch)
1868  y1 = y1 / real(yp * mm_per_inch)
1869  y2 = y2 / real(yp* mm_per_inch)
1870  return
1871  else if(units .eq. 1) then
1872  x1 = x1 / real(xp)
1873  x2 = x2 / real(xp)
1874  y1 = y1 / real(yp)
1875  y2 = y2 / real(yp)
1876  return
1877  end if
1878  else
1879  print *, "unknown units in pgqvp", units
1880  end if
1881  x1 = real(x1d)
1882  x2 = real(x2d)
1883  y1 = real(y1d)
1884  y2 = real(y2d)
1885 end subroutine pgqvp
1886 !***********************************************************************************************************************************
1887 
1888 
1889 !***********************************************************************************************************************************
1890 !> \brief get view surface
1891 subroutine pgqvsz(units, x1, x2, y1, y2)
1892  use plplot, only: plflt, plgpage
1893  use pg2plplot, only : mm_per_inch
1894  implicit none
1895  integer, intent(in) :: units
1896  real, intent(out) :: x1, x2, y1, y2
1897  real(kind=plflt) xp, yp
1898  integer :: xleng, yleng, xoff, yoff
1899 
1900  x1 = 0.0
1901  y1 = 0.0
1902 
1903  if(units .eq. 0) then
1904  x2 = 1.0
1905  y2 = 1.0
1906  return
1907  end if
1908 
1909  call plgpage(xp, yp, xleng, yleng, xoff, yoff)
1910  if(units .eq. 3) then
1911  x2 = real(xleng)
1912  y2 = real(yleng)
1913  else if(units .eq. 2) then
1914  x2 = real(xleng / xp* mm_per_inch)
1915  y2 = real(yleng / yp* mm_per_inch)
1916  else if(units .eq. 1) then
1917  x2 = x2 / real(xp)
1918  y2 = y2 / real(yp)
1919  return
1920  else
1921  print *, 'undefined units in pgqvsz'
1922  return
1923  end if
1924 end subroutine pgqvsz
1925 !***********************************************************************************************************************************
1926 
1927 
1928 !***********************************************************************************************************************************
1929 !> \brief Print user name and date in plot - dummy routine!
1930 !!
1931 
1932 subroutine pgiden()
1934 
1935  implicit none
1936  integer, save :: warn
1937 
1938  if(.not.compatibility_warnings) warn = 123 ! Don't warn about compatibility between PGPlot and PLplot
1939  if(warn.ne.123) call warn_dummy_routine('pgiden','ignoring')
1940  warn = 123
1941 
1942 end subroutine pgiden
1943 !***********************************************************************************************************************************
1944 
1945 
1946 
1947 !***********************************************************************************************************************************
1948 !> \brief get window size
1949 !!
1950 !! \retval x1 Left
1951 !! \retval x2 Right
1952 !! \retval y1 Bottom
1953 !! \retval y2 Top
1954 
1955 subroutine pgqwin(x1, x2, y1, y2)
1956  use plplot, only: plflt, plgspa
1957  implicit none
1958  real, intent(out) :: x1, x2, y1, y2
1959  real(kind=plflt) :: xmin, xmax, ymin, ymax
1960 
1961  call plgspa(xmin, xmax, ymin, ymax)
1962  x1 = real(xmin)
1963  x2 = real(xmax)
1964  y1 = real(ymin)
1965  y2 = real(ymax)
1966 
1967 end subroutine pgqwin
1968 !***********************************************************************************************************************************
1969 
1970 
1971 !***********************************************************************************************************************************
1972 !> \brief Flush - dummy routine
1973 !!
1974 
1975 subroutine pgupdt()
1976  return
1977 end subroutine pgupdt
1978 !***********************************************************************************************************************************
1979 
1980 
1981 !***********************************************************************************************************************************
1982 !> \brief Search and replace occurences of a substring in a string, taken from libSUFR
1983 !!
1984 !! \param string Original string to replace in
1985 !! \param str_in Search string
1986 !! \param str_out Replacement string
1987 
1988 subroutine replace_substring(string, str_in, str_out)
1989  implicit none
1990  character, intent(inout) :: string*(*)
1991  character, intent(in) :: str_in*(*),str_out*(*)
1992  integer :: is,l
1993 
1994  l = len_trim(str_in)
1995  is = huge(is)
1996  do
1997  is = index(string, str_in, back=.false.)
1998  if(is.le.0) exit
1999  string = string(1:is-1)//trim(str_out)//trim(string(is+l:))
2000  end do
2001 
2002 end subroutine replace_substring
2003 !***********************************************************************************************************************************
2004 
2005 !***********************************************************************************************************************************
2006 !> \brief Inquire fill-area style - dummy routine
2007 !!
2008 !! \retval fs The current fill-area style
2009 
2010 subroutine pgqfs(fs)
2011  implicit none
2012  integer, intent(out) :: fs
2013  fs = 1
2014 end subroutine pgqfs
2015 !***********************************************************************************************************************************
2016 
2017 !***********************************************************************************************************************************
2018 !> \brief Set text background color index - dummy routine
2019 !!
2020 !! \param b Background color index
2021 
2022 subroutine pgstbg(b)
2023  implicit none
2024  integer, intent(in) :: b
2025  integer :: bb
2026  bb = b ! Use the dummy variable to prevent compiler complaints
2027  bb = bb ! Use the local variable after setting it to prevent compiler complaints
2028 end subroutine pgstbg
2029 !***********************************************************************************************************************************
2030 
2031 !***********************************************************************************************************************************
2032 !> \brief Query text background color index - dummy routine
2033 !!
2034 !! \param b Background color index
2035 
2036 subroutine pgqtbg(b)
2037  implicit none
2038  integer, intent(out) :: b
2039  b = 0
2040 end subroutine pgqtbg
2041 !***********************************************************************************************************************************
2042 
2043 
2044 !***********************************************************************************************************************************
2045 !> \brief Control new page prompting - dummy routine
2046 !!
2047 !! \param prompt Set prompt state to ON for interactive devices
2048 
2049 subroutine pgask(prompt)
2050  implicit none
2051  logical, intent(in) :: prompt
2052  logical :: prompt1
2053  prompt1 = prompt ! Use the dummy variable to prevent compiler complaints
2054  prompt1 = prompt1 ! Use the local variable after setting it to prevent compiler complaints
2055 end subroutine pgask
2056 !***********************************************************************************************************************************
2057 
2058 !***********************************************************************************************************************************
2059 !> \brief Set window and viewport and draw labeled frame
2060 !!
2061 !! \param xmin Left
2062 !! \param xmax Right
2063 !! \param ymin Top (?)
2064 !! \param ymax Bottom (?)
2065 !! \param just JUST=1: scales of x and y axes are equal, otherwise independent
2066 !! \param axis Controls the plotting of axes, tick marks, etc
2067 
2068 subroutine pgenv(xmin, xmax, ymin, ymax, just, axis)
2069  use plplot, only: plflt, plenv
2070  implicit none
2071  real, intent(in) :: xmin, xmax, ymin, ymax
2072  integer, intent(in) :: just, axis
2073  real(kind=plflt) :: xminp, xmaxp, yminp, ymaxp
2074  xminp = xmin
2075  xmaxp = xmax
2076  yminp = ymin
2077  ymaxp = ymax
2078  call plenv(xminp, xmaxp, yminp, ymaxp, just, axis)
2079 end subroutine pgenv
2080 !***********************************************************************************************************************************
2081 
2082 !***********************************************************************************************************************************
2083 !> \brief Plot a histogram of binned data
2084 !!
2085 !! \param nbin Number of bins
2086 !! \param x Abscissae of the bins
2087 !! \param data Data values of bins
2088 !! \param center If .TRUE., the X values denote the center of the bin, else the lower edge
2089 
2090 subroutine pgbin(nbin, x, data, center)
2091  use plplot, only: plflt, plbin
2092  implicit none
2093  integer, intent(in) :: nbin
2094  real, intent(in) :: x(*), data(*)
2095  logical, intent(in) :: center
2096  real(kind=plflt) :: xp(nbin), datap(nbin)
2097  integer :: opt
2098  xp = x(1:nbin)
2099  datap = data(1:nbin)
2100  if(center) opt = 1
2101  call plbin(xp, datap, opt)
2102 end subroutine pgbin
2103 !***********************************************************************************************************************************
2104 
2105 !***********************************************************************************************************************************
2106 !> \brief Vertical error bar
2107 !!
2108 !! \param n Number of error bars to plot
2109 !! \param x World horizontal coordinates of the data
2110 !! \param ymax World vertical coordinates of top end of the error bars
2111 !! \param ymin World vertical coordinates of bottom end of the error bars
2112 !! \param t Length of terminals to be drawn at the ends of the error bar
2113 
2114 subroutine pgerry(n, x, ymax, ymin, t)
2115  use plplot, only: plflt, plerry
2116  implicit none
2117  integer, intent(in) :: n
2118  real, intent(in) :: x(*), ymin(*), ymax(*), t
2119  real(kind=plflt) :: xp(n), yminp(n), ymaxp(n)
2120 
2121  xp = x(1:n) + 0*t ! Use dummy variable t somewhere to prevent compiler complaints
2122  yminp = ymin(1:n)
2123  ymaxp = ymax(1:n)
2124  call plerry(xp, yminp, ymaxp)
2125 
2126 end subroutine pgerry
2127 !***********************************************************************************************************************************
2128 
2129 !***********************************************************************************************************************************
2130 !> \brief Set viewport (inches)
2131 !!
2132 !! \param xleft Horizontal coordinate of left-hand edge of viewport, in inches from left edge of view surface
2133 !! \param xright Horizontal coordinate of right-hand edge of viewport, in inches from left edge of view surface
2134 !! \param ybot Vertical coordinate of bottom edge of viewport, in inches from bottom of view surface
2135 !! \param ytop Vertical coordinate of top edge of viewport, in inches from bottom of view surface
2136 
2137 subroutine pgvsiz(xleft, xright, ybot, ytop)
2138  use plplot, only: plflt,plsvpa
2139  implicit none
2140  real, intent(in) :: xleft, xright, ybot, ytop
2141  real(kind=plflt) :: x1p, x2p, y1p, y2p
2142  x1p=xleft
2143  x2p=xright
2144  y1p=ybot
2145  y2p=ytop
2146  call plsvpa(x1p, x2p, y1p, y2p)
2147 end subroutine pgvsiz
2148 !***********************************************************************************************************************************
2149 
2150 !***********************************************************************************************************************************
2151 !> \brief Non-standard alias for PGVSIZ
2152 !!
2153 !! \param xleft Horizontal coordinate of left-hand edge of viewport, in inches from left edge of view surface
2154 !! \param xright Horizontal coordinate of right-hand edge of viewport, in inches from left edge of view surface
2155 !! \param ybot Vertical coordinate of bottom edge of viewport, in inches from bottom of view surface
2156 !! \param ytop Vertical coordinate of top edge of viewport, in inches from bottom of view surface
2157 
2158 subroutine pgvsize(xleft, xright, ybot, ytop)
2159  implicit none
2160  real, intent(in) :: xleft, xright, ybot, ytop
2161  call pgvsiz(xleft, xright, ybot, ytop)
2162 end subroutine pgvsize
2163 !***********************************************************************************************************************************
2164 
2165 !***********************************************************************************************************************************
2166 !> \brief Find length of a string in a variety of units - dummy variable
2167 !!
2168 !! \param units 0: normalized device coordinates, 1: in, 2: mm, 3: absolute device coordinates (dots), 4: world coordinates,
2169 !! 5: fraction of the current viewport size
2170 !! \param string String of interest
2171 !! \param xl Length of string in horizontal direction
2172 !! \param yl Length of string in vertical direction
2173 
2174 subroutine pglen(units, string, xl, yl)
2175  implicit none
2176  character, intent(in) :: string*(*)
2177  integer, intent(in) :: units
2178  real, intent(out) :: xl, yl
2179  character :: dummy
2180 
2181  print *, "pglen not implemented"
2182  dummy = string(1:1) ! Use the dummy variable string somewhere to prevent compiler complaints
2183  dummy = dummy ! Use the local variable after setting it to prevent compiler complaints
2184  xl = 1.0 + real(0*units) ! Use the dummy variable units somewhere to prevent compiler complaints
2185  yl = 1.0
2186 
2187 end subroutine pglen
2188 !***********************************************************************************************************************************
2189 
2190 !***********************************************************************************************************************************
2191 !> \brief Find bounding box of text string - dummy variable
2192 !!
2193 !! \param x World x-coordinate
2194 !! \param y World y-coordinate
2195 !! \param angle Angle between baseline and horizontal (degrees)
2196 !! \param fjust Horizontal justification
2197 !! \param text Text string that would be written
2198 !!
2199 !! \retval xbox Horizontal limits of the bounding box
2200 !! \retval ybox Vertical limits of the bounding box
2201 
2202 
2203 subroutine pgqtxt(x, y, angle, fjust, text, xbox, ybox)
2204  implicit none
2205  character, intent(in) :: text*(*)
2206  integer, intent(in) :: x, y, angle, fjust
2207  real, intent(out) :: xbox(4), ybox(4)
2208  integer :: dumInt
2209  character :: dumStr
2210 
2211  ! Use the dummy input variables somewhere to prevent compiler complaints:
2212  dumstr = text(1:1)
2213  dumint = x + y + angle + fjust
2214  ! Use the local variable after setting it to prevent compiler complaints:
2215  dumstr = dumstr
2216  dumint = dumint
2217 
2218  print *, "pgqtxt not implemented"
2219 
2220  xbox(1) = 0.0
2221  xbox(2) = 1.0
2222  xbox(3) = 0.0
2223  xbox(4) = 1.0
2224 
2225  ybox(1) = 0.0
2226  ybox(2) = 1.0
2227  ybox(3) = 0.0
2228  ybox(4) = 1.0
2229 
2230 end subroutine pgqtxt
2231 !***********************************************************************************************************************************
2232 
2233 
2234 
2235 
2236 !***********************************************************************************************************************************
2237 !> \brief Return the relative difference between two numbers: dx/<x> - taken from libSUFR, turned into single precision
2238 !!
2239 !! \param x1 First number
2240 !! \param x2 Second number
2241 
2242 function reldiff(x1,x2)
2243  implicit none
2244  real, intent(in) :: x1,x2
2245  real :: reldiff, xsum,xdiff
2246 
2247  xsum = x1+x2
2248  xdiff = x2-x1
2249 
2250  if(abs(xsum).gt.tiny(xsum)) then
2251  reldiff = xdiff / (xsum*0.5)
2252  else ! Can't divide by zero
2253  if(abs(xdiff).gt.tiny(xdiff)) then
2254  reldiff = xdiff
2255  else
2256  reldiff = 1.0 ! 0/0
2257  end if
2258  end if
2259 
2260 end function reldiff
2261 !***********************************************************************************************************************************
2262 
2263 
2264 !***********************************************************************************************************************************
2265 !> \brief Check whether opening a file gives an error
2266 !!
2267 !! \param fname File name
2268 
2269 function check_error(fname)
2270  implicit none
2271  character, intent(in) :: fname*(*)
2272  integer :: err, check_error
2273 
2274  open(9999, file=trim(fname), err=450, iostat=err)
2275  close(9999)
2276  check_error = 0
2277  return
2278 
2279 450 continue
2280  check_error = err
2281 
2282 end function check_error
2283 !***********************************************************************************************************************************
2284 
2285 
2286 !***********************************************************************************************************************************
2287 !> \brief Print a warning when no (proper) PLplot equivalent is defined and a dummy routine is used instead
2288 !!
2289 !! \param routine Name of the undefined routine
2290 !! \param message Message to be postponed
2291 
2292 subroutine warn_dummy_routine(routine, message)
2293  implicit none
2294  character, intent(in) :: routine*(*),message*(*)
2295 
2296  write(0,'(/,A)') '*** PG2PLplot WARNING: no PLplot equivalent was found for the PGplot routine '//trim(routine)//'() '// &
2297  trim(message)//' ***'
2298 
2299 end subroutine warn_dummy_routine
2300 !***********************************************************************************************************************************
2301 
2302 
2303 !***********************************************************************************************************************************
2304 !> \brief Test whether two double-precision variables are equal to better than twice the machine precision, taken from libSUFR
2305 !!
2306 !! \param x1 First number
2307 !! \param x2 Second number
2308 
2309 function deq(x1,x2)
2310  use plplot, only: plflt
2311 
2312  implicit none
2313  real(plflt), intent(in) :: x1,x2
2314  real(plflt) :: eps
2315  logical :: deq
2316 
2317  eps = 2*tiny(x1)
2318  if(abs(x1-x2).le.eps) then
2319  deq = .true.
2320  else
2321  deq = .false.
2322  end if
2323 
2324 end function deq
2325 !***********************************************************************************************************************************
2326 
2327 
2328 !***********************************************************************************************************************************
2329 !> \brief Test whether two single-precision variables are equal to better than twice the machine precision, taken from libSUFR
2330 !!
2331 !! \param x1 First number
2332 !! \param x2 Second number
2333 
2334 function seq(x1,x2)
2335  implicit none
2336  real, intent(in) :: x1,x2
2337  real :: eps
2338  logical :: seq
2339 
2340  eps = 2*tiny(x1)
2341  if(abs(x1-x2).le.eps) then
2342  seq = .true.
2343  else
2344  seq = .false.
2345  end if
2346 
2347 end function seq
2348 !***********************************************************************************************************************************
2349 
2350 
subroutine pgscf(cf)
Set character font.
Definition: pg2plplot.f90:161
logical, parameter compatibility_warnings
Definition: pg2plplot.f90:37
subroutine pgebuf()
End buffering output - dummy routine!
Definition: pg2plplot.f90:1269
subroutine pgqlw(lw)
Query line width.
Definition: pg2plplot.f90:146
subroutine pgqcir(ci1, ci2)
Query colour-index range for pggray and pgimag - dummy routine!
Definition: pg2plplot.f90:331
subroutine pgupdt()
Flush - dummy routine.
Definition: pg2plplot.f90:1976
subroutine pgsah(fs, angle, barb)
Set arrow head - dummy routine!
Definition: pg2plplot.f90:492
subroutine pgptxt(x1, y1, ang, just1, text)
Print text with arbitrary angle and justification.
Definition: pg2plplot.f90:777
subroutine pglen(units, string, xl, yl)
Find length of a string in a variety of units - dummy variable.
Definition: pg2plplot.f90:2175
integer function check_error(fname)
Check whether opening a file gives an error.
Definition: pg2plplot.f90:2270
integer cur_lstyle
Definition: pg2plplot.f90:50
subroutine pgsubp(nxsub, nysub)
Subdivide view surface into panels.
Definition: pg2plplot.f90:1212
subroutine pgband(mode, posn, xref, yref, x, y, ch)
Get cursor location - dummy routine!
Definition: pg2plplot.f90:1751
subroutine pg2pldev(pgdev, pldev, filename)
Converts PGplot device ID to PLplot device ID + file name.
Definition: pg2plplot.f90:1515
subroutine pgqtxt(x, y, angle, fjust, text, xbox, ybox)
Find bounding box of text string - dummy variable.
Definition: pg2plplot.f90:2204
subroutine pgolin(maxpt, npt, x, y, symbol)
Read data from screen - no PLplot equivalent (yet) - dummy routine!
Definition: pg2plplot.f90:1434
subroutine pgscir(ci1, ci2)
Set colour-index range for pggray and pgimag - dummy routine!
Definition: pg2plplot.f90:306
subroutine pgdraw(x, y)
Draw line to location.
Definition: pg2plplot.f90:1654
subroutine pgbbuf()
Start buffering output - dummy routine!
Definition: pg2plplot.f90:1250
integer, dimension(max_level) save_color
Definition: pg2plplot.f90:49
subroutine pgiden()
Print user name and date in plot - dummy routine!
Definition: pg2plplot.f90:1933
integer, dimension(max_level) save_ffamily
Definition: pg2plplot.f90:44
integer, parameter max_open
Definition: pg2plplot.f90:42
subroutine pgconf(arr, nx, ny, ix1, ix2, iy1, iy2, c1, c2, tr)
Shade a region (between contours/heights) - dummy routine!
Definition: pg2plplot.f90:719
subroutine pgsave()
Save parameters.
Definition: pg2plplot.f90:1576
subroutine pgptext(x, y, ang, just, text)
Non-standard alias for pgptxt()
Definition: pg2plplot.f90:834
subroutine pgqch(ch)
Query character height.
Definition: pg2plplot.f90:468
subroutine pgqtbg(b)
Query text background color index - dummy routine.
Definition: pg2plplot.f90:2037
integer, dimension(max_level) save_fweight
Definition: pg2plplot.f90:46
subroutine warn_dummy_routine(routine, message)
Print a warning when no (proper) PLplot equivalent is defined and a dummy routine is used instead...
Definition: pg2plplot.f90:2293
real(plflt) xcur
Definition: pg2plplot.f90:39
subroutine pgstbg(b)
Set text background color index - dummy routine.
Definition: pg2plplot.f90:2023
real(plflt) paper_ratio
Definition: pg2plplot.f90:53
logical function deq(x1, x2)
Test whether two double-precision variables are equal to better than twice the machine precision...
Definition: pg2plplot.f90:2310
subroutine pgbox(xopt, xtick1, nxsub, yopt, ytick1, nysub)
Draw a box (+axes) around a plot.
Definition: pg2plplot.f90:1294
subroutine pgqcr(ci1, r, g, b)
Query colour representation.
Definition: pg2plplot.f90:278
subroutine pgqwin(x1, x2, y1, y2)
get window size
Definition: pg2plplot.f90:1956
subroutine pgtick(x1, y1, x2, y2, pos, tikl, tikr, disp, orient, lbl)
Draw a single tick mark, optionally with label - no PLplot routine found, using an ad-hoc routine...
Definition: pg2plplot.f90:1330
subroutine pgline(n, x1, y1)
Draw a line.
Definition: pg2plplot.f90:520
subroutine pgvsize(xleft, xright, ybot, ytop)
Non-standard alias for PGVSIZ.
Definition: pg2plplot.f90:2159
subroutine pgclos()
Close stream.
Definition: pg2plplot.f90:1732
subroutine pglabel(xlbl, ylbl, toplbl)
Alias for pglab.
Definition: pg2plplot.f90:958
subroutine pgarro(x1, y1, x2, y2)
Draw an arrow - only a line is drawn, arrows not supported in PLplot!
Definition: pg2plplot.f90:547
real(plflt) ycur
Definition: pg2plplot.f90:39
subroutine pgadvance()
Alias for pgpage.
Definition: pg2plplot.f90:1240
subroutine pgenv(xmin, xmax, ymin, ymax, just, axis)
Set window and viewport and draw labeled frame.
Definition: pg2plplot.f90:2069
real(plflt), parameter mm_per_inch
Definition: pg2plplot.f90:43
subroutine pgunsa()
Unsave parameters.
Definition: pg2plplot.f90:1602
subroutine pgwindow(xmin1, xmax1, ymin1, ymax1)
alias for pgswin
Definition: pg2plplot.f90:1189
subroutine pgend()
End a plot.
Definition: pg2plplot.f90:1086
subroutine pgqvp(units, x1, x2, y1, y2)
Get viewport size.
Definition: pg2plplot.f90:1847
subroutine pgask(prompt)
Control new page prompting - dummy routine.
Definition: pg2plplot.f90:2050
logical is_init
Definition: pg2plplot.f90:52
subroutine pgqvsz(units, x1, x2, y1, y2)
get view surface
Definition: pg2plplot.f90:1892
subroutine pglab(xlbl, ylbl, toplbl)
Interface for pglab.
Definition: pg2plplot.f90:940
subroutine pgqls(ls)
Query line style.
Definition: pg2plplot.f90:109
subroutine pgmtxt(side, disp1, pos1, just1, text)
Print text in the margin.
Definition: pg2plplot.f90:886
subroutine pgsch(ch)
Set character height.
Definition: pg2plplot.f90:407
integer, parameter max_level
Definition: pg2plplot.f90:41
integer, dimension(max_level) save_lwidth
Definition: pg2plplot.f90:47
subroutine pgqci(ci)
Get current colour index - dummy routine!
Definition: pg2plplot.f90:1816
subroutine pgerry(n, x, ymax, ymin, t)
Vertical error bar.
Definition: pg2plplot.f90:2115
subroutine pgtext(x1, y1, text)
Print text with default angle and justification.
Definition: pg2plplot.f90:852
subroutine pgvsiz(xleft, xright, ybot, ytop)
Set viewport (inches)
Definition: pg2plplot.f90:2138
real function reldiff(x1, x2)
Return the relative difference between two numbers: dx/<x> - taken from libSUFR, turned into single p...
Definition: pg2plplot.f90:2243
subroutine pgqcol(c1, c2)
Get colour range - dummy routine!
Definition: pg2plplot.f90:1791
integer cur_color
Definition: pg2plplot.f90:50
subroutine pgswin(xmin1, xmax1, ymin1, ymax1)
Set window.
Definition: pg2plplot.f90:1163
real(plflt) paper_width
Definition: pg2plplot.f90:53
integer, dimension(max_level) save_fstyle
Definition: pg2plplot.f90:45
subroutine pgscr(ci1, r, g, b)
Set colour representation.
Definition: pg2plplot.f90:247
integer devid
Definition: pg2plplot.f90:51
subroutine pgcirc(xc, yc, r)
Draw a circle.
Definition: pg2plplot.f90:648
subroutine pgpage()
Advance to the next (sub-)page.
Definition: pg2plplot.f90:1227
subroutine pgrect(x1, x2, y1, y2)
Draw a rectangle.
Definition: pg2plplot.f90:625
integer cur_lwidth
Definition: pg2plplot.f90:50
subroutine pgsci(ci1)
Set colour index.
Definition: pg2plplot.f90:220
subroutine pgqcs(unit, xch, ych)
Inquire character height in a variety of units.
Definition: pg2plplot.f90:435
subroutine pgbeg(i, pgdev, nx, ny)
Alias for pgbegin.
Definition: pg2plplot.f90:1073
subroutine pgslct(pgdev)
Select output stream.
Definition: pg2plplot.f90:1555
subroutine pgcont(arr, nx, ny, ix1, ix2, iy1, iy2, c, nc, tr)
Make a contour plot.
Definition: pg2plplot.f90:687
subroutine pgqinf(item, value, length)
Inquire PGPLOT general information - dummy routine.
Definition: pg2plplot.f90:204
subroutine pgsvp(xl1, xr1, yb1, yt1)
Set view port.
Definition: pg2plplot.f90:1136
subroutine pgqid(id)
Inquire current device identifier.
Definition: pg2plplot.f90:1014
subroutine pgmove(x, y)
Move pen to location - for use with pgdraw() only!
Definition: pg2plplot.f90:1636
subroutine pgbegin(i, pgdev, nx, ny)
Begin a new plot.
Definition: pg2plplot.f90:1033
integer function pgopen(pgdev)
Start a new plot.
Definition: pg2plplot.f90:973
subroutine pgpoint(n, x1, y1, s)
Draw points.
Definition: pg2plplot.f90:575
subroutine pgpt1(x, y, ncode)
Draw a single point.
Definition: pg2plplot.f90:1712
subroutine pgbin(nbin, x, data, center)
Plot a histogram of binned data.
Definition: pg2plplot.f90:2091
PG2PLplot module.
Definition: pg2plplot.f90:28
integer, dimension(max_level) save_lstyle
Definition: pg2plplot.f90:48
subroutine pgqfs(fs)
Inquire fill-area style - dummy routine.
Definition: pg2plplot.f90:2011
subroutine pgpap(width, ratio)
Set paper size.
Definition: pg2plplot.f90:1102
subroutine pgmtext(side, disp, pos, just, text)
Alias for pgmtxt()
Definition: pg2plplot.f90:918
subroutine pgpoly(n, x1, y1)
Draw a polygone.
Definition: pg2plplot.f90:599
subroutine pg2pltext(string)
Replace the PGPlot escape character &#39;\&#39; with the PLplot escape character &#39;#&#39;.
Definition: pg2plplot.f90:1477
real(plflt), parameter ch_fac
Conversion factor for the character height.
Definition: pg2plplot.f90:35
subroutine pgsls(ls)
Set line style.
Definition: pg2plplot.f90:80
subroutine replace_substring(string, str_in, str_out)
Search and replace occurences of a substring in a string, taken from libSUFR.
Definition: pg2plplot.f90:1989
subroutine pgshs(ang, sep, ph)
Set hash style.
Definition: pg2plplot.f90:385
integer save_level
Definition: pg2plplot.f90:40
subroutine pgpt(n, x, y, ncode)
Draw a point.
Definition: pg2plplot.f90:1679
subroutine pgslw(lw)
Set line width.
Definition: pg2plplot.f90:122
logical function seq(x1, x2)
Test whether two single-precision variables are equal to better than twice the machine precision...
Definition: pg2plplot.f90:2335
subroutine pgeras()
Erase screen.
Definition: pg2plplot.f90:1463
subroutine pgsfs(fs)
Set fill style.
Definition: pg2plplot.f90:354
subroutine do_init()
Definition: pg2plplot.f90:59
subroutine pgqcf(cf)
Query character font.
Definition: pg2plplot.f90:176