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