NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
nemspecs.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get the scale factor, reference value and bit width
3 C> associated with a specified occurrence of a Table B mnemonic.
4 
5 C> Given a Table B mnemonic defined within a data subset, this
6 C> subroutine returns the scale factor, reference value and bit
7 C> width of a specified occurrence of that mnemonic within the
8 C> overall data subset definition, counting from the beginning
9 C> of the subset.
10 C>
11 C> <p>The values returned include the application of any Table C
12 C> operators (e.g. 2-01-YYY, 2-02-YYY, 2-03-YYY, 2-07-YYY,
13 C> 2-08-YYY) which may be in effect for the specified occurrence
14 C> of the mnemonic.
15 C>
16 C> @author J. Ator
17 C> @date 2014-10-02
18 C>
19 C> @param[in] LUNIT - integer: Fortran logical unit number for
20 C> BUFR file
21 C> @param[in] NEMO - character*(*): Table B mnemonic
22 C> @param[in] NNEMO - integer: Ordinal occurrence of NEMO for
23 C> which information is to be returned,
24 C> counting from the beginning of the overall
25 C> subset definition
26 C> @param[out] NSCL - integer: Scale factor in effect for
27 C> (NNEMO)th occurrence of NEMO
28 C> @param[out] NREF - integer: Reference value in effect for
29 C> (NNEMO)th occurrence of NEMO
30 C> @param[out] NBTS - integer: Bit width in effect for
31 C> (NNEMO)th occurrence of NEMO
32 C> @param[out] IRET - integer: return code
33 C> - 0 = normal return
34 C> - -1 = NEMO could not be found, or some
35 C> other error occurred
36 C>
37 C> <p>A data subset must already be in scope within the BUFRLIB
38 C> internal arrays for LUNIT, either via a previous call to one
39 C> of the [subset-reading subroutines](@ref hierarchy)
40 C> (when reading BUFR data subsets) or via a previous call to one
41 C> of the [message-writing subroutines](@ref hierarchy)
42 C> (when writing BUFR data subsets).
43 C>
44 C> <b>Program history log:</b>
45 C> - 2014-10-02 J. Ator -- Original version
46 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
47 C>
48  SUBROUTINE nemspecs ( LUNIT, NEMO, NNEMO,
49  . nscl, nref, nbts, iret )
50 
51  USE moda_usrint
52  USE moda_msgcwd
53  USE moda_tables
54  USE moda_nrv203
55 
56  CHARACTER*10 tagn
57 
58  CHARACTER*(*) nemo
59 
60 C----------------------------------------------------------------------
61 C----------------------------------------------------------------------
62 
63  iret = -1
64 
65 C Get LUN from LUNIT.
66 
67  CALL status( lunit, lun, il, im )
68  IF ( il .EQ. 0 ) RETURN
69  IF ( inode(lun) .NE. inv(1,lun) ) RETURN
70 
71 C Starting from the beginning of the subset, locate the (NNEMO)th
72 C occurrence of NEMO.
73 
74  CALL fstag( lun, nemo, nnemo, 1, nidx, ierfst )
75  IF ( ierfst .NE. 0 ) RETURN
76 
77 C Confirm that NEMO is a Table B mnemonic.
78 
79  node = inv(nidx,lun)
80  IF ( ( typ(node) .NE. 'NUM' ) .AND. ( typ(node) .NE. 'CHR' ) )
81  . RETURN
82 
83 C Get the scale factor, reference value and bit width, including
84 C accounting for any Table C operators which may be in scope for
85 C this particular occurrence of NEMO.
86 
87  iret = 0
88 
89  nscl = isc(node)
90  nbts = ibt(node)
91  nref = irf(node)
92 
93  IF ( nnrv .GT. 0 ) THEN
94 
95 C There are nodes containing redefined reference values (from
96 C one or more 2-03-YYY operators) in the jump/link table, so we
97 C need to check if this node is one of them.
98 
99  tagn = ' '
100  CALL strsuc( nemo, tagn, ltn )
101  IF ( ( ltn .LE. 0 ) .OR. ( ltn .GT. 8 ) ) RETURN
102 
103  DO jj = 1, nnrv
104  IF ( ( node .NE. inodnrv(jj) ) .AND.
105  . ( tagn(1:8) .EQ. tagnrv(jj) ) .AND.
106  . ( node .GE. isnrv(jj) ) .AND.
107  . ( node .LE. ienrv(jj) ) ) THEN
108  nref = nrv(jj)
109  RETURN
110  END IF
111  END DO
112 
113  END IF
114 
115  RETURN
116  END
subroutine nemspecs(LUNIT, NEMO, NNEMO, NSCL, NREF, NBTS, IRET)
Given a Table B mnemonic defined within a data subset, this subroutine returns the scale factor...
Definition: nemspecs.f:48
This module contains array and variable declarations for use with any 2-03-YYY (change reference valu...
Definition: moda_nrv203.F:15
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 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