1 subroutine gf_unpack2(cgrib,lcgrib,iofst,lencsec2,csec2,ierr)
2 !$$$ SUBPROGRAM DOCUMENTATION BLOCK
4 ! SUBPROGRAM: gf_unpack2
5 ! PRGMMR: Gilbert ORG: W/NP11 DATE: 2002-04-09
7 ! ABSTRACT: This subroutine unpacks Section 2 (Local Use Section)
8 ! as defined in GRIB Edition 2.
10 ! PROGRAM HISTORY LOG:
13 ! USAGE: CALL gf_unpack2(cgrib,lcgrib,iofst,lencsec2,csec2,ierr)
14 ! INPUT ARGUMENT LIST:
15 ! cgrib - Character array containing Section 2 of the GRIB2 message
16 ! lcgrib - Length (in bytes) of GRIB message array cgrib.
17 ! iofst - Bit offset of the beginning of Section 2.
19 ! OUTPUT ARGUMENT LIST:
20 ! iofst - Bit offset at the end of Section 2, returned.
21 ! lencsec2 - Length (in octets) of Local Use data
22 ! csec2() - Pointer to a character*1 array containing local use data
23 ! ierr - Error return code.
25 ! 2 = Array passed is not section 2
26 ! 6 = memory allocation error
31 ! LANGUAGE: Fortran 90
36 character(len=1),intent(in) :: cgrib(lcgrib)
37 integer,intent(in) :: lcgrib
38 integer,intent(inout) :: iofst
39 integer,intent(out) :: lencsec2
40 integer,intent(out) :: ierr
41 character(len=1),pointer,dimension(:) :: csec2
47 call g2lib_gbyte(cgrib,lensec,iofst,32) ! Get Length of Section
50 call g2lib_gbyte(cgrib,isecnum,iofst,8) ! Get Section Number
54 if ( isecnum.ne.2 ) then
56 print *,'gf_unpack2: Not Section 2 data. '
60 allocate(csec2(lencsec2),stat=istat)
67 csec2(1:lencsec2)=cgrib(ipos:ipos+lencsec2-1)
68 iofst=iofst+(lencsec2*8)
70 return ! End of Section 2 processing