NCEPLIBS-bufr 11.7.1
pkbs1.f
Go to the documentation of this file.
1C> @file
2C> @brief Write a data value into Section 1 of a BUFR message.
3
4C> This subroutines writes a specified value into a specified location
5C> within Section 1 of a BUFR message, overwriting the value previously
6C> stored in that location.
7C>
8C> <p>This subroutine will work on any BUFR message encoded using BUFR
9C> edition 2, 3, or 4. It is similar to subroutine pkvs01(), except
10C> that it operates on a BUFR message passed in via a memory array,
11C> whereas pkvs01() operates on BUFR messages stored internally within
12C> the software.
13C>
14C> @authors J. Ator
15C> @authors D. Keyser
16C> @date 2005-11-29
17C>
18C> @param[in] IVAL -- integer: Value to be stored
19C> @param[in,out] MBAY -- integer(*): BUFR message
20C> @param[in] S1MNEM -- character*(*): Location in Section 1 of
21C> MBAY within which to store IVAL
22C> - 'BMT' = BUFR master table
23C> - 'OGCE' = Originating center
24C> - 'GSES' = Originating subcenter
25C> - 'USN' = Update sequence number
26C> - 'MTYP' = Data category
27C> - 'MSBTI' = Data subcategory (international)
28C> - 'MSBT' = Data subcategory (local)
29C> - 'MTV' = Version number of master table
30C> - 'MTVL' = Version number of local tables
31C> - 'YCEN' = Year of century (1-100)
32C> - 'CENT' = Century (e.g., 20 for years 1901-2000,
33C> 21 for years 2001-2100)
34C> - 'YEAR' = Year (4-digit)
35C> - 'MNTH' = Month
36C> - 'DAYS' = Day
37C> - 'HOUR' = Hour
38C> - 'MINU' = Minute
39C> - 'SECO' = Second
40C>
41C> @remarks
42C> - The start of the BUFR message (i.e. the string 'BUFR') must be
43C> aligned on the first 4 bytes of MBAY.
44C> - Values corresponding to S1MNEM = 'GSES' can only be stored within
45C> BUFR messages encoded using BUFR edition 3 or 4.
46C> - Values corresponding to S1MNEM = 'YCEN' or 'CENT' can only be stored
47C> within BUFR messages encoded using BUFR edition 2 or 3.
48C> - Values corresponding to S1MNEM = 'YEAR', 'SECO' or 'MSBTI' can only
49C> be stored within BUFR messages encoded using BUFR edition 4.
50C>
51C> <b>Program history log:</b>
52C> | Date | Programmer | Comments |
53C> | -----|------------|----------|
54C> | 2005-11-29 | J. Ator | Original author |
55C> | 2006-04-14 | D. Keyser | Added options for 'MTYP', 'MSBT', 'YEAR', 'MNTH', 'DAYS', 'HOUR', 'YCEN' and 'CENT' |
56C>
57 SUBROUTINE pkbs1(IVAL,MBAY,S1MNEM)
58
59 dimension mbay(*)
60
61 character*(*) s1mnem
62
63 character*128 bort_str
64
65C-----------------------------------------------------------------------
66C-----------------------------------------------------------------------
67
68C Note that the following call to function IUPBS01 will ensure
69C that subroutine WRDLEN has been called.
70
71 iben = iupbs01(mbay,'BEN')
72
73C Determine where to store the value.
74
75 CALL gets1loc(s1mnem,iben,isbyt,iwid,iret)
76 IF ( (iret.EQ.0) .AND.
77 . ( (s1mnem.EQ.'USN') .OR. (s1mnem.EQ.'BMT') .OR.
78 . (s1mnem.EQ.'OGCE') .OR. (s1mnem.EQ.'GSES') .OR.
79 . (s1mnem.EQ.'MTYP') .OR. (s1mnem.EQ.'MSBTI') .OR.
80 . (s1mnem.EQ.'MSBT') .OR. (s1mnem.EQ.'MTV') .OR.
81 . (s1mnem.EQ.'MTVL') .OR. (s1mnem.EQ.'YCEN') .OR.
82 . (s1mnem.EQ.'CENT') .OR. (s1mnem.EQ.'YEAR') .OR.
83 . (s1mnem.EQ.'MNTH') .OR. (s1mnem.EQ.'DAYS') .OR.
84 . (s1mnem.EQ.'HOUR') .OR. (s1mnem.EQ.'MINU') .OR.
85 . (s1mnem.EQ.'SECO') ) ) THEN
86
87C Store the value.
88
89 ibit = (iupbs01(mbay,'LEN0')+isbyt-1)*8
90 CALL pkb(ival,iwid,mbay,ibit)
91 ELSE
92 GOTO 900
93 ENDIF
94
95 RETURN
96900 WRITE(bort_str,'("BUFRLIB: PKBS1 - CANNOT OVERWRITE LOCATION '//
97 . 'CORRESPONDING TO MNEMONIC (",A,") WITHIN BUFR EDITION '//
98 . '(",I1,")")') s1mnem, iben
99 CALL bort(bort_str)
100 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine gets1loc(S1MNEM, IBEN, ISBYT, IWID, IRET)
THIS SUBROUTINE RETURNS THE LOCATION (I.E.
Definition: gets1loc.f:81
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:74
subroutine pkb(NVAL, NBITS, IBAY, IBIT)
This subroutine encodes an integer value within a specified number of bits of an integer array,...
Definition: pkb.f:39
subroutine pkbs1(IVAL, MBAY, S1MNEM)
This subroutines writes a specified value into a specified location within Section 1 of a BUFR messag...
Definition: pkbs1.f:58