2019-04-15 13:44:45 +00:00
|
|
|
! Copyright 2005-2019 ECMWF.
|
2014-03-25 11:12:01 +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
|
|
|
!
|
2014-03-25 11:12:01 +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.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!
|
|
|
|
! Description: how to set keys for a grib2 file with
|
|
|
|
! a Generalized Vertical Height Coordinate
|
|
|
|
!
|
|
|
|
!
|
|
|
|
program set
|
2015-01-28 22:54:42 +00:00
|
|
|
use eccodes
|
2014-03-25 11:12:01 +00:00
|
|
|
implicit none
|
|
|
|
integer :: infile,outfile
|
|
|
|
integer :: igrib
|
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_open_file(infile, '../../data/sample.grib2','r')
|
2014-03-25 11:12:01 +00:00
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_open_file(outfile, 'out_gvc.grib2','w')
|
2014-03-25 11:12:01 +00:00
|
|
|
|
2015-03-04 17:11:18 +00:00
|
|
|
call codes_grib_new_from_file(infile,igrib)
|
2014-03-25 11:12:01 +00:00
|
|
|
|
|
|
|
! Individual ensemble forecast
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_set(igrib,'productDefinitionTemplateNumber', 11)
|
2017-02-06 16:45:30 +00:00
|
|
|
|
2014-03-25 11:12:01 +00:00
|
|
|
! Select level type as Generalized Vertical Height Coordinate
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_set(igrib,'typeOfLevel', 'generalVertical')
|
2017-02-06 16:45:30 +00:00
|
|
|
|
2014-03-25 11:12:01 +00:00
|
|
|
! Now set keys specific to this level type
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_set(igrib,'nlev', 12.21)
|
|
|
|
call codes_set(igrib,'numberOfVGridUsed', 13.55)
|
2014-03-25 11:12:01 +00:00
|
|
|
|
|
|
|
! check integrity of GRIB message
|
|
|
|
call check_settings(igrib)
|
|
|
|
|
|
|
|
! write modified message to a file
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_write(igrib,outfile)
|
2014-03-25 11:12:01 +00:00
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_release(igrib)
|
|
|
|
call codes_close_file(infile)
|
|
|
|
call codes_close_file(outfile)
|
2014-03-25 11:12:01 +00:00
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
!======================================
|
|
|
|
subroutine check_settings(gribid)
|
|
|
|
implicit none
|
|
|
|
integer, intent(in) :: gribid
|
2017-02-06 16:45:30 +00:00
|
|
|
|
2014-03-25 11:12:01 +00:00
|
|
|
integer(kind = 4) :: NV,typeOfFirstFixedSurface
|
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_get(gribid,'NV', NV)
|
2014-03-25 11:12:01 +00:00
|
|
|
if (NV /= 6) then
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_check(-2, 'NV_should_be_6', '')
|
2014-03-25 11:12:01 +00:00
|
|
|
end if
|
|
|
|
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_get(gribid,'typeOfFirstFixedSurface', typeOfFirstFixedSurface)
|
2014-03-25 11:12:01 +00:00
|
|
|
if (typeOfFirstFixedSurface /= 150) then
|
2015-01-07 16:11:28 +00:00
|
|
|
call codes_check(-2, 'typeOfFirstFixedSurface_should_be_150', '')
|
2014-03-25 11:12:01 +00:00
|
|
|
end if
|
2017-02-06 16:45:30 +00:00
|
|
|
|
2014-03-25 11:12:01 +00:00
|
|
|
end subroutine check_settings
|
|
|
|
end program set
|