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