aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/fitsio/ftgbit.f
blob: 08dc9e29131da3272c7392890c4affe3e9a612e7 (plain) (blame)
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
C----------------------------------------------------------------------
        subroutine ftgbit(buffer,log8)

C       decode the individual bits within the byte into an array of 
C       logical values.  The corresponding logical value is set to 
C       true if the bit is set to 1.

C       buffer  i  input integer containing the byte to be decoded
C       log8    l  output array of logical data values corresponding 
C                  to the bits in the input buffer
C
C       written by Wm Pence, HEASARC/GSFC, May 1992

        integer buffer,tbuff
        logical log8(8)

        log8(1)=.false.
        log8(2)=.false.
        log8(3)=.false.
        log8(4)=.false.
        log8(5)=.false.
        log8(6)=.false.
        log8(7)=.false.
        log8(8)=.false.

C       test for special case: no bits are set
        if (buffer .eq. 0)return

C       This algorithm tests to see if each bit is set by testing
C       the numerical value of the byte, starting with the most significant
C       bit.  If the bit is set, then it is reset to zero before testing
C       the next most significant bit, and so on.

        tbuff=buffer

C       now decode the least significant byte
        if (tbuff .gt. 127)then
                log8(1)=.true.
                tbuff=tbuff-128
        end if
        if (tbuff .gt. 63)then
                log8(2)=.true.
                tbuff=tbuff-64
        end if
        if (tbuff .gt. 31)then
                log8(3)=.true.
                tbuff=tbuff-32
        end if
        if (tbuff .gt. 15)then
                log8(4)=.true.
                tbuff=tbuff-16
        end if
        if (tbuff .gt. 7)then
                log8(5)=.true.
                tbuff=tbuff-8
        end if
        if (tbuff .gt. 3)then
                log8(6)=.true.
                tbuff=tbuff-4
        end if
        if (tbuff .gt. 1)then
                log8(7)=.true.
                tbuff=tbuff-2
        end if
        if (tbuff .eq. 1)then
                log8(8)=.true.
        end if
        end