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