NCEPLIBS-bufr  11.7.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> | Date | Programmer | Comments |
53 C> | -----|------------|----------|
54 C> | 2005-11-29 | J. Ator | Original author |
55 C> | 2006-04-14 | D. Keyser | Added options for 'MTYP', 'MSBT', 'YEAR', 'MNTH', 'DAYS', 'HOUR', 'YCEN' and 'CENT' |
56 C>
57  SUBROUTINE pkbs1(IVAL,MBAY,S1MNEM)
58 
59  dimension mbay(*)
60 
61  character*(*) s1mnem
62 
63  character*128 bort_str
64 
65 C-----------------------------------------------------------------------
66 C-----------------------------------------------------------------------
67 
68 C Note that the following call to function IUPBS01 will ensure
69 C that subroutine WRDLEN has been called.
70 
71  iben = iupbs01(mbay,'BEN')
72 
73 C 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 
87 C 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
96 900 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 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:57
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
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:38
function iupbs01(MBAY, S01MNEM)
This function returns a specified value from within Section 0 or Section 1 of a BUFR message...
Definition: iupbs01.f:73