1 C-----------------------------------------------------------------------
2 SUBROUTINE GETGIR
(LUGB
,MSK1
,MSK2
,MNUM
,MBUF
,CBUF
,NLEN
,NNUM
,IRET
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: GETGIR READS A GRIB INDEX FILE
6 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 95-10-31
8 C ABSTRACT: READ A GRIB FILE AND RETURN ITS INDEX CONTENTS.
9 C THE INDEX BUFFER RETURNED CONTAINS INDEX RECORDS WITH THE INTERNAL FORMAT:
10 C BYTE 001-004: BYTES TO SKIP IN DATA FILE BEFORE GRIB MESSAGE
11 C BYTE 005-008: BYTES TO SKIP IN MESSAGE BEFORE PDS
12 C BYTE 009-012: BYTES TO SKIP IN MESSAGE BEFORE GDS (0 IF NO GDS)
13 C BYTE 013-016: BYTES TO SKIP IN MESSAGE BEFORE BMS (0 IF NO BMS)
14 C BYTE 017-020: BYTES TO SKIP IN MESSAGE BEFORE BDS
15 C BYTE 021-024: BYTES TOTAL IN THE MESSAGE
16 C BYTE 025-025: GRIB VERSION NUMBER
17 C BYTE 026-053: PRODUCT DEFINITION SECTION (PDS)
18 C BYTE 054-095: GRID DEFINITION SECTION (GDS) (OR NULLS)
19 C BYTE 096-101: FIRST PART OF THE BIT MAP SECTION (BMS) (OR NULLS)
20 C BYTE 102-112: FIRST PART OF THE BINARY DATA SECTION (BDS)
21 C BYTE 113-172: (OPTIONAL) BYTES 41-100 OF THE PDS
22 C BYTE 173-184: (OPTIONAL) BYTES 29-40 OF THE PDS
23 C BYTE 185-320: (OPTIONAL) BYTES 43-178 OF THE GDS
25 C PROGRAM HISTORY LOG:
27 C 96-10-31 IREDELL AUGMENTED OPTIONAL DEFINITIONS TO BYTE 320
29 C USAGE: CALL GETGIR(LUGB,MSK1,MSK2,MNUM,MBUF,CBUF,NLEN,NNUM,IRET)
31 C LUGB INTEGER UNIT OF THE UNBLOCKED GRIB FILE
32 C MSK1 INTEGER NUMBER OF BYTES TO SEARCH FOR FIRST MESSAGE
33 C MSK2 INTEGER NUMBER OF BYTES TO SEARCH FOR OTHER MESSAGES
34 C MNUM INTEGER NUMBER OF INDEX RECORDS TO SKIP (USUALLY 0)
35 C MBUF INTEGER LENGTH OF CBUF IN BYTES
37 C CBUF CHARACTER*1 (MBUF) BUFFER TO RECEIVE INDEX DATA
38 C NLEN INTEGER LENGTH OF EACH INDEX RECORD IN BYTES
39 C NNUM INTEGER NUMBER OF INDEX RECORDS
40 C (=0 IF NO GRIB MESSAGES ARE FOUND)
41 C IRET INTEGER RETURN CODE
43 C 1 CBUF TOO SMALL TO HOLD INDEX DATA
46 C SKGB SEEK NEXT GRIB MESSAGE
47 C IXGB MAKE INDEX RECORD
49 C REMARKS: SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
50 C DO NOT ENGAGE THE SAME LOGICAL UNIT FROM MORE THAN ONE PROCESSOR.
53 C LANGUAGE: FORTRAN 77
54 C MACHINE: CRAY, WORKSTATIONS
59 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60 C SEARCH FOR FIRST GRIB MESSAGE
62 CALL SKGB
(LUGB
,ISEEK
,MSK1
,LSKIP
,LGRIB
)
63 IF(LGRIB
.GT
.0.AND
.MINDEX
.LE
.MBUF
) THEN
64 CALL IXGB
(LUGB
,LSKIP
,LGRIB
,MINDEX
,1,NLEN
,CBUF
)
71 CALL SKGB
(LUGB
,ISEEK
,MSK2
,LSKIP
,LGRIB
)
74 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75 C MAKE AN INDEX RECORD FOR EVERY GRIB RECORD FOUND
78 DOWHILE
(IRET
.EQ
.0.AND
.LGRIB
.GT
.0)
79 IF(NLEN*
(NNUM
+1).LE
.MBUF
) THEN
81 CALL IXGB
(LUGB
,LSKIP
,LGRIB
,NLEN
,NNUM
,MLEN
,CBUF
)
83 CALL SKGB
(LUGB
,ISEEK
,MSK2
,LSKIP
,LGRIB
)
88 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -