NCEPLIBS-bufr  12.0.1
iok2cpy.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Check whether a BUFR message or data subset can be copied
3 C> from one BUFR file to another.
4 C>
5 C> @author J. Ator @date 2009-06-26
6 
7 C> This function determines whether a BUFR message, or a data subset
8 C> from within a BUFR message, can be copied from one Fortran logical
9 C> unit to another.
10 C>
11 C> The decision is based on whether both logical units contain
12 C> identical definitions for the BUFR message type in question within
13 C> their associated [DX BUFR Table information](@ref dfbftab).
14 C> Note that it's possible for a BUFR message type to be identically
15 C> defined for two different logical units even if the full set of
16 C> associated DX BUFR table information isn't identical between both
17 C> units.
18 C>
19 C> @param[in] LUI - integer: File ID for source BUFR file
20 C> @param[in] LUO - integer: File ID for target BUFR file
21 C> @returns iok2cpy - integer: Flag indicating whether a BUFR message
22 C> or data subset can be copied from LUI to LUO
23 C> - 0 = No
24 C> - 1 = Yes
25 C>
26 C> @author J. Ator @date 2009-06-26
27  INTEGER FUNCTION iok2cpy(LUI,LUO)
28 
29  USE moda_msgcwd
30  USE moda_tables
31 
32  CHARACTER*8 subset
33 
34 C-----------------------------------------------------------------------
35 C-----------------------------------------------------------------------
36 
37  iok2cpy = 0
38 
39 C Do both logical units have the same internal table information?
40 
41  IF ( icmpdx(lui,luo) .EQ. 1 ) THEN
42  iok2cpy = 1
43  RETURN
44  ENDIF
45 
46 C No, so get the Table A mnemonic from the message to be copied,
47 C then check whether that mnemonic is defined within the dictionary
48 C tables for the logical unit to be copied to.
49 
50  subset = tag(inode(lui))(1:8)
51  CALL nemtbax(luo,subset,mtyp,msbt,inod)
52  IF ( inod .EQ. 0 ) RETURN
53 
54 C The Table A mnemonic is defined within the dictionary tables for
55 C both units, so now make sure the definitions are identical.
56 
57  ntei = isc(inode(lui))-inode(lui)
58  nteo = isc(inod)-inod
59  IF ( ntei .NE. nteo ) RETURN
60 
61  DO i = 1, ntei
62  IF ( tag(inode(lui)+i) .NE. tag(inod+i) ) RETURN
63  IF ( typ(inode(lui)+i) .NE. typ(inod+i) ) RETURN
64  IF ( isc(inode(lui)+i) .NE. isc(inod+i) ) RETURN
65  IF ( irf(inode(lui)+i) .NE. irf(inod+i) ) RETURN
66  IF ( ibt(inode(lui)+i) .NE. ibt(inod+i) ) RETURN
67  ENDDO
68 
69  iok2cpy = 1
70 
71  RETURN
72  END
integer function icmpdx(LUD, LUN)
This function determines whether the full set of associated DX BUFR Table information is identical be...
Definition: icmpdx.f:28
integer function iok2cpy(LUI, LUO)
This function determines whether a BUFR message, or a data subset from within a BUFR message,...
Definition: iok2cpy.f:28
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
integer, dimension(:), allocatable ibt
Bit widths corresponding to tag and typ:
character *3, dimension(:), allocatable typ
Type indicators corresponding to tag:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
subroutine nemtbax(LUN, NEMO, MTYP, MSBT, INOD)
This subroutine searches for a descriptor within Table A of the internal DX BUFR tables.
Definition: nemtbax.f:26