NCEPLIBS-bufr  11.6.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> | Date | Programmer | Comments |
52 C> | -----|------------|----------|
53 C> | 2012-09-12 | J. Ator | Original author |
54 C> | 2014-10-02 | J. Ator | Modified to use fstag() |
55 C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
56 C>
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 
67 C----------------------------------------------------------------------
68 C----------------------------------------------------------------------
69 
70  getvalnb = bmiss
71 
72 C 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 
78 C Starting from the beginning of the subset, locate the (NTAGPV)th
79 C occurrence of TAGPV.
80 
81  CALL fstag( lun, tagpv, ntagpv, 1, npv, iret )
82  IF ( iret .NE. 0 ) RETURN
83 
84 C Now, starting from the (NTAGPV)th occurrence of TAGPV, search
85 C 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
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:57
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:55
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