⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grib1.doc

📁 计算线性趋势 回归系数 主要用于气象站点值的线性趋势计算
💻 DOC
📖 第 1 页 / 共 4 页
字号:
                             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===============================================================================                                 IntroductionThis document briefly describes the routines available for encoding/decodingGRIB Edition 1 messages.  A basic familiarity with GRIB is assumed.A GRIB message is a machine independent format for storingone or more gridded data fields.  Each GRIB message consists of the following sections:SECTION 0 - Indicator SectionSECTION 1 - Product Definition Section (PDS)SECTION 2 - Grid Definition Section (GDS)SECTION 3 - Bit-map Section (Optional)SECTION 4 - Binary Data SectionSECTION 5 - End Section===============================================================================                       GRIB1 Encoding RoutinesThere are several routines that one can use to encode a GRIB1 message.Subroutine W3FI72 can be used to encode a GRIB1 message which is passedback to the calling program in a character array.  It is the users responsibility to ensure that the character array that willhold 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      endThere 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 subroutineargument usage for the routines mentioned above.===============================================================================                      GRIB1 Decoding RoutineSubroutine W3FI63 can be used to decode a given GRIB1 message that residesin a character array in memory.  This routine will return the unpacked valuesin 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 havebeen allocated large enough prior to calling W3FI63.  Please see the "GRIB1 Routine Docblocks" section below for subroutineargument usage for the routine mentioned above.===============================================================================                Extracting GRIB1 Fields from a GRIB1 fileSubroutine GETGB can be used to extract a specified field from a filecontaining many GRIB1 messages.  GETGB searches an index to find the location of the user specified field.  The index can be supplied from aseparate GRIB1 index file, or it can be generated internally.The GRIB1 data file ( and the index file, if supplied ) must be opened witha call to subroutine BAOPEN prior to the call to GETGB.Users can request a particular field by specifying the PDS and GDSvalues 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 subroutineargument usage for the routines mentioned above.===============================================================================                         GRIB1 TablesWMO'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 codetable information.  This document can be found athttp://www.wmo.ch/web/www/WDM/Guides/Guide-binary.htmlIn 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 DocblocksC$$$  SUBPROGRAM DOCUMENTATION BLOCKC                .      .    .                                       .C SUBPROGRAM:  W3FI72        MAKE A COMPLETE GRIB MESSAGEC   PRGMMR: FARLEY           ORG: NMC421      DATE:94-11-22CC ABSTRACT: MAKES A COMPLETE GRIB MESSAGE FROM A USER SUPPLIEDC   ARRAY OF FLOATING POINT OR INTEGER DATA.  THE USER HAS THEC   OPTION OF SUPPLYING THE PDS OR AN INTEGER ARRAY THAT WILL BEC   USED TO CREATE A PDS (WITH W3FI68).  THE USER MUST ALSOC   SUPPLY OTHER NECESSARY INFO; SEE USAGE SECTION BELOW.CC PROGRAM HISTORY LOG:C   91-05-08  R.E.JONESC   92-07-01  M. FARLEY    ADDED GDS AND BMS LOGIC.  PLACED EXISTINGC                          LOGIC FOR BDS IN A ROUTINE.C   92-10-02  R.E.JONES    ADD ERROR EXIT FOR W3FI73C   93-04-30  R.E.JONES    REPLACE DO LOOPS TO MOVE CHARACTER DATAC                          WITH XMOVEX, USE XSTORE TO ZERO CHARACTERC                          ARRAY. MAKE CHANGE SO FLAT FIELD WILL PACK.C   93-08-06  CAVANAUGH    MODIFIED CALL TO W3FI75C   93-10-26  CAVANAUGH    ADDED CODE TO RESTORE INPUT FIELD TO ORIGINALC                          VALUES IF D-SCALE NOT 0C   94-01-27  CAVANAUGH    ADDED IGDS ARRAY IN CALL TO W3FI75 TO PROVIDEC                          INFORMATION FOR BOUSTROPHEDONIC PROCESSINGC   94-03-03  CAVANAUGH    INCREASED SIZE OF GDS ARRAY FOR THIN GRIDSC   94-05-16  FARLEY       CLEANED UP DOCUMENTATIONC   94-11-10  FARLEY       INCREASED SIZE OF PFLD/IFLD ARRARYS FROMC                          100K TO 260K FOR .5 DEGREE SST ANAL FIELDSC   94-12-04  R.E.JONES    CHANGE DOCUMENT FOR IPFLAG.C   95-10-31  IREDELL      REMOVED SAVES AND PRINTSC   98-05-19  Gilbert      Increased array dimensions to handle gridsC                          of up to 500,000 grid points.C   95-10-31  IREDELL      GENERALIZED WORD SIZEC   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 wasC                          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.CC 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)CC   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 BEC                CONVERTED TO GRIB FORMAT IF ITYPE=0.C                SEE REMARKS #1 & 2.C     IFLD     - INTEGER ARRAY OF DATA (AT PROPER GRIDPOINTS) TO BEC                CONVERTED TO GRIB FORMAT IF ITYPE=1.C                SEE REMARKS #1 & 2.C     IBITL    - 0 = COMPUTER COMPUTES LENGTH FOR PACKING DATA FROMC                    POWER OF 2 (NUMBER OF BITS) BEST FIT OF DATAC                    USING 'VARIABLE' BIT PACKER W3FI58.C                8, 12, ETC. COMPUTER RESCALES DATA TO FIT INTO THATC                    'FIXED' NUMBER OF BITS USING W3FI59.C                SEE REMARKS #3.CC     IPFLAG   - 0 = MAKE PDS FROM USER SUPPLIED ARRAY (ID)C                1 = USER SUPPLYING PDSC                NOTE: IF PDS IS GREATER THAN 30, USE IPLFAG=1.C                THE USER COULD CALL W3FI68 BEFORE HE CALLSC                W3FI72. THIS WOULD MAKE THE FIRST 30 BYTES OFC                THE PDS, USER THEN WOULD MAKE BYTES AFTER 30.C     ID       - INTEGER ARRAY OF  VALUES THAT W3FI68 WILL USEC                TO MAKE AN EDITION 1 PDS IF IPFLAG=0.  (SEE THEC                DOCBLOCK FOR W3FI68 FOR LAYOUT OF ARRAY)C     PDS      - CHARACTER ARRAY OF VALUES (VALID PDS SUPPLIEDC                BY USER) IF IPFLAG=1. LENGTH MAY EXCEED 28 BYTESC                (CONTENTS OF BYTES BEYOND 28 ARE PASSEDC                THROUGH UNCHANGED).CC     IGFLAG   - 0 = MAKE GDS BASED ON 'IGRID' VALUE.C                1 = MAKE GDS FROM USER SUPPLIED INFO IN 'IGDS'C                    AND 'IGRID' VALUE.C                SEE REMARKS #4.C     IGRID    - #   = GRID IDENTIFICATION (TABLE B)C                255 = IF USER DEFINED GRID; IGDS MUST BE SUPPLIEDC                      AND IGFLAG MUST =1.C     IGDS     - INTEGER ARRAY CONTAINING USER GDS INFO (SAMEC                FORMAT AS SUPPLIED BY W3FI71 - SEE DOCKBLOCK FORC                LAYOUT) IF IGFLAG=1.C     ICOMP    - RESOLUTION AND COMPONENT FLAG FOR BIT 5 OF GDS(17)C                0 = EARTH ORIENTED WINDSC                1 = GRID ORIENTED WINDSCC     IBFLAG   - 0 = MAKE BIT MAP FROM USER SUPPLIED DATAC                # = BIT MAP PREDEFINED BY CENTERC                SEE REMARKS #5.C     IBMAP    - INTEGER ARRAY CONTAINING BIT MAPC     IBLEN    - LENGTH OF BIT MAP WILL BE USED TO VERIFY LENGTHC                OF FIELD (ERROR IF IT DOESN'T MATCH).CC     IBDSFL   - INTEGER ARRAY CONTAINING TABLE 11 FLAG INFOC                BDS OCTET 4:C                (1) 0 = GRID POINT DATAC                    1 = SPHERICAL HARMONIC COEFFICIENTSC                (2) 0 = SIMPLE PACKINGC                    1 = SECOND ORDER PACKINGC                (3) ... SAME VALUE AS 'ITYPE'C                    0 = ORIGINAL DATA WERE FLOATING POINT VALUESC                    1 = ORIGINAL DATA WERE INTEGER VALUESC                (4) 0 = NO ADDITIONAL FLAGS AT OCTET 14C                    1 = OCTET 14 CONTAINS FLAG BITS 5-12C                (5) 0 = RESERVED - ALWAYS SET TO 0C         BYTE 6 OPTION 1 NOT AVAILABLE (AS OF 5-16-93)C                (6) 0 = SINGLE DATUM AT EACH GRID POINTC                    1 = MATRIX OF VALUES AT EACH GRID POINTC         BYTE 7 OPTION 0 WITH SECOND ORDER PACKING N/A (AS OF 5-16-93)C                (7) 0 = NO SECONDARY BIT MAPSC                    1 = SECONDARY BIT MAPS PRESENTC                (8) 0 = SECOND ORDER VALUES HAVE CONSTANT WIDTHC                    1 = SECOND ORDER VALUES HAVE DIFFERENT WIDTHSCC   OUTPUT ARGUMENT LIST:C     NPTS     - NUMBER OF GRIDPOINTS IN ARRAY FLD OR IFLDC     KBUF     - ENTIRE GRIB MESSAGE ('GRIB' TO '7777')C                EQUIVALENCE TO INTEGER ARRAY TO MAKE SURE ITC                IS ON WORD BOUNARY.C     ITOT     - TOTAL LENGTH OF GRIB MESSAGE IN BYTESC     JERR     - = 0, COMPLETED MAKING GRIB FIELD WITHOUT ERRORC                  1, IPFLAG NOT 0 OR 1C                  2, IGFLAG NOT 0 OR 1C                  3, ERROR CONVERTING IEEE F.P. NUMBER TO IBM370 F.P.C                  4, W3FI71 ERROR/IGRID NOT DEFINEDC                  5, W3FK74 ERROR/GRID REPRESENTATION TYPE NOT VALIDC                  6, GRID TOO LARGE FOR PACKER DIMENSION ARRAYSC                     SEE AUTOMATION DIVISION FOR REVISION!C                  7, LENGTH OF BIT MAP NOT EQUAL TO SIZE OF FLD/IFLDC                  8, W3FI73 ERROR, ALL VALUES IN IBMAP ARE ZEROCC   OUTPUT FILES:C     FT06F001 - STANDARD FORTRAN OUTPUT PRINT FILECC   SUBPROGRAMS CALLED:C     LIBRARY:C       W3LIB    - W3FI58, W3FI59, W3FI68, W3FI71, W3FI73, W3FI74C                  W3FI75, W3FI76C       FORTRAN 90 INTRINSIC - BIT_SIZECC REMARKS:C   1)  IF BIT MAP TO BE INCLUDED IN MESSAGE, NULL DATA SHOULDC       BE INCLUDED IN FLD OR IFLD.  THIS ROUTINE WILL TAKE CAREC       OF 'DISCARDING' ANY NULL DATA BASED ON THE BIT MAP.C   2)  UNITS MUST BE THOSE IN GRIB DOCUMENTATION:  NMC O.N. 388C       OR WMO PUBLICATION 306.C   3)  IN EITHER CASE, INPUT NUMBERS WILL BE MULTIPLIED BYC       '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 DEFINITIONC       SECTION INCLUDED IN THE GRIB MESSAGE.  ID(6) WILL BEC       SET TO '1'.C       - GDS WILL BE BUILT BASED ON GRID NUMBER (IGRID), UNLESS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -