eccodes/examples/F90/print_data_fortran.f90

53 lines
1.5 KiB
Fortran
Raw Normal View History

2020-01-28 14:32:34 +00:00
! (C) Copyright 2005- ECMWF.
2013-03-25 12:04:10 +00:00
!
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
2017-02-06 16:45:30 +00:00
!
2013-03-25 12:04:10 +00:00
! 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.
!
! Fortran 90 Implementation: print_data_fortran
!
2021-10-13 15:47:23 +00:00
! Description: prints all the data contained in a GRIB file
2013-03-25 12:04:10 +00:00
!
!
!
program print_data_fortran
use eccodes
implicit none
integer :: ifile
integer :: igrib
integer :: i
real(kind=8), dimension(:), allocatable :: values
real(kind=8) :: average
real(kind=8) :: max
real(kind=8) :: min
2013-03-25 12:04:10 +00:00
2021-10-13 15:47:23 +00:00
call codes_open_file(ifile, '../../data/constant_field.grib1', 'r')
2013-03-25 12:04:10 +00:00
2021-10-13 15:47:23 +00:00
! A new GRIB message is loaded from file
! igrib is the GRIB id to be used in subsequent calls
call codes_grib_new_from_file(ifile, igrib)
2013-03-25 12:04:10 +00:00
call codes_get(igrib, 'values', values)
2013-03-25 12:04:10 +00:00
do i = 1, size(values)
write (*, *) ' ', i, values(i)
end do
2013-03-25 12:04:10 +00:00
write (*, *) size(values), ' values found '
2013-03-25 12:04:10 +00:00
call codes_get(igrib, 'max', max)
write (*, *) 'max=', max
call codes_get(igrib, 'min', min)
write (*, *) 'min=', min
call codes_get(igrib, 'average', average)
write (*, *) 'average=', average
2013-03-25 12:04:10 +00:00
call codes_release(igrib)
2013-03-25 12:04:10 +00:00
call codes_close_file(ifile)
2013-03-25 12:04:10 +00:00
deallocate (values)
2013-03-25 12:04:10 +00:00
end program print_data_fortran