NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
getgir.f
Go to the documentation of this file.
1C> @file
2C> @brief Read a grib index file and return its index contents.
3C> @author Mark Iredell @date 1995-10-31
4
5C> Read a grib file and return its index contents.
6C> The index buffer returned contains index records with the internal format:
7C> - byte 001-004: bytes to skip in data file before grib message.
8C> - byte 005-008: bytes to skip in message before pds.
9C> - byte 009-012: bytes to skip in message before gds (0 if no gds).
10C> - byte 013-016: bytes to skip in message before bms (0 if no bms).
11C> - byte 017-020: bytes to skip in message before bds.
12C> - byte 021-024: bytes total in the message.
13C> - byte 025-025: grib version number.
14C> - byte 026-053: product definition section (pds).
15C> - byte 054-095: grid definition section (gds) (or nulls).
16C> - byte 096-101: first part of the bit map section (bms) (or nulls).
17C> - byte 102-112: first part of the binary data section (bds).
18C> - byte 113-172: (optional) bytes 41-100 of the pds.
19C> - byte 173-184: (optional) bytes 29-40 of the pds.
20C> - byte 185-320: (optional) bytes 43-178 of the gds.
21C>
22C> Program history log:
23C> - Mark Iredell 1995-10-31
24C> - Mark Iredell 1996-10-31 Augmented optional definitions to byte 320.
25C>
26C> @param[in] lugb integer unit of the unblocked grib file.
27C> @param[in] msk1 integer number of bytes to search for first message.
28C> @param[in] msk2 integer number of bytes to search for other messages.
29C> @param[in] mnum integer number of index records to skip (usually 0).
30C> @param[in] mbuf integer length of cbuf in bytes.
31C> @param[out] cbuf character*1 (mbuf) buffer to receive index data.
32C> @param[out] nlen integer length of each index record in bytes.
33C> @param[out] nnum integer number of index records
34C> (=0 if no grib messages are found).
35C> @param[out] iret integer return code.
36C> - 0: all ok.
37C> - 1: cbuf too small to hold index data.
38C>
39C> @note Subprogram can be called from a multiprocessing environment.
40C> Do not engage the same logical unit from more than one processor.
41C>
42C> @author Mark Iredell @date 1995-10-31
43C-----------------------------------------------------------------------
44 SUBROUTINE getgir(LUGB,MSK1,MSK2,MNUM,MBUF,CBUF,NLEN,NNUM,IRET)
45 CHARACTER CBUF(MBUF)
46 parameter(mindex=320)
47C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48C SEARCH FOR FIRST GRIB MESSAGE
49 iseek=0
50 CALL skgb(lugb,iseek,msk1,lskip,lgrib)
51 IF(lgrib.GT.0.AND.mindex.LE.mbuf) THEN
52 CALL ixgb(lugb,lskip,lgrib,mindex,1,nlen,cbuf)
53 ELSE
54 nlen=mindex
55 ENDIF
56 DO m=1,mnum
57 IF(lgrib.GT.0) THEN
58 iseek=lskip+lgrib
59 CALL skgb(lugb,iseek,msk2,lskip,lgrib)
60 ENDIF
61 ENDDO
62C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63C MAKE AN INDEX RECORD FOR EVERY GRIB RECORD FOUND
64 nnum=0
65 iret=0
66 dowhile(iret.EQ.0.AND.lgrib.GT.0)
67 IF(nlen*(nnum+1).LE.mbuf) THEN
68 nnum=nnum+1
69 CALL ixgb(lugb,lskip,lgrib,nlen,nnum,mlen,cbuf)
70 iseek=lskip+lgrib
71 CALL skgb(lugb,iseek,msk2,lskip,lgrib)
72 ELSE
73 iret=1
74 ENDIF
75 ENDDO
76C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77 RETURN
78 END
subroutine getgir(lugb, msk1, msk2, mnum, mbuf, cbuf, nlen, nnum, iret)
Read a grib file and return its index contents.
Definition getgir.f:45
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
subroutine skgb(lugb, iseek, mseek, lskip, lgrib)
This subprogram searches a file for the next grib 1 message.
Definition skgb.f:27