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