1 ! Print information about a grib file.
2 ! Usage: "gribscan [-v] [-V] filename"
3 ! as of now, the filename cannot be a full path name
8 subroutine parse_args(err, a1, h1, i1, l1, a2, h2, i2, l2,&
11 character(len=*) , optional :: a1, a2, a3
12 character(len=*), optional :: h1, h2, h3
13 integer , optional :: i1, i2, i3
14 logical, optional :: l1, l2, l3
15 character(len=*), optional :: hlast
16 end subroutine parse_args
19 character(len=120) :: flnm
20 character(len=30) :: hopt
21 real, allocatable, dimension(:) :: datarray
22 integer :: ierr, igherr
24 character(len=100) :: fmt = '(I4,1X, &
27 & 2(1x,I4),2x,I4.4,2("-",I2.2),"_",I2.2,":",&
28 & I2.2, 1x, "+", i2.2)'
29 logical :: ivb = .FALSE.
30 logical :: idb = .FALSE.
32 character(len=5) :: gc(255)
33 data gc /'PRES','PRMSL','PTEND','PVORT','ICAHT','GP','HGT','DIST',&
34 'HSTDV','TOZNE','TMP','VTMP','POT','EPOT','T MAX','T MIN','DPT',&
35 'DEPR','LAPR','VIS','RDSP1','RDSP2','RDSP3','PLI','TMP A','PRESA',&
36 'GP A','WVSP1','WVSP2','WVSP3','WDIR','WIND','U GRD','V GRD','STRM',&
37 'V POT','MNTSF','SGCVV','V VEL','DZDT','ABS V','ABD D','REL V','REL D',&
38 'VUCSH','VVCSG','DIR C','SP C','UOGRD','VOGRD','SPF H','R H','MIXR',&
39 'P WAT','VAPP','SAT D','EVP','C ICE','PRATE','TSTM','A PCP','NCPCP',&
40 'ACPCP','SRWEQ','WEASD','SNO D','MIXHT','TTHDP','MTHD','MTH A','T CDC',&
41 'CDCON','L CDC','M CDC','H CDC','C WAT','BLI','SNO C','SNO L','WTMP',&
42 'LAND','DSL M','SFC R','ALBDO','TSOIL','SOILM','VEG','SALTY','DEN',&
43 'WATR','ICE C','ICETK','DICED','SICED','U ICE','V ICE','ICE G','ICE D',&
44 'SNO M','HTSGW','WVDIR','WVHGT','WVPER','SWDIR','SWELL','SWPER','DIRPW',&
45 'PERPW','DIRSW','PERSW','NSWRS','NLWRS','NSWRT','NLWRT','LWAVR','SWAVR',&
46 'GRAD','BRTMP','LWRAD','SWRAD','LHTFL','SHTFL','BLYDP','U FLX','V FLX',&
48 ! 128-254 for use by originating center. NWS/NCEP usage is coded here.
49 'MSLSA','MSLMA','MSLET','LFT X','4LFTX','K X','S X','MCONV','VW SH',&
50 'TSLSA','BVF 2','PV MW','CRAIN','CFRZR','CICEP','CSNOW','SOILW',&
51 'PEVPR','CWORK','U-GWD','V-GWD','PV','COVMZ','COVTZ','COVTM','CLWMR',&
52 'O3MR','GFLUX','CIN','CAPE','TKE','CONDP','CSUSF','CSDSF','CSULF',&
53 'CSDLF','CFNSF','CFNLF','VBDSF','VDDSF','NBDSF','NDDSF','RWMR',&
54 'SNMR','M FLX','LMH','LMV','MLYNO','NLAT','ELON','ICMR','GRMR','GUST',&
55 'LPS X','LPS Y','HGT X','HGT Y','TPFI','TIPD','LTNG','RDRIP','VPTMP','HLCY',&
56 'PROB','PROBN','POP','CPOFP','CPOZP','USTM','VSTM','NCIP','EVBS','EVCW',&
57 'ICWAT','CWDI','VAFTD','DSWRF','DLWRF','UVI','MSTAV','SFEXC','MIXLY','TRANS',&
58 'USWRF','ULWRF','CDLYR','CPRAT','TTDIA','TTRAD','TTPHY','PREIX','TSD1D',&
59 'NLGSP','HPBL','5WAVH','CNWAT','SOTYP','VGTYP','BMIXL','AMIXL','PEVAP',&
60 'SNOHF','5WAVA','MFLUX','DTRF','UTRF','BGRUN','SSRUN','SIPD','O3TOT',&
61 'SNOWC','SNOT','COVTW','LRGHR','CNVHR','CNVMR','SHAHR','SHAMR','VDFHR',&
62 'VDFUA','VDFVA','VDFMR','SWHR','LWHR','CD','FRICV','RI',' '/
65 call parse_args(ierr, a1='v', l1=ivb, a2='V', l2=idb, hlast=flnm)
68 write(*,'(//,"Usage: ", A, " [-v] [-V] file",/)') trim(hopt)
69 write(*,'(" -v : Print more information about the GRIB records")')
70 write(*,'(" -V : Print way too much information about the GRIB&
72 write(*,'(" file : GRIB file to read"//)')
79 call c_open(idum, munit, flnm, 1, ierr, 1)
83 write(*,'(" rec GRIB GRIB Lvl Lvl Lvl Time Fcst")')
84 write(*,'(" Num Code name Code one two hour")')
89 call gribget(munit, ierr)
92 call gribheader(0,igherr)
95 call gribget(munit, ierr)
99 if ( sec1(3) .ne. 7 ) then ! gc defined only for NCEP
103 if ( sec1(3) .eq. 57 ) then ! AFWA
149 if (sec2(4).eq.50) then
150 ndat = (infogrid(1)+1)*(infogrid(2)+1)
152 ndat = (infogrid(1)*infogrid(2))
154 allocate(datarray(ndat))
155 call gribdata(datarray, ndat)
159 if (datarray(j).gt.fldmax) fldmax=datarray(j)
160 if (datarray(j).lt.fldmin) fldmin=datarray(j)
163 write(*,*) " ",gc(sec1(7))," : "
164 write(*,'(5x,"Minimum Data Value ",t45,":",g14.5)') fldmin
165 write(*,'(5x,"Maximum Data Value ",t45,":",g14.5)') fldmax
166 write(*,'(//,70("*"))')
168 print*, 'Datarray = ', Datarray
173 year = (cc-1)*100 + sec1(11)
174 write(*,FMT) irec, sec1(7), gc(sec1(7)), sec1(8:10), year,sec1(12:15),sec1(17)
179 call gribget(munit, ierr)
181 if (ierr.eq.1) write(*,'(/,"***** End-Of-File on C unit ", I3,/)') munit
182 call c_close( munit, 0, ierr)
186 subroutine parse_args(err, a1, h1, i1, l1, a2, h2, i2, l2, a3, h3, i3, l3, &
189 character(len=*) , optional :: a1, a2, a3
190 character(len=*), optional :: h1, h2, h3
191 integer , optional :: i1, i2, i3
192 logical, optional :: l1, l2, l3
193 character(len=*), optional :: hlast
195 character(len=100) :: hold
198 if (present(hlast)) then
208 LOOP : do while ( i <= numarg)
211 if (present(i1)) then
212 call checkiarg(i, a1, i1, ierr)
213 elseif (present(h1)) then
214 call checkharg(i, a1, h1, ierr)
215 elseif (present(l1)) then
216 call checklarg(i, a1, l1, ierr)
218 if (ierr.eq.0) cycle LOOP
220 if (present(i2)) then
221 call checkiarg(i, a2, i2, ierr)
222 elseif (present(h2)) then
223 call checkharg(i, a2, h2, ierr)
224 elseif (present(l2)) then
225 call checklarg(i, a2, l2, ierr)
227 if (ierr.eq.0) cycle LOOP
229 if (present(i3)) then
230 call checkiarg(i, a3, i3, ierr)
231 elseif (present(h3)) then
232 call checkharg(i, a3, h3, ierr)
233 elseif (present(l3)) then
234 call checklarg(i, a3, l3, ierr)
236 if (ierr.eq.0) cycle LOOP
240 write(*, '("arg = ", A)') trim(hold)
246 if (present(hlast)) then
250 call getarg(narg, hlast)
255 subroutine checkiarg(c, a, i, ierr)
257 character(len=*) :: a
260 character(len=100) :: hold
265 if ('-'//a.eq.trim(hold)) then
271 elseif ('-'//a .eq. hold(1:len_trim(a)+1)) then
272 hold = hold(len_trim(a)+2: len(hold))
278 end subroutine checkiarg
279 subroutine checkharg(c, a, h, ierr)
281 character(len=*) :: a
282 character(len=*) :: h
284 character(len=100) :: hold
289 if ('-'//a.eq.trim(hold)) then
295 elseif ('-'//a .eq. hold(1:len_trim(a)+1)) then
296 hold = hold(len_trim(a)+2: len(hold))
302 end subroutine checkharg
304 subroutine checklarg(c, a, l, ierr)
306 character(len=*) :: a
309 character(len=100) :: hold
313 if ('-'//a.eq.trim(hold)) then
319 end subroutine checklarg
321 end subroutine parse_args