NCEPLIBS-bufr  11.6.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> | Date | Programmer | Comments |
52 C> | -----|------------|----------|
53 C> | 2016-07-29 | J. Ator | Original author |
54 C>
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 
66 C----------------------------------------------------------------------
67 C----------------------------------------------------------------------
68 
69  iret = -1
70 
71 C 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 
77 C Starting from the beginning of the subset, locate the (NTAGPV)th
78 C occurrence of TAGPV.
79 
80  CALL fstag( lun, tagpv, ntagpv, 1, npv, ierft )
81  IF ( ierft .NE. 0 ) RETURN
82 
83 C Now, starting from the (NTAGPV)th occurrence of TAGPV, search
84 C 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
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 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: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