NCEPLIBS-w3emc  2.9.3
w3ai41.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Constant size binary string unpacker.
3 C> @author Robert Allard @date 1980-04-01
4 
5 C> Unpack consecutive binary strings of the same size from
6 C> one user supplied array and store them in the same order right
7 C> aligned in another array. W3AI41() is the reverse of W3AI40().
8 C>
9 C> Program history log:
10 C> - Robert Allard 1980-04-01 R.ALLARD (ORIGINAL AUTHOR) ASMEMBLER LANGUAGE VERSION.
11 C> - Ralph Jones 1984-07-05 Recompiled for NAS-9050
12 C> - Ralph Jones 1988-07-05 Wrote fortran version of w3ai41 to unpack
13 C> variable size binary strings, added code to reverse orfer of bytes.
14 C> - Ralph Jones 1989-11-04 Convert to craf CFT77 FORTRAN
15 C> - Boi Vuong 1998-03-10 Remove the cdir$ integer=64 directive.
16 C>
17 C> @param[in] KFLD Integer array contining binary string(s).
18 C> @param[in] KLEN Integer number of bits per string (0 < klen < 65).
19 C> @param[in] KNUM Integer number of strings to unpack. this value must
20 C> not exceed the dimension of 'kout'.
21 C> @param[in] KOFF Integer number specifying the bit offset of the
22 C> first string 'kfld'. the offset value is reset to
23 C> include the low order bit of the last string unpacked
24 C> ('koff' > 0 ).
25 C> @param[out] KOUT Integer*4 array holding unpacked string(s).
26 C>
27 C> Exit states:
28 C> error - 'koff' < 0 if 'klen' has an illegal value or 'knum' < 1
29 C> then 'kout' has no strings stored.
30 C>
31 C> @note This subroutine should be written in assembler language.
32 C> The fortran version runs two or three times slower than the asembler
33 C> version. The fortran version can be converted to run on other
34 C> computers with a few changes. The bit manipulation functions are the
35 C> same in IBM370 vs fortran 4.1, microsoft fortran 4.10, vax fortran.
36 C> Most modern fortran compiler have and, or, shift functions. If you
37 C> are running on a pc, vax and your input was made on a IBM370, apollo
38 C> sun, h.p.. etc. you may have to add more code to reverse the order o
39 C> bytes in an integer word. NCAR gbytes() can be used instead of this
40 C> subroutine.
41 C>
42 C> @author Robert Allard @date 1980-04-01
43  SUBROUTINE w3ai41(KFLD,KOUT,KLEN,KNUM,KOFF)
44 C
45  INTEGER KFLD(*)
46  INTEGER KOUT(*)
47  INTEGER BITSET
48  INTEGER OFFSET
49  INTEGER WRDSET
50 C
51  offset = koff
52  IF (offset.LT.0) RETURN
53  IF (klen.GT.64.OR.klen.LT.1) THEN
54  koff = -1
55  RETURN
56  ENDIF
57 C
58  IF (knum.LT.1) THEN
59  koff = -1
60  RETURN
61  ENDIF
62 C
63  jcount = klen - 64
64  length = klen
65 C
66  DO 100 i = 1,knum
67  wrdset = ishft(offset,-6)
68  bitset = mod(offset,64)
69  itemp = kfld(wrdset+1)
70  ntemp = kfld(wrdset+2)
71  itemp = ishft(itemp,bitset)
72  ntemp = ishft(ntemp,bitset-64)
73  kout(i) = ishft(ior(itemp,ntemp),jcount)
74  offset = offset + length
75  100 CONTINUE
76  koff = offset
77  RETURN
78  END
w3ai41
subroutine w3ai41(KFLD, KOUT, KLEN, KNUM, KOFF)
Unpack consecutive binary strings of the same size from one user supplied array and store them in the...
Definition: w3ai41.f:44