NCEPLIBS-bufr  12.0.0
pkvs01.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Specify a value to be included in Section 0 or Section 1 when
3 C> writing BUFR messages.
4 C>
5 C> @authors J. Ator @date 2005-11-29
6 
7 C> This subroutine is used to specify a value to be written into a
8 C> specified location within Section 0 or Section 1 of all BUFR messages
9 C> output by future calls to other
10 C> [message-writing subroutines](@ref hierarchy) and
11 C> [subset-writing subroutines](@ref hierarchy).
12 C>
13 C> This subroutine is similar to subroutine pkbs1(), except that
14 C> pkbs1() operates on a single BUFR message passed in via a memory
15 C> array. Alternatively, whenever this subroutine is called, the
16 C> specified IVAL will be written into all BUFR messages output by all
17 C> future calls to other [message-writing subroutines](@ref hierarchy)
18 C> and [subset-writing subroutines](@ref hierarchy),
19 C> for all Fortran logical units that are open for
20 C> output within the application program, unless a subsequent call is
21 C> made to this subroutine with the same value of S01MNEM in order to
22 C> reset the corresponding IVAL again. Otherwise, if this subroutine
23 C> is never called for a particular value of S01MNEM, then a default
24 C> value is used for the corresponding IVAL, as set within subroutine
25 C> msgini(), cmsgini() or dxmini().
26 C>
27 C> @param[in] IVAL -- integer: Value to be stored
28 C> @param[in] S01MNEM -- character*(*): Location where IVAL is to
29 C> be stored within Section 0 or Section 1 of
30 C> all future output BUFR messages
31 C> - 'BEN' = BUFR edition number
32 C> - 'BMT' = BUFR master table
33 C> - 'OGCE' = Originating center
34 C> - 'GSES' = Originating subcenter
35 C> - 'USN' = Update sequence number
36 C> - 'MTYP' = Data category
37 C> - 'MSBTI' = Data subcategory (international)
38 C> - 'MSBT' = Data subcategory (local)
39 C> - 'MTV' = Version number of master table
40 C> - 'MTVL' = Version number of local tables
41 C> - 'YCEN' = Year of century (1-100)
42 C> - 'CENT' = Century (e.g., 20 for years 1901-2000,
43 C> 21 for years 2001-2100)
44 C> - 'YEAR' = Year (4-digit)
45 C> - 'MNTH' = Month
46 C> - 'DAYS' = Day
47 C> - 'HOUR' = Hour
48 C> - 'MINU' = Minute
49 C> - 'SECO' = Second
50 C>
51 C> @remarks
52 C> - A separate call to this subroutine must be made for each value of
53 C> S01MNEM that is to be set within Section 0 or Section 1 of
54 C> all future output BUFR messages.
55 C> - A call to this subroutine with S01MNEM = 'BEN' and IVAL = 4 will
56 C> force all future output BUFR messages to be encoded using BUFR
57 C> edition 4; otherwise, messages will be encoded using BUFR edition 3
58 C> by default.
59 C> - Values corresponding to S01MNEM = 'YCEN' or 'CENT' can only be stored
60 C> within BUFR messages encoded using BUFR edition 3.
61 C> - Values corresponding to S01MNEM = 'YEAR', 'SECO' or 'MSBTI' can only
62 C> be stored within BUFR messages encoded using BUFR edition 4.
63 C>
64 C> @authors J. Ator @date 2005-11-29
65  RECURSIVE SUBROUTINE pkvs01(S01MNEM,IVAL)
66 
67  USE modv_mxs01v
68  USE moda_s01cm
69  USE modv_im8b
70 
71  CHARACTER*(*) s01mnem
72 
73  CHARACTER*128 bort_str
74 
75 C-----------------------------------------------------------------------
76 C-----------------------------------------------------------------------
77 
78 C CHECK FOR I8 INTEGERS
79 
80  IF(im8b) THEN
81  im8b=.false.
82 
83  CALL x84(ival,my_ival,1)
84  CALL pkvs01(s01mnem,my_ival)
85 
86  im8b=.true.
87  RETURN
88  ENDIF
89 
90 C CONFIRM THAT THE ARRAYS NEEDED BY THIS SUBROUTINE HAVE ALREADY
91 C BEEN ALLOCATED (AND IF NOT, GO AHEAD AND ALLOCATE THEM NOW), SINCE
92 C IT'S POSSIBLE FOR THIS SUBROUTINE TO BE CALLED BEFORE THE FIRST
93 C CALL TO SUBROUTINE OPENBF.
94 
95  IF ( ( .NOT. ALLOCATED(cmnem) ) .OR.
96  . ( .NOT. ALLOCATED(ivmnem) ) ) THEN
97  CALL openbf(0,'FIRST',0)
98  ENDIF
99 
100 C IF AN IVAL HAS ALREADY BEEN ASSIGNED FOR THIS PARTICULAR S01MNEM,
101 C THEN OVERWRITE THAT ENTRY IN COMMON /S01CM/ USING THE NEW IVAL.
102 
103  IF(ns01v.GT.0) THEN
104  DO i=1,ns01v
105  IF(s01mnem.EQ.cmnem(i)) THEN
106  ivmnem(i) = ival
107  RETURN
108  ENDIF
109  ENDDO
110  ENDIF
111 
112 C OTHERWISE, USE THE NEXT AVAILABLE UNUSED ENTRY IN COMMON /S01CM/.
113 
114  IF(ns01v.GE.mxs01v) GOTO 900
115 
116  ns01v = ns01v + 1
117  cmnem(ns01v) = s01mnem
118  ivmnem(ns01v) = ival
119 
120 C EXITS
121 C -----
122 
123  RETURN
124 900 WRITE(bort_str,'("BUFRLIB: PKVS01 - CANNOT OVERWRITE MORE THAN '//
125  . '",I2," DIFFERENT LOCATIONS WITHIN SECTION 0 OR SECTION 1")')
126  . mxs01v
127  CALL bort(bort_str)
128  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
This module contains array and variable declarations used to store custom values for certain mnemonic...
integer, dimension(:), allocatable ivmnem
Custom values for use within Sections 0 and 1 of all future output BUFR messages written to all Fortr...
integer ns01v
Number of custom values stored.
character *8, dimension(:), allocatable cmnem
Section 0 and 1 mnemonics corresponding to ivmnem.
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
This module declares and initializes the MXS01V variable.
integer mxs01v
Maximum number of default Section 0 or Section 1 values that can be overwritten within an output BUFR...
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
recursive subroutine pkvs01(S01MNEM, IVAL)
This subroutine is used to specify a value to be written into a specified location within Section 0 o...
Definition: pkvs01.f:66
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19