NCEPLIBS-bufr  12.1.0
copydata.F90 File Reference

Copy data between BUFR files or messages. More...

Go to the source code of this file.

Functions/Subroutines

recursive subroutine copybf (lunin, lunot)
 Copy an entire BUFR file from one Fortran logical unit to another. More...
 
recursive subroutine copymg (lunin, lunot)
 Copy a BUFR message from one file to another. More...
 
recursive subroutine copysb (lunin, lunot, iret)
 Copy a BUFR data subset from one Fortran logical unit to another. More...
 
subroutine cpbfdx (lud, lun)
 Copy all of the DX BUFR table information from one unit to another within internal memory. More...
 
recursive subroutine cpymem (lunot)
 Copy a BUFR message from internal arrays to a file. More...
 
subroutine cpyupd (lunit, lin, lun, ibyt)
 Copy a BUFR data subset from one unit to another within internal memory. More...
 
recursive integer function icopysb (lunin, lunot)
 Copy a BUFR data subset from one Fortran logical unit to another. More...
 
integer function iok2cpy (lui, luo)
 Check whether a BUFR message, or a data subset from within a BUFR message, can be copied from one Fortran logical unit to another. More...
 
subroutine mvb (ib1, nb1, ib2, nb2, nbm)
 Copy a specified number of bytes from one packed binary array to another. More...
 
recursive subroutine ufbcpy (lubin, lubot)
 Copy a BUFR data subset from one Fortran logical unit to another. More...
 
recursive subroutine ufbcup (lubin, lubot)
 Copy unique elements of a data subset. More...
 

Detailed Description

Copy data between BUFR files or messages.

Author
J. Woollen
Date
1994-01-06

Definition in file copydata.F90.

Function/Subroutine Documentation

◆ copybf()

recursive subroutine copybf ( integer, intent(in)  lunin,
integer, intent(in)  lunot 
)

Copy an entire BUFR file from one Fortran logical unit to another.

Parameters
lunin- Fortran logical unit number for source BUFR file
lunot- Fortran logical unit number for target BUFR file

The logical unit numbers lunin and lunot must already be associated with actual filenames on the local system, typically via a Fortran "OPEN" statement.

Remarks
  • This subroutine uses subroutine msgwrt() to copy each BUFR message from lunin to lunot; therefore, this subroutine can be used to create a copy of lunin where each corresponding message in lunot contains any or all of the updates described in the documentation for subroutine msgwrt().
Author
J. Woollen
Date
1994-01-06

Definition at line 22 of file copydata.F90.

References bort(), closbf(), iupbs01(), moda_mgwa::mgwa, msgwrt(), openbf(), rdmsgw(), status(), and x84().

◆ copymg()

recursive subroutine copymg ( integer, intent(in)  lunin,
integer, intent(in)  lunot 
)

Copy a BUFR message from one file to another.

This subroutine is similar to subroutine cpymem(), except that it copies a BUFR message from one Fortran logical unit to another, whereas cpymem() copies a BUFR message from internal arrays in memory to a specified Fortran logical unit.

Logical unit lUNIN should have already been opened for input operations via a previous call to subroutine openbf(). A BUFR message should have already been read into internal arrays for lunin via a previous call to one of the message-reading subroutines.

Logical unit lunot should have already been opened for output operations via a previous call to subroutine openbf(), but there should not be any BUFR message already open for output within the internal arrays for lunot via a previous call to one of the message-writing subroutines.

The DX BUFR Table information associated with each of the logical units lunin and lunot must contain identical definitions for the type of BUFR message to be copied from lunin to lunot.

This subroutine uses subroutine msgwrt() to write to lunot; therefore, it can be used to transform a copy of the original BUFR message from lunin with any or all of the updates described in the documentation for subroutine msgwrt().

Parameters
lunin- Fortran logical unit number for source BUFR file
lunot- Fortran logical unit number for target BUFR file
Author
J. Woollen
Date
1994-01-06

Definition at line 107 of file copydata.F90.

References bort(), moda_msgcwd::idate, moda_msgcwd::inode, iok2cpy(), iupbs01(), moda_bitbuf::mbay, msgwrt(), moda_msgcwd::msub, nemtba(), moda_msgcwd::nmsg, moda_msgcwd::nsub, status(), moda_tables::tag, and x84().

Referenced by split_by_subset().

◆ copysb()

recursive subroutine copysb ( integer, intent(in)  lunin,
integer, intent(in)  lunot,
integer, intent(out)  iret 
)

Copy a BUFR data subset from one Fortran logical unit to another.

Logical unit lunin should have already been opened for input operations via a previous call to subroutine openbf(), and a BUFR message should have already been read into internal arrays for lunin via a previous call to one of the message-reading subroutines.

