mirror of https://github.com/ecmwf/eccodes.git
Examples: cleanup
This commit is contained in:
parent
53a870d67b
commit
25b20cec5f
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_attributes
|
|
||||||
!
|
!
|
||||||
! Description: How to read attributes of keys in BUFR messages.
|
! Description: How to read attributes of keys in BUFR messages.
|
||||||
!
|
!
|
||||||
|
@ -25,8 +24,8 @@ program bufr_attributes
|
||||||
|
|
||||||
call codes_open_file(ifile, '../../data/bufr/syno_multi.bufr', 'r')
|
call codes_open_file(ifile, '../../data/bufr/syno_multi.bufr', 'r')
|
||||||
|
|
||||||
! the first BUFR message is loaded from file
|
! the first BUFR message is loaded from file
|
||||||
! ibufr is the BUFR id to be used in subsequent calls
|
! ibufr is the BUFR id to be used in subsequent calls
|
||||||
call codes_bufr_new_from_file(ifile, ibufr, iret)
|
call codes_bufr_new_from_file(ifile, ibufr, iret)
|
||||||
|
|
||||||
do while (iret /= CODES_END_OF_FILE)
|
do while (iret /= CODES_END_OF_FILE)
|
||||||
|
@ -38,8 +37,8 @@ program bufr_attributes
|
||||||
! i.e. unpack the data values
|
! i.e. unpack the data values
|
||||||
call codes_set(ibufr, "unpack", 1);
|
call codes_set(ibufr, "unpack", 1);
|
||||||
! ----------------------------------------------------------------
|
! ----------------------------------------------------------------
|
||||||
! We will read the value and all the attributes available for
|
! We will read the value and all the attributes available for
|
||||||
! the 2m temperature.
|
! the 2m temperature.
|
||||||
! ----------------------------------------------------------------
|
! ----------------------------------------------------------------
|
||||||
|
|
||||||
! Get the element's value as as real
|
! Get the element's value as as real
|
||||||
|
@ -67,9 +66,9 @@ program bufr_attributes
|
||||||
write (*, *) ' airTemperatureAt2M->width:', iVal
|
write (*, *) ' airTemperatureAt2M->width:', iVal
|
||||||
|
|
||||||
! -------------------------------------------------------------------
|
! -------------------------------------------------------------------
|
||||||
! The 2m temperature data element in this message has an associated
|
! The 2m temperature data element in this message has an associated
|
||||||
! field: percentConfidence. Its value and attributes can be accessed
|
! field: percentConfidence. Its value and attributes can be accessed
|
||||||
! in a similar manner as was shown above for 2m temperature.
|
! in a similar manner as was shown above for 2m temperature.
|
||||||
! -------------------------------------------------------------------
|
! -------------------------------------------------------------------
|
||||||
|
|
||||||
! Get the element's value as as real
|
! Get the element's value as as real
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_clone
|
|
||||||
!
|
!
|
||||||
! Description: How to create a new BUFR message by cloning
|
! Description: How to create a new BUFR message by cloning
|
||||||
! an existing message.
|
! an existing message.
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_copy_data
|
|
||||||
!
|
!
|
||||||
! Description: How to copy all the values in the data section that are present in the same
|
! Description: How to copy all the values in the data section that are present in the same
|
||||||
! position in the data tree and with the same number of values to the output handle
|
! position in the data tree and with the same number of values to the output handle
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_expanded
|
|
||||||
!
|
!
|
||||||
! Description: How to read all the expanded data values from BUFR messages.
|
! Description: How to read all the expanded data values from BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_get_keys
|
|
||||||
!
|
!
|
||||||
! Description: How to read values of different type of keys from BUFR messages.
|
! Description: How to read values of different type of keys from BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_get_string_array
|
|
||||||
!
|
!
|
||||||
! Description: How to get an array of strings from a BUFR message.
|
! Description: How to get an array of strings from a BUFR message.
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_keys_iterator
|
|
||||||
!
|
|
||||||
!
|
!
|
||||||
! Description: How to use keys_iterator functions and the
|
! Description: How to use keys_iterator functions and the
|
||||||
! codes_bufr_keys_iterator structure to get all the available
|
! codes_bufr_keys_iterator structure to get all the available
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_read_header
|
|
||||||
!
|
!
|
||||||
! Description: How to read the header of BUFR messages.
|
! Description: How to read the header of BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_read_scatterometer
|
|
||||||
!
|
!
|
||||||
! Description: How to read data for a given beam from scatterometer BUFR messages.
|
! Description: How to read data for a given beam from scatterometer BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_read_synop
|
|
||||||
!
|
!
|
||||||
! Description: How to read SYNOP BUFR messages.
|
! Description: How to read SYNOP BUFR messages.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_read_temp
|
|
||||||
!
|
!
|
||||||
! Description: How to read levels from TEMP BUFR messages.
|
! Description: How to read levels from TEMP BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: bufr_read_tropical_cyclone
|
|
||||||
!
|
!
|
||||||
! Description: How to read data for a tropical cyclone BUFR message.
|
! Description: How to read data for a tropical cyclone BUFR message.
|
||||||
!
|
!
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_set_keys
|
|
||||||
!
|
!
|
||||||
! Description: How to set different type of keys in BUFR messages.
|
! Description: How to set different type of keys in BUFR messages.
|
||||||
!
|
!
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 implementation: bufr_subset
|
|
||||||
!
|
|
||||||
! Description: how to read data values from a given subset of a BUFR message.
|
! Description: how to read data values from a given subset of a BUFR message.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
|
@ -22,7 +20,7 @@ program bufr_subset
|
||||||
integer(kind=4) :: numberOfSubsets
|
integer(kind=4) :: numberOfSubsets
|
||||||
integer(kind=4) :: blockNumber, stationNumber
|
integer(kind=4) :: blockNumber, stationNumber
|
||||||
character(100) :: key
|
character(100) :: key
|
||||||
!real(kind=8) :: t2m
|
!real(kind=8) :: t2m
|
||||||
|
|
||||||
call codes_open_file(ifile, '../../data/bufr/synop_multi_subset.bufr', 'r')
|
call codes_open_file(ifile, '../../data/bufr/synop_multi_subset.bufr', 'r')
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: get_product_kind
|
|
||||||
!
|
!
|
||||||
! Description: how to process a file containing a mix of messages
|
! Description: how to process a file containing a mix of messages
|
||||||
! and print the kind of product (e.g. GRIB, BUFR etc)
|
! and print the kind of product (e.g. GRIB, BUFR etc)
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! FORTRAN 90 Implementation: grib_clone
|
|
||||||
!
|
|
||||||
! Description: How to create a new GRIB message by cloning
|
! Description: How to create a new GRIB message by cloning
|
||||||
! an existing message.
|
! an existing message.
|
||||||
!
|
!
|
||||||
|
|
|
@ -36,7 +36,7 @@ program get
|
||||||
allocate (igrib(n))
|
allocate (igrib(n))
|
||||||
igrib = -1
|
igrib = -1
|
||||||
|
|
||||||
! Load the messages from the file.
|
! load the messages from the file.
|
||||||
DO i = 1, n
|
DO i = 1, n
|
||||||
call codes_grib_new_from_file(ifile, igrib(i), iret)
|
call codes_grib_new_from_file(ifile, igrib(i), iret)
|
||||||
END DO
|
END DO
|
||||||
|
@ -44,49 +44,49 @@ program get
|
||||||
! we can close the file
|
! we can close the file
|
||||||
call codes_close_file(ifile)
|
call codes_close_file(ifile)
|
||||||
|
|
||||||
! Loop on all the messages in memory
|
! loop on all the messages in memory
|
||||||
DO i = 1, n
|
DO i = 1, n
|
||||||
write (*, *) 'processing message number ', i
|
write (*, *) 'processing message number ', i
|
||||||
! get as a integer
|
! get as a integer
|
||||||
call codes_get(igrib(i), 'Ni', numberOfPointsAlongAParallel)
|
call codes_get(igrib(i), 'Ni', numberOfPointsAlongAParallel)
|
||||||
write (*, *) 'numberOfPointsAlongAParallel=', &
|
write (*, *) 'numberOfPointsAlongAParallel=', &
|
||||||
numberOfPointsAlongAParallel
|
numberOfPointsAlongAParallel
|
||||||
|
|
||||||
! get as a integer
|
! get as a integer
|
||||||
call codes_get(igrib(i), 'Nj', numberOfPointsAlongAMeridian)
|
call codes_get(igrib(i), 'Nj', numberOfPointsAlongAMeridian)
|
||||||
write (*, *) 'numberOfPointsAlongAMeridian=', &
|
write (*, *) 'numberOfPointsAlongAMeridian=', &
|
||||||
numberOfPointsAlongAMeridian
|
numberOfPointsAlongAMeridian
|
||||||
|
|
||||||
! get as a real
|
! get as a real
|
||||||
call codes_get(igrib(i), 'latitudeOfFirstGridPointInDegrees', &
|
call codes_get(igrib(i), 'latitudeOfFirstGridPointInDegrees', &
|
||||||
latitudeOfFirstPointInDegrees)
|
latitudeOfFirstPointInDegrees)
|
||||||
write (*, *) 'latitudeOfFirstGridPointInDegrees=', &
|
write (*, *) 'latitudeOfFirstGridPointInDegrees=', &
|
||||||
latitudeOfFirstPointInDegrees
|
latitudeOfFirstPointInDegrees
|
||||||
|
|
||||||
! get as a real
|
! get as a real
|
||||||
call codes_get(igrib(i), 'longitudeOfFirstGridPointInDegrees', &
|
call codes_get(igrib(i), 'longitudeOfFirstGridPointInDegrees', &
|
||||||
longitudeOfFirstPointInDegrees)
|
longitudeOfFirstPointInDegrees)
|
||||||
write (*, *) 'longitudeOfFirstGridPointInDegrees=', &
|
write (*, *) 'longitudeOfFirstGridPointInDegrees=', &
|
||||||
longitudeOfFirstPointInDegrees
|
longitudeOfFirstPointInDegrees
|
||||||
|
|
||||||
! get as a real
|
! get as a real
|
||||||
call codes_get(igrib(i), 'latitudeOfLastGridPointInDegrees', &
|
call codes_get(igrib(i), 'latitudeOfLastGridPointInDegrees', &
|
||||||
latitudeOfLastPointInDegrees)
|
latitudeOfLastPointInDegrees)
|
||||||
write (*, *) 'latitudeOfLastGridPointInDegrees=', &
|
write (*, *) 'latitudeOfLastGridPointInDegrees=', &
|
||||||
latitudeOfLastPointInDegrees
|
latitudeOfLastPointInDegrees
|
||||||
|
|
||||||
! get as a real
|
! get as a real
|
||||||
call codes_get(igrib(i), 'longitudeOfLastGridPointInDegrees', &
|
call codes_get(igrib(i), 'longitudeOfLastGridPointInDegrees', &
|
||||||
longitudeOfLastPointInDegrees)
|
longitudeOfLastPointInDegrees)
|
||||||
write (*, *) 'longitudeOfLastGridPointInDegrees=', &
|
write (*, *) 'longitudeOfLastGridPointInDegrees=', &
|
||||||
longitudeOfLastPointInDegrees
|
longitudeOfLastPointInDegrees
|
||||||
|
|
||||||
! get the size of the values array
|
! get the size of the values array
|
||||||
call codes_get_size(igrib(i), 'values', numberOfValues)
|
call codes_get_size(igrib(i), 'values', numberOfValues)
|
||||||
write (*, *) 'numberOfValues=', numberOfValues
|
write (*, *) 'numberOfValues=', numberOfValues
|
||||||
|
|
||||||
allocate (values(numberOfValues), stat=iret)
|
allocate (values(numberOfValues), stat=iret)
|
||||||
! get data values
|
! get data values
|
||||||
call codes_get(igrib(i), 'values', values)
|
call codes_get(igrib(i), 'values', values)
|
||||||
call codes_get(igrib(i), 'min', min_val) ! can also be obtained through minval(values)
|
call codes_get(igrib(i), 'min', min_val) ! can also be obtained through minval(values)
|
||||||
call codes_get(igrib(i), 'max', max_val) ! can also be obtained through maxval(values)
|
call codes_get(igrib(i), 'max', max_val) ! can also be obtained through maxval(values)
|
||||||
|
|
|
@ -20,16 +20,13 @@ program get_data
|
||||||
integer(4) :: numberOfPoints
|
integer(4) :: numberOfPoints
|
||||||
logical :: is_missing_value
|
logical :: is_missing_value
|
||||||
integer :: count1 = 0, count2 = 0, bitmapPresent = 0, bmp_len = 0
|
integer :: count1 = 0, count2 = 0, bitmapPresent = 0, bmp_len = 0
|
||||||
|
integer :: igrib ! message identifier
|
||||||
! Message identifier.
|
|
||||||
integer :: igrib
|
|
||||||
|
|
||||||
ifile = 5
|
ifile = 5
|
||||||
|
|
||||||
call codes_open_file(ifile, &
|
call codes_open_file(ifile, '../../data/reduced_latlon_surface.grib1', 'r')
|
||||||
'../../data/reduced_latlon_surface.grib1', 'R')
|
|
||||||
|
|
||||||
! Loop on all the messages in a file.
|
! loop on all the messages in a file.
|
||||||
call codes_grib_new_from_file(ifile, igrib, iret)
|
call codes_grib_new_from_file(ifile, igrib, iret)
|
||||||
|
|
||||||
do while (iret /= CODES_END_OF_FILE)
|
do while (iret /= CODES_END_OF_FILE)
|
||||||
|
@ -51,12 +48,12 @@ program get_data
|
||||||
call codes_grib_get_data(igrib, lats, lons, values)
|
call codes_grib_get_data(igrib, lats, lons, values)
|
||||||
|
|
||||||
do i = 1, numberOfPoints
|
do i = 1, numberOfPoints
|
||||||
! Consult bitmap to see if the i'th value is missing
|
! consult bitmap to see if the i'th value is missing
|
||||||
is_missing_value = .false.
|
is_missing_value = .false.
|
||||||
if (bitmapPresent == 1 .and. bitmap(i) == 0) then
|
if (bitmapPresent == 1 .and. bitmap(i) == 0) then
|
||||||
is_missing_value = .true.
|
is_missing_value = .true.
|
||||||
end if
|
end if
|
||||||
! Only print non-missing values
|
! only print non-missing values
|
||||||
if (.not. is_missing_value) then
|
if (.not. is_missing_value) then
|
||||||
print *, lats(i), lons(i), values(i)
|
print *, lats(i), lons(i), values(i)
|
||||||
count2 = count2 + 1
|
count2 = count2 + 1
|
||||||
|
|
|
@ -29,22 +29,21 @@ program grib_get_keys
|
||||||
integer :: is_missing
|
integer :: is_missing
|
||||||
character(len=10) :: open_mode = 'r'
|
character(len=10) :: open_mode = 'r'
|
||||||
|
|
||||||
call codes_open_file(ifile, &
|
call codes_open_file(ifile, '../../data/reduced_latlon_surface.grib1', open_mode)
|
||||||
'../../data/reduced_latlon_surface.grib1', open_mode)
|
|
||||||
|
|
||||||
! Loop on all the messages in a file.
|
! loop on all the messages in a file.
|
||||||
|
|
||||||
! A new GRIB message is loaded from file
|
! a new GRIB message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the grib id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(ifile, igrib, iret)
|
call codes_grib_new_from_file(ifile, igrib, iret)
|
||||||
|
|
||||||
LOOP: DO WHILE (iret /= CODES_END_OF_FILE)
|
LOOP: DO WHILE (iret /= CODES_END_OF_FILE)
|
||||||
|
|
||||||
! Check if the value of the key is MISSING
|
! check if the value of the key is MISSING
|
||||||
is_missing = 0;
|
is_missing = 0;
|
||||||
call codes_is_missing(igrib, 'Ni', is_missing);
|
call codes_is_missing(igrib, 'Ni', is_missing);
|
||||||
if (is_missing /= 1) then
|
if (is_missing /= 1) then
|
||||||
! Key value is not missing so get as an integer
|
! key value is not missing so get as an integer
|
||||||
call codes_get(igrib, 'Ni', numberOfPointsAlongAParallel)
|
call codes_get(igrib, 'Ni', numberOfPointsAlongAParallel)
|
||||||
write (*, *) 'numberOfPointsAlongAParallel=', &
|
write (*, *) 'numberOfPointsAlongAParallel=', &
|
||||||
numberOfPointsAlongAParallel
|
numberOfPointsAlongAParallel
|
||||||
|
@ -52,41 +51,41 @@ program grib_get_keys
|
||||||
write (*, *) 'numberOfPointsAlongAParallel is missing'
|
write (*, *) 'numberOfPointsAlongAParallel is missing'
|
||||||
end if
|
end if
|
||||||
|
|
||||||
! Get as an integer
|
! get as an integer
|
||||||
call codes_get(igrib, 'Nj', numberOfPointsAlongAMeridian)
|
call codes_get(igrib, 'Nj', numberOfPointsAlongAMeridian)
|
||||||
write (*, *) 'numberOfPointsAlongAMeridian=', &
|
write (*, *) 'numberOfPointsAlongAMeridian=', &
|
||||||
numberOfPointsAlongAMeridian
|
numberOfPointsAlongAMeridian
|
||||||
|
|
||||||
! Get as a real
|
! get as a real
|
||||||
call codes_get(igrib, 'latitudeOfFirstGridPointInDegrees', &
|
call codes_get(igrib, 'latitudeOfFirstGridPointInDegrees', &
|
||||||
latitudeOfFirstPointInDegrees)
|
latitudeOfFirstPointInDegrees)
|
||||||
write (*, *) 'latitudeOfFirstGridPointInDegrees=', &
|
write (*, *) 'latitudeOfFirstGridPointInDegrees=', &
|
||||||
latitudeOfFirstPointInDegrees
|
latitudeOfFirstPointInDegrees
|
||||||
|
|
||||||
! Get as a real
|
! get as a real
|
||||||
call codes_get(igrib, 'longitudeOfFirstGridPointInDegrees', &
|
call codes_get(igrib, 'longitudeOfFirstGridPointInDegrees', &
|
||||||
longitudeOfFirstPointInDegrees)
|
longitudeOfFirstPointInDegrees)
|
||||||
write (*, *) 'longitudeOfFirstGridPointInDegrees=', &
|
write (*, *) 'longitudeOfFirstGridPointInDegrees=', &
|
||||||
longitudeOfFirstPointInDegrees
|
longitudeOfFirstPointInDegrees
|
||||||
|
|
||||||
! Get as a real
|
! get as a real
|
||||||
call codes_get(igrib, 'latitudeOfLastGridPointInDegrees', &
|
call codes_get(igrib, 'latitudeOfLastGridPointInDegrees', &
|
||||||
latitudeOfLastPointInDegrees)
|
latitudeOfLastPointInDegrees)
|
||||||
write (*, *) 'latitudeOfLastGridPointInDegrees=', &
|
write (*, *) 'latitudeOfLastGridPointInDegrees=', &
|
||||||
latitudeOfLastPointInDegrees
|
latitudeOfLastPointInDegrees
|
||||||
|
|
||||||
! Get as a real
|
! get as a real
|
||||||
call codes_get(igrib, 'longitudeOfLastGridPointInDegrees', &
|
call codes_get(igrib, 'longitudeOfLastGridPointInDegrees', &
|
||||||
longitudeOfLastPointInDegrees)
|
longitudeOfLastPointInDegrees)
|
||||||
write (*, *) 'longitudeOfLastGridPointInDegrees=', &
|
write (*, *) 'longitudeOfLastGridPointInDegrees=', &
|
||||||
longitudeOfLastPointInDegrees
|
longitudeOfLastPointInDegrees
|
||||||
|
|
||||||
! Get the size of the values array
|
! get the size of the values array
|
||||||
call codes_get_size(igrib, 'values', numberOfValues)
|
call codes_get_size(igrib, 'values', numberOfValues)
|
||||||
write (*, *) 'numberOfValues=', numberOfValues
|
write (*, *) 'numberOfValues=', numberOfValues
|
||||||
|
|
||||||
allocate (values(numberOfValues), stat=iret)
|
allocate (values(numberOfValues), stat=iret)
|
||||||
! Get data values
|
! get data values
|
||||||
call codes_get(igrib, 'values', values)
|
call codes_get(igrib, 'values', values)
|
||||||
call codes_get(igrib, 'min', min_val) ! can also be obtained through minval(values)
|
call codes_get(igrib, 'min', min_val) ! can also be obtained through minval(values)
|
||||||
call codes_get(igrib, 'max', max_val) ! can also be obtained through maxval(values)
|
call codes_get(igrib, 'max', max_val) ! can also be obtained through maxval(values)
|
||||||
|
|
|
@ -18,8 +18,7 @@ program grib_get_pv
|
||||||
integer :: PVPresent, nb_pv
|
integer :: PVPresent, nb_pv
|
||||||
real, dimension(:), allocatable :: pv
|
real, dimension(:), allocatable :: pv
|
||||||
|
|
||||||
call codes_open_file(infile, &
|
call codes_open_file(infile, '../../data/reduced_gaussian_model_level.grib1', 'r')
|
||||||
'../../data/reduced_gaussian_model_level.grib1', 'r')
|
|
||||||
|
|
||||||
! A new grib message is loaded from file
|
! A new grib message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the grib id to be used in subsequent calls
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! Description: How to create a multi-field message in memory and write
|
! Description: How to create a multi-field message in memory and write
|
||||||
! it to a file. The multi-field messages can be created
|
! it to a file. The multi-field messages can be created
|
||||||
! only in GRIB edition 2.
|
! only in GRIB edition 2.
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
! Description: How to control decimal precision when packing fields.
|
! Description: How to control decimal precision when packing GRIB fields.
|
||||||
!
|
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
|
@ -30,34 +29,33 @@ program precision
|
||||||
call codes_open_file(outfile, &
|
call codes_open_file(outfile, &
|
||||||
'../../data/regular_latlon_surface_prec.grib1', 'w')
|
'../../data/regular_latlon_surface_prec.grib1', 'w')
|
||||||
|
|
||||||
! a new grib message is loaded from file
|
! a new grib message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the grib id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(infile, igrib)
|
call codes_grib_new_from_file(infile, igrib)
|
||||||
|
|
||||||
! bitsPerValue before changing the packing parameters
|
! bitsPerValue before changing the packing parameters
|
||||||
call codes_get(igrib, 'bitsPerValue', bitsPerValue1)
|
call codes_get(igrib, 'bitsPerValue', bitsPerValue1)
|
||||||
|
|
||||||
! get the size of the values array
|
! get the size of the values array
|
||||||
call codes_get_size(igrib, "values", size1)
|
call codes_get_size(igrib, "values", size1)
|
||||||
|
|
||||||
allocate (values1(size1), stat=iret)
|
allocate (values1(size1), stat=iret)
|
||||||
allocate (values2(size1), stat=iret)
|
allocate (values2(size1), stat=iret)
|
||||||
! get data values before changing the packing parameters*/
|
! get data values before changing the packing parameters*/
|
||||||
call codes_get(igrib, "values", values1)
|
call codes_get(igrib, "values", values1)
|
||||||
|
|
||||||
! setting decimal precision=2 means that 2 decimal digits
|
! setting decimal precision=2 means that 2 decimal digits
|
||||||
! are preserved when packing.
|
! are preserved when packing.
|
||||||
decimalPrecision = 2
|
decimalPrecision = 2
|
||||||
call codes_set(igrib, "changeDecimalPrecision", &
|
call codes_set(igrib, "changeDecimalPrecision", decimalPrecision)
|
||||||
decimalPrecision)
|
|
||||||
|
|
||||||
! bitsPerValue after changing the packing parameters
|
! bitsPerValue after changing the packing parameters
|
||||||
call codes_get(igrib, "bitsPerValue", bitsPerValue2)
|
call codes_get(igrib, "bitsPerValue", bitsPerValue2)
|
||||||
|
|
||||||
! get data values after changing the packing parameters
|
! get data values after changing the packing parameters
|
||||||
call codes_get(igrib, "values", values2)
|
call codes_get(igrib, "values", values2)
|
||||||
|
|
||||||
! computing error
|
! computing error
|
||||||
maxa = 0
|
maxa = 0
|
||||||
maxr = 0
|
maxr = 0
|
||||||
maxv = values2(1)
|
maxv = values2(1)
|
||||||
|
@ -80,7 +78,7 @@ program precision
|
||||||
write (*, *) "old number of bits per value=", bitsPerValue1
|
write (*, *) "old number of bits per value=", bitsPerValue1
|
||||||
write (*, *) "new number of bits per value=", bitsPerValue2
|
write (*, *) "new number of bits per value=", bitsPerValue2
|
||||||
|
|
||||||
! write modified message to a file
|
! write modified message to a file
|
||||||
call codes_write(igrib, outfile)
|
call codes_write(igrib, outfile)
|
||||||
|
|
||||||
call codes_release(igrib)
|
call codes_release(igrib)
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
! Description: Prints all the data contained in a GRIB file
|
! Description: Prints all the data contained in a GRIB file
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
|
||||||
program print_data
|
program print_data
|
||||||
use eccodes
|
use eccodes
|
||||||
implicit none
|
implicit none
|
||||||
|
@ -24,17 +23,16 @@ program print_data
|
||||||
real(kind=8) :: the_max
|
real(kind=8) :: the_max
|
||||||
real(kind=8) :: the_min
|
real(kind=8) :: the_min
|
||||||
|
|
||||||
call codes_open_file(ifile, &
|
call codes_open_file(ifile, '../../data/constant_field.grib1', 'r')
|
||||||
'../../data/constant_field.grib1', 'r')
|
|
||||||
|
|
||||||
! A new GRIB message is loaded from file
|
! a new GRIB message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the grib id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(ifile, igrib)
|
call codes_grib_new_from_file(ifile, igrib)
|
||||||
|
|
||||||
! Get the size of the values array
|
! get the size of the values array
|
||||||
call codes_get_size(igrib, 'values', numPoints)
|
call codes_get_size(igrib, 'values', numPoints)
|
||||||
|
|
||||||
! Get data values
|
! get data values
|
||||||
print *, 'number of points ', numPoints
|
print *, 'number of points ', numPoints
|
||||||
allocate (values(numPoints), stat=iret)
|
allocate (values(numPoints), stat=iret)
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,13 @@ program print_data
|
||||||
'../../data/regular_latlon_surface_constant.grib1', 'r')
|
'../../data/regular_latlon_surface_constant.grib1', 'r')
|
||||||
|
|
||||||
! A new GRIB message is loaded from file
|
! A new GRIB message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the GRIB id to be used in subsequent calls
|
||||||
call grib_new_from_file(ifile, igrib)
|
call grib_new_from_file(ifile, igrib)
|
||||||
|
|
||||||
! Get the size of the values array
|
! get the size of the values array
|
||||||
call grib_get_size(igrib, 'values', numPoints)
|
call grib_get_size(igrib, 'values', numPoints)
|
||||||
|
|
||||||
! Get data values
|
! get data values
|
||||||
print *, 'number of points ', numPoints
|
print *, 'number of points ', numPoints
|
||||||
|
|
||||||
call grib_get(igrib, 'values', values_static)
|
call grib_get(igrib, 'values', values_static)
|
||||||
|
|
|
@ -20,7 +20,7 @@ program grib_read_from_file_example
|
||||||
99186, 97517, 97466, 99307, 98460, 101491, 99361, 100292, 96838, &
|
99186, 97517, 97466, 99307, 98460, 101491, 99361, 100292, 96838, &
|
||||||
91093, 83247, 78244, 74872, 72663, 69305, 69881, 68572/)
|
91093, 83247, 78244, 74872, 72663, 69305, 69881, 68572/)
|
||||||
|
|
||||||
! Get the grib message length using two different interfaces
|
! get the GRIB message length using two different interfaces
|
||||||
call read_using_size_t()
|
call read_using_size_t()
|
||||||
call read_using_integer()
|
call read_using_integer()
|
||||||
print *, 'Passed'
|
print *, 'Passed'
|
||||||
|
|
|
@ -20,16 +20,16 @@ program grib_read_message
|
||||||
call codes_open_file(ifile, '../../data/index.grib', 'r')
|
call codes_open_file(ifile, '../../data/index.grib', 'r')
|
||||||
call codes_open_file(ofile, 'out.readmsg.grib', 'w')
|
call codes_open_file(ofile, 'out.readmsg.grib', 'w')
|
||||||
|
|
||||||
! a grib message is read from file into buffer
|
! a GRIB message is read from file into buffer
|
||||||
len1 = size(buffer)*4
|
len1 = size(buffer)*4
|
||||||
call codes_read_from_file(ifile, buffer, len1, iret)
|
call codes_read_from_file(ifile, buffer, len1, iret)
|
||||||
|
|
||||||
do while (iret /= CODES_END_OF_FILE)
|
do while (iret /= CODES_END_OF_FILE)
|
||||||
|
|
||||||
! a new grib message is created from buffer
|
! a new GRIB message is created from buffer
|
||||||
call codes_new_from_message(igrib, buffer)
|
call codes_new_from_message(igrib, buffer)
|
||||||
|
|
||||||
! get as a integer
|
! get as a integer
|
||||||
call codes_get(igrib, 'step', step)
|
call codes_get(igrib, 'step', step)
|
||||||
write (*, *) 'step=', step
|
write (*, *) 'step=', step
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ program grib_read_message
|
||||||
|
|
||||||
call codes_write_bytes(ofile, buffer, len1)
|
call codes_write_bytes(ofile, buffer, len1)
|
||||||
|
|
||||||
! a grib message is read from file into buffer
|
! a message is read from file into buffer
|
||||||
len1 = size(buffer)*4
|
len1 = size(buffer)*4
|
||||||
call codes_read_from_file(ifile, buffer, len1, iret)
|
call codes_read_from_file(ifile, buffer, len1, iret)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ program sample
|
||||||
indicatorOfParameter = 61
|
indicatorOfParameter = 61
|
||||||
decimalPrecision = 2
|
decimalPrecision = 2
|
||||||
|
|
||||||
! A new grib message is loaded from an existing sample.
|
! a new GRIB message is loaded from an existing sample.
|
||||||
! Samples are searched in a default sample path (use codes_info
|
! Samples are searched in a default sample path (use codes_info
|
||||||
! to see where that is). The default sample path can be changed by
|
! to see where that is). The default sample path can be changed by
|
||||||
! setting the environment variable ECCODES_SAMPLES_PATH
|
! setting the environment variable ECCODES_SAMPLES_PATH
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
|
||||||
! Description: How to set a bitmap in a GRIB message
|
! Description: How to set a bitmap in a GRIB message
|
||||||
! to encode missing values in the data
|
! to encode missing values in the data
|
||||||
!
|
!
|
||||||
|
@ -34,11 +33,11 @@ program set_bitmap
|
||||||
|
|
||||||
call codes_open_file(outfile, 'out.set_bitmap_f.grib', 'w')
|
call codes_open_file(outfile, 'out.set_bitmap_f.grib', 'w')
|
||||||
|
|
||||||
! A new grib message is loaded from file
|
! a new GRIB message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the GRIB id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(infile, igrib)
|
call codes_grib_new_from_file(infile, igrib)
|
||||||
|
|
||||||
! The missingValue is not coded in the message.
|
! the missingValue is not coded in the message.
|
||||||
! It is a value we define as a placeholder for a missing value
|
! It is a value we define as a placeholder for a missing value
|
||||||
! at a point in the grid.
|
! at a point in the grid.
|
||||||
! It should be chosen so that it cannot be confused
|
! It should be chosen so that it cannot be confused
|
||||||
|
|
|
@ -25,15 +25,15 @@ program set_data
|
||||||
call getarg(1, outfile_name)
|
call getarg(1, outfile_name)
|
||||||
call codes_open_file(outfile, outfile_name, 'w')
|
call codes_open_file(outfile, outfile_name, 'w')
|
||||||
|
|
||||||
! Note: the full name of the sample file is "regular_ll_pl_grib1.tmpl"
|
! note: the full name of the sample file is "regular_ll_pl_grib1.tmpl"
|
||||||
! Sample files are stored in the samples directory (use codes_info to
|
! sample files are stored in the samples directory (use codes_info to
|
||||||
! see where that is). The default sample path can be changed by
|
! see where that is). The default sample path can be changed by
|
||||||
! setting the environment variable ECCODES_SAMPLES_PATH
|
! setting the environment variable ECCODES_SAMPLES_PATH
|
||||||
call codes_grib_new_from_samples(igrib, 'regular_ll_pl_grib1')
|
call codes_grib_new_from_samples(igrib, 'regular_ll_pl_grib1')
|
||||||
|
|
||||||
! Here we're changing the data values only, so the number of values
|
! here we're changing the data values only, so the number of values
|
||||||
! will be the same as the sample GRIB.
|
! will be the same as the sample GRIB.
|
||||||
! But if your data array has a different size, then specify the grid geometry
|
! but if your data array has a different size, then specify the grid geometry
|
||||||
! (e.g. keys Ni, Nj etc) and set the correct number of data values
|
! (e.g. keys Ni, Nj etc) and set the correct number of data values
|
||||||
call codes_get_size(igrib, 'values', numberOfValues)
|
call codes_get_size(igrib, 'values', numberOfValues)
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@ program set
|
||||||
|
|
||||||
call codes_grib_new_from_file(infile, igrib)
|
call codes_grib_new_from_file(infile, igrib)
|
||||||
|
|
||||||
! Individual ensemble forecast
|
! individual ensemble forecast
|
||||||
call codes_set(igrib, 'productDefinitionTemplateNumber', 11)
|
call codes_set(igrib, 'productDefinitionTemplateNumber', 11)
|
||||||
|
|
||||||
! Select level type as Generalized Vertical Height Coordinate
|
! select level type as Generalized Vertical Height Coordinate
|
||||||
call codes_set(igrib, 'typeOfLevel', 'generalVertical')
|
call codes_set(igrib, 'typeOfLevel', 'generalVertical')
|
||||||
|
|
||||||
! Now set keys specific to this level type
|
! now set keys specific to this level type
|
||||||
call codes_set(igrib, 'nlev', 12.21)
|
call codes_set(igrib, 'nlev', 12.21)
|
||||||
call codes_set(igrib, 'numberOfVGridUsed', 13.55)
|
call codes_set(igrib, 'numberOfVGridUsed', 13.55)
|
||||||
|
|
||||||
|
|
|
@ -23,20 +23,20 @@ program set
|
||||||
call codes_open_file(infile, '../../data/regular_latlon_surface_constant.grib1', 'r')
|
call codes_open_file(infile, '../../data/regular_latlon_surface_constant.grib1', 'r')
|
||||||
call codes_open_file(outfile, 'out.set.grib1', 'w')
|
call codes_open_file(outfile, 'out.set.grib1', 'w')
|
||||||
|
|
||||||
! A new GRIB message is loaded from file
|
! a new GRIB message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the GRIB id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(infile, igrib)
|
call codes_grib_new_from_file(infile, igrib)
|
||||||
|
|
||||||
call codes_set(igrib, 'dataDate', date1)
|
call codes_set(igrib, 'dataDate', date1)
|
||||||
call codes_set(igrib, 'type', marsType)
|
call codes_set(igrib, 'type', marsType)
|
||||||
|
|
||||||
! set centre as a integer */
|
! set centre as a integer */
|
||||||
call codes_set(igrib, 'centre', centre)
|
call codes_set(igrib, 'centre', centre)
|
||||||
|
|
||||||
! Check if it is correct in the actual GRIB message
|
! check if it is correct in the actual GRIB message
|
||||||
call check_settings(igrib)
|
call check_settings(igrib)
|
||||||
|
|
||||||
! Write modified message to a file
|
! write modified message to a file
|
||||||
call codes_write(igrib, outfile)
|
call codes_write(igrib, outfile)
|
||||||
|
|
||||||
call codes_release(igrib)
|
call codes_release(igrib)
|
||||||
|
|
|
@ -34,7 +34,7 @@ program set
|
||||||
call codes_set_missing(igrib, 'scaleFactorOfFirstFixedSurface')
|
call codes_set_missing(igrib, 'scaleFactorOfFirstFixedSurface')
|
||||||
call codes_set_missing(igrib, 'scaledValueOfFirstFixedSurface')
|
call codes_set_missing(igrib, 'scaledValueOfFirstFixedSurface')
|
||||||
|
|
||||||
! See GRIB-490
|
! see GRIB-490
|
||||||
call codes_get(igrib, 'Ni', Ni)
|
call codes_get(igrib, 'Ni', Ni)
|
||||||
call codes_is_missing(igrib, 'Ni', is_missing)
|
call codes_is_missing(igrib, 'Ni', is_missing)
|
||||||
if (is_missing == 0) then
|
if (is_missing == 0) then
|
||||||
|
|
|
@ -63,7 +63,7 @@ program grib_set_pv
|
||||||
! write modified message to a file
|
! write modified message to a file
|
||||||
call codes_write(igrib, outfile)
|
call codes_write(igrib, outfile)
|
||||||
|
|
||||||
! Free memory
|
! free memory
|
||||||
call codes_release(igrib)
|
call codes_release(igrib)
|
||||||
deallocate (pv)
|
deallocate (pv)
|
||||||
|
|
||||||
|
|
|
@ -28,34 +28,34 @@ program precision
|
||||||
call codes_open_file(outfile, &
|
call codes_open_file(outfile, &
|
||||||
'../../data/regular_latlon_surface_prec.grib1', 'w')
|
'../../data/regular_latlon_surface_prec.grib1', 'w')
|
||||||
|
|
||||||
! a new grib message is loaded from file
|
! a new grib message is loaded from file
|
||||||
! igrib is the grib id to be used in subsequent calls
|
! igrib is the grib id to be used in subsequent calls
|
||||||
call codes_grib_new_from_file(infile, igrib)
|
call codes_grib_new_from_file(infile, igrib)
|
||||||
|
|
||||||
! bitsPerValue before changing the packing parameters
|
! bitsPerValue before changing the packing parameters
|
||||||
call codes_get(igrib, 'bitsPerValue', bitsPerValue1)
|
call codes_get(igrib, 'bitsPerValue', bitsPerValue1)
|
||||||
|
|
||||||
! get the size of the values array
|
! get the size of the values array
|
||||||
call codes_get_size(igrib, "values", size)
|
call codes_get_size(igrib, "values", size)
|
||||||
|
|
||||||
allocate (values1(size), stat=iret)
|
allocate (values1(size), stat=iret)
|
||||||
allocate (values2(size), stat=iret)
|
allocate (values2(size), stat=iret)
|
||||||
! get data values before changing the packing parameters*/
|
! get data values before changing the packing parameters*/
|
||||||
call codes_get(igrib, "values", values1)
|
call codes_get(igrib, "values", values1)
|
||||||
|
|
||||||
! setting decimal precision=2 means that 2 decimal digits
|
! setting decimal precision=2 means that 2 decimal digits
|
||||||
! are preserved when packing.
|
! are preserved when packing.
|
||||||
decimalPrecision = 2
|
decimalPrecision = 2
|
||||||
call codes_set(igrib, "setDecimalPrecision", &
|
call codes_set(igrib, "setDecimalPrecision", &
|
||||||
decimalPrecision)
|
decimalPrecision)
|
||||||
|
|
||||||
! bitsPerValue after changing the packing parameters
|
! bitsPerValue after changing the packing parameters
|
||||||
call codes_get(igrib, "bitsPerValue", bitsPerValue2)
|
call codes_get(igrib, "bitsPerValue", bitsPerValue2)
|
||||||
|
|
||||||
! get data values after changing the packing parameters
|
! get data values after changing the packing parameters
|
||||||
call codes_get(igrib, "values", values2)
|
call codes_get(igrib, "values", values2)
|
||||||
|
|
||||||
! computing error
|
! computing error
|
||||||
maxa = 0
|
maxa = 0
|
||||||
maxr = 0
|
maxr = 0
|
||||||
maxv = values2(1)
|
maxv = values2(1)
|
||||||
|
@ -78,7 +78,7 @@ program precision
|
||||||
write (*, *) "old number of bits per value=", bitsPerValue1
|
write (*, *) "old number of bits per value=", bitsPerValue1
|
||||||
write (*, *) "new number of bits per value=", bitsPerValue2
|
write (*, *) "new number of bits per value=", bitsPerValue2
|
||||||
|
|
||||||
! write modified message to a file
|
! write modified message to a file
|
||||||
call codes_write(igrib, outfile)
|
call codes_write(igrib, outfile)
|
||||||
|
|
||||||
call codes_release(igrib)
|
call codes_release(igrib)
|
||||||
|
|
Loading…
Reference in New Issue