NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
gettagre.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Check whether a Table B mnemonic references another
3 C> Table B mnemonic via an internal bitmap.
4 
5 C> This subroutine determines whether a specified Table B mnemonic
6 C> references another Table B mnemonic within the same data subset
7 C> via an internal bitmap, and if so returns the referenced
8 C> mnemonic and its location within the subset.
9 C>
10 C> @author J. Ator
11 C> @date 2016-06-07
12 C>
13 C> @param[in] LUNIT - integer: Fortran logical unit number for
14 C> BUFR file
15 C> @param[in] TAGI - character*(*): Table B mnemonic
16 C> @param[in] NTAGI - integer: Ordinal occurrence of TAGI for
17 C> which TAGRE is to be returned, counting from
18 C> the beginning of the overall subset definition
19 C> @param[out] TAGRE - character*(*): Table B mnemonic referenced by
20 C> TAGI via an internal bitmap
21 C> @param[out] NTAGRE - integer: Ordinal occurrence of TAGRE
22 C> referenced by (NTAGI)th occurrence of TAGI,
23 C> counting from the beginning of the overall
24 C> subset definition
25 C> @param[out] IRET - integer: return code
26 C> - 0 = normal return
27 C> - -1 = TAGRE could not be found, or some
28 C> other error occurred
29 C>
30 C> <p>A data subset must already be in scope within the BUFRLIB
31 C> internal arrays for LUNIT, either via a previous call to one
32 C> of the [subset-reading subroutines](@ref hierarchy)
33 C> (when reading BUFR data subsets) or via a previous call to one
34 C> of the [message-writing subroutines](@ref hierarchy)
35 C> (when writing BUFR data subsets).
36 C>
37 C> <b>Program history log:</b>
38 C> - 2016-06-07 J. Ator -- Original author
39 C>
40  SUBROUTINE gettagre ( LUNIT, TAGI, NTAGI, TAGRE, NTAGRE, IRET )
41 
42  USE moda_usrint
43  USE moda_msgcwd
44  USE moda_tables
45 
46  CHARACTER*(*) tagi, tagre
47 
48  CHARACTER*10 tagtmp
49 
50 C----------------------------------------------------------------------
51 C----------------------------------------------------------------------
52 
53  iret = -1
54 
55 C Get LUN from LUNIT.
56 
57  CALL status( lunit, lun, il, im )
58  IF ( il .EQ. 0 ) RETURN
59  IF ( inode(lun) .NE. inv(1,lun) ) RETURN
60 
61 C Get TAGRE and NTAGRE from the (NTAGI)th occurrence of TAGI.
62 
63  CALL fstag( lun, tagi, ntagi, 1, ni, iret )
64  IF ( iret .NE. 0 ) RETURN
65  nre = nrfelm(ni,lun)
66  IF ( nre .GT. 0 ) THEN
67  iret = 0
68  tagre = tag(inv(nre,lun))
69  CALL strsuc( tagre, tagtmp, ltre )
70  ntagre = 0
71  DO ii = 1, nre
72  IF ( tag(inv(ii,lun))(1:ltre) .EQ. tagre(1:ltre) ) THEN
73  ntagre = ntagre + 1
74  END IF
75  END DO
76  END IF
77 
78  RETURN
79  END
subroutine strsuc(STR1, STR2, LENS)
THIS SUBROUTINE REMOVES LEADING AND TRAILING BLANKS FROM A STRING.
Definition: strsuc.f:34
This module contains array and variable declarations used to store the internal jump/link table...
Definition: moda_tables.F:13
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:61
subroutine gettagre(LUNIT, TAGI, NTAGI, TAGRE, NTAGRE, IRET)
This subroutine determines whether a specified Table B mnemonic references another Table B mnemonic w...
Definition: gettagre.f:40
subroutine fstag(LUN, UTAG, NUTAG, NIN, NOUT, IRET)
THIS SUBROUTINE FINDS THE (NUTAG)th OCCURRENCE OF MNEMONIC UTAG WITHIN THE CURRENT OVERALL SUBSET DEF...
Definition: fstag.f:40