NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
getvalnb.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read one data value from a data subset.
3 
4 C> This function can be used to read a data value corresponding to
5 C> a specific occurrence of a mnemonic within a data subset, based on
6 C> its position relative to a different mnemonic within the subset.
7 C>
8 C> <p>The function first searches for a specific occurrence of a pivot
9 C> mnemonic, counting from the beginning of the subset. From there,
10 C> it then searches in either a forward or backward direction for a
11 C> specific occurrence of a nearby mnemonic, and if found
12 C> returns the data value from the corresponding location
13 C> within the subset.
14 C>
15 C> @author J. Ator
16 C> @date 2012-09-12
17 C>
18 C> @param[in] LUNIT - integer: Fortran logical unit number for
19 C> BUFR file
20 C> @param[in] TAGPV - character*(*): Pivot mnemonic; the subroutine
21 C> will first search for the (NTAGPV)th occurrence
22 C> of this mnemonic, counting from the beginning
23 C> of the overall subset definition
24 C> @param[in] NTAGPV - integer: Ordinal occurrence of TAGPV to search for,
25 C> counting from the beginning of the overall
26 C> subset definition
27 C> @param[in] TAGNB - character*(*): Nearby mnemonic; assuming TAGPV is
28 C> successfully found, the subroutine will then search
29 C> nearby for the (NTAGNB)th occurrence of TAGNB and
30 C> return the corresponding value
31 C> @param[in] NTAGNB - integer: Ordinal occurrence of TAGNB to search for,
32 C> counting from the location of TAGPV within the
33 C> overall subset definition. If NTAGNB is positive,
34 C> the subroutine will search in a forward direction
35 C> from the location of TAGPV; otherwise, if NTAGNB is
36 C> negative, it will instead search in a backwards
37 C> direction from the location of TAGPV.
38 C> @returns getvalnb - real*8: Value corresponding to (NTAGNB)th occurrence
39 C> of TAGNB. If for any reason this value cannot be
40 C> located, then the current placeholder value for
41 C> "missing" data will be returned instead.
42 C>
43 C> <p>The current placeholder value for "missing" data can be determined
44 C> via a separate call to function getbmiss().
45 C>
46 C> <p>Before calling this function, a BUFR data subset should already be
47 C> open for reading via a previous call to one of the BUFRLIB
48 C> [subset-reading subroutines](@ref hierarchy).
49 C>
50 C> <b>Program history log:</b>
51 C> - 2012-09-12 J. Ator -- Original author
52 C> - 2014-10-02 J. Ator -- Modified to use fstag()
53 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
54 C>
55  REAL*8 FUNCTION getvalnb ( LUNIT, TAGPV, NTAGPV, TAGNB, NTAGNB )
56 
57  USE modv_bmiss
58 
59  USE moda_usrint
60  USE moda_msgcwd
61  USE moda_tables
62 
63  CHARACTER*(*) tagpv, tagnb
64 
65 C----------------------------------------------------------------------
66 C----------------------------------------------------------------------
67 
68  getvalnb = bmiss
69 
70 C Get LUN from LUNIT.
71 
72  CALL status(lunit, lun, il, im )
73  IF ( il .GE. 0 ) RETURN
74  IF ( inode(lun) .NE. inv(1,lun) ) RETURN
75 
76 C Starting from the beginning of the subset, locate the (NTAGPV)th
77 C occurrence of TAGPV.
78 
79  CALL fstag( lun, tagpv, ntagpv, 1, npv, iret )
80  IF ( iret .NE. 0 ) RETURN
81 
82 C Now, starting from the (NTAGPV)th occurrence of TAGPV, search
83 C forward or backward for the (NTAGNB)th occurrence of TAGNB.
84 
85  CALL fstag( lun, tagnb, ntagnb, npv, nnb, iret )
86  IF ( iret .NE. 0 ) RETURN
87 
88  getvalnb = val(nnb,lun)
89 
90  RETURN
91  END
REAL *8 function getvalnb(LUNIT, TAGPV, NTAGPV, TAGNB, NTAGNB)
This function can be used to read a data value corresponding to a specific occurrence of a mnemonic w...
Definition: getvalnb.f:55
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
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