1 |
kusanagi |
1.1 |
C------------------------------------------------
|
2 |
|
|
SUBROUTINE CALPEDESTAL(vect,ERROR,CAL_PED,CAL_GOOD,CAL_THR,
|
3 |
|
|
& CAL_RMS,CAL_BASE,CAL_VAR)
|
4 |
|
|
C------------------------------------------------
|
5 |
|
|
|
6 |
|
|
IMPLICIT NONE
|
7 |
|
|
C
|
8 |
|
|
C Normal variables definition
|
9 |
|
|
C
|
10 |
|
|
INTEGER ERROR
|
11 |
|
|
C
|
12 |
|
|
INTEGER i, j, ival
|
13 |
|
|
C
|
14 |
|
|
INTEGER*2 VECT(20000)
|
15 |
|
|
C
|
16 |
|
|
integer*2 check, crc
|
17 |
|
|
C
|
18 |
|
|
INTEGER ic, k, ke
|
19 |
|
|
INTEGER status
|
20 |
|
|
INTEGER inf, sup
|
21 |
|
|
INTEGER XO, YO, XE, YE
|
22 |
|
|
|
23 |
|
|
INTEGER*2 length, length2
|
24 |
|
|
|
25 |
|
|
INTEGER*2 st1, st2
|
26 |
|
|
|
27 |
|
|
REAL CAL_PED(4,11,96), CAL_GOOD(4,11,96), CAL_THR(4,11,6)
|
28 |
|
|
REAL CAL_RMS(4,11,96), CAL_BASE(4,11,6), CAL_VAR(4,11,6)
|
29 |
|
|
|
30 |
|
|
DATA XO/177/ ! CODE_DSP_R XO = 101 10001
|
31 |
|
|
DATA YO/173/ ! CODE_DSP_R YO = 101 01101
|
32 |
|
|
DATA XE/170/ ! CODE_DSP_R XE = 101 01010
|
33 |
|
|
DATA YE/182/ ! CODE_DSP_R YE = 101 10110
|
34 |
|
|
|
35 |
|
|
C
|
36 |
|
|
C Begin !
|
37 |
|
|
C
|
38 |
|
|
ERROR = 0
|
39 |
|
|
ival = 0
|
40 |
|
|
C
|
41 |
|
|
ic = 0
|
42 |
|
|
c
|
43 |
|
|
length = ic
|
44 |
|
|
do k = 1,4
|
45 |
|
|
ic = ic + length + 1
|
46 |
|
|
ke = 0
|
47 |
|
|
do while (ke = 0)
|
48 |
|
|
C
|
49 |
|
|
C Check consistency of status word.
|
50 |
|
|
C
|
51 |
|
|
st1 = IAND(vect(ic),'00FF'x)
|
52 |
|
|
if (st1.ne.0) then
|
53 |
|
|
write (*,10) k,vect(ic)
|
54 |
|
|
endif
|
55 |
|
|
st2 = IAND(vect(ic),'FF00'x)
|
56 |
|
|
status = ISHFT(st2,-8)
|
57 |
|
|
C
|
58 |
|
|
if (k.eq.1) then
|
59 |
|
|
if (status.eq.YE) then
|
60 |
|
|
ke = 1
|
61 |
|
|
else
|
62 |
|
|
write (*,11) k,vect(ic)
|
63 |
|
|
ERROR = 1
|
64 |
|
|
endif
|
65 |
|
|
if (status.eq.YO.or.status.eq.XE.or.status.eq.XO) then
|
66 |
|
|
write (*,12) k
|
67 |
|
|
length = -1
|
68 |
|
|
goto 50
|
69 |
|
|
endif
|
70 |
|
|
endif
|
71 |
|
|
C
|
72 |
|
|
if (k.eq.2) then
|
73 |
|
|
if (status.eq.YO) then
|
74 |
|
|
ke = 1
|
75 |
|
|
else
|
76 |
|
|
write (*,11) k,vect(ic)
|
77 |
|
|
ERROR = 1
|
78 |
|
|
endif
|
79 |
|
|
if (status.eq.YE.or.status.eq.XE.or.status.eq.XO) then
|
80 |
|
|
write (*,12) k
|
81 |
|
|
length = -1
|
82 |
|
|
goto 50
|
83 |
|
|
endif
|
84 |
|
|
endif
|
85 |
|
|
C
|
86 |
|
|
if (k.eq.3) then
|
87 |
|
|
if (status.eq.XE) then
|
88 |
|
|
ke = 1
|
89 |
|
|
else
|
90 |
|
|
write (*,11) k,vect(ic)
|
91 |
|
|
ERROR = 1
|
92 |
|
|
endif
|
93 |
|
|
if (status.eq.XO.or.status.eq.YO.or.status.eq.YE) then
|
94 |
|
|
write (*,12) k
|
95 |
|
|
length = -1
|
96 |
|
|
goto 50
|
97 |
|
|
endif
|
98 |
|
|
endif
|
99 |
|
|
C
|
100 |
|
|
if (k.eq.4) then
|
101 |
|
|
if (status.eq.XO) then
|
102 |
|
|
ke = 1
|
103 |
|
|
else
|
104 |
|
|
write (*,11) k,vect(ic)
|
105 |
|
|
ERROR = 1
|
106 |
|
|
endif
|
107 |
|
|
endif
|
108 |
|
|
C
|
109 |
|
|
ic = ic + 1
|
110 |
|
|
if (ic.gt.20000) then
|
111 |
|
|
write (*,13)
|
112 |
|
|
ERROR = 1
|
113 |
|
|
goto 100
|
114 |
|
|
endif
|
115 |
|
|
enddo
|
116 |
|
|
C
|
117 |
|
|
10 FORMAT(2X,'Error for view:',2X,I1,2X,'Status word:',2X,Z4)
|
118 |
|
|
11 FORMAT(2X,'View or command not recognized for view:',2X,I1,2X,
|
119 |
|
|
& 'Status word:',2X,Z4)
|
120 |
|
|
12 FORMAT(2X,'Error - did NOT find view:',2X,I1)
|
121 |
|
|
13 FORMAT(2X,'Error - eof reached, exiting')
|
122 |
|
|
C
|
123 |
|
|
C ic = ic + 1
|
124 |
|
|
length = length + (vect(ic) + 2)
|
125 |
|
|
length2 = vect(ic)
|
126 |
|
|
C
|
127 |
|
|
C Check validity of length.
|
128 |
|
|
C
|
129 |
|
|
if (vect(ic).ne.4629) then
|
130 |
|
|
print *,'problems with view',k
|
131 |
|
|
ERROR = 1
|
132 |
|
|
goto 50
|
133 |
|
|
endif
|
134 |
|
|
C
|
135 |
|
|
C Check consistency of CRC.
|
136 |
|
|
C
|
137 |
|
|
check = 0.
|
138 |
|
|
inf = (length-length2-2)+1
|
139 |
|
|
sup = length - 1
|
140 |
|
|
do i = inf,sup
|
141 |
|
|
check=crc(check,vect(i))
|
142 |
|
|
enddo
|
143 |
|
|
if (check.ne.vect(length)) then
|
144 |
|
|
print *,'Problems with CRC of view:',k
|
145 |
|
|
ERROR = 1
|
146 |
|
|
goto 50
|
147 |
|
|
endif
|
148 |
|
|
C
|
149 |
|
|
C Process data.
|
150 |
|
|
C
|
151 |
|
|
do i = 1,11
|
152 |
|
|
do j = 1,96
|
153 |
|
|
ic = ic + 1
|
154 |
|
|
cal_ped(k,i,j) = vect(ic)
|
155 |
|
|
cal_good(k,i,j) = vect(ic+1)
|
156 |
|
|
ic = ic + 1
|
157 |
|
|
enddo
|
158 |
|
|
enddo
|
159 |
|
|
C
|
160 |
|
|
ic = ic + 4
|
161 |
|
|
do i = 1,11
|
162 |
|
|
do j = 1,6
|
163 |
|
|
ic = ic + 1
|
164 |
|
|
cal_thr(k,i,j) = vect(ic)
|
165 |
|
|
ic = ic + 1
|
166 |
|
|
enddo
|
167 |
|
|
enddo
|
168 |
|
|
|
169 |
|
|
c
|
170 |
|
|
ic = ic + 4
|
171 |
|
|
do i = 1,11
|
172 |
|
|
do j = 1,96
|
173 |
|
|
ic = ic + 1
|
174 |
|
|
cal_rms(k,i,j) = vect(ic)
|
175 |
|
|
ic = ic + 1
|
176 |
|
|
enddo
|
177 |
|
|
enddo
|
178 |
|
|
c
|
179 |
|
|
do i = 1,11
|
180 |
|
|
do j = 1,6
|
181 |
|
|
ic = ic + 1
|
182 |
|
|
cal_base(k,i,j) = vect(ic)
|
183 |
|
|
ic = ic + 1
|
184 |
|
|
ic = ic + 1
|
185 |
|
|
cal_var(k,i,j) = vect(ic)
|
186 |
|
|
ic = ic + 1
|
187 |
|
|
enddo
|
188 |
|
|
enddo
|
189 |
|
|
c
|
190 |
|
|
50 continue
|
191 |
|
|
c
|
192 |
|
|
enddo
|
193 |
|
|
C
|
194 |
|
|
100 continue
|
195 |
|
|
C
|
196 |
|
|
RETURN
|
197 |
|
|
END
|
198 |
|
|
|
199 |
|
|
|