GRIB1 USERS GUIDE (FORTRAN 90) Contents: - Introduction GRIB1 Encoding Routines GRIB1 Decoding Routine Extracting GRIB1 Fields from a GRIB1 file GRIB1 Tables GRIB1 Routine Docblocks ========================================================================= ====== Introduction This document briefly describes the routines available for encoding/decoding GRIB Edition 1 messages. A basic familiarity with GRIB is assumed. A GRIB message is a machine independent format for storing one or more gridded data fields. Each GRIB message consists of the following sections: SECTION SECTION SECTION SECTION SECTION SECTION 0 1 2 3 4 5 - Indicator Section Product Definition Section (PDS) Grid Definition Section (GDS) Bit-map Section (Optional) Binary Data Section End Section ========================================================================= ====== GRIB1 Encoding Routines There are several routines that one can use to encode a GRIB1 message. Subroutine W3FI72 can be used to encode a GRIB1 message which is passed back to the calling program in a character array. It is the users responsibility to ensure that the character array that will hold the packed GRIB1 message has been allocated large enough prior to calling W3FI72. Another option is subroutine PUTGB. PUTGB encodes a GRIB1 message and writes it to a file. The message is not returned to the calling routine. The output GRIB1 data file must be opened with a call to subroutine BAOPEN (or BAOPENW) prior to the call to PUTGB. A call to BACLOSE is recommended at the end of the program to close the output file properly. Example usage: integer,dimension(200) :: KPDS,KGDS logical*1,allocatable :: LB(:) ! bitmap real,allocatable :: F(:) ! grid point data values lugb=50 ! Open GRIB1 file call baopenw(LUGB,"filename",iret) ! Set up bitmap and data field numpts=?????? allocate(LB(numpts)) allocate(F(numpts)) ! Set GRIB1 field identification values to encode KPDS(?)= KGDS(?)= ! pack and write field to file CALL PUTGB(LUGB,numpts,KPDS,KGDS,LB,F,iret) ! Close file ... call baclose(LUGB,iret) stop end There are other similar routines in the PUTGB family that can be used to encode GRIB1 messages and write them out to a file: PUTGBEX - Used to encode GRIB1 messages with NCEP PDS extensions to specify ensemble information. PUTGN - Allows users to specify a binary scale factor or limit amount of space each data point should occupy. Please see the "GRIB1 Routine Docblocks" section below for subroutine argument usage for the routines mentioned above. ========================================================================= ====== GRIB1 Decoding Routine Subroutine W3FI63 can be used to decode a given GRIB1 message that resides in a character array in memory. This routine will return the unpacked values in the PDS and GDS, a bitmap array, and the unpacked grid point data values. It is the users responsibility to ensure that the returned arrays have been allocated large enough prior to calling W3FI63. Please see the "GRIB1 Routine Docblocks" section below for subroutine argument usage for the routine mentioned above. ========================================================================= ====== Extracting GRIB1 Fields from a GRIB1 file Subroutine GETGB can be used to extract a specified field from a file containing many GRIB1 messages. GETGB searches an index to find the location of the user specified field. The index can be supplied from a separate GRIB1 index file, or it can be generated internally. The GRIB1 data file ( and the index file, if supplied ) must be opened with a call to subroutine BAOPEN prior to the call to GETGB. Users can request a particular field by specifying the PDS and GDS values that they wish to match. GETGB will return the PDS, GDS, bitmap, and grid point data values. Example usage: integer,parameter :: MAXPTS=?????? integer,dimension(200) :: JPDS,JGDS,KPDS,KGDS logical*1,dimension(MAXPTS) :: LB ! bitmap real,dimension(MAXPTS) :: F ! grid point data values lugb=10 lugi=0 ! Open GRIB1 file call baopenr(LUGB,"filename",iret) ! Set GRIB1 field identification values to search for j=0 ! search from beginning jpds(?)= jgds(?)= ! Get field from file CALL GETGB(LUGB,LUGI,MAXPTS,J,JPDS,JGDS, & KF,K,KPDS,KGDS,LB,F,IRET) ! Process field ... firstval=F(1) lastval=F(KF) fldmax=maxval(F) fldmin=minval(F) stop end There are other similar routines in the GETGB family that can be used to extract data from a GRIB1 file: GETGBEX - Used to search for and decode GRIB1 messages using NCEP PDS extensions used to specify ensemble information. GETGBP - Returns the requested packed GRIB message instead of the unpacked bitmap and data values. GETGBH - Returns the full PDS and GDS values of the requested field without having to unpack the bitmap and grid point data values. Please see the "GRIB1 Routine Docblocks" section below for subroutine argument usage for the routines mentioned above. ========================================================================= ====== GRIB1 Tables WMO's GRIB1 guide "A GUIDE TO THE CODE FORM FM 92-IX Ext. GRIB" contains a description of the GRIB1 code form and the master code table information. This document can be found at http://www.wmo.ch/web/www/WDM/Guides/Guide-binary.html In addition, NCEP Office Note 388 (http://www.nco.ncep.noaa.gov/pmb/docs/on388) also contains a description of GRIB1 along with master and local NCEP Code Table values. ========================================================================= ====== GRIB1 Routine Docblocks C$$$ SUBPROGRAM DOCUMENTATION BLOCK C . . . . C SUBPROGRAM: W3FI72 MAKE A COMPLETE GRIB MESSAGE C PRGMMR: FARLEY ORG: NMC421 DATE:94-11-22 C C ABSTRACT: MAKES A COMPLETE GRIB MESSAGE FROM A USER SUPPLIED C ARRAY OF FLOATING POINT OR INTEGER DATA. THE USER HAS THE C OPTION OF SUPPLYING THE PDS OR AN INTEGER ARRAY THAT WILL BE C USED TO CREATE A PDS (WITH W3FI68). THE USER MUST ALSO C SUPPLY OTHER NECESSARY INFO; SEE USAGE SECTION BELOW. C C PROGRAM HISTORY LOG: C 91-05-08 R.E.JONES C 92-07-01 M. FARLEY ADDED GDS AND BMS LOGIC. PLACED EXISTING C LOGIC FOR BDS IN A ROUTINE. C 92-10-02 R.E.JONES ADD ERROR EXIT FOR W3FI73 C 93-04-30 R.E.JONES REPLACE DO LOOPS TO MOVE CHARACTER DATA C WITH XMOVEX, USE XSTORE TO ZERO CHARACTER C ARRAY. MAKE CHANGE SO FLAT FIELD WILL PACK. C 93-08-06 CAVANAUGH MODIFIED CALL TO W3FI75 C 93-10-26 CAVANAUGH ADDED CODE TO RESTORE INPUT FIELD TO ORIGINAL C VALUES IF D-SCALE NOT 0 C 94-01-27 CAVANAUGH ADDED IGDS ARRAY IN CALL TO W3FI75 TO PROVIDE C INFORMATION FOR BOUSTROPHEDONIC PROCESSING C 94-03-03 CAVANAUGH INCREASED SIZE OF GDS ARRAY FOR THIN GRIDS C 94-05-16 FARLEY CLEANED UP DOCUMENTATION C 94-11-10 FARLEY INCREASED SIZE OF PFLD/IFLD ARRARYS FROM C 100K TO 260K FOR .5 DEGREE SST ANAL FIELDS C 94-12-04 R.E.JONES CHANGE DOCUMENT FOR IPFLAG. C 95-10-31 IREDELL REMOVED SAVES AND PRINTS C 98-05-19 Gilbert Increased array dimensions to handle grids C of up to 500,000 grid points. C 95-10-31 IREDELL GENERALIZED WORD SIZE C 98-12-21 Gilbert Replaced Function ICHAR with mova2i. C 99-02-01 Gilbert Changed the method of zeroing out array KBUF. C the old method, using W3FI01 and XSTORE was C incorrect with 4-byte integers and 8-byte reals. C 2001-06-07 Gilbert Removed calls to xmovex. C changed IPFLD from integer to character. C C USAGE: CALL W3FI72(ITYPE,FLD,IFLD,IBITL, C & IPFLAG,ID,PDS, C & IGFLAG,IGRID,IGDS,ICOMP, C & IBFLAG,IBMAP,IBLEN,IBDSFL, C & IBDSFL, C & NPTS,KBUF,ITOT,JERR) C C INPUT ARGUMENT LIST: C ITYPE - 0 = FLOATING POINT DATA SUPPLIED IN ARRAY 'FLD' C 1 = INTEGER DATA SUPPLIED IN ARRAY 'IFLD' C FLD - REAL ARRAY OF DATA (AT PROPER GRIDPOINTS) TO BE C CONVERTED TO GRIB FORMAT IF ITYPE=0. C SEE REMARKS #1 & 2. C IFLD - INTEGER ARRAY OF DATA (AT PROPER GRIDPOINTS) TO BE C CONVERTED TO GRIB FORMAT IF ITYPE=1. C SEE REMARKS #1 & 2. C IBITL - 0 = COMPUTER COMPUTES LENGTH FOR PACKING DATA FROM C POWER OF 2 (NUMBER OF BITS) BEST FIT OF DATA C USING 'VARIABLE' BIT PACKER W3FI58. C 8, 12, ETC. COMPUTER RESCALES DATA TO FIT INTO THAT C 'FIXED' NUMBER OF BITS USING W3FI59. C SEE REMARKS #3. C C IPFLAG - 0 = MAKE PDS FROM USER SUPPLIED ARRAY (ID) C 1 = USER SUPPLYING PDS C NOTE: IF PDS IS GREATER THAN 30, USE IPLFAG=1. C THE USER COULD CALL W3FI68 BEFORE HE CALLS C W3FI72. THIS WOULD MAKE THE FIRST 30 BYTES OF C THE PDS, USER THEN WOULD MAKE BYTES AFTER 30. C ID - INTEGER ARRAY OF VALUES THAT W3FI68 WILL USE C TO MAKE AN EDITION 1 PDS IF IPFLAG=0. (SEE THE C DOCBLOCK FOR W3FI68 FOR LAYOUT OF ARRAY) C PDS - CHARACTER ARRAY OF VALUES (VALID PDS SUPPLIED C BY USER) IF IPFLAG=1. LENGTH MAY EXCEED 28 BYTES C (CONTENTS OF BYTES BEYOND 28 ARE PASSED C THROUGH UNCHANGED). C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C IGFLAG IGRID IGDS ICOMP IBFLAG IBMAP IBLEN - 0 = MAKE GDS BASED ON 'IGRID' VALUE. 1 = MAKE GDS FROM USER SUPPLIED INFO IN 'IGDS' AND 'IGRID' VALUE. SEE REMARKS #4. - # = GRID IDENTIFICATION (TABLE B) 255 = IF USER DEFINED GRID; IGDS MUST BE SUPPLIED AND IGFLAG MUST =1. - INTEGER ARRAY CONTAINING USER GDS INFO (SAME FORMAT AS SUPPLIED BY W3FI71 - SEE DOCKBLOCK FOR LAYOUT) IF IGFLAG=1. - RESOLUTION AND COMPONENT FLAG FOR BIT 5 OF GDS(17) 0 = EARTH ORIENTED WINDS 1 = GRID ORIENTED WINDS - 0 = MAKE BIT MAP FROM USER SUPPLIED DATA # = BIT MAP PREDEFINED BY CENTER SEE REMARKS #5. - INTEGER ARRAY CONTAINING BIT MAP - LENGTH OF BIT MAP WILL BE USED TO VERIFY LENGTH OF FIELD (ERROR IF IT DOESN'T MATCH). IBDSFL - INTEGER ARRAY CONTAINING TABLE 11 FLAG INFO BDS OCTET 4: (1) 0 = GRID POINT DATA 1 = SPHERICAL HARMONIC COEFFICIENTS (2) 0 = SIMPLE PACKING 1 = SECOND ORDER PACKING (3) ... SAME VALUE AS 'ITYPE' 0 = ORIGINAL DATA WERE FLOATING POINT VALUES 1 = ORIGINAL DATA WERE INTEGER VALUES (4) 0 = NO ADDITIONAL FLAGS AT OCTET 14 1 = OCTET 14 CONTAINS FLAG BITS 5-12 (5) 0 = RESERVED - ALWAYS SET TO 0 BYTE 6 OPTION 1 NOT AVAILABLE (AS OF 5-16-93) (6) 0 = SINGLE DATUM AT EACH GRID POINT 1 = MATRIX OF VALUES AT EACH GRID POINT BYTE 7 OPTION 0 WITH SECOND ORDER PACKING N/A (AS OF 5-16-93) (7) 0 = NO SECONDARY BIT MAPS 1 = SECONDARY BIT MAPS PRESENT (8) 0 = SECOND ORDER VALUES HAVE CONSTANT WIDTH 1 = SECOND ORDER VALUES HAVE DIFFERENT WIDTHS OUTPUT ARGUMENT LIST: NPTS - NUMBER OF GRIDPOINTS IN ARRAY FLD OR IFLD KBUF - ENTIRE GRIB MESSAGE ('GRIB' TO '7777') EQUIVALENCE TO INTEGER ARRAY TO MAKE SURE IT IS ON WORD BOUNARY. ITOT - TOTAL LENGTH OF GRIB MESSAGE IN BYTES JERR - = 0, COMPLETED MAKING GRIB FIELD WITHOUT ERROR 1, IPFLAG NOT 0 OR 1 2, IGFLAG NOT 0 OR 1 3, ERROR CONVERTING IEEE F.P. NUMBER TO IBM370 F.P. 4, W3FI71 ERROR/IGRID NOT DEFINED 5, W3FK74 ERROR/GRID REPRESENTATION TYPE NOT VALID C 6, GRID TOO LARGE FOR PACKER DIMENSION ARRAYS C SEE AUTOMATION DIVISION FOR REVISION! C 7, LENGTH OF BIT MAP NOT EQUAL TO SIZE OF FLD/IFLD C 8, W3FI73 ERROR, ALL VALUES IN IBMAP ARE ZERO C C OUTPUT FILES: C FT06F001 - STANDARD FORTRAN OUTPUT PRINT FILE C C SUBPROGRAMS CALLED: C LIBRARY: C W3LIB - W3FI58, W3FI59, W3FI68, W3FI71, W3FI73, W3FI74 C W3FI75, W3FI76 C FORTRAN 90 INTRINSIC - BIT_SIZE C C REMARKS: C 1) IF BIT MAP TO BE INCLUDED IN MESSAGE, NULL DATA SHOULD C BE INCLUDED IN FLD OR IFLD. THIS ROUTINE WILL TAKE CARE C OF 'DISCARDING' ANY NULL DATA BASED ON THE BIT MAP. C 2) UNITS MUST BE THOSE IN GRIB DOCUMENTATION: NMC O.N. 388 C OR WMO PUBLICATION 306. C 3) IN EITHER CASE, INPUT NUMBERS WILL BE MULTIPLIED BY C '10 TO THE NTH' POWER FOUND IN ID(25) OR PDS(27-28), C THE D-SCALING FACTOR, PRIOR TO BINARY PACKING. C 4) ALL NMC PRODUCED GRIB FIELDS WILL HAVE A GRID DEFINITION C SECTION INCLUDED IN THE GRIB MESSAGE. ID(6) WILL BE C SET TO '1'. C - GDS WILL BE BUILT BASED ON GRID NUMBER (IGRID), UNLESS C IGFLAG=1 (USER SUPPLYING IGDS). USER MUST STILL SUPPLY C IGRID EVEN IF IGDS PROVIDED. C 5) IF BIT MAP USED THEN ID(7) OR PDS(8) MUST INDICATE THE C PRESENCE OF A BIT MAP. C 6) ARRAY KBUF SHOULD BE EQUIVALENCED TO AN INTEGER VALUE OR C ARRAY TO MAKE SURE IT IS ON A WORD BOUNDARY. C 7) SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT. C C ATTRIBUTES: C LANGUAGE: FORTRAN 90 C C$$$ C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: PUTGB PACKS AND WRITES A GRIB MESSAGE C PRGMMR: IREDELL ORG: W/NMC23 DATE: 94-04-01 C C ABSTRACT: PACK AND WRITE A GRIB MESSAGE. C THIS SUBPROGRAM IS NEARLY THE INVERSE OF GETGB. C C PROGRAM HISTORY LOG: C 94-04-01 IREDELL C 95-10-31 IREDELL REMOVED SAVES AND PRINTS C C USAGE: CALL PUTGB(LUGB,KF,KPDS,KGDS,LB,F,IRET) C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C INPUT ARGUMENTS: LUGB INTEGER UNIT OF THE UNBLOCKED GRIB DATA FILE KF INTEGER NUMBER OF DATA POINTS KPDS INTEGER (200) PDS PARAMETERS (1) - ID OF CENTER (2) - GENERATING PROCESS ID NUMBER (3) - GRID DEFINITION (4) - GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8) (5) - INDICATOR OF PARAMETER (6) - TYPE OF LEVEL (7) - HEIGHT/PRESSURE , ETC OF LEVEL (8) - YEAR INCLUDING (CENTURY-1) (9) - MONTH OF YEAR (10) - DAY OF MONTH (11) - HOUR OF DAY (12) - MINUTE OF HOUR (13) - INDICATOR OF FORECAST TIME UNIT (14) - TIME RANGE 1 (15) - TIME RANGE 2 (16) - TIME RANGE FLAG (17) - NUMBER INCLUDED IN AVERAGE (18) - VERSION NR OF GRIB SPECIFICATION (19) - VERSION NR OF PARAMETER TABLE (20) - NR MISSING FROM AVERAGE/ACCUMULATION (21) - CENTURY OF REFERENCE TIME OF DATA (22) - UNITS DECIMAL SCALE FACTOR (23) - SUBCENTER NUMBER (24) - PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS 128 IF FORECAST FIELD ERROR 64 IF BIAS CORRECTED FCST FIELD 32 IF SMOOTHED FIELD WARNING: CAN BE COMBINATION OF MORE THAN 1 (25) - PDS BYTE 30, NOT USED KGDS INTEGER (200) GDS PARAMETERS (1) - DATA REPRESENTATION TYPE (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE PARAMETERS OR OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS IN EACH ROW OR 255 IF NEITHER ARE PRESENT (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID (22) - NUMBER OF WORDS IN EACH ROW LATITUDE/LONGITUDE GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF EXTREME POINT (8) - LO(2) LONGITUDE OF EXTREME POINT (9) - DI LONGITUDINAL DIRECTION OF INCREMENT C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C (10) (11) GAUSSIAN (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) - DJ LATITUDINAL DIRECTION INCREMENT - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) GRIDS - N(I) NR POINTS ON LATITUDE CIRCLE - N(J) NR POINTS ON LONGITUDE MERIDIAN - LA(1) LATITUDE OF ORIGIN - LO(1) LONGITUDE OF ORIGIN - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) - LA(2) LATITUDE OF EXTREME POINT - LO(2) LONGITUDE OF EXTREME POINT - DI LONGITUDINAL DIRECTION OF INCREMENT - N - NR OF CIRCLES POLE TO EQUATOR - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) - NV - NR OF VERT COORD PARAMETERS - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS OR PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN EACH ROW (IF NO VERT COORD PARAMETERS ARE PRESENT OR 255 IF NEITHER ARE PRESENT POLAR STEREOGRAPHIC GRIDS (2) - N(I) NR POINTS ALONG LAT CIRCLE (3) - N(J) NR POINTS ALONG LON CIRCLE (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LOV GRID ORIENTATION (8) - DX - X DIRECTION INCREMENT (9) - DY - Y DIRECTION INCREMENT (10) - PROJECTION CENTER FLAG (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28) SPHERICAL HARMONIC COEFFICIENTS (2) - J PENTAGONAL RESOLUTION PARAMETER (3) - K " " " (4) - M " " " (5) - REPRESENTATION TYPE (6) - COEFFICIENT STORAGE MODE MERCATOR GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF LAST GRID POINT (8) - LO(2) LONGITUDE OF LAST GRID POINT (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION (10) - RESERVED (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) (12) - LONGITUDINAL DIR GRID LENGTH (13) - LATITUDINAL DIR GRID LENGTH LAMBERT CONFORMAL GRIDS (2) - NX NR POINTS ALONG X-AXIS (3) - NY NR POINTS ALONG Y-AXIS C (4) - LA1 LAT OF ORIGIN (LOWER LEFT) C (5) - LO1 LON OF ORIGIN (LOWER LEFT) C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17) C (7) - LOV - ORIENTATION OF GRID C (8) - DX - X-DIR INCREMENT C (9) - DY - Y-DIR INCREMENT C (10) - PROJECTION CENTER FLAG C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER C LB LOGICAL*1 (KF) BITMAP IF PRESENT C F REAL (KF) DATA C OUTPUT ARGUMENTS: C IRET INTEGER RETURN CODE C 0 ALL OK C OTHER W3FI72 GRIB PACKER RETURN CODE C C SUBPROGRAMS CALLED: C R63W72 MAP W3FI63 PARAMETERS ONTO W3FI72 PARAMETERS C GETBIT GET NUMBER OF BITS AND ROUND DATA C W3FI72 PACK GRIB C WRYTE WRITE DATA C C REMARKS: SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT. C DO NOT ENGAGE THE SAME LOGICAL UNIT FROM MORE THAN ONE PROCESSOR. C C ATTRIBUTES: C LANGUAGE: FORTRAN 77 C MACHINE: CRAY, WORKSTATIONS C C$$$ C$$$ SUBPROGRAM DOCUMENTATION BLOCK C . . . . C SUBPROGRAM: W3FI63 UNPK GRIB FIELD TO GRIB GRID C PRGMMR: FARLEY ORG: NMC421 DATE:94-11-22 C C ABSTRACT: UNPACK A GRIB (EDITION 1) FIELD TO THE EXACT GRID C SPECIFIED IN THE GRIB MESSAGE, ISOLATE THE BIT MAP, AND MAKE C THE VALUES OF THE PRODUCT DESCRIPTON SECTION (PDS) AND THE C GRID DESCRIPTION SECTION (GDS) AVAILABLE IN RETURN ARRAYS. C C WHEN DECODING IS COMPLETED, DATA AT EACH GRID POINT HAS BEEN C RETURNED IN THE UNITS SPECIFIED IN THE GRIB MANUAL. C C PROGRAM HISTORY LOG: C 91-09-13 CAVANAUGH C 91-11-12 CAVANAUGH MODIFIED SIZE OF ECMWF GRIDS 5-8 C 91-12-22 CAVANAUGH CORRECTED PROCESSING OF MERCATOR PROJECTIONS C IN GRID DEFINITION SECTION (GDS) IN C ROUTINE FI633 C 92-08-05 CAVANAUGH CORRECTED MAXIMUM GRID SIZE TO ALLOW FOR C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C 92-08-27 CAVANAUGH 92-10-21 CAVANAUGH 93-01-07 CAVANAUGH 93-01-13 CAVANAUGH 93-02-04 93-02-26 CAVANAUGH CAVANAUGH 93-04-07 CAVANAUGH 93-04-20 CAVANAUGH 93-05-26 CAVANAUGH 93-06-08 CAVANAUGH 93-09-22 CAVANAUGH 93-10-13 CAVANAUGH 93-10-14 CAVANAUGH 93-12-08 CAVANAUGH 93-12-15 CAVANAUGH 94-03-02 CAVANAUGH 94-04-22 CAVANAUGH 94-05-17 CAVANAUGH 94-05-25 CAVANAUGH 94-06-27 CAVANAUGH 94-07-08 CAVANAUGH ONE DEGREE BY ONE DEGREE GLOBAL GRIDS CORRECTED TYPO ERROR, ADDED CODE TO COMPARE TOTAL BYTE SIZE FROM SECTION 0 WITH SUM OF SECTION SIZES. CORRECTIONS WERE MADE (IN FI634) TO REDUCE PROCESSING TIME FOR INTERNATIONAL GRIDS. REMOVED A TYPOGRAPHICAL ERROR IN FI635. CORRECTIONS WERE MADE (IN FI635) TO FACILITATE USE OF THESE ROUTINES ON A PC. A TYPOGRAPHICAL ERROR WAS ALSO CORRECTED CORRECTIONS WERE MADE (IN FI632) TO PROPERLY HANDLE CONDITION WHEN TIME RANGE INDICATOR = 10. ADDED U.S.GRID 87. ADDED U.S.GRIDS 85 AND 86 ADDED GRIDS 2, 3, 37 THRU 44,AND GRIDS 55, 56, 90, 91, 92, AND 93 TO LIST OF U.S. GRIDS. ADDED GRIDS 67 THRU 77 TO LIST OF U.S. GRIDS. INCREASED MAX SIZE TO ACCOMODATE GAUSSIAN GRIDS. CORRECTED GRID RANGE SELECTION IN FI634 FOR RANGES 67-71 & 75-77 CORRECTED FI635 TO ACCEPT GRIB MESSAGES WITH SECOND ORDER PACKING. ADDED ROUTINE FI636 TO PROCESS MESSAGES WITH SECOND ORDER PACKING. MODIFIED TO EXTRACT SUB-CENTER NUMBER FROM PDS BYTE 26 MODIFIED FI634 TO CORRECT GRID SIZES FOR GRIDS 204 AND 208 INCREASED SIZE OF KGDS TO INCLUDE ENTRIES FOR NUMBER OF POINTS IN GRID AND NUMBER OF WORDS IN EACH ROW CORRECTED TEST FOR EDITION NUMBER INSTEAD OF VERSION NUMBER MODIFIED SECOND ORDER POINTERS TO FIRST ORDER VALUES AND SECOND ORDER VALUES CORRECTLY IN ROUTINE FI636 ADDED CALL TO W3FI83 WITHIN DECODER. USER NO LONGER NEEDS TO MAKE CALL TO THIS ROUTINE MODIFIED FI635, FI636 TO PROCESS ROW BY ROW SECOND ORDER PACKING, ADDED SCALING CORRECTION TO FI635, AND CORRECTED TYPOGRAPHICAL ERRORS IN COMMENT FIELDS IN FI634 CORRECTED ERROR IN FI633 TO EXTRACT RESOLUTION FOR LAMBERT-CONFORMAL GRIDS. ADDED CLARIFYING INFORMATION TO DOCBLOCK ENTRIES ADDED CODE TO PROCESS COLUMN BY COLUMN AS WELL AS ROW BY ROW ORDERING OF SECOND ORDER DATA ADDED PROCESSING FOR GRIDS 45, 94 AND 95. INCLUDES CONSTRUCTION OF SECOND ORDER BIT MAPS FOR THINNED GRIDS IN FI636. COMMENTED OUT PRINT OUTS USED FOR DEBUGGING C 94-09-08 CAVANAUGH ADDED GRIDS 220, 221, 223 FOR FNOC C 94-11-10 FARLEY INCREASED MXSIZE FROM 72960 TO 260000 C FOR .5 DEGREE SST ANALYSIS FIELDS C 94-12-06 R.E.JONES CHANGES IN FI632 FOR PDS GREATER THAN 28 C 95-02-14 R.E.JONES CORRECT IN FI633 FOR NAVY WAFS GRIB C 95-03-20 M.BALDWIN FI633 MODIFICATION TO GET C DATA REP TYPES [KGDS(1)] 201 AND 202 TO WORK. C 95-04-10 E.ROGERS ADDED GRIDS 96 AND 97 FOR ETA MODEL IN FI634. C 95-04-26 R.E.JONES FI636 CORECTION FOR 2ND ORDER COMPLEX C UNPACKING. R C 95-05-19 R.E.JONES ADDED GRID 215, 20 KM AWIPS GRID C 95-07-06 R.E.JONES ADDED GAUSSIAN T62, T126 GRID 98, 126 C 95-10-19 R.E.JONES ADDED GRID 216, 45 KM ETA AWIPS ALASKA GRID C 95-10-31 IREDELL REMOVED SAVES AND PRINTS C 96-03-07 R.E.JONES CONTINUE UNPACK WITH KRET ERROR 9 IN FI631. C 96-08-19 R.E.JONES ADDED MERCATOR GRIDS 8 AND 53, AND GRID 196 C 97-02-12 W BOSTELMAN CORRECTS ECMWF US GRID 2 PROCESSING C 98-06-17 IREDELL REMOVED ALTERNATE RETURN IN FI637 C 98-08-31 IREDELL ELIMINATED NEED FOR MXSIZE C 98-09-02 Gilbert Corrected error in map size for U.S. Grid 92 C 98-09-08 BALDWIN ADD DATA REP TYPE [KGDS(1)] 203 C 01-03-08 ROGERS CHANGED ETA GRIDS 90-97, ADDED ETA GRIDS C 194, 198. ADDED AWIPS GRIDS 241,242,243, C 245, 246, 247, 248, AND 250 C 01-03-19 VUONG ADDED AWIPS GRIDS 238,239,240, AND 244. C 2001-06-06 GILBERT CHanged gbyte/sbyte calls to refer to C Wesley Ebisuzaki's endian independent C versions gbytec/sbytec. C Removed equivalences. C 01-05-03 ROGERS ADDED GRID 249 (12KM FOR ALASKA) C 01-10-10 ROGERS REDEFINED GRID 218 FOR 12 KM ETA C REDEFINED GRID 192 FOR NEW 32-KM ETA GRID C 02-03-27 VUONG ADDED RSAS GRID 88 AND AWIPS GRIDS 219, 220, C 223, 224, 225, 226, 227, 228, 229, 230, 231, C 232, 233, 234, 235, 251, AND 252 C 02-08-06 ROGERS REDEFINED GRIDS 90-93,97,194,245-250 FOR THE C 8KM HI-RES-WINDOW MODEL AND ADD AWIPS GRID 253 C 2003-06-30 GILBERT SET NEW VALUES IN ARRAY KPTR TO PASS BACK ADDITIONAL C PACKING INFO. C KPTR(19) - BINARY SCALE FACTOR C KPTR(20) - NUM BITS USED TO PACK EACH DATUM C 2003-06-30 GILBERT ADDED GRIDS 145 and 146 for CMAQ C and GRID 175 for AWIPS over GUAM. C 2003-07-08 VUONG ADDED GRIDS 110, 127, 171, 172 AND MODIFIED GRID 170 C C USAGE: CALL W3FI63(MSGA,KPDS,KGDS,KBMS,DATA,KPTR,KRET) C INPUT ARGUMENT LIST: C MSGA - GRIB FIELD - "GRIB" THRU "7777" CHAR*1 C (MESSAGE CAN BE PRECEDED BY JUNK CHARS) C C OUTPUT ARGUMENT LIST: C DATA - ARRAY CONTAINING DATA ELEMENTS C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C KPDS (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) ARRAY CONTAINING PDS ELEMENTS. (EDITION 1) - ID OF CENTER - GENERATING PROCESS ID NUMBER - GRID DEFINITION - GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8) - INDICATOR OF PARAMETER - TYPE OF LEVEL - HEIGHT/PRESSURE , ETC OF LEVEL - YEAR INCLUDING (CENTURY-1) - MONTH OF YEAR - DAY OF MONTH - HOUR OF DAY - MINUTE OF HOUR - INDICATOR OF FORECAST TIME UNIT - TIME RANGE 1 - TIME RANGE 2 - TIME RANGE FLAG - NUMBER INCLUDED IN AVERAGE - VERSION NR OF GRIB SPECIFICATION - VERSION NR OF PARAMETER TABLE - NR MISSING FROM AVERAGE/ACCUMULATION - CENTURY OF REFERENCE TIME OF DATA - UNITS DECIMAL SCALE FACTOR - SUBCENTER NUMBER - PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS 128 IF FORECAST FIELD ERROR 64 IF BIAS CORRECTED FCST FIELD 32 IF SMOOTHED FIELD WARNING: CAN BE COMBINATION OF MORE THAN 1 (25) - PDS BYTE 30, NOT USED (26-35) - RESERVED (36-N) - CONSECUTIVE BYTES EXTRACTED FROM PROGRAM DEFINITION SECTION (PDS) OF GRIB MESSAGE KGDS - ARRAY CONTAINING GDS ELEMENTS. (1) - DATA REPRESENTATION TYPE (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE PARAMETERS OR OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS IN EACH ROW OR 255 IF NEITHER ARE PRESENT (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID (22) - NUMBER OF WORDS IN EACH ROW LATITUDE/LONGITUDE GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF EXTREME POINT (8) - LO(2) LONGITUDE OF EXTREME POINT (9) - DI LONGITUDINAL DIRECTION OF INCREMENT C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C (10) (11) GAUSSIAN (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) - DJ LATITUDINAL DIRECTION INCREMENT - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) GRIDS - N(I) NR POINTS ON LATITUDE CIRCLE - N(J) NR POINTS ON LONGITUDE MERIDIAN - LA(1) LATITUDE OF ORIGIN - LO(1) LONGITUDE OF ORIGIN - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) - LA(2) LATITUDE OF EXTREME POINT - LO(2) LONGITUDE OF EXTREME POINT - DI LONGITUDINAL DIRECTION OF INCREMENT - N - NR OF CIRCLES POLE TO EQUATOR - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) - NV - NR OF VERT COORD PARAMETERS - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS OR PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN EACH ROW (IF NO VERT COORD PARAMETERS ARE PRESENT OR 255 IF NEITHER ARE PRESENT POLAR STEREOGRAPHIC GRIDS (2) - N(I) NR POINTS ALONG LAT CIRCLE (3) - N(J) NR POINTS ALONG LON CIRCLE (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LOV GRID ORIENTATION (8) - DX - X DIRECTION INCREMENT (9) - DY - Y DIRECTION INCREMENT (10) - PROJECTION CENTER FLAG (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28) SPHERICAL HARMONIC COEFFICIENTS (2) - J PENTAGONAL RESOLUTION PARAMETER (3) - K " " " (4) - M " " " (5) - REPRESENTATION TYPE (6) - COEFFICIENT STORAGE MODE MERCATOR GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF LAST GRID POINT (8) - LO(2) LONGITUDE OF LAST GRID POINT (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION (10) - RESERVED (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) (12) - LONGITUDINAL DIR GRID LENGTH (13) - LATITUDINAL DIR GRID LENGTH LAMBERT CONFORMAL GRIDS (2) - NX NR POINTS ALONG X-AXIS (3) - NY NR POINTS ALONG Y-AXIS C (4) - LA1 LAT OF ORIGIN (LOWER LEFT) C (5) - LO1 LON OF ORIGIN (LOWER LEFT) C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17) C (7) - LOV - ORIENTATION OF GRID C (8) - DX - X-DIR INCREMENT C (9) - DY - Y-DIR INCREMENT C (10) - PROJECTION CENTER FLAG C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER C STAGGERED ARAKAWA ROTATED LAT/LON GRIDS (TYPE 203) C (2) - N(I) NR POINTS ON LATITUDE CIRCLE C (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN C (4) - LA(1) LATITUDE OF ORIGIN C (5) - LO(1) LONGITUDE OF ORIGIN C (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) C (7) - LA(2) LATITUDE OF CENTER C (8) - LO(2) LONGITUDE OF CENTER C (9) - DI LONGITUDINAL DIRECTION OF INCREMENT C (10) - DJ LATITUDINAL DIRECTION INCREMENT C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) C KBMS - BITMAP DESCRIBING LOCATION OF OUTPUT ELEMENTS. C (ALWAYS CONSTRUCTED) C KPTR - ARRAY CONTAINING STORAGE FOR FOLLOWING PARAMETERS C (1) - TOTAL LENGTH OF GRIB MESSAGE C (2) - LENGTH OF INDICATOR (SECTION 0) C (3) - LENGTH OF PDS (SECTION 1) C (4) - LENGTH OF GDS (SECTION 2) C (5) - LENGTH OF BMS (SECTION 3) C (6) - LENGTH OF BDS (SECTION 4) C (7) - VALUE OF CURRENT BYTE C (8) - BIT POINTER C (9) - GRIB START BIT NR C (10) - GRIB/GRID ELEMENT COUNT C (11) - NR UNUSED BITS AT END OF SECTION 3 C (12) - BIT MAP FLAG (COPY OF BMS OCTETS 5,6) C (13) - NR UNUSED BITS AT END OF SECTION 2 C (14) - BDS FLAGS (RIGHT ADJ COPY OF OCTET 4) C (15) - NR UNUSED BITS AT END OF SECTION 4 C (16) - RESERVED C (17) - RESERVED C (18) - RESERVED C (19) - BINARY SCALE FACTOR C (20) - NUM BITS USED TO PACK EACH DATUM C KRET - FLAG INDICATING QUALITY OF COMPLETION C C REMARKS: WHEN DECODING IS COMPLETED, DATA AT EACH GRID POINT HAS BEEN C RETURNED IN THE UNITS SPECIFIED IN THE GRIB MANUAL. C C VALUES FOR RETURN FLAG (KRET) C KRET = 0 - NORMAL RETURN, NO ERRORS C = 1 - 'GRIB' NOT FOUND IN FIRST 100 CHARS C = 2 - '7777' NOT IN CORRECT LOCATION C = 3 - UNPACKED FIELD IS LARGER THAN 260000 C = 4 - GDS/ GRID NOT ONE OF CURRENTLY ACCEPTED VALUES C = 5 - GRID NOT CURRENTLY AVAIL FOR CENTER INDICATED C = 8 - TEMP GDS INDICATED, BUT GDS FLAG IS OFF C = 9 - GDS INDICATES SIZE MISMATCH WITH STD GRID C =10 - INCORRECT CENTER INDICATOR C =11 - BINARY DATA SECTION (BDS) NOT COMPLETELY PROCESSED. C PROGRAM IS NOT SET TO PROCESS FLAG COMBINATIONS C SHOWN IN OCTETS 4 AND 14. C =12 - BINARY DATA SECTION (BDS) NOT COMPLETELY PROCESSED. C PROGRAM IS NOT SET TO PROCESS FLAG COMBINATIONS C C SUBPROGRAM CAN BE CALLED FROM A MULTIPROCESSING ENVIRONMENT. C C ATTRIBUTES: C LANGUAGE: FORTRAN 90 C C$$$ C 4 AUG 1988 C W3FI63 C C C GRIB UNPACKING ROUTINE C C C THIS ROUTINE WILL UNPACK A 'GRIB' FIELD TO THE EXACT GRID C TYPE SPECIFIED IN THE MESSAGE, RETURN A BIT MAP AND MAKE THE C VALUES OF THE PRODUCT DEFINITION SEC (PDS) AND THE GRID C DESCRIPTION SEC (GDS) AVAILABLE IN RETURN ARRAYS. C SEE "GRIB - THE WMO FORMAT FOR THE STORAGE OF WEATHER PRODUCT C INFORMATION AND THE EXCHANGE OF WEATHER PRODUCT MESSAGES IN C GRIDDED BINARY FORM" DATED JULY 1, 1988 BY JOHN D. STACKPOLE C DOC, NOAA, NWS, NATIONAL METEOROLOGICAL CENTER. C C THE CALL TO THE GRIB UNPACKING ROUTINE IS AS FOLLOWS: C C CALL W3FI63(MSGA,KPDS,KGDS,LBMS,DATA,KPTR,KRET) C C INPUT: C C MSGA = CONTAINS THE GRIB MESSAGE TO BE UNPACKED. CHARACTERS C "GRIB" MAY BEGIN ANYWHERE WITHIN FIRST 100 BYTES. C C OUTPUT: C C KPDS(100) INTEGER*4 C ARRAY TO CONTAIN THE ELEMENTS OF THE PRODUCT C DEFINITION SEC . C (VERSION 1) C KPDS(1) - ID OF CENTER C KPDS(2) - MODEL IDENTIFICATION (SEE "GRIB" TABLE 1) C KPDS(3) - GRID IDENTIFICATION (SEE "GRIB" TABLE 2) C KPDS(4) - GDS/BMS FLAG C BIT DEFINITION C 25 0 - GDS OMITTED C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C 1 - GDS INCLUDED 0 - BMS OMITTED 1 - BMS INCLUDED NOTE:- LEFTMOST BIT = 1, RIGHTMOST BIT = 32 INDICATOR OF PARAMETER (SEE "GRIB" TABLE 5) TYPE OF LEVEL (SEE "GRIB" TABLES 6 & 7) HEIGHT,PRESSURE,ETC OF LEVEL YEAR INCLUDING CENTURY MONTH OF YEAR DAY OF MONTH HOUR OF DAY MINUTE OF HOUR INDICATOR OF FORECAST TIME UNIT (SEE "GRIB" TABLE 8) TIME 1 (SEE "GRIB" TABLE 8A) TIME 2 (SEE "GRIB" TABLE 8A) TIME RANGE INDICATOR (SEE "GRIB" TABLE 8A) NUMBER INCLUDED IN AVERAGE EDITION NR OF GRIB SPECIFICATION VERSION NR OF PARAMETER TABLE 26 KPDS(5) KPDS(6) KPDS(7) KPDS(8) KPDS(9) KPDS(10) KPDS(11) KPDS(12) KPDS(13) - KPDS(14) KPDS(15) KPDS(16) KPDS(17) KPDS(18) KPDS(19) - KGDS(13) INTEGER*4 ARRAY CONTAINING GDS ELEMENTS. KGDS(1) - DATA REPRESENTATION TYPE LATITUDE/LONGITUDE GRIDS (SEE "GRIB" TABLE 10) KGDS(2) - N(I) NUMBER OF POINTS ON LATITUDE CIRCLE KGDS(3) - N(J) NUMBER OF POINTS ON LONGITUDE CIRCLE KGDS(4) - LA(1) LATITUDE OF ORIGIN KGDS(5) - LO(1) LONGITUDE OF ORIGIN KGDS(6) - RESOLUTION FLAG BIT MEANING 25 0 - DIRECTION INCREMENTS NOT GIVEN 1 - DIRECTION INCREMENTS GIVEN KGDS(7) - LA(2) LATITUDE OF EXTREME POINT KGDS(8) - LO(2) LONGITUDE OF EXTREME POINT KGDS(9) - DI LONGITUDINAL DIRECTION INCREMENT KGDS(10) - REGULAR LAT/LON GRID DJ - LATITUDINAL DIRECTION INCREMENT GAUSSIAN GRID N - NUMBER OF LATITUDE CIRCLES BETWEEN A POLE AND THE EQUATOR KGDS(11) - SCANNING MODE FLAG BIT MEANING 25 0 - POINTS ALONG A LATITUDE SCAN FROM WEST TO EAST 1 - POINTS ALONG A LATITUDE SCAN FROM EAST TO WEST C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C 26 27 0 - POINTS ALONG A MERIDIAN SCAN FROM NORTH TO SOUTH 1 - POINTS ALONG A MERIDIAN SCAN FROM SOUTH TO NORTH 0 - POINTS SCAN FIRST ALONG CIRCLES OF LATITUDE, THEN ALONG MERIDIANS (FORTRAN: (I,J)) 1 - POINTS SCAN FIRST ALONG MERIDIANS THEN ALONG CIRCLES OF LATITUDE (FORTRAN: (J,I)) POLAR STEREOGRAPHIC GRIDS (SEE GRIB TABLE 12) KGDS(2) - N(I) NR POINTS ALONG LAT CIRCLE KGDS(3) - N(J) NR POINTS ALONG LON CIRCLE KGDS(4) - LA(1) LATITUDE OF ORIGIN KGDS(5) - LO(1) LONGITUDE OF ORIGIN KGDS(6) - RESERVED KGDS(7) - LOV GRID ORIENTATION KGDS(8) - DX - X DIRECTION INCREMENT KGDS(9) - DY - Y DIRECTION INCREMENT KGDS(10) - PROJECTION CENTER FLAG KGDS(11) - SCANNING MODE SPHERICAL HARMONIC COEFFICIENTS (SEE "GRIB" TABLE 14) KGDS(2) - J PENTAGONAL RESOLUTION PARAMETER KGDS(3) - K PENTAGONAL RESOLUTION PARAMETER KGDS(4) - M PENTAGONAL RESOLUTION PARAMETER KGDS(5) - REPRESENTATION TYPE KGDS(6) - COEFFICIENT STORAGE MODE MERCATOR GRIDS KGDS(2) - N(I) NR POINTS ON LATITUDE CIRCLE KGDS(3) - N(J) NR POINTS ON LONGITUDE MERIDIAN KGDS(4) - LA(1) LATITUDE OF ORIGIN KGDS(5) - LO(1) LONGITUDE OF ORIGIN KGDS(6) - RESOLUTION FLAG KGDS(7) - LA(2) LATITUDE OF LAST GRID POINT KGDS(8) - LO(2) LONGITUDE OF LAST GRID POINT KGDS(9) - LATIN - LATITUDE OF PROJECTION INTERSECTION KGDS(10) - RESERVED KGDS(11) - SCANNING MODE FLAG KGDS(12) - LONGITUDINAL DIR GRID LENGTH KGDS(13) - LATITUDINAL DIR GRID LENGTH LAMBERT CONFORMAL GRIDS KGDS(2) - NX NR POINTS ALONG X-AXIS KGDS(3) - NY NR POINTS ALONG Y-AXIS KGDS(4) - LA1 LAT OF ORIGIN (LOWER LEFT) KGDS(5) - LO1 LON OF ORIGIN (LOWER LEFT) KGDS(6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17) KGDS(7) - LOV - ORIENTATION OF GRID KGDS(8) - DX - X-DIR INCREMENT KGDS(9) - DY - Y-DIR INCREMENT C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C KGDS(10) KGDS(11) KGDS(12) KGDS(13) - PROJECTION CENTER FLAG - SCANNING MODE FLAG - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTERSECTION - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTERSECTION LBMS(*) LOGICAL ARRAY TO CONTAIN THE BIT MAP DESCRIBING THE PLACEMENT OF DATA IN THE OUTPUT ARRAY. IF A BIT MAP IS NOT INCLUDED IN THE SOURCE MESSAGE, ONE WILL BE GENERATED AUTOMATICALLY BY THE UNPACKING ROUTINE. DATA(*) REAL*4 THIS ARRAY WILL CONTAIN THE UNPACKED DATA POINTS. NOTE:- 65160 IS MAXIMUN FIELD SIZE ALLOWABLE KPTR(10) INTEGER*4 ARRAY CONTAINING STORAGE FOR THE FOLLOWING PARAMETERS. (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) KRET - UNUSED UNUSED LENGTH OF PDS (IN BYTES) LENGTH OF GDS (IN BYTES) LENGTH OF BMS (IN BYTES) LENGTH OF BDS (IN BYTES) USED BY UNPACKING ROUTINE NUMBER OF DATA POINTS FOR GRID "GRIB" CHARACTERS START IN BYTE NUMBER USED BY UNPACKING ROUTINE INTEGER*4 THIS VARIABLE WILL CONTAIN THE RETURN INDICATOR. 0 - NO ERRORS DETECTED. 1 - 'GRIB' NOT FOUND IN FIRST 100 CHARACTERS. 2 - '7777' NOT FOUND, EITHER MISSING OR TOTAL OF SEC COUNTS OF INDIVIDUAL SECTIONS IS INCORRECT. 3 - UNPACKED FIELD IS LARGER THAN 65160. 4 - IN GDS, DATA REPRESENTATION TYPE NOT ONE OF THE CURRENTLY ACCEPTABLE VALUES. SEE "GRIB" TABLE 9. VALUE OF INCORRECT TYPE RETURNED IN KGDS(1). C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C 5 - GRID INDICATED IN KPDS(3) IS NOT AVAILABLE FOR THE CENTER INDICATED IN KPDS(1) AND NO GDS SENT. 7 - EDITION INDICATED IN KPDS(18) HAS NOT YET BEEN INCLUDED IN THE DECODER. 8 - GRID IDENTIFICATION = 255 (NOT STANDARD GRID) BUT FLAG INDICATING PRESENCE OF GDS IS TURNED OFF. NO METHOD OF GENERATING PROPER GRID. 9 - PRODUCT OF KGDS(2) AND KGDS(3) DOES NOT MATCH STANDARD NUMBER OF POINTS FOR THIS GRID (FOR OTHER THAN SPECTRALS). THIS WILL OCCUR ONLY IF THE GRID. IDENTIFICATION, KPDS(3), AND A TRANSMITTED GDS ARE INCONSISTENT. 10 - CENTER INDICATOR WAS NOT ONE INDICATED IN "GRIB" TABLE 1. PLEASE CONTACT AD PRODUCTION MANAGEMENT BRANCH (W/NMC42) IF THIS ERROR IS ENCOUNTERED. 11 - BINARY DATA SECTION (BDS) NOT COMPLETELY PROCESSED. PROGRAM IS NOT SET TO PROCESS FLAG COMBINATIONS AS SHOWN IN OCTETS 4 AND 14. LIST OF TEXT MESSAGES FROM CODE W3FI63/FI632 'HAVE ENCOUNTERED A NEW GRID FOR NMC, PLEASE NOTIFY AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH (W/NMC42)' 'HAVE ENCOUNTERED A NEW GRID FOR ECMWF, PLEASE NOTIFY AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH (W/NMC42)' 'HAVE ENCOUNTERED A NEW GRID FOR U.K. METEOROLOGICAL OFFICE, BRACKNELL. PLEASE NOTIFY AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH (W/NMC42)' 'HAVE ENCOUNTERED A NEW GRID FOR FNOC, PLEASE NOTIFY AUTOMATION DIVISION, PRODUCTION MANAGEMENT BRANCH (W/NMC42)' W3FI63/FI633 C C C C C C C C C C C C C C C C 'POLAR STEREO PROCESSING NOT AVAILABLE' * W3FI63/FI634 'WARNING - BIT MAP MAY NOT BE ASSOCIATED WITH SPHERICAL COEFFICIENTS' W3FI63/FI637 'NO CURRENT LISTING OF FNOC GRIDS' * * WILL BE AVAILABLE IN NEXT UPDATE *************************************************************** C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: GETGB FINDS AND UNPACKS A GRIB MESSAGE C PRGMMR: IREDELL ORG: W/NMC23 DATE: 94-04-01 C C ABSTRACT: FIND AND UNPACK A GRIB MESSAGE. C READ A GRIB INDEX FILE (OR OPTIONALLY THE GRIB FILE ITSELF) C TO GET THE INDEX BUFFER (I.E. TABLE OF CONTENTS) FOR THE GRIB FILE. C (THE INDEX BUFFER IS SAVED FOR USE BY FUTURE PROSPECTIVE CALLS.) C FIND IN THE INDEX BUFFER A REFERENCE TO THE GRIB MESSAGE REQUESTED. C THE GRIB MESSAGE REQUEST SPECIFIES THE NUMBER OF MESSAGES TO SKIP C AND THE UNPACKED PDS AND GDS PARAMETERS. (A REQUESTED PARAMETER C OF -1 MEANS TO ALLOW ANY VALUE OF THIS PARAMETER TO BE FOUND.) C IF THE REQUESTED GRIB MESSAGE IS FOUND, THEN IT IS READ FROM THE C GRIB FILE AND UNPACKED. ITS MESSAGE NUMBER IS RETURNED ALONG WITH C THE UNPACKED PDS AND GDS PARAMETERS, THE UNPACKED BITMAP (IF ANY), C AND THE UNPACKED DATA. IF THE GRIB MESSAGE IS NOT FOUND, THEN THE C RETURN CODE WILL BE NONZERO. C C PROGRAM HISTORY LOG: C 94-04-01 IREDELL C 95-10-31 IREDELL MODULARIZED PORTIONS OF CODE INTO SUBPROGRAMS C AND ALLOWED FOR UNSPECIFIED INDEX FILE C C USAGE: CALL GETGB(LUGB,LUGI,JF,J,JPDS,JGDS, C & KF,K,KPDS,KGDS,LB,F,IRET) C INPUT ARGUMENTS: C LUGB INTEGER UNIT OF THE UNBLOCKED GRIB DATA FILE C LUGI INTEGER UNIT OF THE UNBLOCKED GRIB INDEX FILE C (=0 TO GET INDEX BUFFER FROM THE GRIB FILE) C JF INTEGER MAXIMUM NUMBER OF DATA POINTS TO UNPACK C J INTEGER NUMBER OF MESSAGES TO SKIP C (=0 TO SEARCH FROM BEGINNING) C (<0 TO READ INDEX BUFFER AND SKIP -1-J MESSAGES) C JPDS INTEGER (200) PDS PARAMETERS FOR WHICH TO SEARCH C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C (=-1 FOR WILDCARD) ID OF CENTER GENERATING PROCESS ID NUMBER GRID DEFINITION GDS/BMS FLAG (RIGHT ADJ COPY OF OCTET 8) INDICATOR OF PARAMETER TYPE OF LEVEL HEIGHT/PRESSURE , ETC OF LEVEL YEAR INCLUDING (CENTURY-1) MONTH OF YEAR DAY OF MONTH HOUR OF DAY MINUTE OF HOUR INDICATOR OF FORECAST TIME UNIT TIME RANGE 1 TIME RANGE 2 TIME RANGE FLAG NUMBER INCLUDED IN AVERAGE VERSION NR OF GRIB SPECIFICATION VERSION NR OF PARAMETER TABLE NR MISSING FROM AVERAGE/ACCUMULATION CENTURY OF REFERENCE TIME OF DATA UNITS DECIMAL SCALE FACTOR SUBCENTER NUMBER PDS BYTE 29, FOR NMC ENSEMBLE PRODUCTS 128 IF FORECAST FIELD ERROR 64 IF BIAS CORRECTED FCST FIELD 32 IF SMOOTHED FIELD WARNING: CAN BE COMBINATION OF MORE THAN 1 (25) - PDS BYTE 30, NOT USED JGDS INTEGER (200) GDS PARAMETERS FOR WHICH TO SEARCH (ONLY SEARCHED IF JPDS(3)=255) (=-1 FOR WILDCARD) (1) - DATA REPRESENTATION TYPE (19) - NUMBER OF VERTICAL COORDINATE PARAMETERS (20) - OCTET NUMBER OF THE LIST OF VERTICAL COORDINATE PARAMETERS OR OCTET NUMBER OF THE LIST OF NUMBERS OF POINTS IN EACH ROW OR 255 IF NEITHER ARE PRESENT (21) - FOR GRIDS WITH PL, NUMBER OF POINTS IN GRID (22) - NUMBER OF WORDS IN EACH ROW LATITUDE/LONGITUDE GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF EXTREME POINT (8) - LO(2) LONGITUDE OF EXTREME POINT (9) - DI LONGITUDINAL DIRECTION OF INCREMENT (10) - DJ LATITUDINAL DIRECTION INCREMENT (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) - C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C (11) GAUSSIAN (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) GRIDS - N(I) NR POINTS ON LATITUDE CIRCLE - N(J) NR POINTS ON LONGITUDE MERIDIAN - LA(1) LATITUDE OF ORIGIN - LO(1) LONGITUDE OF ORIGIN - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) - LA(2) LATITUDE OF EXTREME POINT - LO(2) LONGITUDE OF EXTREME POINT - DI LONGITUDINAL DIRECTION OF INCREMENT - N - NR OF CIRCLES POLE TO EQUATOR - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) - NV - NR OF VERT COORD PARAMETERS - PV - OCTET NR OF LIST OF VERT COORD PARAMETERS OR PL - LOCATION OF THE LIST OF NUMBERS OF POINTS IN EACH ROW (IF NO VERT COORD PARAMETERS ARE PRESENT OR 255 IF NEITHER ARE PRESENT POLAR STEREOGRAPHIC GRIDS (2) - N(I) NR POINTS ALONG LAT CIRCLE (3) - N(J) NR POINTS ALONG LON CIRCLE (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LOV GRID ORIENTATION (8) - DX - X DIRECTION INCREMENT (9) - DY - Y DIRECTION INCREMENT (10) - PROJECTION CENTER FLAG (11) - SCANNING MODE (RIGHT ADJ COPY OF OCTET 28) SPHERICAL HARMONIC COEFFICIENTS (2) - J PENTAGONAL RESOLUTION PARAMETER (3) - K " " " (4) - M " " " (5) - REPRESENTATION TYPE (6) - COEFFICIENT STORAGE MODE MERCATOR GRIDS (2) - N(I) NR POINTS ON LATITUDE CIRCLE (3) - N(J) NR POINTS ON LONGITUDE MERIDIAN (4) - LA(1) LATITUDE OF ORIGIN (5) - LO(1) LONGITUDE OF ORIGIN (6) - RESOLUTION FLAG (RIGHT ADJ COPY OF OCTET 17) (7) - LA(2) LATITUDE OF LAST GRID POINT (8) - LO(2) LONGITUDE OF LAST GRID POINT (9) - LATIT - LATITUDE OF PROJECTION INTERSECTION (10) - RESERVED (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) (12) - LONGITUDINAL DIR GRID LENGTH (13) - LATITUDINAL DIR GRID LENGTH LAMBERT CONFORMAL GRIDS (2) - NX NR POINTS ALONG X-AXIS (3) - NY NR POINTS ALONG Y-AXIS (4) - LA1 LAT OF ORIGIN (LOWER LEFT) C (5) - LO1 LON OF ORIGIN (LOWER LEFT) C (6) - RESOLUTION (RIGHT ADJ COPY OF OCTET 17) C (7) - LOV - ORIENTATION OF GRID C (8) - DX - X-DIR INCREMENT C (9) - DY - Y-DIR INCREMENT C (10) - PROJECTION CENTER FLAG C (11) - SCANNING MODE FLAG (RIGHT ADJ COPY OF OCTET 28) C (12) - LATIN 1 - FIRST LAT FROM POLE OF SECANT CONE INTER C (13) - LATIN 2 - SECOND LAT FROM POLE OF SECANT CONE INTER C OUTPUT ARGUMENTS: C KF INTEGER NUMBER OF DATA POINTS UNPACKED C K INTEGER MESSAGE NUMBER UNPACKED C (CAN BE SAME AS J IN CALLING PROGRAM C IN ORDER TO FACILITATE MULTIPLE SEARCHES) C KPDS INTEGER (200) UNPACKED PDS PARAMETERS C KGDS INTEGER (200) UNPACKED GDS PARAMETERS C LB LOGICAL*1 (KF) UNPACKED BITMAP IF PRESENT C F REAL (KF) UNPACKED DATA C IRET INTEGER RETURN CODE C 0 ALL OK C 96 ERROR READING INDEX FILE C 97 ERROR READING GRIB FILE C 98 NUMBER OF DATA POINTS GREATER THAN JF C 99 REQUEST NOT FOUND C OTHER W3FI63 GRIB UNPACKER RETURN CODE C C SUBPROGRAMS CALLED: C GETGBM FIND AND UNPACK GRIB MESSAGE C C REMARKS: IN ORDER TO UNPACK GRIB FROM A MULTIPROCESSING ENVIRONMENT C WHERE EACH PROCESSOR IS ATTEMPTING TO READ FROM ITS OWN PAIR OF C LOGICAL UNITS, ONE MUST DIRECTLY CALL SUBPROGRAM GETGBM AS BELOW, C ALLOCATING A PRIVATE COPY OF CBUF, NLEN AND NNUM TO EACH PROCESSOR. C DO NOT ENGAGE THE SAME LOGICAL UNIT FROM MORE THAN ONE PROCESSOR. C C ATTRIBUTES: C LANGUAGE: FORTRAN 77 C MACHINE: CRAY, WORKSTATIONS C C$$$ C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: BAOPEN BYTE-ADDRESSABLE OPEN C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04 C C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE. C C PROGRAM HISTORY LOG: C 1998-06-04 IREDELL C C USAGE: CALL BAOPEN(LU,CFN,IRET) C INPUT ARGUMENTS: C LU INTEGER UNIT TO OPEN C CFN CHARACTER FILENAME TO OPEN C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS) C OUTPUT ARGUMENTS: C IRET INTEGER RETURN CODE C C MODULES USED: C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE C C SUBPROGRAMS CALLED: C BACIO BYTE-ADDRESSABLE I/O C PACKAGE C C ATTRIBUTES: C LANGUAGE: FORTRAN 90 C C$$$ C$$$ SUBPROGRAM DOCUMENTATION BLOCK C C SUBPROGRAM: BACLOSE BYTE-ADDRESSABLE CLOSE C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04 C C ABSTRACT: CLOSE A BYTE-ADDRESSABLE FILE. C C PROGRAM HISTORY LOG: C 1998-06-04 IREDELL C C USAGE: CALL BACLOSE(LU,IRET) C INPUT ARGUMENTS: C LU INTEGER UNIT TO CLOSE C OUTPUT ARGUMENTS: C IRET INTEGER RETURN CODE C C MODULES USED: C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE C C SUBPROGRAMS CALLED: C BACIO BYTE-ADDRESSABLE I/O C PACKAGE C C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED. C C ATTRIBUTES: C LANGUAGE: FORTRAN 90 C C$$$