-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertpr.f90
278 lines (244 loc) · 6.72 KB
/
vertpr.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
! Code converted using TO_F90 by Alan Miller
! Date: 2012-03-16 Time: 11:09:42
!> \file
!! Print vertical.
!!
!! \author Volker Blobel, University Hamburg, 2005-2009 (initial Fortran77 version)
!! \author Claus Kleinwort, DESY (maintenance and developement)
!!
!! \copyright
!! Copyright (c) 2009 - 2015 Deutsches Elektronen-Synchroton,
!! Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY \n\n
!! This library is free software; you can redistribute it and/or modify
!! it under the terms of the GNU Library General Public License as
!! published by the Free Software Foundation; either version 2 of the
!! License, or (at your option) any later version. \n\n
!! This library is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU Library General Public License for more details. \n\n
!! You should have received a copy of the GNU Library General Public
!! License along with this program (see the file COPYING.LIB for more
!! details); if not, write to the Free Software Foundation, Inc.,
!! 675 Mass Ave, Cambridge, MA 02139, USA.
!!
!> Print vertical.
!!
!! Print the array X of dimension N (MAX 120) in 6 lines.
!!
!! \param[in] n number of numbers
!! \param[in] x array of numbers
SUBROUTINE pzvert(n,x)
USE mpdef
IMPLICIT NONE
INTEGER(mpi) :: i
INTEGER(mpi) :: i1
INTEGER(mpi) :: i2
INTEGER(mpi) :: ia
INTEGER(mpi) :: ij
INTEGER(mpi) :: im
INTEGER(mpi) :: in
INTEGER(mpi) :: iz
INTEGER(mpi) :: j
INTEGER(mpi) :: jl
INTEGER(mpi) :: jm
INTEGER(mpi) :: ke
INTEGER(mpi) :: kl
INTEGER(mpi) :: kn
INTEGER(mpi) :: lc
INTEGER(mpi) :: m
INTEGER(mpi) :: mx
REAL(mps) :: fac
REAL(mps) :: xm
!
INTEGER(mpi), INTENT(IN) :: n
REAL(mps), INTENT(IN) :: x(n)
INTEGER(mpi), PARAMETER :: nn=6
CHARACTER (LEN=66):: px(10)
CHARACTER (LEN=66)::ch(10)*1
SAVE
DATA ch/'0','1','2','3','4','5','6','7','8','9'/
! ...
IF(n <= 0) RETURN
jm=0
DO i=1,10
px(i)=' '
END DO
m=MIN(60,n)
jl=0
xm=0.0
DO j=1,m
IF(ABS(x(j)) > xm) THEN
xm=ABS(x(j))
mx=j ! index of max
END IF
IF(x(j) < 0.0) px(1)(6+j:6+j)='-' ! negative columns
IF(x(j) /= 0.0) jl=j ! last non-zero column
END DO
IF(xm == 0.0.OR.jl <= 0) RETURN ! empty array
jl=60
kn=MIN(6,MAX(2,IABS(nn)))
ke=INT(LOG10(xm*1.0001),mpi)
IF(xm < 1.0) ke=ke-1
22 fac=10.0**(kn-1-ke)
ij=NINT(fac*xm,mpi)
IF(ij >= 10**kn) THEN
ke=ke+1
GO TO 22
END IF
ia=2+kn
DO j=1,jl
ij=NINT(fac*ABS(x(j)),mpi) ! convert to integer
im=0
IF(ij /= 0) THEN
DO i=1,kn
IF(ij /= 0) THEN
in=MOD(ij,10) ! last digit
ij=ij/10 ! reduce
IF(in /= 0.AND.im == 0) im=ia-i+1
px(ia-i)(6+j:6+j)=ch(in+1)
END IF
END DO
END IF
jm=MAX(im,jm)
END DO
kl=ke
50 IF(ke >= kn) THEN
ke=ke-3
GO TO 50
END IF
55 IF(ke < 0) THEN
ke=ke+3
GO TO 55
END IF
in=ke+2 ! exponent
iz=kl-ke
px(in)(6:6)='.'
px(in)(1:1)='E'
IF(iz < 0) THEN
px(in)(2:2)='-'
iz=-iz
END IF
i1=iz/10 ! insert exponent
i2=MOD(iz,10)
px(in)(3:3)=ch(i1+1)
px(in)(4:4)=ch(i2+1)
jm=MIN(2+kn,jm)
jm=MAX(in+1,jm)
DO j=1,jl ! '0' for small nonzero values
IF(x(j) /= 0.0.AND.px(jm-1)(6+j:6+j) == ' ') px(jm-1)(6+j:6+j)='0'
END DO
DO i=jm,8
px(i)=' '
END DO
DO j=1,((jl+9)/10)*10 ! index line below
IF(px(jm-1)(6+j:6+j) == ' ') px(jm-1)(6+j:6+j)='_'
IF(MOD(j,2) /= 1) THEN
i=MOD(j,10)+1
px(jm+1)(6+j:6+j)=ch(i) ! last digit of even bin numbers
IF(i == 1) THEN ! ten'th column
i=MOD(j/10,10)+1
px(jm)(6+j:6+j)=ch(i)
END IF
END IF
END DO
DO j=1,jl
IF(x(j) == x(mx)) THEN
px(jm)(6+j:6+j)='*' ! * in max bin
END IF
END DO
jm=jm+1
IF(nn < 0) jm=jm-2 ! no index line
lc=((jl+9)/10)*10+6
DO j=1,jm
WRITE(*,*) px(j)(1:lc) ! print
! WRITE(*,101) PX(J)(1:LC) ! print
END DO
RETURN
! 101 FORMAT(A)
END SUBROUTINE pzvert
!> Vertical print of integer data.
!!
!! Print in up to 60 columns. Optionally average data.
!!
!! \param[in] n number of integers
!! \param[in] list array of integers
SUBROUTINE pivert(n,list) !
USE mpdef
IMPLICIT NONE
INTEGER(mpi) :: i
INTEGER(mpi) :: l
INTEGER(mpi) :: ll
INTEGER(mpi) :: m
INTEGER(mpi) :: nhist
INTEGER(mpi), INTENT(IN) :: n
INTEGER(mpi), INTENT(IN) :: list(n)
REAL(mps) :: y(60)
SAVE
! ...
ll=(n+59)/60 ! compression factor
m=0
i=0
10 nhist=0
DO l=1,ll
IF(i+l <= n) nhist=nhist+list(i+l)
END DO
i=i+ll
m=m+1
y(m)=nhist
IF(i < n) GO TO 10
CALL pzvert(m,y)
RETURN
END SUBROUTINE pivert
!> Vertical print of floating point data.
!!
!! Print in up to 60 columns. Optionally average data.
!!
!! \param[in] n number of floats
!! \param[in] x array of floats
SUBROUTINE pfvert(n,x) ! vert. print fltpt data
USE mpdef
IMPLICIT NONE
REAL(mps) :: dsum
INTEGER(mpi) :: i
INTEGER(mpi) :: l
INTEGER(mpi) :: ll
INTEGER(mpi) :: m
REAL(mps) :: y(60)
INTEGER(mpi), INTENT(IN) :: n
INTEGER(mpi), INTENT(IN) :: x(n)
ll=(n+59)/60 ! compression factor
m=0
i=0
20 dsum=0.0
DO l=1,ll
IF(i+l <= n) dsum=dsum+x(i+l)
END DO
i=i+ll
m=m+1
y(m)=REAL(dsum,mps)
IF(i < n) GO TO 20
CALL pzvert(m,y)
RETURN
END SUBROUTINE pfvert
!> Print scale.
!!
!! \param[in] xa lower bound of range
!! \param[in] xb upper bound of range
SUBROUTINE psvert(xa,xb) ! print scale
USE mpdef
IMPLICIT NONE
INTEGER(mpi) :: i
REAL(mps) :: xc
! print scale from XA ... XB
REAL(mps), INTENT(IN) :: xa
REAL(mps), INTENT(IN) :: xb
REAL(mps) :: sc(7)
xc=xb
DO i=1,7
sc(i)=(REAL(7-i,mps)*xa+REAL(i-1,mps)*xc)/6.0
END DO
WRITE(*,101) sc
101 FORMAT(3X,7G10.3)
RETURN
END SUBROUTINE psvert