NCEPLIBS-bufr  12.0.1
iupvs01.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read a data value from Section 0 or Section 1 of a BUFR
3 C> message.
4 C>
5 C> @author J. Ator @date 2005-11-29
6 
7 C> Read a specified value from within Section 0 or 1 of a BUFR message.
8 C>
9 C> This function will work on any BUFR message encoded using BUFR
10 C> edition 2, 3, or 4. It is similar to function iupbs01(), except
11 C> that iupbs01() operates on a BUFR message passed in via a memory
12 C> array, whereas this function operates on the BUFR message that was
13 C> read into internal arrays via the most recent call to any of the
14 C> other [message-reading subroutines](@ref hierarchy) for a specified
15 C> Fortran logical unit.
16 C>
17 C> @remarks
18 C> - Values corresponding to S01MNEM = 'GSES' can only be read from
19 C> BUFR messages encoded using BUFR edition 3 or 4.
20 C> - Values corresponding to S01MNEM = 'YCEN' or 'CENT' can only be
21 C> read from BUFR messages encoded using BUFR edition 2 or 3.
22 C> - When reading from BUFR messages encoded using BUFR edition 2
23 C> or 3, values corresponding to S01MNEM = 'YEAR' will be
24 C> calculated internally using the values for 'YCEN' and 'CENT',
25 C> or inferred using a windowing technique.
26 C> - Values corresponding to S01MNEM = 'SECO' or 'MSBTI' can only
27 C> be read from BUFR messages encoded using BUFR edition 4.
28 C>
29 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file.
30 C> @param[in] S01MNEM - character*(*): Value to be read from Section 0
31 C> or Section 1 of BUFR message in internal arrays for LUNIT:
32 C> - 'LENM' = Length (in bytes) of BUFR message
33 C> - 'LEN0' = Length (in bytes) of Section 0
34 C> - 'LEN1' = Length (in bytes) of Section 1
35 C> - 'BEN' = BUFR edition number
36 C> - 'BMT' = BUFR master table
37 C> - 'OGCE' = Originating center
38 C> - 'GSES' = Originating subcenter
39 C> - 'USN' = Update sequence number
40 C> - 'ISC2' = Flag indicating absence/presence of (optional) Section 2
41 C> in BUFR message:
42 C> - 0 = Section 2 absent
43 C> - 1 = Section 2 present
44 C> - 'MTYP' = Data category
45 C> - 'MSBTI' = Data subcategory (international)
46 C> - 'MSBT' = Data subcategory (local)
47 C> - 'MTV' = Version number of master table
48 C> - 'MTVL' = Version number of local tables
49 C> - 'YCEN' = Year of century (1-100)
50 C> - 'CENT' = Century (e.g., 20 for years 1901-2000, 21 for years 2001-2100)
51 C> - 'YEAR' = Year (4-digit)
52 C> - 'MNTH' = Month
53 C> - 'DAYS' = Day
54 C> - 'HOUR' = Hour
55 C> - 'MINU' = Minute
56 C> - 'SECO' = Second
57 C>
58 C> @returns - integer: Value corresponding to S01MNEM:
59 C> - -1 = S01MNEM was invalid for the edition of BUFR message in
60 C> internal arrays for LUNIT, or some other error occurred.
61 C>
62 C> @author J. Ator @date 2005-11-29
63  RECURSIVE FUNCTION iupvs01(LUNIT,S01MNEM) RESULT(IRET)
64 
65  USE modv_im8b
66 
67  USE moda_bitbuf
68 
69  CHARACTER*(*) s01mnem
70 
71 C-----------------------------------------------------------------------
72 C-----------------------------------------------------------------------
73 
74 C CHECK FOR I8 INTEGERS
75 C ---------------------
76 
77  IF(im8b) THEN
78  im8b=.false.
79 
80  CALL x84(lunit,my_lunit,1)
81  iret=iupvs01(my_lunit,s01mnem)
82 
83  im8b=.true.
84  RETURN
85  ENDIF
86 
87  iret = -1
88 
89 C CHECK THE FILE STATUS
90 C ---------------------
91 
92  CALL status(lunit,lun,ilst,imst)
93  IF(ilst.EQ.0) GOTO 900
94  IF(ilst.GT.0) GOTO 901
95  IF(imst.EQ.0) GOTO 902
96 
97 C UNPACK THE REQUESTED VALUE
98 C --------------------------
99 
100  iret = iupbs01(mbay(1,lun),s01mnem)
101 
102 C EXITS
103 C -----
104 
105  RETURN
106 900 CALL bort('BUFRLIB: IUPVS01 - INPUT BUFR FILE IS CLOSED, IT '//
107  . 'MUST BE OPEN FOR INPUT')
108 901 CALL bort('BUFRLIB: IUPVS01 - INPUT BUFR FILE IS OPEN FOR '//
109  . 'OUTPUT, IT MUST BE OPEN FOR INPUT')
110 902 CALL bort('BUFRLIB: IUPVS01 - A MESSAGE MUST BE OPEN IN INPUT '//
111  . 'BUFR FILE, NONE ARE')
112  END
113 
114 
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
recursive function iupvs01(LUNIT, S01MNEM)
Read a specified value from within Section 0 or 1 of a BUFR message.
Definition: iupvs01.f:64
This module contains array and variable declarations used to store BUFR messages internally for multi...
integer, dimension(:,:), allocatable mbay
Current BUFR message for each internal I/O stream.
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19