NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
gtbits.f
Go to the documentation of this file.
1C> @file
2C> @brief The number of bits required to pack a given field.
3C> @author Mark Iredell @date 1992-10-31
4
5C> The number of bits required to pack a given field
6c> at a particular decimal scaling is computed using the field range.
7C> The field is rounded off to the decimal scaling for packing.
8C> The minimum and maximum rounded field values are also returned.
9C> Grib bitmap masking for valid data is optionally used.
10C>
11C> Program history log:
12C> - Mark Iredell 1992-10-31
13C>
14C> @param[in] ibm integer bitmap flag (=0 for no bitmap).
15c> @param[in] ids integer decimal scaling
16c> (e.g. ids=3 to round field to nearest milli-value).
17c> @param[in] len integer length of the field and bitmap.
18c> @param[in] mg integer (len) bitmap if ibm=1 (0 to skip, 1 to keep).
19c> @param[in] g real (len) field.
20c> @param[out] ground real (len) field rounded to decimal scaling
21c> (set to zero where bitmap is 0 if ibm=1).
22c> @param[out] gmin real minimum valid rounded field value.
23c> @param[out] gmax real maximum valid rounded field value.
24c> @param[out] nbit integer number of bits to pack.
25C>
26C> @author Mark Iredell @date 1992-10-31
27 SUBROUTINE gtbits(IBM,IDS,LEN,MG,G,GROUND,GMIN,GMAX,NBIT)
28 dimension mg(len),g(len),ground(len)
29C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30C ROUND FIELD AND DETERMINE EXTREMES WHERE BITMAP IS ON
31 ds=10.**ids
32 IF(ibm.EQ.0) THEN
33 ground(1)=nint(g(1)*ds)/ds
34 gmax=ground(1)
35 gmin=ground(1)
36 DO i=2,len
37 ground(i)=nint(g(i)*ds)/ds
38 gmax=max(gmax,ground(i))
39 gmin=min(gmin,ground(i))
40 ENDDO
41 ELSE
42 i1=isrchne(len,mg,1,0)
43 IF(i1.GT.0.AND.i1.LE.len) THEN
44 DO i=1,i1-1
45 ground(i)=0.
46 ENDDO
47 ground(i1)=nint(g(i1)*ds)/ds
48 gmax=ground(i1)
49 gmin=ground(i1)
50 DO i=i1+1,len
51 IF(mg(i).NE.0) THEN
52 ground(i)=nint(g(i)*ds)/ds
53 gmax=max(gmax,ground(i))
54 gmin=min(gmin,ground(i))
55 ELSE
56 ground(i)=0.
57 ENDIF
58 ENDDO
59 ELSE
60 DO i=1,len
61 ground(i)=0.
62 ENDDO
63 gmax=0.
64 gmin=0.
65 ENDIF
66 ENDIF
67C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68C COMPUTE NUMBER OF BITS
69 nbit=log((gmax-gmin)*ds+0.9)/log(2.)+1.
70C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
71 RETURN
72 END
subroutine gtbits(ibm, ids, len, mg, g, ground, gmin, gmax, nbit)
The number of bits required to pack a given field at a particular decimal scaling is computed using t...
Definition gtbits.f:28
function isrchne(n, x, incx, target)
Program history log:
Definition isrchne.f:21