NCEPLIBS-g2 4.0.0
Loading...
Searching...
No Matches
skgb.F90
Go to the documentation of this file.
1
4
20subroutine skgb(lugb, iseek, mseek, lskip, lgrib)
21 implicit none
22
23 integer :: lugb, iseek, mseek, lskip, lgrib
24 integer*8 :: iseek8, mseek8, lskip8, lgrib8
25
26 iseek8 = iseek
27 mseek8 = mseek
28 call skgb8(lugb, iseek8, mseek8, lskip8, lgrib8)
29 lskip = int(lskip8, kind = 4)
30 lgrib = int(lgrib8, kind = 4)
31
32end subroutine skgb
33
52subroutine skgb8(lugb, iseek8, mseek8, lskip8, lgrib8)
53 implicit none
54
55 integer*8 iseek8, mseek8, lskip8, lgrib8
56 integer*8 ks8, kn8, kz8, k48, km8
57 integer lseek, lugb, i1, i4, k, kg
58 parameter(lseek = 512)
59 character z(lseek)
60 character z4(4)
61
62 lgrib8 = 0
63 ks8 = iseek8
64 kn8 = min(int(lseek, kind = 8), mseek8)
65 kz8 = lseek
66
67 ! loop until grib message is found
68 do while (lgrib8 .eq. 0 .and. kn8 .ge. 8 .and. kz8 .eq. lseek)
69 ! read partial section
70 call bareadl(lugb, ks8, kn8, kz8, z)
71
72 km8 = kz8 - 8 + 1
73 k = 0
74 ! look for 'grib...1' in partial section
75 do while (lgrib8 .eq. 0 .and. k .lt. km8)
76 call g2_gbytec(z, i4, (k + 0) * 8, 4 * 8)
77 call g2_gbytec(z, i1, (k + 7) * 8, 1 * 8)
78 if (i4 .eq. 1196575042 .and. (i1 .eq. 1 .or. i1 .eq. 2)) then
79 ! look for '7777' at end of grib message
80 if (i1 .eq. 1) call g2_gbytec(z, kg, (k + 4) * 8, 3 * 8)
81 if (i1 .eq. 2) call g2_gbytec(z, kg, (k + 12) * 8, 4 * 8)
82
83 call bareadl(lugb, ks8 + k + kg - 4, 4_8, k48, z4)
84 if (k48 .eq. 4) then
85 call g2_gbytec(z4, i4, 0, 4 * 8)
86 if (i4 .eq. 926365495) then
87 ! grib message found
88 lskip8 = ks8 + k
89 lgrib8 = kg
90 endif
91 endif
92 endif
93 k = k + 1
94 enddo
95 ks8 = ks8 + km8
96 kn8 = min(int(lseek, kind = 8), iseek8 + mseek8 - ks8)
97 enddo
98end subroutine skgb8
subroutine g2_gbytec(in, iout, iskip, nbits)
Extract one arbitrary size big-endian value (up to 32 bits) from a packed bit string into one element...
Definition g2bytes.F90:21
subroutine skgb(lugb, iseek, mseek, lskip, lgrib)
Search a file for the next GRIB1 or GRIB2 message.
Definition skgb.F90:21
subroutine skgb8(lugb, iseek8, mseek8, lskip8, lgrib8)
Search a file for the next GRIB1 or GRIB2 message.
Definition skgb.F90:53