Logical unit lunot should have already been opened for output operations via a previous call to subroutine openbf(), and a BUFR message should already be open for output within internal arrays via a previous call to one of the NCEPLIBS-bufr message-writing subroutines.

The compression status of the data subset (i.e. compressed or uncompressed) will be preserved when copying from lunin to lunot.

If lunot < 0, then a data subset is read from the BUFR message in internal arrays for lunin but is not copied to the BUFR message in internal arrays for lunot. Otherwise, the DX BUFR Table information associated with each of the logical units lunin and lunot must contain identical definitions for the type of BUFR message containing the data subset to be copied from lunin to lunot.

Parameters
lunin- Fortran logical unit number for source BUFR file
lunot- Fortran logical unit number for target BUFR file
iret- return code:
  • 0 = normal return
  • -1 = a BUFR data subset could not be read from the BUFR message in internal arrays for lunin
Author
J. Woollen
Date
1994-01-06

Definition at line 202 of file copydata.F90.

References bort(), cmpmsg(), cpyupd(), getlens(), moda_bitbuf::ibit, moda_msgcwd::inode, iok2cpy(), moda_bitbuf::mbay, moda_bitbuf::mbyt, mesgbc(), moda_msgcwd::msub, moda_msgcwd::nsub, readsb(), status(), moda_tables::tag, ufbcpy(), upb(), writsb(), x48(), and x84().

Referenced by icopysb().

◆ cpbfdx()

subroutine cpbfdx ( integer, intent(in)  lud,
integer, intent(in)  lun 
)

Copy all of the DX BUFR table information from one unit to another within internal memory.

Parameters
lud- File ID for input unit
lun- File ID for output unit
Author
Woollen
Date
1994-01-06

Definition at line 677 of file copydata.F90.

References dxinit(), moda_tababd::idna, moda_tababd::idnb, moda_tababd::idnd, moda_msgcwd::inode, moda_tababd::mtab, moda_tababd::ntba, moda_tababd::ntbb, moda_tababd::ntbd, moda_tababd::taba, moda_tababd::tabb, and moda_tababd::tabd.

Referenced by makestab(), readdx(), and wrdxtb().

◆ cpymem()

recursive subroutine cpymem ( integer, intent(in)  lunot)

Copy a BUFR message from internal arrays to a file.

This subroutine is similar to subroutine copymg(), except that it copies a BUFR message from internal arrays in memory to a specified Fortran logical unit, whereas copymg() copies a BUFR message from one Fortran logical unit to another.

One or more files of BUFR messages should have already been read into internal arrays in memory via one or more previous calls to subroutine ufbmem(), and a BUFR message should already be in scope for processing from these arrays via a previous call to subroutine rdmemm() or readmm().

Logical unit lunot should have already been opened for output operations via a previous call to subroutine openbf(), but there should not be any BUFR message already open for output within the internal arrays for lunot via a previous call to one of the message-writing subroutines.

The DX BUFR Table information associated with the internal arrays in memory and with logical unit lunot must contain identical definitions for the type of BUFR message to be copied from the former to the latter.

This subroutine uses subroutine msgwrt() to write to lunot; therefore, it can be used to transform a copy of the original BUFR message from memory with any or all of the updates described in the documentation for subroutine msgwrt().

Parameters
lunot- Fortran logical unit number for target BUFR file.
Author
J. Woollen
Date
1994-01-06

Definition at line 433 of file copydata.F90.

References bort(), moda_msgcwd::idate, moda_msgcwd::inode, iok2cpy(), iupbs01(), moda_bitbuf::mbay, msgwrt(), moda_msgcwd::msub, moda_msgmem::munit, nemtba(), moda_msgcwd::nmsg, moda_msgcwd::nsub, status(), moda_tables::tag, and x84().

◆ cpyupd()

subroutine cpyupd ( integer, intent(in)  lunit,
integer, intent(in)  lin,
integer, intent(in)  lun,
integer, intent(in)  ibyt 
)

Copy a BUFR data subset from one unit to another within internal memory.

If the subset will not fit into the output message, or if the subset byte count exceeds 65530 (sufficiently close to the 16-bit byte counter upper limit of 65535), then that message is flushed to lunit and a new one is created in order to hold the copied subset. Any subset with byte count > 65530 will be written into its own one-subset message. If the subset to be copied is larger than the maximum message length, then a call is issued to subroutine bort().

Parameters
lunit- Fortran logical unit number for BUFR file associated with output unit
lin- File ID for input unit
lun- File ID for output unit
ibyt- Length (in bytes) of data subset
Author
Woollen
Date
1994-01-06

Definition at line 512 of file copydata.F90.

