NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3fi73.f
Go to the documentation of this file.
1C> @file
2C> @brief Construct grib bit map section (BMS).
3C> @author M. Farley @date 1992-07-01
4
5C> This subroutine constructs a grib bit map section.
6C>
7C> Program history log:
8C> - M. Farley 1992-07-01
9C> - Bill Cavanaugh 1994-02-14 Recoded
10C> - Ebisuzaki 1998-06-30 Linux port
11C>
12C> @param[in] IBFLAG
13C> - 0, if bit map supplied by user
14C> - #, Number of predefined center bit map
15C> @param[in] IBMAP Integer array containing user bit map.
16C> @param[in] IBLEN Length of bit map.
17C> @param[out] BMS Completed grib bit map section.
18C> @param[out] LENBMS Length of bit map section in bytes.
19C> @param[out] IER 0 normal exit, 8 = ibmap values are all zero.
20C>
21C> @author M. Farley @date 1992-07-01
22 SUBROUTINE w3fi73 (IBFLAG,IBMAP,IBLEN,BMS,LENBMS,IER)
23C
24 INTEGER IBMAP(*)
25 INTEGER LENBMS
26 INTEGER IBLEN
27 INTEGER IBFLAG
28C
29 CHARACTER*1 BMS(*)
30C
31 ier = 0
32C
33 iz = 0
34 DO 20 i = 1, iblen
35 IF (ibmap(i).EQ.0) iz = iz + 1
36 20 CONTINUE
37 IF (iz.EQ.iblen) THEN
38C
39C AT THIS POINT ALL BIT MAP POSITIONS ARE ZERO
40C
41 ier = 8
42 RETURN
43 END IF
44C
45C BIT MAP IS A COMBINATION OF ONES AND ZEROS
46C OR BIT MAP ALL ONES
47C
48C CONSTRUCT BIT MAP FIELD OF BIT MAP SECTION
49C
50 CALL sbytesc(bms,ibmap,48,1,0,iblen)
51C
52 IF (mod(iblen,16).NE.0) THEN
53 nleft = 16 - mod(iblen,16)
54 ELSE
55 nleft = 0
56 END IF
57C
58 num = 6 + (iblen+nleft) / 8
59C
60C CONSTRUCT BMS FROM COLLECTED DATA
61C
62C SIZE INTO FIRST THREE BYTES
63C
64 CALL sbytec(bms,num,0,24)
65C NUMBER OF FILL BITS INTO BYTE 4
66 CALL sbytec(bms,nleft,24,8)
67C OCTET 5-6 TO CONTAIN INFO FROM IBFLAG
68 CALL sbytec(bms,ibflag,32,16)
69C
70C BIT MAP MAY BE ALL ONES OR A COMBINATION
71C OF ONES AND ZEROS
72C
73C ACTUAL BITS OF BIT MAP PLACED ALL READY
74C
75C INSTALL FILL POSITIONS IF NEEDED
76 IF (nleft.NE.0) THEN
77 nleft = 16 - nleft
78C ZERO FILL POSITIONS
79 CALL sbytec(bms,0,iblen+48,nleft)
80 END IF
81C
82C STORE NUM IN LENBMS (LENGTH OF BMS SECTION)
83C
84 lenbms = num
85C PRINT *,'W3FI73 - BMS LEN =',NUM,LENBMS
86C
87 RETURN
88 END
subroutine sbytec(out, in, iskip, nbyte)
This is a wrapper for sbytesc()
Definition sbytec.f:14
subroutine sbytesc(out, in, iskip, nbyte, nskip, n)
Store bytes - pack bits: Put arbitrary size values into a packed bit string, taking the low order bit...
Definition sbytesc.f:17
subroutine w3fi73(ibflag, ibmap, iblen, bms, lenbms, ier)
This subroutine constructs a grib bit map section.
Definition w3fi73.f:23