1 C-----------------------------------------------------------------------
2 SUBROUTINE GETGB1S
(CBUF
,NLEN
,NNUM
,J
,JPDS
,JGDS
,JENS
,
3 & K
,KPDS
,KGDS
,KENS
,LSKIP
,LGRIB
,IRET
)
4 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C SUBPROGRAM: GETGB1S FINDS A GRIB MESSAGE
7 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 95-10-31
9 C ABSTRACT: FIND A GRIB MESSAGE.
10 C FIND IN THE INDEX FILE A REFERENCE TO THE GRIB MESSAGE REQUESTED.
11 C THE GRIB MESSAGE REQUEST SPECIFIES THE NUMBER OF MESSAGES TO SKIP
12 C AND THE UNPACKED PDS AND GDS PARAMETERS. (A REQUESTED PARAMETER
13 C OF -1 MEANS TO ALLOW ANY VALUE OF THIS PARAMETER TO BE FOUND.)
15 C PROGRAM HISTORY LOG:
18 C USAGE: CALL GETGB1S(CBUF,NLEN,NNUM,J,JPDS,JGDS,JENS,
19 C & K,KPDS,KGDS,KENS,LSKIP,LGRIB,IRET)
21 C CBUF CHARACTER*1 (NLEN*NNUM) BUFFER CONTAINING INDEX DATA
22 C NLEN INTEGER LENGTH OF EACH INDEX RECORD IN BYTES
23 C NNUM INTEGER NUMBER OF INDEX RECORDS
24 C J INTEGER NUMBER OF MESSAGES TO SKIP
25 C (=0 TO SEARCH FROM BEGINNING)
26 C JPDS INTEGER (200) PDS PARAMETERS FOR WHICH TO SEARCH
28 C JGDS INTEGER (200) GDS PARAMETERS FOR WHICH TO SEARCH
29 C (ONLY SEARCHED IF JPDS(3)=255)
31 C JENS INTEGER (200) ENSEMBLE PDS PARMS FOR WHICH TO SEARCH
32 C (ONLY SEARCHED IF JPDS(23)=2)
35 C K INTEGER MESSAGE NUMBER FOUND
36 C (CAN BE SAME AS J IN CALLING PROGRAM
37 C IN ORDER TO FACILITATE MULTIPLE SEARCHES)
38 C KPDS INTEGER (200) UNPACKED PDS PARAMETERS
39 C KGDS INTEGER (200) UNPACKED GDS PARAMETERS
40 C KENS INTEGER (200) UNPACKED ENSEMBLE PDS PARMS
41 C LSKIP INTEGER NUMBER OF BYTES TO SKIP
42 C LGRIB INTEGER NUMBER OF BYTES TO READ
43 C IRET INTEGER RETURN CODE
47 C REMARKS: SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
48 C THIS SUBPROGRAM IS INTENDED FOR PRIVATE USE BY GETGB ROUTINES ONLY.
54 C PDSEUP UNPACK PDS EXTENSION
57 C LANGUAGE: FORTRAN 77
58 C MACHINE: CRAY, WORKSTATIONS
61 CHARACTER CBUF
(NLEN*NNUM
)
62 INTEGER JPDS
(200),JGDS
(200),JENS
(200)
63 INTEGER KPDS
(200),KGDS
(200),KENS
(200)
64 PARAMETER(LPDS
=23,LGDS
=22,LENS
=5) ! ACTUAL SEARCH RANGES
65 CHARACTER CPDS
(400)*1,CGDS
(400)*1
67 INTEGER IPDSP
(LPDS
),JPDSP
(LPDS
)
68 INTEGER IGDSP
(LGDS
),JGDSP
(LGDS
)
69 INTEGER IENSP
(LENS
),JENSP
(LENS
)
70 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
71 C COMPRESS REQUEST LISTS
76 C COMPRESS PDS REQUEST
79 IF(JPDS
(I
).NE
.-1) THEN
85 C COMPRESS GDS REQUEST
87 IF(JPDS
(3).EQ
.255) THEN
89 IF(JGDS
(I
).NE
.-1) THEN
96 C COMPRESS ENS REQUEST
98 IF(JPDS
(23).EQ
.2) THEN
100 IF(JENS
(I
).NE
.-1) THEN
107 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109 DOWHILE
(IRET
.NE
.0.AND
.K
.LT
.NNUM
)
112 C SEARCH FOR PDS REQUEST
115 CPDS
(1:28)=CBUF
((K
-1)*NLEN
+26:(K
-1)*NLEN
+53)
116 NLESS
=MAX
(184-NLEN
,0)
117 CPDS
(29:40-NLESS
)=CBUF
((K
-1)*NLEN
+173:(K
-1)*NLEN
+184-NLESS
)
119 CALL GBYTE
(CBUF
,KPTR
(3),(K
-1)*NLEN*8
+25*8,3*8)
121 CALL GBYTE
(CPDS
,KPDS
(4),7*8,8)
122 CALL FI632
(CPDS
,KPTR
,KPDS
,IRET
)
125 LT
=LT
+ABS
(JPDS
(IP
)-KPDS
(IP
))
128 C SEARCH FOR GDS REQUEST
129 IF(LT
.EQ
.0.AND
.LGDSP
.GT
.0) THEN
131 CGDS
(1:42)=CBUF
((K
-1)*NLEN
+54:(K
-1)*NLEN
+95)
132 NLESS
=MAX
(320-NLEN
,0)
133 CGDS
(43:178-NLESS
)=CBUF
((K
-1)*NLEN
+185:(K
-1)*NLEN
+320-NLESS
)
135 CALL FI633
(CGDS
,KPTR
,KGDS
,IRET
)
138 LT
=LT
+ABS
(JGDS
(IP
)-KGDS
(IP
))
141 C SEARCH FOR ENS REQUEST
142 IF(LT
.EQ
.0.AND
.LENSP
.GT
.0) THEN
143 NLESS
=MAX
(172-NLEN
,0)
144 CPDS
(41:100-NLESS
)=CBUF
((K
-1)*NLEN
+113:(K
-1)*NLEN
+172-NLESS
)
145 CALL PDSEUP
(KENS
,KPROB
,XPROB
,KCLUST
,KMEMBR
,45,CPDS
)
148 LT
=LT
+ABS
(JENS
(IP
)-KENS
(IP
))
151 C RETURN IF REQUEST IS FOUND
153 CALL GBYTE
(CBUF
,LSKIP
,(K
-1)*NLEN*8
,4*8)
154 CALL GBYTE
(CBUF
,LGRIB
,(K
-1)*NLEN*8
+20*8,4*8)
157 CPDS
(1:28)=CBUF
((K
-1)*NLEN
+26:(K
-1)*NLEN
+53)
158 NLESS
=MAX
(184-NLEN
,0)
159 CPDS
(29:40-NLESS
)=CBUF
((K
-1)*NLEN
+173:(K
-1)*NLEN
+184-NLESS
)
161 CALL GBYTE
(CBUF
,KPTR
(3),(K
-1)*NLEN*8
+25*8,3*8)
163 CALL GBYTE
(CPDS
,KPDS
(4),7*8,8)
164 CALL FI632
(CPDS
,KPTR
,KPDS
,IRET
)
168 CGDS
(1:42)=CBUF
((K
-1)*NLEN
+54:(K
-1)*NLEN
+95)
169 NLESS
=MAX
(320-NLEN
,0)
170 CGDS
(43:178-NLESS
)=CBUF
((K
-1)*NLEN
+185:(K
-1)*NLEN
+320-NLESS
)
172 CALL FI633
(CGDS
,KPTR
,KGDS
,IRET
)
174 IF(KPDS
(23).EQ
.2.AND
.LENSP
.EQ
.0) THEN
175 NLESS
=MAX
(172-NLEN
,0)
176 CPDS
(41:100-NLESS
)=CBUF
((K
-1)*NLEN
+113:(K
-1)*NLEN
+172-NLESS
)
177 CALL PDSEUP
(KENS
,KPROB
,XPROB
,KCLUST
,KMEMBR
,45,CPDS
)
182 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -