NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
getgi.f
Go to the documentation of this file.
1C> @file
2C> @brief Read a grib index file and return its contents.
3C> @author Mark Iredell @date 1995-10-31
4
5C> Read a grib index file and return its contents.
6C> Version 1 of the index file has the following format:
7C> 81-byte s.lord header with 'gb1ix1' in columns 42-47 followed by
8C> 81-byte header with number of bytes to skip before index records,
9C> number of bytes in each index record, number of index records,
10C> and grib file basename written in format ('ix1form:',3i10,2x,a40).
11C> Each following index record corresponds to a grib message
12C> and has the internal format:
13C> - byte 001-004: bytes to skip in data file before grib message.
14C> - byte 005-008: bytes to skip in message before pds.
15C> - byte 009-012: bytes to skip in message before gds (0 if no gds).
16C> - byte 013-016: bytes to skip in message before bms (0 if no bms).
17C> - byte 017-020: bytes to skip in message before bds.
18C> - byte 021-024: bytes total in the message.
19C> - byte 025-025: grib version number.
20C> - byte 026-053: product definition section (pds).
21C> - byte 054-095: grid definition section (gds) (or nulls).
22C> - byte 096-101: first part of the bit map section (bms) (or nulls).
23C> - byte 102-112: first part of the binary data section (bds).
24C> - byte 113-172: (optional) bytes 41-100 of the pds.
25C> - byte 173-184: (optional) bytes 29-40 of the pds.
26C> - byte 185-320: (optional) bytes 43-178 of the gds.
27C>
28C> Program history log:
29C> - Mark Iredell 1995-10-31
30C> - Mark Iredell 1996-10-31 Augmented optional definitions to byte 320.
31C>
32C> @param[in] lugi integer unit of the unblocked grib index file.
33C> @param[in] mnum integer number of index records to skip (usually 0).
34C> @param[in] mbuf integer length of cbuf in bytes.
35C> @param[out] cbuf character*1 (mbuf) buffer to receive index data.
36C> @param[out] nlen integer length of each index record in bytes.
37C> @param[out] nnum integer number of index records.
38C> @param[out] iret integer return code.
39C> - 0: all ok.
40C> - 1: cbuf too small to hold index buffer.
41C> - 2: error reading index file buffer.
42C> - 3: error reading index file header.
43C>
44C> @note Subprogram can be called from a multiprocessing environment.
45C> Do not engage the same logical unit from more than one processor.
46C>
47C> @author Mark Iredell @date 1995-10-31
48C-----------------------------------------------------------------------
49 SUBROUTINE getgi(LUGI,MNUM,MBUF,CBUF,NLEN,NNUM,IRET)
50 CHARACTER CBUF(MBUF)
51 CHARACTER CHEAD*162
52C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53 nlen=0
54 nnum=0
55 iret=3
56 CALL baread(lugi,0,162,lhead,chead)
57 IF(lhead.EQ.162.AND.chead(42:47).EQ.'GB1IX1') THEN
58 READ(chead(82:162),'(8X,3I10,2X,A40)',iostat=ios) nskp,nlen,nnum
59 IF(ios.EQ.0) THEN
60 nskp=nskp+mnum*nlen
61 nnum=nnum-mnum
62 nbuf=nnum*nlen
63 iret=0
64 IF(nbuf.GT.mbuf) THEN
65 nnum=mbuf/nlen
66 nbuf=nnum*nlen
67 iret=1
68 ENDIF
69 IF(nbuf.GT.0) THEN
70 CALL baread(lugi,nskp,nbuf,lbuf,cbuf)
71 IF(lbuf.NE.nbuf) iret=2
72 ENDIF
73 ENDIF
74 ENDIF
75C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76 RETURN
77 END
subroutine getgi(lugi, mnum, mbuf, cbuf, nlen, nnum, iret)
Read a grib index file and return its contents.
Definition getgi.f:50