-
Notifications
You must be signed in to change notification settings - Fork 0
/
Draw.f08
139 lines (115 loc) · 4.15 KB
/
Draw.f08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
MODULE Draw
IMPLICIT NONE
CONTAINS
FUNCTION DRAW_POINTS(m0, x, y)
IMPLICIT NONE
LOGICAL :: DRAW_POINTS
INTEGER, INTENT(IN) :: m0
REAL, DIMENSION(:), INTENT(IN) :: x, y
! How many data points we have
INTEGER :: n
! How many data points we want to draw
INTEGER :: m
! add that amount of space around the drawing
REAL, PARAMETER :: space = 0.05
REAL :: xmin, xmax, ymin, ymax, deltax, deltay
LOGICAL :: do_init, reset_limits, again
LOGICAL :: do_box = .TRUE.
m = m0
n = SIZE(x)
do_init = .TRUE.
reset_limits = .TRUE.
again = .TRUE.
drawing: DO WHILE (again)
setup_limits: IF (reset_limits) THEN
xmin = MINVAL(x)
xmax = MAXVAL(x)
ymin = MINVAL(y)
ymax = MAXVAL(y)
deltax = space * (xmax - xmin)
deltay = space * (ymax - ymin)
xmin = xmin - deltax
xmax = xmax + deltax
ymin = ymin - deltay
ymax = ymax + deltay
reset_limits = .FALSE.
END IF setup_limits
! Init pgplot library
IF (do_init) THEN
init: BLOCK
INTEGER :: ier
INTERFACE PGBEG
FUNCTION PGBEG(ignored, device, nxsub, nysub)
INTEGER :: PGBEG
INTEGER, INTENT(IN) :: ignored
CHARACTER*(*), INTENT(IN) :: device
INTEGER, INTENT(IN) :: nxsub, nysub
END FUNCTION PGBEG
END INTERFACE PGBEG
ier = PGBEG(0, '?', 1, 1)
if (ier /= 1) STOP 'Cannot open output device'
do_init = .FALSE.
END BLOCK init
END IF
CALL PGBBUF
CALL PGENV(xmin, xmax, ymin, ymax, 0, 0)
! We want black on white
CALL PGSCR(0, 1., 1., 1.)
CALL PGSCR(1, 0., 0., 0.)
CALL PGERAS
coordinates: IF (do_box) THEN
! We just erased coordinate box; redraw it
CALL PGBOX('BCNST', 0.0, 0, 'BCNST', 0.0, 0)
END IF coordinates
WRITE (*, '(A)') 'Drawing, please wait (this takes time!)'
CALL PGPT(m, x(:m), y(:m), -1)
CALL PGEBUF
WRITE (*, '(I10, A)') m, ' points plotted'
WRITE (*, '(A)') 'F: [F]ind next map (default)'
WRITE (*, '(A)') 'N: Change the [N]umber of points to plot'
WRITE (*, '(A)') 'D: Select different drawing [D]evice'
WRITE (*, '(A)') 'L: Change X/Y [L]imits'
WRITE (*, '(A)') 'R: [R]eset X/Y limits'
WRITE (*, '(A)') 'S: [S]witch coordinates on/off'
WRITE (*, '(A)') 'Q: [Q]uit'
WRITE (*, '(A)', ADVANCE='NO') '=> '
prompt: BLOCK
CHARACTER(LEN=1) :: reply
READ (*, *) reply
SELECT CASE (reply)
CASE ('n', 'N')
WRITE (*, '(I10, A)', ADVANCE='NO') n, &
' data points available, how many to plot? '
READ (*, *) m
sanity: IF (m > n) THEN
m = n
END IF sanity
WRITE (*, '(I10, A)') m, ' poins will be drawn'
CASE ('d', 'D')
do_init = .TRUE.
CALL PGCLOS
CASE ('q', 'Q')
DRAW_POINTS = .FALSE.
again = .FALSE.
CASE ('l', 'L')
WRITE (*, '(A)', ADVANCE='NO') 'Xmin: '
READ (*, *) xmin
WRITE (*, '(A)', ADVANCE='NO') 'Xmax: '
READ (*, *) xmax
WRITE (*, '(A)', ADVANCE='NO') 'Ymin: '
READ (*, *) ymin
WRITE (*, '(A)', ADVANCE='NO') 'Ymax: '
READ (*, *) ymax
CASE ('r', 'R')
reset_limits = .TRUE.
CASE ('s', 'S')
do_box = .NOT. do_box
CASE DEFAULT
DRAW_POINTS = .TRUE.
again = .FALSE.
END SELECT
END BLOCK prompt
END DO drawing
CALL PGEND
END FUNCTION DRAW_POINTS
END MODULE Draw