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

📄 grib2.doc

📁 计算线性趋势 回归系数 主要用于气象站点值的线性趋势计算
💻 DOC
📖 第 1 页 / 共 5 页
字号:
                             GRIB2 USERS GUIDE (FORTRAN 90)Contents:- Introduction- GRIB2 Encoding Routines- GRIB2 Decoding Routines- Extracting GRIB2 Fields from a GRIB2 file- GRIB2 Tables/Templates- GRIB2 Routine Docblocks===============================================================================                                 IntroductionThis document briefly describes the routines available for encoding/decodingGRIB Edition 2 (GRIB2) messages.  A basic familiarity with GRIB is assumed.A GRIB Edition 2 message is a machine independent format for storingone or more gridded data fields.  Each GRIB2 message consists of the following sections:SECTION 0 - Indicator SectionSECTION 1 - Identification SectionSECTION 2 - (Local Use Section) - optional                           }SECTION 3 - Grid Definition Section                     }            }SECTION 4 - Product Definition Section    }             }            }(repeated)SECTION 5 - Data Representation Section   }             }(repeated)  }SECTION 6 - Bit-map Section               }(repeated)   }            }SECTION 7 - Data Section                  }             }            }SECTION 8 - End Section                   }             }            }Sequences of GRIB sections 2 to 7, 3 to 7, or sections 4 to 7 may be repeatedwithin a single GRIB message.  All sections within such repeated sequencesmust be present and shall appear in the numerical order noted above.Unrepeated sections remain in effect until redefined.The above overview was taken from WMO's FM 92-XII GRIB descriptionof the experimental GRIB Edition 2 form.===============================================================================                       GRIB2 Encoding RoutinesSince a GRIB2 message can contain gridded fields for many parameters ona number of different grids, several routines are used to encode a message.This should give users more flexibility in how to organize datawithin one or more GRIB2 messages.To start a new GRIB2 message, call subroutine GRIBCREATE.  GRIBCREATE encodes Sections 0 and 1 at the beginning of the message.  This routine must be used to create each message.Subroutine ADDLOCAL can be used to add a Local Use Section ( Section 2 ).Note that section is optional and need not appear in a GRIB2 message.Subroutine ADDGRID is used to encode a grid definition into Section 3.This grid definition defines the geometry of the the data values in thefields that follow it.  ADDGRID can be called again to change the grid definition describing subsequent data fields.Each data field is added to the GRIB2 message using routine ADDFIELD,which adds Sections 4, 5, 6, and 7 to the message.After all desired data fields have been added to the GRIB2 message, acall to routine GRIBEND is needed to add the final section 8 to themessage and to update the length of the message.  A call to GRIBENDis required for each GRIB2 message.Please see the "GRIB2 Routine Docblocks" section below for subroutineargument usage for the routines mentioned above.===============================================================================                      GRIB2 Decoding RoutinesSubroutine GB_INFO can be used to find out how many Local Use sectionsand data fields are contained in a given GRIB2 message.  In addition,this routine also returns the number of octets of the largest Local Use section in the message.  This value can be used to ensure that the output array of subroutine GETLOCAL ( described below ) is dimensionedlarge enough.Subroutine GETLOCAL will return the requested occurrence of Section 2from a given GRIB2 message.  GF_GETFLD can be used to get all information pertaining to the nth data field in the message.  The subroutine returns all the unpacked valuesfor each Section and Template in a Fortran 90 derived type gribfield,which is defined in module GRIB_MOD.  An option exists that lets theuser decide if the subroutine should unpack the Bit-map ( ifapplicable ) and the data values or just return the field descriptioninformation.Note that derived type gribfield contains pointers to dynamicallyallocated space that holds the contents of all arrays, and users are encouraged to free up this memory, when it is no longer needed, by an explicit callto subroutine GF_FREE.Please see the "GRIB2 Routine Docblocks" section below for subroutineargument usage for the routines mentioned above.===============================================================================                Extracting GRIB2 Fields from a GRIB2 fileSubroutine GETGB2 can be used to extract a specified field from a filecontaining many GRIB2 messages.  GETGB2 searches an index to find the location of the user specified field.  The index can be supplied from aseperate GRIB2 index file, or it can be generated internally.The GRIB2 file ( and the index file, if supplied ) must be opened witha call to subroutine BAOPEN prior to the call to GETGB2.The decoded information for the selected GRIB field is returned in a derived type variable, gfld.  Gfld is of type gribfield, which is definedin module grib_mod, so users of this routine will need to includethe line "USE GRIB_MOD" in their calling routine.  Each component of thegribfield type is described in the OUTPUT ARGUMENT LIST in the docblockfor subroutine GETGB2 below.Note that derived type gribfield contains pointers to many arrays of data.  The memory for these arrays is allocated when the values in the arrays are set, to help minimize problems with array overloading.  Because of this,users are encouraged to free up this memory, when it is no longerneeded, by an explicit call to subroutine GF_FREE.Example usage:      use grib_mod      type(gribfield) :: gfld      integer,dimension(200) :: jids,jpdt,jgdt      logical :: unpack=.true.      ifile=10  ! Open GRIB2 file       call baopenr(ifile,"filename",iret)      .  ! Set GRIB2 field identification values to search for      jdisc=      jids(?)=      jpdtn=      jpdt(?)=      jgdtn=      jgdt(?)=  ! Get field from file      call getgb2(ifile,0,j,jdisc,jids,jpdtn,jpdt,jgdtn,jgdt,     &            unpack,j,gfld,iret)  ! Process field ...      firstval=gfld%fld(1)      lastval=gfld%fld(gfld%ndpts)      fldmax=maxval(gfld%fld)      fldmin=minval(gfld%fld)        ! Free memory when done with field      call gf_free(gfld)      stop      end      Please see the "GRIB2 Routine Docblocks" section below for subroutineargument usage for the routines mentioned above.===============================================================================                         GRIB2 Tables/TemplatesWMO's GRIB2 specification "FM 92-XII GRIB - General Regularly-distributedInformation in Binary Form" contains descriptions of each templateand code table information.  This document can be found athttp://www.wmo.ch/web/www/WMOCodes.html(PDF and MSWord formats are available)MDL has made an HTML version of the document available athttp://www.nws.noaa.gov/tdl/iwt/grib2/frameset_grib2.htm.===============================================================================                       GRIB2 Routine Docblocks!$$$  SUBPROGRAM DOCUMENTATION BLOCK!                .      .    .                                       .! SUBPROGRAM:    gribcreate !   PRGMMR: Gilbert         ORG: W/NP11    DATE: 2000-04-28!! ABSTRACT: This subroutine initializes a new GRIB2 message and packs!   GRIB2 sections 0 (Indicator Section) and 1 (Identification Section).!   This routine is used with routines "addlocal", "addgrid", "addfield",!   and "gribend" to create a complete GRIB2 message.  Subroutine!   gribcreate must be called first to initialize a new GRIB2 message.!   Also, a call to gribend is required to complete GRIB2 message!   after all fields have been added.!! PROGRAM HISTORY LOG:! 2000-04-28  Gilbert!! USAGE:    CALL gribcreate(cgrib,lcgrib,listsec0,listsec1,ierr)!   INPUT ARGUMENT LIST:!     cgrib    - Character array to contain the GRIB2 message!     lcgrib   - Maximum length (bytes) of array cgrib.!     listsec0 - Contains information needed for GRIB Indicator Section 0.!                Must be dimensioned >= 2.!                listsec0(1)=Discipline-GRIB Master Table Number!                            (see Code Table 0.0)!                listsec0(2)=GRIB Edition Number (currently 2)!     listsec1 - Contains information needed for GRIB Identification Section 1.!                Must be dimensioned >= 13.!                listsec1(1)=Id of orginating centre (Common Code Table C-1)!                listsec1(2)=Id of orginating sub-centre (local table)!                listsec1(3)=GRIB Master Tables Version Number (Code Table 1.0)!                listsec1(4)=GRIB Local Tables Version Number (Code Table 1.1)!                listsec1(5)=Significance of Reference Time (Code Table 1.2)!                listsec1(6)=Reference Time - Year (4 digits)!                listsec1(7)=Reference Time - Month!                listsec1(8)=Reference Time - Day!                listsec1(9)=Reference Time - Hour!                listsec1(10)=Reference Time - Minute!                listsec1(11)=Reference Time - Second!                listsec1(12)=Production status of data (Code Table 1.3)!                listsec1(13)=Type of processed data (Code Table 1.4)!!   OUTPUT ARGUMENT LIST:      !     cgrib    - Character array to contain the GRIB2 message!     ierr     - Error return code.!                0 = no error!                1 = Tried to use for version other than GRIB Edition 2!! REMARKS: This routine is intended for use with routines "addlocal", !          "addgrid", "addfield", and "gribend" to create a complete !          GRIB2 message.!! ATTRIBUTES:!   LANGUAGE: Fortran 90!   MACHINE:  IBM SP!!$$$!$$$  SUBPROGRAM DOCUMENTATION BLOCK!                .      .    .                                       .! SUBPROGRAM:    addlocal !   PRGMMR: Gilbert         ORG: W/NP11    DATE: 2000-05-01!! ABSTRACT: This subroutine adds a Local Use Section (Section 2) to !   a GRIB2 message.!   This routine is used with routines "gribcreate", "addgrid", "addfield",

⌨️ 快捷键说明

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