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