NCEPLIBS-bufr  12.0.1
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 C>
5 C> @author J. Ator @date 2014-10-02
6 
7 C> Given a Table B mnemonic defined within a data subset, this
8 C> subroutine returns the scale factor, reference value and bit
9 C> width of a specified occurrence of that mnemonic within the
10 C> overall data subset definition, counting from the beginning
11 C> of the subset.
12 C>
13 C> The values returned include the application of any Table C
14 C> operators (e.g. 2-01-YYY, 2-02-YYY, 2-03-YYY, 2-07-YYY,
15 C> 2-08-YYY) which may be in effect for the specified occurrence
16 C> of the mnemonic.
17 C>
18 C> @param[in] LUNIT - integer: Fortran logical unit number for
19 C> BUFR file
20 C> @param[in] NEMO - character*(*): Table B mnemonic
21 C> @param[in] NNEMO - integer: Ordinal occurrence of NEMO for
22 C> which information is to be returned,
23 C> counting from the beginning of the overall
24 C> subset definition
25 C> @param[out] NSCL - integer: Scale factor in effect for
26 C> (NNEMO)th occurrence of NEMO
27 C> @param[out] NREF - integer: Reference value in effect for
28 C> (NNEMO)th occurrence of NEMO
29 C> @param[out] NBTS - integer: Bit width in effect for
30 C> (NNEMO)th occurrence of NEMO
31 C> @param[out] IRET - integer: return code
32 C> - 0 normal return
33 C> - -1 NEMO could not be found, or some
34 C> other error occurred
35 C>
36 C> A data subset must already be in scope within the BUFRLIB
37 C> internal arrays for LUNIT, either via a previous call to one
38 C> of the [subset-reading subroutines](@ref hierarchy)
39 C> (when reading BUFR data subsets) or via a previous call to one
40 C> of the [message-writing subroutines](@ref hierarchy)
41 C> (when writing BUFR data subsets).
42 C>
43 C> @author J. Ator @date 2014-10-02
44 
45  RECURSIVE SUBROUTINE nemspecs
46  . ( lunit, nemo, nnemo, nscl, nref, nbts, iret )
47 
48  USE moda_usrint
49  USE moda_msgcwd
50  USE moda_tables
51  USE moda_nrv203
52  USE modv_im8b
53 
54  CHARACTER*10 tagn
55 
56  CHARACTER*(*) nemo
57 
58 C----------------------------------------------------------------------
59 C----------------------------------------------------------------------
60 
61 C Check for I8 integers.
62 
63  IF(im8b) THEN
64  im8b=.false.
65 
66  CALL x84(lunit,my_lunit,1)
67  CALL x84(nnemo,my_nnemo,1)
68  CALL nemspecs(my_lunit,nemo,my_nnemo,nscl,nref,nbts,iret)
69  CALL x48(nscl,nscl,1)
70  CALL x48(nref,nref,1)
71  CALL x48(nbts,nbts,1)
72  CALL x48(iret,iret,1)
73 
74  im8b=.true.
75  RETURN
76  ENDIF
77 
78  iret = -1
79 
80 C Get LUN from LUNIT.
81 
82  CALL status( lunit, lun, il, im )
83  IF ( il .EQ. 0 ) RETURN
84  IF ( inode(lun) .NE. inv(1,lun) ) RETURN
85 
86 C Starting from the beginning of the subset, locate the (NNEMO)th
87 C occurrence of NEMO.
88 
89  CALL fstag( lun, nemo, nnemo, 1, nidx, ierfst )
90  IF ( ierfst .NE. 0 ) RETURN
91 
92 C Confirm that NEMO is a Table B mnemonic.
93 
94  node = inv(nidx,lun)
95  IF ( ( typ(node) .NE. 'NUM' ) .AND. ( typ(node) .NE. 'CHR' ) )
96  . RETURN
97 
98 C Get the scale factor, reference value and bit width, including
99 C accounting for any Table C operators which may be in scope for
100 C this particular occurrence of NEMO.
101 
102  iret = 0
103 
104  nscl = isc(node)
105  nbts = ibt(node)
106  nref = irf(node)
107 
108  IF ( nnrv .GT. 0 ) THEN
109 
110 C There are nodes containing redefined reference values (from
111 C one or more 2-03-YYY operators) in the jump/link table, so we
112 C need to check if this node is one of them.
113 
114  tagn = ' '
115  CALL strsuc( nemo, tagn, ltn )
116  IF ( ( ltn .LE. 0 ) .OR. ( ltn .GT. 8 ) ) RETURN
117 
118  DO jj = 1, nnrv
119  IF ( ( node .NE. inodnrv(jj) ) .AND.
120  . ( tagn(1:8) .EQ. tagnrv(jj) ) .AND.
121  . ( node .GE. isnrv(jj) ) .AND.
122  . ( node .LE. ienrv(jj) ) ) THEN
123  nref = int(nrv(jj))
124  RETURN
125  END IF
126  END DO
127 
128  END IF
129 
130  RETURN
131  END
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:26
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 for use with any 2-03-YYY (change reference valu...
integer, dimension(:), allocatable ienrv
End of entry range in jump/link table, within which the corresponding new reference value in nrv will...
character *8, dimension(:), allocatable tagnrv
Table B mnemonic to which the corresponding new reference value in nrv applies.
integer, dimension(:), allocatable isnrv
Start of entry range in jump/link table, within which the corresponding new reference value in nrv wi...
integer nnrv
Number of entries in the jump/link table which contain new reference values (up to a maximum of MXNRV...
integer *8, dimension(:), allocatable nrv
New reference values corresponding to inodnrv.
integer, dimension(:), allocatable inodnrv
Entries within jump/link table which contain new reference values.
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:
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
recursive 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:47
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine strsuc(str1, str2, lens)
This subroutine removes leading and trailing blanks from a character string.
Definition: strsuc.F90:16
subroutine x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19