NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
ixgb.f
Go to the documentation of this file.
1C> @file
2C> @brief This subprogram makes one index record.
3C> @author Mark iredell @date 1995-10-31
4
5C> Byte 001-004: Bytes to skip in data file before grib message.
6C> Byte 005-008: Bytes to skip in message before pds.
7C> Byte 009-012: Bytes to skip in message before gds (0 if no gds).
8C> Byte 013-016: Bytes to skip in message before bms (0 if no bms).
9C> Byte 017-020: Bytes to skip in message before bds.
10C> Byte 021-024: Bytes total in the message.
11C> Byte 025-025: Grib version number.
12C> Byte 026-053: Product definition section (pds).
13C> Byte 054-095: Grid definition section (gds) (or nulls).
14C> Byte 096-101: First part of the bit map section (bms) (or nulls).
15C> Byte 102-112: First part of the binary data section (bds).
16C> Byte 113-172: (optional) bytes 41-100 of the pds.
17C> Byte 173-184: (optional) bytes 29-40 of the pds.
18C> Byte 185-320: (optional) bytes 43-178 of the gds.
19C>
20C> Program history log:
21C> - Mark iredell 1995-10-31
22C> - Mark iredell 1996-10-31 Augmented optional definitions to byte 320.
23C> - Mark iredell 2001-06-05 Apply linux port by ebisuzaki.
24C>
25C> @param[in] LUGB Integer logical unit of input grib file.
26C> @param[in] LSKIP Integer number of bytes to skip before grib message.
27C> @param[in] LGRIB Integer number of bytes in grib message.
28C> @param[in] NLEN Integer length of each index record in bytes.
29C> @param[in] NNUM Integer index record number to make.
30C> @param[out] MLEN Integer actual valid length of index record.
31C> @param[out] CBUF Character*1 (mbuf) buffer to receive index data.
32C>
33C> @author Mark iredell @date 1995-10-31
34C-----------------------------------------------------------------------
35 SUBROUTINE ixgb(LUGB,LSKIP,LGRIB,NLEN,NNUM,MLEN,CBUF)
36 CHARACTER CBUF(*)
37 parameter(lindex=112,mindex=320)
38 parameter(ixskp=0,ixspd=4,ixsgd=8,ixsbm=12,ixsbd=16,ixlen=20,
39 & ixver=24,ixpds=25,ixgds=53,ixbms=95,ixbds=101,
40 & ixpdx=112,ixpdw=172,ixgdx=184)
41 parameter(mxskp=4,mxspd=4,mxsgd=4,mxsbm=4,mxsbd=4,mxlen=4,
42 & mxver=1,mxpds=28,mxgds=42,mxbms=6,mxbds=11,
43 & mxpdx=60,mxpdw=12,mxgdx=136)
44 CHARACTER CBREAD(MINDEX),CINDEX(MINDEX)
45C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46C INITIALIZE INDEX RECORD AND READ GRIB MESSAGE
47 mlen=lindex
48 cindex=char(0)
49 CALL sbytec(cindex,lskip,8*ixskp,8*mxskp)
50 CALL sbytec(cindex,lgrib,8*ixlen,8*mxlen)
51C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52C PUT PDS IN INDEX RECORD
53 iskpds=8
54 ibskip=lskip
55 ibread=iskpds+mxpds
56 CALL baread(lugb,ibskip,ibread,lbread,cbread)
57 IF(lbread.NE.ibread) RETURN
58 cindex(ixver+1)=cbread(8)
59 CALL sbytec(cindex,iskpds,8*ixspd,8*mxspd)
60 CALL gbytec(cbread,lenpds,8*iskpds,8*3)
61 CALL gbytec(cbread,incgds,8*iskpds+8*7+0,1)
62 CALL gbytec(cbread,incbms,8*iskpds+8*7+1,1)
63 ilnpds=min(lenpds,mxpds)
64 cindex(ixpds+1:ixpds+ilnpds)=cbread(iskpds+1:iskpds+ilnpds)
65 isktot=iskpds+lenpds
66C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
67C PUT PDS EXTENSION IN INDEX RECORD
68 IF(lenpds.GT.mxpds) THEN
69 iskpdw=iskpds+mxpds
70 ilnpdw=min(lenpds-mxpds,mxpdw)
71 ibskip=lskip+iskpdw
72 ibread=ilnpdw
73 CALL baread(lugb,ibskip,ibread,lbread,cbread)
74 IF(lbread.NE.ibread) RETURN
75 cindex(ixpdw+1:ixpdw+ilnpdw)=cbread(1:ilnpdw)
76 iskpdx=iskpds+(mxpds+mxpdw)
77 ilnpdx=min(lenpds-(mxpds+mxpdw),mxpdx)
78 ibskip=lskip+iskpdx
79 ibread=ilnpdx
80 CALL baread(lugb,ibskip,ibread,lbread,cbread)
81 IF(lbread.NE.ibread) RETURN
82 cindex(ixpdx+1:ixpdx+ilnpdx)=cbread(1:ilnpdx)
83 mlen=max(mlen,ixpdw+ilnpdw,ixpdx+ilnpdx)
84 ENDIF
85C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86C PUT GDS IN INDEX RECORD
87 IF(incgds.NE.0) THEN
88 iskgds=isktot
89 ibskip=lskip+iskgds
90 ibread=mxgds
91 CALL baread(lugb,ibskip,ibread,lbread,cbread)
92 IF(lbread.NE.ibread) RETURN
93 CALL sbytec(cindex,iskgds,8*ixsgd,8*mxsgd)
94 CALL gbytec(cbread,lengds,0,8*3)
95 ilngds=min(lengds,mxgds)
96 cindex(ixgds+1:ixgds+ilngds)=cbread(1:ilngds)
97 isktot=iskgds+lengds
98 IF(lengds.GT.mxgds) THEN
99 iskgdx=iskgds+mxgds
100 ilngdx=min(lengds-mxgds,mxgdx)
101 ibskip=lskip+iskgdx
102 ibread=ilngdx
103 CALL baread(lugb,ibskip,ibread,lbread,cbread)
104 IF(lbread.NE.ibread) RETURN
105 cindex(ixgdx+1:ixgdx+ilngdx)=cbread(1:ilngdx)
106 mlen=max(mlen,ixgdx+ilngdx)
107 ENDIF
108 ENDIF
109C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110C PUT BMS IN INDEX RECORD
111 IF(incbms.NE.0) THEN
112 iskbms=isktot
113 ibskip=lskip+iskbms
114 ibread=mxbms
115 CALL baread(lugb,ibskip,ibread,lbread,cbread)
116 IF(lbread.NE.ibread) RETURN
117 CALL sbytec(cindex,iskbms,8*ixsbm,8*mxsbm)
118 CALL gbytec(cbread,lenbms,0,8*3)
119 ilnbms=min(lenbms,mxbms)
120 cindex(ixbms+1:ixbms+ilnbms)=cbread(1:ilnbms)
121 isktot=iskbms+lenbms
122 ENDIF
123C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
124C PUT BDS IN INDEX RECORD
125 iskbds=isktot
126 ibskip=lskip+iskbds
127 ibread=mxbds
128 CALL baread(lugb,ibskip,ibread,lbread,cbread)
129 IF(lbread.NE.ibread) RETURN
130 CALL sbytec(cindex,iskbds,8*ixsbd,8*mxsbd)
131 CALL gbytec(cbread,lenbds,0,8*3)
132 ilnbds=min(lenbds,mxbds)
133 cindex(ixbds+1:ixbds+ilnbds)=cbread(1:ilnbds)
134C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135C STORE INDEX RECORD
136 mlen=min(mlen,nlen)
137 nskip=nlen*(nnum-1)
138 cbuf(nskip+1:nskip+mlen)=cindex(1:mlen)
139 cbuf(nskip+mlen+1:nskip+nlen)=char(0)
140C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141 RETURN
142 END
subroutine gbytec(in, iout, iskip, nbyte)
Wrapper for gbytesc() limiting NSKIP and N to 0 and 1.
Definition gbytec.f:14
subroutine ixgb(lugb, lskip, lgrib, nlen, nnum, mlen, cbuf)
Byte 001-004: Bytes to skip in data file before grib message.
Definition ixgb.f:36
function lengds(kgds)
Program history log:
Definition lengds.f:15
subroutine sbytec(out, in, iskip, nbyte)
This is a wrapper for sbytesc()
Definition sbytec.f:14