1 GRIB1 USERS GUIDE (FORTRAN 90)
6 - GRIB1 Encoding Routines
7 - GRIB1 Decoding Routine
8 - Extracting GRIB1 Fields from a GRIB1 file
10 - GRIB1 Routine Docblocks
12 ===============================================================================
16 This document briefly describes the routines available for encoding/decoding
17 GRIB Edition 1 messages. A basic familiarity with GRIB is assumed.
19 A GRIB message is a machine independent format for storing
20 one or more gridded data fields. Each GRIB message consists of the
23 SECTION 0 - Indicator Section
24 SECTION 1 - Product Definition Section (PDS)
25 SECTION 2 - Grid Definition Section (GDS)
26 SECTION 3 - Bit-map Section (Optional)
27 SECTION 4 - Binary Data Section
28 SECTION 5 - End Section
30 ===============================================================================
32 GRIB1 Encoding Routines
34 There are several routines that one can use to encode a GRIB1 message.
35 Subroutine W3FI72 can be used to encode a GRIB1 message which is passed
36 back to the calling program in a character array.
37 It is the users responsibility to ensure that the character array that will
38 hold the packed GRIB1 message has been allocated large enough prior to
41 Another option is subroutine PUTGB. PUTGB encodes a GRIB1 message and writes
42 it to a file. The message is not returned to the calling routine.
43 The output GRIB1 data file must be opened with a call to subroutine BAOPEN
44 (or BAOPENW) prior to the call to PUTGB. A call to BACLOSE is recommended at
45 the end of the program to close the output file properly.
49 integer,dimension(200) :: KPDS,KGDS
50 logical*1,allocatable :: LB(:) ! bitmap
51 real,allocatable :: F(:) ! grid point data values
54 call baopenw(LUGB,"filename",iret)
56 ! Set up bitmap and data field
61 ! Set GRIB1 field identification values to encode
65 ! pack and write field to file
66 CALL PUTGB(LUGB,numpts,KPDS,KGDS,LB,F,iret)
69 call baclose(LUGB,iret)
74 There are other similar routines in the PUTGB family that can be used to
75 encode GRIB1 messages and write them out to a file:
76 PUTGBEX - Used to encode GRIB1 messages with NCEP PDS
77 extensions to specify ensemble information.
78 PUTGN - Allows users to specify a binary scale factor or limit amount of
79 space each data point should occupy.
81 Please see the "GRIB1 Routine Docblocks" section below for subroutine
82 argument usage for the routines mentioned above.
84 ===============================================================================
86 GRIB1 Decoding Routine
88 Subroutine W3FI63 can be used to decode a given GRIB1 message that resides
89 in a character array in memory. This routine will return the unpacked values
90 in the PDS and GDS, a bitmap array, and the unpacked grid point data values.
92 It is the users responsibility to ensure that the returned arrays have
93 been allocated large enough prior to calling W3FI63.
95 Please see the "GRIB1 Routine Docblocks" section below for subroutine
96 argument usage for the routine mentioned above.
98 ===============================================================================
100 Extracting GRIB1 Fields from a GRIB1 file
102 Subroutine GETGB can be used to extract a specified field from a file
103 containing many GRIB1 messages. GETGB searches an index to find the
104 location of the user specified field. The index can be supplied from a
105 separate GRIB1 index file, or it can be generated internally.
107 The GRIB1 data file ( and the index file, if supplied ) must be opened with
108 a call to subroutine BAOPEN prior to the call to GETGB.
110 Users can request a particular field by specifying the PDS and GDS
111 values that they wish to match. GETGB will return the PDS, GDS, bitmap,
112 and grid point data values.
117 integer,parameter :: MAXPTS=??????
118 integer,dimension(200) :: JPDS,JGDS,KPDS,KGDS
119 logical*1,dimension(MAXPTS) :: LB ! bitmap
120 real,dimension(MAXPTS) :: F ! grid point data values
124 call baopenr(LUGB,"filename",iret)
126 ! Set GRIB1 field identification values to search for
127 j=0 ! search from beginning
131 ! Get field from file
132 CALL GETGB(LUGB,LUGI,MAXPTS,J,JPDS,JGDS,
133 & KF,K,KPDS,KGDS,LB,F,IRET)
144 There are other similar routines in the GETGB family that can be used to
145 extract data from a GRIB1 file:
146 GETGBEX - Used to search for and decode GRIB1 messages using NCEP PDS
147 extensions used to specify ensemble information.
148 GETGBP - Returns the requested packed GRIB message instead of the unpacked
149 bitmap and data values.
150 GETGBH - Returns the full PDS and GDS values of the requested field
151 without having to unpack the bitmap and grid point data values.
154 Please see the "GRIB1 Routine Docblocks" section below for subroutine
155 argument usage for the routines mentioned above.
157 ===============================================================================
161 WMO's GRIB1 guide "A GUIDE TO THE CODE FORM FM 92-IX Ext. GRIB"
162 contains a description of the GRIB1 code form and the master code
163 table information. This document can be found at
164 http://www.wmo.ch/web/www/WDM/Guides/Guide-binary.html
166 In addition, NCEP Office Note 388 (http://www.nco.ncep.noaa.gov/pmb/docs/on388)
167 also contains a description of GRIB1 along with master and local NCEP
170 ===============================================================================
172 GRIB1 Routine Docblocks
174 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
176 C SUBPROGRAM: W3FI72 MAKE A COMPLETE GRIB MESSAGE
177 C PRGMMR: FARLEY ORG: NMC421 DATE:94-11-22
179 C ABSTRACT: MAKES A COMPLETE GRIB MESSAGE FROM A USER SUPPLIED
180 C ARRAY OF FLOATING POINT OR INTEGER DATA. THE USER HAS THE
181 C OPTION OF SUPPLYING THE PDS OR AN INTEGER ARRAY THAT WILL BE
182 C USED TO CREATE A PDS (WITH W3FI68). THE USER MUST ALSO
183 C SUPPLY OTHER NECESSARY INFO; SEE USAGE SECTION BELOW.
185 C PROGRAM HISTORY LOG:
187 C 92-07-01 M. FARLEY ADDED GDS AND BMS LOGIC. PLACED EXISTING
188 C LOGIC FOR BDS IN A ROUTINE.
189 C 92-10-02 R.E.JONES ADD ERROR EXIT FOR W3FI73
190 C 93-04-30 R.E.JONES REPLACE DO LOOPS TO MOVE CHARACTER DATA
191 C WITH XMOVEX, USE XSTORE TO ZERO CHARACTER
192 C ARRAY. MAKE CHANGE SO FLAT FIELD WILL PACK.
193 C 93-08-06 CAVANAUGH MODIFIED CALL TO W3FI75
194 C 93-10-26 CAVANAUGH ADDED CODE TO RESTORE INPUT FIELD TO ORIGINAL
195 C VALUES IF D-SCALE NOT 0
196 C 94-01-27 CAVANAUGH ADDED IGDS ARRAY IN CALL TO W3FI75 TO PROVIDE
197 C INFORMATION FOR BOUSTROPHEDONIC PROCESSING
198 C 94-03-03 CAVANAUGH INCREASED SIZE OF GDS ARRAY FOR THIN GRIDS
199 C 94-05-16 FARLEY CLEANED UP DOCUMENTATION
200 C 94-11-10 FARLEY INCREASED SIZE OF PFLD/IFLD ARRARYS FROM
201 C 100K TO 260K FOR .5 DEGREE SST ANAL FIELDS
202 C 94-12-04 R.E.JONES CHANGE DOCUMENT FOR IPFLAG.
203 C 95-10-31 IREDELL REMOVED SAVES AND PRINTS
204 C 98-05-19 Gilbert Increased array dimensions to handle grids
205 C of up to 500,000 grid points.
206 C 95-10-31 IREDELL GENERALIZED WORD SIZE
207 C 98-12-21 Gilbert Replaced Function ICHAR with mova2i.
208 C 99-02-01 Gilbert Changed the method of zeroing out array KBUF.
209 C the old method, using W3FI01 and XSTORE was
210 C incorrect with 4-byte integers and 8-byte reals.
211 C 2001-06-07 Gilbert Removed calls to xmovex.
212 C changed IPFLD from integer to character.
214 C USAGE: CALL W3FI72(ITYPE,FLD,IFLD,IBITL,
216 C & IGFLAG,IGRID,IGDS,ICOMP,
217 C & IBFLAG,IBMAP,IBLEN,IBDSFL,
219 C & NPTS,KBUF,ITOT,JERR)
221 C INPUT ARGUMENT LIST:
222 C ITYPE - 0 = FLOATING POINT DATA SUPPLIED IN ARRAY 'FLD'
223 C 1 = INTEGER DATA SUPPLIED IN ARRAY 'IFLD'
224 C FLD - REAL ARRAY OF DATA (AT PROPER GRIDPOINTS) TO BE
225 C CONVERTED TO GRIB FORMAT IF ITYPE=0.
226 C SEE REMARKS #1 & 2.
227 C IFLD - INTEGER ARRAY OF DATA (AT PROPER GRIDPOINTS) TO BE
228 C CONVERTED TO GRIB FORMAT IF ITYPE=1.
229 C SEE REMARKS #1 & 2.
230 C IBITL - 0 = COMPUTER COMPUTES LENGTH FOR PACKING DATA FROM
231 C POWER OF 2 (NUMBER OF BITS) BEST FIT OF DATA
232 C USING 'VARIABLE' BIT PACKER W3FI58.
233 C 8, 12, ETC. COMPUTER RESCALES DATA TO FIT INTO THAT
234 C 'FIXED' NUMBER OF BITS USING W3FI59.
237 C IPFLAG - 0 = MAKE PDS FROM USER SUPPLIED ARRAY (ID)
238 C 1 = USER SUPPLYING PDS
239 C NOTE: IF PDS IS GREATER THAN 30, USE IPLFAG=1.
240 C THE USER COULD CALL W3FI68 BEFORE HE CALLS
241 C W3FI72. THIS WOULD MAKE THE FIRST 30 BYTES OF
242 C THE PDS, USER THEN WOULD MAKE BYTES AFTER 30.
243 C ID - INTEGER ARRAY OF VALUES THAT W3FI68 WILL USE
244 C TO MAKE AN EDITION 1 PDS IF IPFLAG=0. (SEE THE
245 C DOCBLOCK FOR W3FI68 FOR LAYOUT OF ARRAY)
246 C PDS - CHARACTER ARRAY OF VALUES (VALID PDS SUPPLIED
247 C BY USER) IF IPFLAG=1. LENGTH MAY EXCEED 28 BYTES
248 C (CONTENTS OF BYTES BEYOND 28 ARE PASSED
249 C THROUGH UNCHANGED).
251 C IGFLAG - 0 = MAKE GDS BASED ON 'IGRID' VALUE.
252 C 1 = MAKE GDS FROM USER SUPPLIED INFO IN 'IGDS'
255 C IGRID - # = GRID IDENTIFICATION (TABLE B)
256 C 255 = IF USER DEFINED GRID; IGDS MUST BE SUPPLIED
257 C AND IGFLAG MUST =1.
258 C IGDS - INTEGER ARRAY CONTAINING USER GDS INFO (SAME
259 C FORMAT AS SUPPLIED BY W3FI71 - SEE DOCKBLOCK FOR
260 C LAYOUT) IF IGFLAG=1.
261 C ICOMP - RESOLUTION AND COMPONENT FLAG FOR BIT 5 OF GDS(17)
262 C 0 = EARTH ORIENTED WINDS
263 C 1 = GRID ORIENTED WINDS
265 C IBFLAG - 0 = MAKE BIT MAP FROM USER SUPPLIED DATA
266 C # = BIT MAP PREDEFINED BY CENTER
268 C IBMAP - INTEGER ARRAY CONTAINING BIT MAP
269 C IBLEN - LENGTH OF BIT MAP WILL BE USED TO VERIFY LENGTH
270 C OF FIELD (ERROR IF IT DOESN'T MATCH).
272 C IBDSFL - INTEGER ARRAY CONTAINING TABLE 11 FLAG INFO
274 C (1) 0 = GRID POINT DATA
275 C 1 = SPHERICAL HARMONIC COEFFICIENTS
276 C (2) 0 = SIMPLE PACKING
277 C 1 = SECOND ORDER PACKING
278 C (3) ... SAME VALUE AS 'ITYPE'
279 C 0 = ORIGINAL DATA WERE FLOATING POINT VALUES
280 C 1 = ORIGINAL DATA WERE INTEGER VALUES
281 C (4) 0 = NO ADDITIONAL FLAGS AT OCTET 14
282 C 1 = OCTET 14 CONTAINS FLAG BITS 5-12
283 C (5) 0 = RESERVED - ALWAYS SET TO 0
284 C BYTE 6 OPTION 1 NOT AVAILABLE (AS OF 5-16-93)
285 C (6) 0 = SINGLE DATUM AT EACH GRID POINT
286 C 1 = MATRIX OF VALUES AT EACH GRID POINT
287 C BYTE 7 OPTION 0 WITH SECOND ORDER PACKING N/A (AS OF 5-16-93)
288 C (7) 0 = NO SECONDARY BIT MAPS
289 C 1 = SECONDARY BIT MAPS PRESENT
290 C (8) 0 = SECOND ORDER VALUES HAVE CONSTANT WIDTH
291 C 1 = SECOND ORDER VALUES HAVE DIFFERENT WIDTHS
293 C OUTPUT ARGUMENT LIST:
294 C NPTS - NUMBER OF GRIDPOINTS IN ARRAY FLD OR IFLD
295 C KBUF - ENTIRE GRIB MESSAGE ('GRIB' TO '7777')
296 C EQUIVALENCE TO INTEGER ARRAY TO MAKE SURE IT
297 C IS ON WORD BOUNARY.
298 C ITOT - TOTAL LENGTH OF GRIB MESSAGE IN BYTES
299 C JERR - = 0, COMPLETED MAKING GRIB FIELD WITHOUT ERROR
300 C 1, IPFLAG NOT 0 OR 1
301 C 2, IGFLAG NOT 0 OR 1
302 C 3, ERROR CONVERTING IEEE F.P. NUMBER TO IBM370 F.P.
303 C 4, W3FI71 ERROR/IGRID NOT DEFINED
304 C 5, W3FK74 ERROR/GRID REPRESENTATION TYPE NOT VALID
305 C 6, GRID TOO LARGE FOR PACKER DIMENSION ARRAYS
306 C SEE AUTOMATION DIVISION FOR REVISION!
307 C 7, LENGTH OF BIT MAP NOT EQUAL TO SIZE OF FLD/IFLD
308 C 8, W3FI73 ERROR, ALL VALUES IN IBMAP ARE ZERO
311 C FT06F001 - STANDARD FORTRAN OUTPUT PRINT FILE
313 C SUBPROGRAMS CALLED:
315 C W3LIB - W3FI58, W3FI59, W3FI68, W3FI71, W3FI73, W3FI74
317 C FORTRAN 90 INTRINSIC - BIT_SIZE
320 C 1) IF BIT MAP TO BE INCLUDED IN MESSAGE, NULL DATA SHOULD
321 C BE INCLUDED IN FLD OR IFLD. THIS ROUTINE WILL TAKE CARE
322 C OF 'DISCARDING' ANY NULL DATA BASED ON THE BIT MAP.
323 C 2) UNITS MUST BE THOSE IN GRIB DOCUMENTATION: NMC O.N. 388
324 C OR WMO PUBLICATION 306.
325 C 3) IN EITHER CASE, INPUT NUMBERS WILL BE MULTIPLIED BY
326 C '10 TO THE NTH' POWER FOUND IN ID(25) OR PDS(27-28),
327 C THE D-SCALING FACTOR, PRIOR TO BINARY PACKING.
328 C 4) ALL NMC PRODUCED GRIB FIELDS WILL HAVE A GRID DEFINITION
329 C SECTION INCLUDED IN THE GRIB MESSAGE. ID(6) WILL BE
331 C - GDS WILL BE BUILT BASED ON GRID NUMBER (IGRID), UNLESS
332 C IGFLAG=1 (USER SUPPLYING IGDS). USER MUST STILL SUPPLY
333 C IGRID EVEN IF IGDS PROVIDED.
334 C 5) IF BIT MAP USED THEN ID(7) OR PDS(8) MUST INDICATE THE
335 C PRESENCE OF A BIT MAP.
336 C 6) ARRAY KBUF SHOULD BE EQUIVALENCED TO AN INTEGER VALUE OR
337 C ARRAY TO MAKE SURE IT IS ON A WORD BOUNDARY.
338 C 7) SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
341 C LANGUAGE: FORTRAN 90
346 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
348 C SUBPROGRAM: PUTGB PACKS AND WRITES A GRIB MESSAGE
349 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 94-04-01
351 C ABSTRACT: PACK AND WRITE A GRIB MESSAGE.
352 C THIS SUBPROGRAM IS NEARLY THE INVERSE OF GETGB.
354 C PROGRAM HISTORY LOG:
356 C 95-10-31 IREDELL REMOVED SAVES AND PRINTS
358 C USAGE: CALL PUTGB(LUGB,KF,KPDS,KGDS,LB,F,IRET)
360 C LUGB INTEGER UNIT OF THE UNBLOCKED GRIB DATA FILE
361 C KF INTEGER NUMBER OF DATA POINTS
362 C KPDS INTEGER (200) PDS PARAMETERS
364 C (2) - GENERATING PROCESS ID NUMBER
365 C (3) - GRID DEFINITION
366 C (4) - GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8)
367 C (5) - INDICATOR OF PARAMETER
368 C (6) - TYPE OF LEVEL
369 C (7) - HEIGHT/PRESSURE , ETC OF LEVEL
370 C (8) - YEAR INCLUDING (CENTURY-1)
371 C (9) - MONTH OF YEAR
372 C (10) - DAY OF MONTH
374 C (12) - MINUTE OF HOUR
375 C (13) - INDICATOR OF FORECAST TIME UNIT
376 C (14) - TIME RANGE 1
377 C (15) - TIME RANGE 2
378 C (16) - TIME RANGE FLAG
379 C (17) - NUMBER INCLUDED IN AVERAGE
380 C (18) - VERSION NR OF GRIB SPECIFICATION
381 C (19) - VERSION NR OF PARAMETER TABLE
382 C (20) - NR MISSING FROM AVERAGE/ACCUMULATION
383 C (21) - CENTURY OF REFERENCE TIME OF DATA
384 C (22) - UNITS DECIMAL SCALE FACTOR
385 C (23) - SUBCENTER NUMBER
386 C (24) - PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS
387 C 128 IF FORECAST FIELD ERROR
388 C 64 IF BIAS CORRECTED FCST FIELD
389 C 32 IF SMOOTHED FIELD
390 C WARNING: CAN BE COMBINATION OF MORE THAN 1
391 C (25) - PDS BYTE 30, NOT USED
392 C KGDS INTEGER (200) GDS PARAMETERS
393 C (1) - DATA REPRESENTATION TYPE
394 C (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS
395 C (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE
398 C OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS
401 C 255 IF NEITHER ARE PRESENT
402 C (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID
403 C (22) - NUMBER OF WORDS IN EACH ROW
404 C LATITUDE/LONGITUDE GRIDS
405 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
406 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
407 C (4) - LA(1) LATITUDE OF ORIGIN
408 C (5) - LO(1) LONGITUDE OF ORIGIN
409 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
410 C (7) - LA(2) LATITUDE OF EXTREME POINT
411 C (8) - LO(2) LONGITUDE OF EXTREME POINT
412 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
413 C (10) - DJ LATITUDINAL DIRECTION INCREMENT
414 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
416 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
417 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
418 C (4) - LA(1) LATITUDE OF ORIGIN
419 C (5) - LO(1) LONGITUDE OF ORIGIN
420 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
421 C (7) - LA(2) LATITUDE OF EXTREME POINT
422 C (8) - LO(2) LONGITUDE OF EXTREME POINT
423 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
424 C (10) - N - NR OF CIRCLES POLE TO EQUATOR
425 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
426 C (12) - NV - NR OF VERT COORD PARAMETERS
427 C (13) - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS
429 C PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN
430 C EACH ROW (IF NO VERT COORD PARAMETERS
433 C 255 IF NEITHER ARE PRESENT
434 C POLAR STEREOGRAPHIC GRIDS
435 C (2) - N(I) NR POINTS ALONG LAT CIRCLE
436 C (3) - N(J) NR POINTS ALONG LON CIRCLE
437 C (4) - LA(1) LATITUDE OF ORIGIN
438 C (5) - LO(1) LONGITUDE OF ORIGIN
439 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
440 C (7) - LOV GRID ORIENTATION
441 C (8) - DX - X DIRECTION INCREMENT
442 C (9) - DY - Y DIRECTION INCREMENT
443 C (10) - PROJECTION CENTER FLAG
444 C (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28)
445 C SPHERICAL HARMONIC COEFFICIENTS
446 C (2) - J PENTAGONAL RESOLUTION PARAMETER
449 C (5) - REPRESENTATION TYPE
450 C (6) - COEFFICIENT STORAGE MODE
452 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
453 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
454 C (4) - LA(1) LATITUDE OF ORIGIN
455 C (5) - LO(1) LONGITUDE OF ORIGIN
456 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
457 C (7) - LA(2) LATITUDE OF LAST GRID POINT
458 C (8) - LO(2) LONGITUDE OF LAST GRID POINT
459 C (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION
461 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
462 C (12) - LONGITUDINAL DIR GRID LENGTH
463 C (13) - LATITUDINAL DIR GRID LENGTH
464 C LAMBERT CONFORMAL GRIDS
465 C (2) - NX NR POINTS ALONG X-AXIS
466 C (3) - NY NR POINTS ALONG Y-AXIS
467 C (4) - LA1 LAT OF ORIGIN (LOWER LEFT)
468 C (5) - LO1 LON OF ORIGIN (LOWER LEFT)
469 C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17)
470 C (7) - LOV - ORIENTATION OF GRID
471 C (8) - DX - X-DIR INCREMENT
472 C (9) - DY - Y-DIR INCREMENT
473 C (10) - PROJECTION CENTER FLAG
474 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
475 C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER
476 C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER
477 C LB LOGICAL*1 (KF) BITMAP IF PRESENT
480 C IRET INTEGER RETURN CODE
482 C OTHER W3FI72 GRIB PACKER RETURN CODE
484 C SUBPROGRAMS CALLED:
485 C R63W72 MAP W3FI63 PARAMETERS ONTO W3FI72 PARAMETERS
486 C GETBIT GET NUMBER OF BITS AND ROUND DATA
490 C REMARKS: SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
491 C DO NOT ENGAGE THE SAME LOGICAL UNIT FROM MORE THAN ONE PROCESSOR.
494 C LANGUAGE: FORTRAN 77
495 C MACHINE: CRAY, WORKSTATIONS
501 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
503 C SUBPROGRAM: W3FI63 UNPK GRIB FIELD TO GRIB GRID
504 C PRGMMR: FARLEY ORG: NMC421 DATE:94-11-22
506 C ABSTRACT: UNPACK A GRIB (EDITION 1) FIELD TO THE EXACT GRID
507 C SPECIFIED IN THE GRIB MESSAGE, ISOLATE THE BIT MAP, AND MAKE
508 C THE VALUES OF THE PRODUCT DESCRIPTON SECTION (PDS) AND THE
509 C GRID DESCRIPTION SECTION (GDS) AVAILABLE IN RETURN ARRAYS.
511 C WHEN DECODING IS COMPLETED, DATA AT EACH GRID POINT HAS BEEN
512 C RETURNED IN THE UNITS SPECIFIED IN THE GRIB MANUAL.
514 C PROGRAM HISTORY LOG:
516 C 91-11-12 CAVANAUGH MODIFIED SIZE OF ECMWF GRIDS 5-8
517 C 91-12-22 CAVANAUGH CORRECTED PROCESSING OF MERCATOR PROJECTIONS
518 C IN GRID DEFINITION SECTION (GDS) IN
520 C 92-08-05 CAVANAUGH CORRECTED MAXIMUM GRID SIZE TO ALLOW FOR
521 C ONE DEGREE BY ONE DEGREE GLOBAL GRIDS
522 C 92-08-27 CAVANAUGH CORRECTED TYPO ERROR, ADDED CODE TO COMPARE
523 C TOTAL BYTE SIZE FROM SECTION 0 WITH SUM OF
525 C 92-10-21 CAVANAUGH CORRECTIONS WERE MADE (IN FI634) TO REDUCE
526 C PROCESSING TIME FOR INTERNATIONAL GRIDS.
527 C REMOVED A TYPOGRAPHICAL ERROR IN FI635.
528 C 93-01-07 CAVANAUGH CORRECTIONS WERE MADE (IN FI635) TO
529 C FACILITATE USE OF THESE ROUTINES ON A PC.
530 C A TYPOGRAPHICAL ERROR WAS ALSO CORRECTED
531 C 93-01-13 CAVANAUGH CORRECTIONS WERE MADE (IN FI632) TO
532 C PROPERLY HANDLE CONDITION WHEN
533 C TIME RANGE INDICATOR = 10.
535 C 93-02-04 CAVANAUGH ADDED U.S.GRIDS 85 AND 86
536 C 93-02-26 CAVANAUGH ADDED GRIDS 2, 3, 37 THRU 44,AND
537 C GRIDS 55, 56, 90, 91, 92, AND 93 TO
538 C LIST OF U.S. GRIDS.
539 C 93-04-07 CAVANAUGH ADDED GRIDS 67 THRU 77 TO
540 C LIST OF U.S. GRIDS.
541 C 93-04-20 CAVANAUGH INCREASED MAX SIZE TO ACCOMODATE
543 C 93-05-26 CAVANAUGH CORRECTED GRID RANGE SELECTION IN FI634
544 C FOR RANGES 67-71 & 75-77
545 C 93-06-08 CAVANAUGH CORRECTED FI635 TO ACCEPT GRIB MESSAGES
546 C WITH SECOND ORDER PACKING. ADDED ROUTINE FI636
547 C TO PROCESS MESSAGES WITH SECOND ORDER PACKING.
548 C 93-09-22 CAVANAUGH MODIFIED TO EXTRACT SUB-CENTER NUMBER FROM
550 C 93-10-13 CAVANAUGH MODIFIED FI634 TO CORRECT GRID SIZES FOR
552 C 93-10-14 CAVANAUGH INCREASED SIZE OF KGDS TO INCLUDE ENTRIES FOR
553 C NUMBER OF POINTS IN GRID AND NUMBER OF WORDS
555 C 93-12-08 CAVANAUGH CORRECTED TEST FOR EDITION NUMBER INSTEAD
557 C 93-12-15 CAVANAUGH MODIFIED SECOND ORDER POINTERS TO FIRST ORDER
558 C VALUES AND SECOND ORDER VALUES CORRECTLY
560 C 94-03-02 CAVANAUGH ADDED CALL TO W3FI83 WITHIN DECODER. USER
561 C NO LONGER NEEDS TO MAKE CALL TO THIS ROUTINE
562 C 94-04-22 CAVANAUGH MODIFIED FI635, FI636 TO PROCESS ROW BY ROW
563 C SECOND ORDER PACKING, ADDED SCALING CORRECTION
564 C TO FI635, AND CORRECTED TYPOGRAPHICAL ERRORS
565 C IN COMMENT FIELDS IN FI634
566 C 94-05-17 CAVANAUGH CORRECTED ERROR IN FI633 TO EXTRACT RESOLUTION
567 C FOR LAMBERT-CONFORMAL GRIDS. ADDED CLARIFYING
568 C INFORMATION TO DOCBLOCK ENTRIES
569 C 94-05-25 CAVANAUGH ADDED CODE TO PROCESS COLUMN BY COLUMN AS WELL
570 C AS ROW BY ROW ORDERING OF SECOND ORDER DATA
571 C 94-06-27 CAVANAUGH ADDED PROCESSING FOR GRIDS 45, 94 AND 95.
572 C INCLUDES CONSTRUCTION OF SECOND ORDER BIT MAPS
573 C FOR THINNED GRIDS IN FI636.
574 C 94-07-08 CAVANAUGH COMMENTED OUT PRINT OUTS USED FOR DEBUGGING
575 C 94-09-08 CAVANAUGH ADDED GRIDS 220, 221, 223 FOR FNOC
576 C 94-11-10 FARLEY INCREASED MXSIZE FROM 72960 TO 260000
577 C FOR .5 DEGREE SST ANALYSIS FIELDS
578 C 94-12-06 R.E.JONES CHANGES IN FI632 FOR PDS GREATER THAN 28
579 C 95-02-14 R.E.JONES CORRECT IN FI633 FOR NAVY WAFS GRIB
580 C 95-03-20 M.BALDWIN FI633 MODIFICATION TO GET
581 C DATA REP TYPES [KGDS(1)] 201 AND 202 TO WORK.
582 C 95-04-10 E.ROGERS ADDED GRIDS 96 AND 97 FOR ETA MODEL IN FI634.
583 C 95-04-26 R.E.JONES FI636 CORECTION FOR 2ND ORDER COMPLEX
585 C 95-05-19 R.E.JONES ADDED GRID 215, 20 KM AWIPS GRID
586 C 95-07-06 R.E.JONES ADDED GAUSSIAN T62, T126 GRID 98, 126
587 C 95-10-19 R.E.JONES ADDED GRID 216, 45 KM ETA AWIPS ALASKA GRID
588 C 95-10-31 IREDELL REMOVED SAVES AND PRINTS
589 C 96-03-07 R.E.JONES CONTINUE UNPACK WITH KRET ERROR 9 IN FI631.
590 C 96-08-19 R.E.JONES ADDED MERCATOR GRIDS 8 AND 53, AND GRID 196
591 C 97-02-12 W BOSTELMAN CORRECTS ECMWF US GRID 2 PROCESSING
592 C 98-06-17 IREDELL REMOVED ALTERNATE RETURN IN FI637
593 C 98-08-31 IREDELL ELIMINATED NEED FOR MXSIZE
594 C 98-09-02 Gilbert Corrected error in map size for U.S. Grid 92
595 C 98-09-08 BALDWIN ADD DATA REP TYPE [KGDS(1)] 203
596 C 01-03-08 ROGERS CHANGED ETA GRIDS 90-97, ADDED ETA GRIDS
597 C 194, 198. ADDED AWIPS GRIDS 241,242,243,
598 C 245, 246, 247, 248, AND 250
599 C 01-03-19 VUONG ADDED AWIPS GRIDS 238,239,240, AND 244.
600 C 2001-06-06 GILBERT CHanged gbyte/sbyte calls to refer to
601 C Wesley Ebisuzaki's endian independent
602 C versions gbytec/sbytec.
603 C Removed equivalences.
604 C 01-05-03 ROGERS ADDED GRID 249 (12KM FOR ALASKA)
605 C 01-10-10 ROGERS REDEFINED GRID 218 FOR 12 KM ETA
606 C REDEFINED GRID 192 FOR NEW 32-KM ETA GRID
607 C 02-03-27 VUONG ADDED RSAS GRID 88 AND AWIPS GRIDS 219, 220,
608 C 223, 224, 225, 226, 227, 228, 229, 230, 231,
609 C 232, 233, 234, 235, 251, AND 252
610 C 02-08-06 ROGERS REDEFINED GRIDS 90-93,97,194,245-250 FOR THE
611 C 8KM HI-RES-WINDOW MODEL AND ADD AWIPS GRID 253
612 C 2003-06-30 GILBERT SET NEW VALUES IN ARRAY KPTR TO PASS BACK ADDITIONAL
614 C KPTR(19) - BINARY SCALE FACTOR
615 C KPTR(20) - NUM BITS USED TO PACK EACH DATUM
616 C 2003-06-30 GILBERT ADDED GRIDS 145 and 146 for CMAQ
617 C and GRID 175 for AWIPS over GUAM.
618 C 2003-07-08 VUONG ADDED GRIDS 110, 127, 171, 172 AND MODIFIED GRID 170
620 C USAGE: CALL W3FI63(MSGA,KPDS,KGDS,KBMS,DATA,KPTR,KRET)
621 C INPUT ARGUMENT LIST:
622 C MSGA - GRIB FIELD - "GRIB" THRU "7777" CHAR*1
623 C (MESSAGE CAN BE PRECEDED BY JUNK CHARS)
625 C OUTPUT ARGUMENT LIST:
626 C DATA - ARRAY CONTAINING DATA ELEMENTS
627 C KPDS - ARRAY CONTAINING PDS ELEMENTS. (EDITION 1)
629 C (2) - GENERATING PROCESS ID NUMBER
630 C (3) - GRID DEFINITION
631 C (4) - GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8)
632 C (5) - INDICATOR OF PARAMETER
633 C (6) - TYPE OF LEVEL
634 C (7) - HEIGHT/PRESSURE , ETC OF LEVEL
635 C (8) - YEAR INCLUDING (CENTURY-1)
636 C (9) - MONTH OF YEAR
637 C (10) - DAY OF MONTH
639 C (12) - MINUTE OF HOUR
640 C (13) - INDICATOR OF FORECAST TIME UNIT
641 C (14) - TIME RANGE 1
642 C (15) - TIME RANGE 2
643 C (16) - TIME RANGE FLAG
644 C (17) - NUMBER INCLUDED IN AVERAGE
645 C (18) - VERSION NR OF GRIB SPECIFICATION
646 C (19) - VERSION NR OF PARAMETER TABLE
647 C (20) - NR MISSING FROM AVERAGE/ACCUMULATION
648 C (21) - CENTURY OF REFERENCE TIME OF DATA
649 C (22) - UNITS DECIMAL SCALE FACTOR
650 C (23) - SUBCENTER NUMBER
651 C (24) - PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS
652 C 128 IF FORECAST FIELD ERROR
653 C 64 IF BIAS CORRECTED FCST FIELD
654 C 32 IF SMOOTHED FIELD
655 C WARNING: CAN BE COMBINATION OF MORE THAN 1
656 C (25) - PDS BYTE 30, NOT USED
658 C (36-N) - CONSECUTIVE BYTES EXTRACTED FROM PROGRAM
659 C DEFINITION SECTION (PDS) OF GRIB MESSAGE
660 C KGDS - ARRAY CONTAINING GDS ELEMENTS.
661 C (1) - DATA REPRESENTATION TYPE
662 C (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS
663 C (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE
666 C OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS
669 C 255 IF NEITHER ARE PRESENT
670 C (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID
671 C (22) - NUMBER OF WORDS IN EACH ROW
672 C LATITUDE/LONGITUDE GRIDS
673 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
674 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
675 C (4) - LA(1) LATITUDE OF ORIGIN
676 C (5) - LO(1) LONGITUDE OF ORIGIN
677 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
678 C (7) - LA(2) LATITUDE OF EXTREME POINT
679 C (8) - LO(2) LONGITUDE OF EXTREME POINT
680 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
681 C (10) - DJ LATITUDINAL DIRECTION INCREMENT
682 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
684 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
685 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
686 C (4) - LA(1) LATITUDE OF ORIGIN
687 C (5) - LO(1) LONGITUDE OF ORIGIN
688 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
689 C (7) - LA(2) LATITUDE OF EXTREME POINT
690 C (8) - LO(2) LONGITUDE OF EXTREME POINT
691 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
692 C (10) - N - NR OF CIRCLES POLE TO EQUATOR
693 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
694 C (12) - NV - NR OF VERT COORD PARAMETERS
695 C (13) - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS
697 C PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN
698 C EACH ROW (IF NO VERT COORD PARAMETERS
701 C 255 IF NEITHER ARE PRESENT
702 C POLAR STEREOGRAPHIC GRIDS
703 C (2) - N(I) NR POINTS ALONG LAT CIRCLE
704 C (3) - N(J) NR POINTS ALONG LON CIRCLE
705 C (4) - LA(1) LATITUDE OF ORIGIN
706 C (5) - LO(1) LONGITUDE OF ORIGIN
707 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
708 C (7) - LOV GRID ORIENTATION
709 C (8) - DX - X DIRECTION INCREMENT
710 C (9) - DY - Y DIRECTION INCREMENT
711 C (10) - PROJECTION CENTER FLAG
712 C (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28)
713 C SPHERICAL HARMONIC COEFFICIENTS
714 C (2) - J PENTAGONAL RESOLUTION PARAMETER
717 C (5) - REPRESENTATION TYPE
718 C (6) - COEFFICIENT STORAGE MODE
720 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
721 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
722 C (4) - LA(1) LATITUDE OF ORIGIN
723 C (5) - LO(1) LONGITUDE OF ORIGIN
724 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
725 C (7) - LA(2) LATITUDE OF LAST GRID POINT
726 C (8) - LO(2) LONGITUDE OF LAST GRID POINT
727 C (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION
729 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
730 C (12) - LONGITUDINAL DIR GRID LENGTH
731 C (13) - LATITUDINAL DIR GRID LENGTH
732 C LAMBERT CONFORMAL GRIDS
733 C (2) - NX NR POINTS ALONG X-AXIS
734 C (3) - NY NR POINTS ALONG Y-AXIS
735 C (4) - LA1 LAT OF ORIGIN (LOWER LEFT)
736 C (5) - LO1 LON OF ORIGIN (LOWER LEFT)
737 C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17)
738 C (7) - LOV - ORIENTATION OF GRID
739 C (8) - DX - X-DIR INCREMENT
740 C (9) - DY - Y-DIR INCREMENT
741 C (10) - PROJECTION CENTER FLAG
742 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
743 C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER
744 C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER
745 C STAGGERED ARAKAWA ROTATED LAT/LON GRIDS (TYPE 203)
746 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
747 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
748 C (4) - LA(1) LATITUDE OF ORIGIN
749 C (5) - LO(1) LONGITUDE OF ORIGIN
750 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
751 C (7) - LA(2) LATITUDE OF CENTER
752 C (8) - LO(2) LONGITUDE OF CENTER
753 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
754 C (10) - DJ LATITUDINAL DIRECTION INCREMENT
755 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
756 C KBMS - BITMAP DESCRIBING LOCATION OF OUTPUT ELEMENTS.
757 C (ALWAYS CONSTRUCTED)
758 C KPTR - ARRAY CONTAINING STORAGE FOR FOLLOWING PARAMETERS
759 C (1) - TOTAL LENGTH OF GRIB MESSAGE
760 C (2) - LENGTH OF INDICATOR (SECTION 0)
761 C (3) - LENGTH OF PDS (SECTION 1)
762 C (4) - LENGTH OF GDS (SECTION 2)
763 C (5) - LENGTH OF BMS (SECTION 3)
764 C (6) - LENGTH OF BDS (SECTION 4)
765 C (7) - VALUE OF CURRENT BYTE
767 C (9) - GRIB START BIT NR
768 C (10) - GRIB/GRID ELEMENT COUNT
769 C (11) - NR UNUSED BITS AT END OF SECTION 3
770 C (12) - BIT MAP FLAG (COPY OF BMS OCTETS 5,6)
771 C (13) - NR UNUSED BITS AT END OF SECTION 2
772 C (14) - BDS FLAGS (RIGHT ADJ COPY OF OCTET 4)
773 C (15) - NR UNUSED BITS AT END OF SECTION 4
777 C (19) - BINARY SCALE FACTOR
778 C (20) - NUM BITS USED TO PACK EACH DATUM
779 C KRET - FLAG INDICATING QUALITY OF COMPLETION
781 C REMARKS: WHEN DECODING IS COMPLETED, DATA AT EACH GRID POINT HAS BEEN
782 C RETURNED IN THE UNITS SPECIFIED IN THE GRIB MANUAL.
784 C VALUES FOR RETURN FLAG (KRET)
785 C KRET = 0 - NORMAL RETURN, NO ERRORS
786 C = 1 - 'GRIB' NOT FOUND IN FIRST 100 CHARS
787 C = 2 - '7777' NOT IN CORRECT LOCATION
788 C = 3 - UNPACKED FIELD IS LARGER THAN 260000
789 C = 4 - GDS/ GRID NOT ONE OF CURRENTLY ACCEPTED VALUES
790 C = 5 - GRID NOT CURRENTLY AVAIL FOR CENTER INDICATED
791 C = 8 - TEMP GDS INDICATED, BUT GDS FLAG IS OFF
792 C = 9 - GDS INDICATES SIZE MISMATCH WITH STD GRID
793 C =10 - INCORRECT CENTER INDICATOR
794 C =11 - BINARY DATA SECTION (BDS) NOT COMPLETELY PROCESSED.
795 C PROGRAM IS NOT SET TO PROCESS FLAG COMBINATIONS
796 C SHOWN IN OCTETS 4 AND 14.
797 C =12 - BINARY DATA SECTION (BDS) NOT COMPLETELY PROCESSED.
798 C PROGRAM IS NOT SET TO PROCESS FLAG COMBINATIONS
800 C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT.
803 C LANGUAGE: FORTRAN 90
810 C GRIB UNPACKING ROUTINE
813 C THIS ROUTINE WILL UNPACK A 'GRIB' FIELD TO THE EXACT GRID
814 C TYPE SPECIFIED IN THE MESSAGE, RETURN A BIT MAP AND MAKE THE
815 C VALUES OF THE PRODUCT DEFINITION SEC (PDS) AND THE GRID
816 C DESCRIPTION SEC (GDS) AVAILABLE IN RETURN ARRAYS.
817 C SEE "GRIB - THE WMO FORMAT FOR THE STORAGE OF WEATHER PRODUCT
818 C INFORMATION AND THE EXCHANGE OF WEATHER PRODUCT MESSAGES IN
819 C GRIDDED BINARY FORM" DATED JULY 1, 1988 BY JOHN D. STACKPOLE
820 C DOC, NOAA, NWS, NATIONAL METEOROLOGICAL CENTER.
822 C THE CALL TO THE GRIB UNPACKING ROUTINE IS AS FOLLOWS:
824 C CALL W3FI63(MSGA,KPDS,KGDS,LBMS,DATA,KPTR,KRET)
828 C MSGA = CONTAINS THE GRIB MESSAGE TO BE UNPACKED. CHARACTERS
829 C "GRIB" MAY BEGIN ANYWHERE WITHIN FIRST 100 BYTES.
833 C KPDS(100) INTEGER*4
834 C ARRAY TO CONTAIN THE ELEMENTS OF THE PRODUCT
837 C KPDS(1) - ID OF CENTER
838 C KPDS(2) - MODEL IDENTIFICATION (SEE "GRIB" TABLE 1)
839 C KPDS(3) - GRID IDENTIFICATION (SEE "GRIB" TABLE 2)
840 C KPDS(4) - GDS/BMS FLAG
846 C NOTE:- LEFTMOST BIT = 1,
848 C KPDS(5) - INDICATOR OF PARAMETER (SEE "GRIB" TABLE 5)
849 C KPDS(6) - TYPE OF LEVEL (SEE "GRIB" TABLES 6 & 7)
850 C KPDS(7) - HEIGHT,PRESSURE,ETC OF LEVEL
851 C KPDS(8) - YEAR INCLUDING CENTURY
852 C KPDS(9) - MONTH OF YEAR
853 C KPDS(10) - DAY OF MONTH
854 C KPDS(11) - HOUR OF DAY
855 C KPDS(12) - MINUTE OF HOUR
856 C KPDS(13) - INDICATOR OF FORECAST TIME UNIT (SEE "GRIB"
858 C KPDS(14) - TIME 1 (SEE "GRIB" TABLE 8A)
859 C KPDS(15) - TIME 2 (SEE "GRIB" TABLE 8A)
860 C KPDS(16) - TIME RANGE INDICATOR (SEE "GRIB" TABLE 8A)
861 C KPDS(17) - NUMBER INCLUDED IN AVERAGE
862 C KPDS(18) - EDITION NR OF GRIB SPECIFICATION
863 C KPDS(19) - VERSION NR OF PARAMETER TABLE
866 C ARRAY CONTAINING GDS ELEMENTS.
868 C KGDS(1) - DATA REPRESENTATION TYPE
870 C LATITUDE/LONGITUDE GRIDS (SEE "GRIB" TABLE 10)
871 C KGDS(2) - N(I) NUMBER OF POINTS ON LATITUDE
873 C KGDS(3) - N(J) NUMBER OF POINTS ON LONGITUDE
875 C KGDS(4) - LA(1) LATITUDE OF ORIGIN
876 C KGDS(5) - LO(1) LONGITUDE OF ORIGIN
877 C KGDS(6) - RESOLUTION FLAG
879 C 25 0 - DIRECTION INCREMENTS NOT
881 C 1 - DIRECTION INCREMENTS GIVEN
882 C KGDS(7) - LA(2) LATITUDE OF EXTREME POINT
883 C KGDS(8) - LO(2) LONGITUDE OF EXTREME POINT
884 C KGDS(9) - DI LONGITUDINAL DIRECTION INCREMENT
885 C KGDS(10) - REGULAR LAT/LON GRID
886 C DJ - LATITUDINAL DIRECTION
889 C N - NUMBER OF LATITUDE CIRCLES
890 C BETWEEN A POLE AND THE EQUATOR
891 C KGDS(11) - SCANNING MODE FLAG
893 C 25 0 - POINTS ALONG A LATITUDE
894 C SCAN FROM WEST TO EAST
895 C 1 - POINTS ALONG A LATITUDE
896 C SCAN FROM EAST TO WEST
897 C 26 0 - POINTS ALONG A MERIDIAN
898 C SCAN FROM NORTH TO SOUTH
899 C 1 - POINTS ALONG A MERIDIAN
900 C SCAN FROM SOUTH TO NORTH
901 C 27 0 - POINTS SCAN FIRST ALONG
902 C CIRCLES OF LATITUDE, THEN
905 C 1 - POINTS SCAN FIRST ALONG
906 C MERIDIANS THEN ALONG
907 C CIRCLES OF LATITUDE
910 C POLAR STEREOGRAPHIC GRIDS (SEE GRIB TABLE 12)
911 C KGDS(2) - N(I) NR POINTS ALONG LAT CIRCLE
912 C KGDS(3) - N(J) NR POINTS ALONG LON CIRCLE
913 C KGDS(4) - LA(1) LATITUDE OF ORIGIN
914 C KGDS(5) - LO(1) LONGITUDE OF ORIGIN
916 C KGDS(7) - LOV GRID ORIENTATION
917 C KGDS(8) - DX - X DIRECTION INCREMENT
918 C KGDS(9) - DY - Y DIRECTION INCREMENT
919 C KGDS(10) - PROJECTION CENTER FLAG
920 C KGDS(11) - SCANNING MODE
922 C SPHERICAL HARMONIC COEFFICIENTS (SEE "GRIB" TABLE 14)
923 C KGDS(2) - J PENTAGONAL RESOLUTION PARAMETER
924 C KGDS(3) - K PENTAGONAL RESOLUTION PARAMETER
925 C KGDS(4) - M PENTAGONAL RESOLUTION PARAMETER
926 C KGDS(5) - REPRESENTATION TYPE
927 C KGDS(6) - COEFFICIENT STORAGE MODE
930 C KGDS(2) - N(I) NR POINTS ON LATITUDE CIRCLE
931 C KGDS(3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
932 C KGDS(4) - LA(1) LATITUDE OF ORIGIN
933 C KGDS(5) - LO(1) LONGITUDE OF ORIGIN
934 C KGDS(6) - RESOLUTION FLAG
935 C KGDS(7) - LA(2) LATITUDE OF LAST GRID POINT
936 C KGDS(8) - LO(2) LONGITUDE OF LAST GRID POINT
937 C KGDS(9) - LATIN - LATITUDE OF PROJECTION INTERSECTION
938 C KGDS(10) - RESERVED
939 C KGDS(11) - SCANNING MODE FLAG
940 C KGDS(12) - LONGITUDINAL DIR GRID LENGTH
941 C KGDS(13) - LATITUDINAL DIR GRID LENGTH
942 C LAMBERT CONFORMAL GRIDS
943 C KGDS(2) - NX NR POINTS ALONG X-AXIS
944 C KGDS(3) - NY NR POINTS ALONG Y-AXIS
945 C KGDS(4) - LA1 LAT OF ORIGIN (LOWER LEFT)
946 C KGDS(5) - LO1 LON OF ORIGIN (LOWER LEFT)
947 C KGDS(6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17)
948 C KGDS(7) - LOV - ORIENTATION OF GRID
949 C KGDS(8) - DX - X-DIR INCREMENT
950 C KGDS(9) - DY - Y-DIR INCREMENT
951 C KGDS(10) - PROJECTION CENTER FLAG
952 C KGDS(11) - SCANNING MODE FLAG
953 C KGDS(12) - LATIN 1 - FIRST LAT FROM POLE OF
954 C SECANT CONE INTERSECTION
955 C KGDS(13) - LATIN 2 - SECOND LAT FROM POLE OF
956 C SECANT CONE INTERSECTION
959 C ARRAY TO CONTAIN THE BIT MAP DESCRIBING THE
960 C PLACEMENT OF DATA IN THE OUTPUT ARRAY. IF A
961 C BIT MAP IS NOT INCLUDED IN THE SOURCE MESSAGE,
962 C ONE WILL BE GENERATED AUTOMATICALLY BY THE
967 C THIS ARRAY WILL CONTAIN THE UNPACKED DATA POINTS.
969 C NOTE:- 65160 IS MAXIMUN FIELD SIZE ALLOWABLE
972 C ARRAY CONTAINING STORAGE FOR THE FOLLOWING
977 C (3) - LENGTH OF PDS (IN BYTES)
978 C (4) - LENGTH OF GDS (IN BYTES)
979 C (5) - LENGTH OF BMS (IN BYTES)
980 C (6) - LENGTH OF BDS (IN BYTES)
981 C (7) - USED BY UNPACKING ROUTINE
982 C (8) - NUMBER OF DATA POINTS FOR GRID
983 C (9) - "GRIB" CHARACTERS START IN BYTE NUMBER
984 C (10) - USED BY UNPACKING ROUTINE
988 C THIS VARIABLE WILL CONTAIN THE RETURN INDICATOR.
990 C 0 - NO ERRORS DETECTED.
992 C 1 - 'GRIB' NOT FOUND IN FIRST 100
995 C 2 - '7777' NOT FOUND, EITHER MISSING OR
996 C TOTAL OF SEC COUNTS OF INDIVIDUAL
997 C SECTIONS IS INCORRECT.
999 C 3 - UNPACKED FIELD IS LARGER THAN 65160.
1001 C 4 - IN GDS, DATA REPRESENTATION TYPE
1002 C NOT ONE OF THE CURRENTLY ACCEPTABLE
1003 C VALUES. SEE "GRIB" TABLE 9. VALUE
1004 C OF INCORRECT TYPE RETURNED IN KGDS(1).
1006 C 5 - GRID INDICATED IN KPDS(3) IS NOT
1007 C AVAILABLE FOR THE CENTER INDICATED IN
1008 C KPDS(1) AND NO GDS SENT.
1010 C 7 - EDITION INDICATED IN KPDS(18) HAS NOT
1011 C YET BEEN INCLUDED IN THE DECODER.
1013 C 8 - GRID IDENTIFICATION = 255 (NOT STANDARD
1014 C GRID) BUT FLAG INDICATING PRESENCE OF
1015 C GDS IS TURNED OFF. NO METHOD OF
1016 C GENERATING PROPER GRID.
1018 C 9 - PRODUCT OF KGDS(2) AND KGDS(3) DOES NOT
1019 C MATCH STANDARD NUMBER OF POINTS FOR THIS
1020 C GRID (FOR OTHER THAN SPECTRALS). THIS
1021 C WILL OCCUR ONLY IF THE GRID.
1022 C IDENTIFICATION, KPDS(3), AND A
1023 C TRANSMITTED GDS ARE INCONSISTENT.
1025 C 10 - CENTER INDICATOR WAS NOT ONE INDICATED
1026 C IN "GRIB" TABLE 1. PLEASE CONTACT AD
1027 C PRODUCTION MANAGEMENT BRANCH (W/NMC42)
1028 C IF THIS ERROR IS ENCOUNTERED.
1030 C 11 - BINARY DATA SECTION (BDS) NOT COMPLETELY
1031 C PROCESSED. PROGRAM IS NOT SET TO PROCESS
1032 C FLAG COMBINATIONS AS SHOWN IN
1036 C LIST OF TEXT MESSAGES FROM CODE
1041 C 'HAVE ENCOUNTERED A NEW GRID FOR NMC, PLEASE NOTIFY
1042 C AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH
1045 C 'HAVE ENCOUNTERED A NEW GRID FOR ECMWF, PLEASE NOTIFY
1046 C AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH
1049 C 'HAVE ENCOUNTERED A NEW GRID FOR U.K. METEOROLOGICAL
1050 C OFFICE, BRACKNELL. PLEASE NOTIFY AUTOMATION DIVISION,
1051 C PRODUCTION MANAGEMENT BRANCH (W/NMC42)'
1053 C 'HAVE ENCOUNTERED A NEW GRID FOR FNOC, PLEASE NOTIFY
1054 C AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH
1060 C 'POLAR STEREO PROCESSING NOT AVAILABLE' *
1064 C 'WARNING - BIT MAP MAY NOT BE ASSOCIATED WITH SPHERICAL
1070 C 'NO CURRENT LISTING OF FNOC GRIDS' *
1073 C * WILL BE AVAILABLE IN NEXT UPDATE
1074 C ***************************************************************
1078 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
1080 C SUBPROGRAM: GETGB FINDS AND UNPACKS A GRIB MESSAGE
1081 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 94-04-01
1083 C ABSTRACT: FIND AND UNPACK A GRIB MESSAGE.
1084 C READ A GRIB INDEX FILE (OR OPTIONALLY THE GRIB FILE ITSELF)
1085 C TO GET THE INDEX BUFFER (I.E. TABLE OF CONTENTS) FOR THE GRIB FILE.
1086 C (THE INDEX BUFFER IS SAVED FOR USE BY FUTURE PROSPECTIVE CALLS.)
1087 C FIND IN THE INDEX BUFFER A REFERENCE TO THE GRIB MESSAGE REQUESTED.
1088 C THE GRIB MESSAGE REQUEST SPECIFIES THE NUMBER OF MESSAGES TO SKIP
1089 C AND THE UNPACKED PDS AND GDS PARAMETERS. (A REQUESTED PARAMETER
1090 C OF -1 MEANS TO ALLOW ANY VALUE OF THIS PARAMETER TO BE FOUND.)
1091 C IF THE REQUESTED GRIB MESSAGE IS FOUND, THEN IT IS READ FROM THE
1092 C GRIB FILE AND UNPACKED. ITS MESSAGE NUMBER IS RETURNED ALONG WITH
1093 C THE UNPACKED PDS AND GDS PARAMETERS, THE UNPACKED BITMAP (IF ANY),
1094 C AND THE UNPACKED DATA. IF THE GRIB MESSAGE IS NOT FOUND, THEN THE
1095 C RETURN CODE WILL BE NONZERO.
1097 C PROGRAM HISTORY LOG:
1099 C 95-10-31 IREDELL MODULARIZED PORTIONS OF CODE INTO SUBPROGRAMS
1100 C AND ALLOWED FOR UNSPECIFIED INDEX FILE
1102 C USAGE: CALL GETGB(LUGB,LUGI,JF,J,JPDS,JGDS,
1103 C & KF,K,KPDS,KGDS,LB,F,IRET)
1105 C LUGB INTEGER UNIT OF THE UNBLOCKED GRIB DATA FILE
1106 C LUGI INTEGER UNIT OF THE UNBLOCKED GRIB INDEX FILE
1107 C (=0 TO GET INDEX BUFFER FROM THE GRIB FILE)
1108 C JF INTEGER MAXIMUM NUMBER OF DATA POINTS TO UNPACK
1109 C J INTEGER NUMBER OF MESSAGES TO SKIP
1110 C (=0 TO SEARCH FROM BEGINNING)
1111 C (<0 TO READ INDEX BUFFER AND SKIP -1-J MESSAGES)
1112 C JPDS INTEGER (200) PDS PARAMETERS FOR WHICH TO SEARCH
1113 C (=-1 FOR WILDCARD)
1114 C (1) - ID OF CENTER
1115 C (2) - GENERATING PROCESS ID NUMBER
1116 C (3) - GRID DEFINITION
1117 C (4) - GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8)
1118 C (5) - INDICATOR OF PARAMETER
1119 C (6) - TYPE OF LEVEL
1120 C (7) - HEIGHT/PRESSURE , ETC OF LEVEL
1121 C (8) - YEAR INCLUDING (CENTURY-1)
1122 C (9) - MONTH OF YEAR
1123 C (10) - DAY OF MONTH
1124 C (11) - HOUR OF DAY
1125 C (12) - MINUTE OF HOUR
1126 C (13) - INDICATOR OF FORECAST TIME UNIT
1127 C (14) - TIME RANGE 1
1128 C (15) - TIME RANGE 2
1129 C (16) - TIME RANGE FLAG
1130 C (17) - NUMBER INCLUDED IN AVERAGE
1131 C (18) - VERSION NR OF GRIB SPECIFICATION
1132 C (19) - VERSION NR OF PARAMETER TABLE
1133 C (20) - NR MISSING FROM AVERAGE/ACCUMULATION
1134 C (21) - CENTURY OF REFERENCE TIME OF DATA
1135 C (22) - UNITS DECIMAL SCALE FACTOR
1136 C (23) - SUBCENTER NUMBER
1137 C (24) - PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS
1138 C 128 IF FORECAST FIELD ERROR
1139 C 64 IF BIAS CORRECTED FCST FIELD
1140 C 32 IF SMOOTHED FIELD
1141 C WARNING: CAN BE COMBINATION OF MORE THAN 1
1142 C (25) - PDS BYTE 30, NOT USED
1143 C JGDS INTEGER (200) GDS PARAMETERS FOR WHICH TO SEARCH
1144 C (ONLY SEARCHED IF JPDS(3)=255)
1145 C (=-1 FOR WILDCARD)
1146 C (1) - DATA REPRESENTATION TYPE
1147 C (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS
1148 C (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE
1151 C OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS
1154 C 255 IF NEITHER ARE PRESENT
1155 C (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID
1156 C (22) - NUMBER OF WORDS IN EACH ROW
1157 C LATITUDE/LONGITUDE GRIDS
1158 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
1159 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
1160 C (4) - LA(1) LATITUDE OF ORIGIN
1161 C (5) - LO(1) LONGITUDE OF ORIGIN
1162 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
1163 C (7) - LA(2) LATITUDE OF EXTREME POINT
1164 C (8) - LO(2) LONGITUDE OF EXTREME POINT
1165 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
1166 C (10) - DJ LATITUDINAL DIRECTION INCREMENT
1167 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
1169 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
1170 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
1171 C (4) - LA(1) LATITUDE OF ORIGIN
1172 C (5) - LO(1) LONGITUDE OF ORIGIN
1173 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
1174 C (7) - LA(2) LATITUDE OF EXTREME POINT
1175 C (8) - LO(2) LONGITUDE OF EXTREME POINT
1176 C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT
1177 C (10) - N - NR OF CIRCLES POLE TO EQUATOR
1178 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
1179 C (12) - NV - NR OF VERT COORD PARAMETERS
1180 C (13) - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS
1182 C PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN
1183 C EACH ROW (IF NO VERT COORD PARAMETERS
1186 C 255 IF NEITHER ARE PRESENT
1187 C POLAR STEREOGRAPHIC GRIDS
1188 C (2) - N(I) NR POINTS ALONG LAT CIRCLE
1189 C (3) - N(J) NR POINTS ALONG LON CIRCLE
1190 C (4) - LA(1) LATITUDE OF ORIGIN
1191 C (5) - LO(1) LONGITUDE OF ORIGIN
1192 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
1193 C (7) - LOV GRID ORIENTATION
1194 C (8) - DX - X DIRECTION INCREMENT
1195 C (9) - DY - Y DIRECTION INCREMENT
1196 C (10) - PROJECTION CENTER FLAG
1197 C (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28)
1198 C SPHERICAL HARMONIC COEFFICIENTS
1199 C (2) - J PENTAGONAL RESOLUTION PARAMETER
1202 C (5) - REPRESENTATION TYPE
1203 C (6) - COEFFICIENT STORAGE MODE
1205 C (2) - N(I) NR POINTS ON LATITUDE CIRCLE
1206 C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN
1207 C (4) - LA(1) LATITUDE OF ORIGIN
1208 C (5) - LO(1) LONGITUDE OF ORIGIN
1209 C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17)
1210 C (7) - LA(2) LATITUDE OF LAST GRID POINT
1211 C (8) - LO(2) LONGITUDE OF LAST GRID POINT
1212 C (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION
1214 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
1215 C (12) - LONGITUDINAL DIR GRID LENGTH
1216 C (13) - LATITUDINAL DIR GRID LENGTH
1217 C LAMBERT CONFORMAL GRIDS
1218 C (2) - NX NR POINTS ALONG X-AXIS
1219 C (3) - NY NR POINTS ALONG Y-AXIS
1220 C (4) - LA1 LAT OF ORIGIN (LOWER LEFT)
1221 C (5) - LO1 LON OF ORIGIN (LOWER LEFT)
1222 C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17)
1223 C (7) - LOV - ORIENTATION OF GRID
1224 C (8) - DX - X-DIR INCREMENT
1225 C (9) - DY - Y-DIR INCREMENT
1226 C (10) - PROJECTION CENTER FLAG
1227 C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28)
1228 C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER
1229 C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER
1231 C KF INTEGER NUMBER OF DATA POINTS UNPACKED
1232 C K INTEGER MESSAGE NUMBER UNPACKED
1233 C (CAN BE SAME AS J IN CALLING PROGRAM
1234 C IN ORDER TO FACILITATE MULTIPLE SEARCHES)
1235 C KPDS INTEGER (200) UNPACKED PDS PARAMETERS
1236 C KGDS INTEGER (200) UNPACKED GDS PARAMETERS
1237 C LB LOGICAL*1 (KF) UNPACKED BITMAP IF PRESENT
1238 C F REAL (KF) UNPACKED DATA
1239 C IRET INTEGER RETURN CODE
1241 C 96 ERROR READING INDEX FILE
1242 C 97 ERROR READING GRIB FILE
1243 C 98 NUMBER OF DATA POINTS GREATER THAN JF
1244 C 99 REQUEST NOT FOUND
1245 C OTHER W3FI63 GRIB UNPACKER RETURN CODE
1247 C SUBPROGRAMS CALLED:
1248 C GETGBM FIND AND UNPACK GRIB MESSAGE
1250 C REMARKS: IN ORDER TO UNPACK GRIB FROM A MULTIPROCESSING ENVIRONMENT
1251 C WHERE EACH PROCESSOR IS ATTEMPTING TO READ FROM ITS OWN PAIR OF
1252 C LOGICAL UNITS, ONE MUST DIRECTLY CALL SUBPROGRAM GETGBM AS BELOW,
1253 C ALLOCATING A PRIVATE COPY OF CBUF, NLEN AND NNUM TO EACH PROCESSOR.
1254 C DO NOT ENGAGE THE SAME LOGICAL UNIT FROM MORE THAN ONE PROCESSOR.
1257 C LANGUAGE: FORTRAN 77
1258 C MACHINE: CRAY, WORKSTATIONS
1264 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
1266 C SUBPROGRAM: BAOPEN BYTE-ADDRESSABLE OPEN
1267 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
1269 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE.
1271 C PROGRAM HISTORY LOG:
1272 C 1998-06-04 IREDELL
1274 C USAGE: CALL BAOPEN(LU,CFN,IRET)
1276 C LU INTEGER UNIT TO OPEN
1277 C CFN CHARACTER FILENAME TO OPEN
1278 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
1280 C IRET INTEGER RETURN CODE
1283 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
1285 C SUBPROGRAMS CALLED:
1286 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
1289 C LANGUAGE: FORTRAN 90
1294 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
1296 C SUBPROGRAM: BACLOSE BYTE-ADDRESSABLE CLOSE
1297 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
1299 C ABSTRACT: CLOSE A BYTE-ADDRESSABLE FILE.
1301 C PROGRAM HISTORY LOG:
1302 C 1998-06-04 IREDELL
1304 C USAGE: CALL BACLOSE(LU,IRET)
1306 C LU INTEGER UNIT TO CLOSE
1308 C IRET INTEGER RETURN CODE
1311 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
1313 C SUBPROGRAMS CALLED:
1314 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
1316 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
1319 C LANGUAGE: FORTRAN 90