NCEPLIBS-bufr 11.7.1
setvalnb.f
Go to the documentation of this file.
1C> @file
2C> @brief Write one data value to a data subset.
3
4C> This subroutine can be used to write 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 subroutine 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> stores the specified data value in the corresponding location
13C> within the subset.
14C>
15C> @author J. Ator
16C> @date 2016-07-29
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> store R8VAL as 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> @param[in] R8VAL -- real*8: Value to be stored corresponding to
39C> (NTAGNB)th occurrence of TAGNB within the subset
40C> @param[out] IRET -- integer: return code
41C> - 0 = R8VAL was successfully stored
42C> - -1 = the (NTAGNB)th occurence of mnemonic TAGNB
43C> could not be found, or some other error
44C> occurred
45C>
46C> <p>Before calling this subroutine, a BUFR message should already be
47C> opened and initialized for output via a previous call to one of the
48C> BUFRLIB [message-writing subroutines](@ref hierarchy).
49C>
50C> <b>Program history log:</b>
51C> | Date | Programmer | Comments |
52C> | -----|------------|----------|
53C> | 2016-07-29 | J. Ator | Original author |
54C>
55 SUBROUTINE setvalnb ( LUNIT, TAGPV, NTAGPV, TAGNB, NTAGNB,
56 . R8VAL, IRET )
57
58 USE moda_usrint
59 USE moda_msgcwd
60 USE moda_tables
61
62 CHARACTER*(*) TAGPV, TAGNB
63
64 real*8 r8val
65
66C----------------------------------------------------------------------
67C----------------------------------------------------------------------
68
69 iret = -1
70
71C Get LUN from LUNIT.
72
73 CALL status (lunit, lun, il, im )
74 IF ( il .LE. 0 ) RETURN
75 IF ( inode(lun) .NE. inv(1,lun) ) RETURN
76
77C Starting from the beginning of the subset, locate the (NTAGPV)th
78C occurrence of TAGPV.
79
80 CALL fstag( lun, tagpv, ntagpv, 1, npv, ierft )
81 IF ( ierft .NE. 0 ) RETURN
82
83C Now, starting from the (NTAGPV)th occurrence of TAGPV, search
84C forward or backward for the (NTAGNB)th occurrence of TAGNB.
85
86 CALL fstag( lun, tagnb, ntagnb, npv, nnb, ierft )
87 IF ( ierft .NE. 0 ) RETURN
88
89 iret = 0
90 val(nnb,lun) = r8val
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
This module contains array and variable declarations used to store the internal jump/link table.
Definition: moda_tables.F:13
subroutine setvalnb(LUNIT, TAGPV, NTAGPV, TAGNB, NTAGNB, R8VAL, IRET)
This subroutine can be used to write a data value corresponding to a specific occurrence of a mnemoni...
Definition: setvalnb.f:57
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