00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 program get_data
00016 use grib_api
00017 implicit none
00018 integer :: ifile
00019 integer :: iret,i
00020 real(kind=8),dimension(:),allocatable :: lats,lons,values
00021 integer(4) :: numberOfPoints
00022 real(8) :: missingValue=9999
00023 integer :: count=0
00024 character(len=256) :: filename
00025
00026
00027 integer :: igrib
00028
00029 ifile=5
00030
00031 call grib_open_file(ifile, &
00032 '../../data/reduced_latlon_surface.grib1','R')
00033
00034
00035
00036 call grib_new_from_file(ifile,igrib,iret)
00037
00038 do while (iret/=GRIB_END_OF_FILE)
00039 count=count+1
00040 print *, "===== Message #",count
00041 call grib_get(igrib,'numberOfPoints',numberOfPoints)
00042 call grib_set(igrib,'missingValue',missingValue)
00043
00044 allocate(lats(numberOfPoints))
00045 allocate(lons(numberOfPoints))
00046 allocate(values(numberOfPoints))
00047
00048 call grib_get_data(igrib,lats,lons,values)
00049
00050 do i=1,numberOfPoints
00051 if (values(i) /= missingValue) then
00052 print *, lats(i),lons(i),values(i)
00053 end if
00054 enddo
00055
00056 deallocate(lats)
00057 deallocate(lons)
00058 deallocate(values)
00059
00060 call grib_release(igrib)
00061 call grib_new_from_file(ifile,igrib, iret)
00062
00063 end do
00064
00065
00066 call grib_close_file(ifile)
00067
00068 end program