00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 program set_bitmap
00016 use grib_api
00017 implicit none
00018 integer :: infile,outfile
00019 integer :: igrib, iret
00020 integer :: numberOfValues
00021 real, dimension(:), allocatable :: values
00022 real :: missingValue
00023 logical :: grib1Example
00024
00025 grib1Example=.true.
00026
00027 if (grib1Example) then
00028
00029 call grib_open_file(infile,'../../data/regular_latlon_surface.grib1','r')
00030 else
00031
00032 call grib_open_file(infile,'../../data/regular_latlon_surface.grib2','r')
00033 end if
00034
00035 call grib_open_file(outfile,'out.grib','w')
00036
00037
00038
00039 call grib_new_from_file(infile,igrib)
00040
00041
00042
00043
00044
00045
00046 missingValue=9999
00047 call grib_set(igrib, 'missingValue',missingValue)
00048 write(*,*) 'missingValue=',missingValue
00049
00050
00051 call grib_get_size(igrib,'values',numberOfValues)
00052 write(*,*) 'numberOfValues=',numberOfValues
00053
00054 allocate(values(numberOfValues), stat=iret)
00055
00056
00057 call grib_get(igrib,'values',values)
00058
00059
00060 call grib_set(igrib,"bitmapPresent",1)
00061
00062
00063 values(1:10) = missingValue
00064
00065
00066 call grib_set(igrib,'values', values)
00067
00068
00069 call grib_write(igrib,outfile)
00070
00071
00072 call grib_release(igrib)
00073
00074 call grib_close_file(infile)
00075
00076 call grib_close_file(outfile)
00077
00078 deallocate(values)
00079
00080 end program set_bitmap