NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
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 
5 C> This function determines whether a BUFR message, or a data subset
6 C> from within a BUFR message, can be copied from one Fortran logical
7 C> unit to another.
8 C>
9 C> <p>The decision is based on whether both logical units contain
10 C> identical definitions for the BUFR message type in question within
11 C> their associated [DX BUFR Table information](@ref dfbftab).
12 C> Note that it's possible for a BUFR message type to be identically
13 C> defined for two different logical units even if the full set of
14 C> associated DX BUFR table information isn't identical between both
15 C> units.
16 C>
17 C> @author J. Ator
18 C> @date 2009-06-26
19 C>
20 C> @param[in] LUI - integer: Internal I/O stream index associated
21 C> with source BUFR file
22 C> @param[in] LUO - integer: Internal I/O stream index associated
23 C> with target BUFR file
24 C> @returns iok2cpy - integer: Flag indicating whether a BUFR
25 C> message or data subset can be copied from the
26 C> BUFR file associated with LUI to the BUFR file
27 C> associated with LUO
28 C> - 0 = No
29 C> - 1 = Yes
30 C>
31 C> <b>Program history log:</b>
32 C> - 2009-06-26 J. Ator -- Original author
33 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
34 C>
35  INTEGER FUNCTION iok2cpy(LUI,LUO)
36 
37  USE moda_msgcwd
38  USE moda_tables
39 
40  CHARACTER*8 subset
41 
42 C-----------------------------------------------------------------------
43 C-----------------------------------------------------------------------
44 
45  iok2cpy = 0
46 
47 C Do both logical units have the same internal table information?
48 
49  IF ( icmpdx(lui,luo) .EQ. 1 ) THEN
50  iok2cpy = 1
51  RETURN
52  ENDIF
53 
54 C No, so get the Table A mnemonic from the message to be copied,
55 C then check whether that mnemonic is defined within the dictionary
56 C tables for the logical unit to be copied to.
57 
58  subset = tag(inode(lui))
59  CALL nemtbax(luo,subset,mtyp,msbt,inod)
60  IF ( inod .EQ. 0 ) RETURN
61 
62 C The Table A mnemonic is defined within the dictionary tables for
63 C both units, so now make sure the definitions are identical.
64 
65  ntei = isc(inode(lui))-inode(lui)
66  nteo = isc(inod)-inod
67  IF ( ntei .NE. nteo ) RETURN
68 
69  DO i = 1, ntei
70  IF ( tag(inode(lui)+i) .NE. tag(inod+i) ) RETURN
71  IF ( typ(inode(lui)+i) .NE. typ(inod+i) ) RETURN
72  IF ( isc(inode(lui)+i) .NE. isc(inod+i) ) RETURN
73  IF ( irf(inode(lui)+i) .NE. irf(inod+i) ) RETURN
74  IF ( ibt(inode(lui)+i) .NE. ibt(inod+i) ) RETURN
75  ENDDO
76 
77  iok2cpy = 1
78 
79  RETURN
80  END
subroutine nemtbax(LUN, NEMO, MTYP, MSBT, INOD)
THIS SUBROUTINE SEARCHES FOR MNEMONIC NEMO WITHIN THE INTERNAL TABLE A ARRAYS HOLDING THE DICTIONARY ...
Definition: nemtbax.f:40
This module contains array and variable declarations used to store the internal jump/link table...
Definition: moda_tables.F:13
INTEGER function iok2cpy(LUI, LUO)
This function determines whether a BUFR message, or a data subset from within a BUFR message...
Definition: iok2cpy.f:35
INTEGER function icmpdx(LUD, LUN)
This function determines whether the full set of associated DX BUFR Table information is identical be...
Definition: icmpdx.f:31