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