References bort(), errwrt(), moda_bitbuf::maxbyt, moda_bitbuf::mbay, moda_bitbuf::mbyt, msgini(), msgwrt(), mvb(), moda_msgcwd::nsub, and pkb().

Referenced by copysb().

◆ icopysb()

recursive integer function icopysb ( integer, intent(in)  lunin,
integer, intent(in)  lunot 
)

Copy a BUFR data subset from one Fortran logical unit to another.

This function calls subroutine copysb() and passes back its return code as the function value.

Parameters
lunin- Fortran logical unit number for source BUFR file
lunot- Fortran logical unit number for target BUFR file
Returns
icopysb - return code:
  • 0 = normal return
  • -1 = a BUFR data subset could not be read from the BUFR message in internal arrays for lunin
Remarks
  • The use of this function allows the return code from copysb() to be used as the target variable within an iterative program loop.
Author
J. Woollen
Date
1994-01-06

Definition at line 311 of file copydata.F90.

References copysb(), and x84().

◆ iok2cpy()

integer function iok2cpy ( integer, intent(in)  lui,
integer, intent(in)  luo 
)

Check whether a BUFR message, or a data subset from within a BUFR message, can be copied from one Fortran logical unit to another.

The decision is based on whether both logical units contain identical definitions for the BUFR message type in question within their associated DX BUFR Table information. Note that it's possible for a BUFR message type to be identically defined for two different logical units even if the full set of associated DX BUFR table information isn't identical between both units.

Parameters
lui- File ID for source BUFR file
luo- File ID for target BUFR file
Returns
iok2cpy - Flag indicating whether a BUFR message or data subset can be copied from lui to luo:
  • 0 = No
  • 1 = Yes
Author
J. Ator
Date
2009-06-26

Definition at line 354 of file copydata.F90.

References moda_tables::ibt, icmpdx(), moda_msgcwd::inode, moda_tables::irf, moda_tables::isc, nemtbax(), moda_tables::tag, and moda_tables::typ.

Referenced by copymg(), copysb(), cpymem(), and ufbcpy().

◆ mvb()

subroutine mvb ( integer, dimension(*), intent(in)  ib1,
integer, intent(in)  nb1,
integer, dimension(*), intent(out)  ib2,
integer, intent(in)  nb2,
integer, intent(in)  nbm 
)

Copy a specified number of bytes from one packed binary array to another.

Parameters
ib1- Packed input binary array
nb1- Pointer to first byte in ib1 to copy from
ib2- Packed output binary array
nb2- Pointer to first byte in ib2 to copy to
nbm- Number of bytes to copy
Author
Woollen
Date
1994-01-06

Definition at line 730 of file copydata.F90.

References pkb(), and upb().

Referenced by atrcpt(), cnved4(), cpyupd(), msgupd(), stndrd(), x48(), and x84().

◆ ufbcpy()

recursive subroutine ufbcpy ( integer, intent(in)  lubin,
integer, intent(in)  lubot 
)

Copy a BUFR data subset from one Fortran logical unit to another.

This subroutine is similar to subroutine copysb(), except that here a BUFR data subset should have already been read into internal arrays for logical unit lubin via a previous call to one of the subset-reading subroutines, whereas copysb() only requires that a BUFR message should have already been read into internal arrays via a previous call to one of the message-reading subroutines.

For logical unit lubot, a BUFR message should already be open for output within internal arrays via a previous call to one of the message-writing subroutines.

The DX BUFR Table information associated with each of the logical units lubin and lubot must contain identical definitions for the data subset to be copied.

Parameters
lubin- Fortran logical unit number for source BUFR file
lubot- Fortran logical unit number for target BUFR file
Author
J. Woollen
Date
1994-01-06

Definition at line 611 of file copydata.F90.

References bort(), moda_msgcwd::inode, moda_usrint::inv, iok2cpy(), moda_ufbcpl::luncpy, moda_usrint::nrfelm, moda_usrint::nval, status(), moda_tables::tag, moda_usrint::val, and x84().

Referenced by copysb().

◆ ufbcup()

recursive subroutine ufbcup ( integer, intent(in)  lubin,
integer, intent(in)  lubot 
)

Copy unique elements of a data subset.

Copy each unique element from an input subset into the identical mnemonic slot in the output subset.

Before this subroutine is called:

After this subroutine is called, one of the subset-writing subroutines must be called on the output file to write the subset to file.

Parameters
lubin- Fortran logical unit number for input BUFR file
lubot- Fortran logical unit number for output BUFR file
Author
Woollen
Date
1994-01-06

Definition at line 767 of file copydata.F90.

References bort(), moda_msgcwd::inode, moda_usrint::inv, moda_ivttmp::itmp, moda_tables::itp, moda_usrint::nval, status(), moda_tables::tag, moda_ivttmp::ttmp, moda_usrint::val, and x84().