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