2020-01-28 14:32:34 +00:00
|
|
|
! (C) Copyright 2005- ECMWF.
|
2015-02-04 16:32:00 +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
|
|
|
!
|
2015-02-04 16:32:00 +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.
|
|
|
|
!
|
2015-02-09 15:41:15 +00:00
|
|
|
! FORTRAN 90 implementation: bufr_clone
|
2015-02-04 16:32:00 +00:00
|
|
|
!
|
2017-02-06 16:45:30 +00:00
|
|
|
! Description: how to create a new BUFR message by cloning
|
2015-02-04 16:32:00 +00:00
|
|
|
! an existing message.
|
|
|
|
!
|
|
|
|
!
|
|
|
|
program bufr_clone
|
|
|
|
use eccodes
|
|
|
|
implicit none
|
2016-06-21 10:02:46 +00:00
|
|
|
integer :: i,iret
|
|
|
|
integer :: infile,outfile
|
|
|
|
integer :: ibufr_in
|
|
|
|
integer :: ibufr_out
|
2016-12-29 15:53:10 +00:00
|
|
|
|
2017-02-06 16:45:30 +00:00
|
|
|
! Open source file
|
2015-02-04 16:32:00 +00:00
|
|
|
call codes_open_file(infile,'../../data/bufr/syno_multi.bufr','r')
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Open target file
|
2015-02-06 09:32:42 +00:00
|
|
|
call codes_open_file(outfile,'bufr_clone_test_f.clone.bufr','w')
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! The first bufr message is loaded from file,
|
2015-02-04 16:32:00 +00:00
|
|
|
! ibufr is the bufr id to be used in subsequent calls
|
|
|
|
call codes_bufr_new_from_file(infile,ibufr_in,iret)
|
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Create several clones of this message and alter them
|
2015-02-09 15:41:15 +00:00
|
|
|
! in different ways
|
|
|
|
do i=1,3
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Clone the current handle
|
2015-02-04 16:32:00 +00:00
|
|
|
call codes_clone(ibufr_in, ibufr_out)
|
|
|
|
|
2017-02-06 16:45:30 +00:00
|
|
|
! This is the place where you may wish to modify the clone
|
|
|
|
! E.g. we change the bufrHeaderCentre
|
2015-03-04 17:15:48 +00:00
|
|
|
call codes_set(ibufr_out,'bufrHeaderCentre',222)
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Write cloned messages to a file
|
2015-02-04 16:32:00 +00:00
|
|
|
call codes_write(ibufr_out,outfile)
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Release the clone's handle
|
2015-02-04 16:32:00 +00:00
|
|
|
call codes_release(ibufr_out)
|
2017-02-06 16:45:30 +00:00
|
|
|
end do
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2016-12-29 15:53:10 +00:00
|
|
|
! Release the original handle
|
2015-02-09 15:41:15 +00:00
|
|
|
call codes_release(ibufr_in)
|
2016-06-21 10:02:46 +00:00
|
|
|
|
2015-02-04 16:32:00 +00:00
|
|
|
call codes_close_file(infile)
|
|
|
|
call codes_close_file(outfile)
|
|
|
|
|
|
|
|
end program bufr_clone
|