2 PROGRAM test_grib1_routines
5 CHARACTER, DIMENSION(:), POINTER :: fileindex
6 REAL , DIMENSION(:), POINTER :: data
15 CHARACTER(40) :: datestr
21 character(200) :: value
22 character(20) :: strval
25 integer :: NumberTimes
26 character (19) :: Time
27 character (19), pointer :: Times(:)
29 integer :: numcols, numrows
30 integer :: center, subcenter, parmtbl
34 datestr = '2005041412'
44 print *,'about to call GET_FILEINDEX_SIZE'
45 CALL GET_FILEINDEX_SIZE(size)
46 ALLOCATE(fileindex(1:size), STAT=istat)
48 print *,'about to call ALLOC_INDEX_FILE'
49 CALL ALLOC_INDEX_FILE(fileindex)
50 print *,'about to call OPEN_FILE'
51 CALL OPEN_FILE('test.grb','r',fid,err)
52 print *,'about to call INDEX_FILE'
53 CALL INDEX_FILE(fid,fileindex)
55 print *,'about to call GET_GRIB_INDEX'
56 CALL GET_GRIB_INDEX(fileindex, center, subcenter, parmtbl, &
57 parmid,trim(datestr),leveltype,level1,level2, &
58 fcsttime1,fcsttime2,index)
59 print *,'got grib index: ',index
61 print *,'about to call GET_METADATA_VALUE'
62 CALL GET_METADATA_VALUE(fileindex, 'GRIB_GRID_ID', "none", "none", &
65 print *,'about to call GET_NUM_TIMES'
66 CALL GET_NUM_TIMES(fileindex, NumberTimes)
67 print *,'found ',NumberTimes,' times'
69 ALLOCATE(Times(1:NumberTimes), STAT=ierr)
70 print *,'about to call GET_TIME'
71 CALL GET_TIME(fileindex,1,Time)
74 print *,'about to call GET_SIZEOF_GRID'
75 CALL GET_SIZEOF_GRID(fileindex,index,numcols,numrows)
76 allocate(data(1:numcols*numrows))
78 print *,'about to call READ_GRIB'
79 CALL READ_GRIB(fileindex,fid,index,data)
80 print *,'data(20): ',data(20)
84 print *,'about to call FREE_INDEX_FILE'
85 CALL FREE_INDEX_FILE(fileindex)
87 print *,'program completed'