NCEPLIBS-bufr  12.0.0
dumpbf.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read the Section 1 date-time from the first two "dummy"
3 C> messages of an NCEP dump file
4 C>
5 C> @author J. Woollen @date 1996-12-11
6 
7 C> Read the Section 1 date-time from the first two "dummy" messages of an
8 C> NCEP dump file.
9 C>
10 C> This bypasses any messages at the beginning of the
11 C> file which may contain embedded DX BUFR table information. Normally,
12 C> the first of these two "dummy" messages contains the dump center
13 C> date-time in Section 1, while the second message contains the dump
14 C> initiation date-time in Section 1. Neither of these two "dummy"
15 C> messages should contain any data subsets in Section 4.
16 C>
17 C> Logical unit LUNIT must already be associated with a filename
18 C> on the local system, typically via a Fortran "OPEN" statement.
19 C>
20 C> If the subroutine fails to locate either of the two "dummy"
21 C> messages within the file pointed to by LUNIT, then the corresponding
22 C> JDATE or JDUMP array will be filled with all values set to (-1).
23 C>
24 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR
25 C> dump file.
26 C> @param[out] JDATE - integer(5): Dump center date-time stored
27 C> within Section 1 of first "dummy" message:
28 C> - Index 1 contains the year, in format of either YY or YYYY,
29 C> depending on the most recent call to subroutine datelen().
30 C> - Index 2 contains the month.
31 C> - Index 3 contains the day.
32 C> - Index 4 contains the hour.
33 C> - Index 5 contains the minute.
34 C> @param[out] JDUMP -- integer(5): Dump initiation date-time stored
35 C> within Section 1 of second "dummy" message:
36 C> - Index 1 contains the year, in format of either YY or YYYY,
37 C> depending on the most recent call to subroutine datelen().
38 C> - Index 2 contains the month.
39 C> - Index 3 contains the day.
40 C> - Index 4 contains the hour.
41 C> - Index 5 contains the minute.
42 C>
43 C> @author J. Woollen @date 1996-12-11
44  RECURSIVE SUBROUTINE dumpbf(LUNIT,JDATE,JDUMP)
45 
46  USE moda_mgwa
47  USE modv_im8b
48 
49  COMMON /quiet / iprt
50 
51  dimension jdate(*),jdump(*)
52 
53  CHARACTER*128 errstr
54 
55 C-----------------------------------------------------------------------
56 C-----------------------------------------------------------------------
57 
58 C CHECK FOR I8 INTEGERS
59 C ---------------------
60 
61  IF(im8b) THEN
62  im8b=.false.
63 
64  CALL x84(lunit,my_lunit,1)
65  CALL dumpbf(my_lunit,jdate,jdump)
66  CALL x48(jdate,jdate,5)
67  CALL x48(jdump,jdump,5)
68 
69  im8b=.true.
70  RETURN
71  ENDIF
72 
73 C CALL SUBROUTINE WRDLEN TO INITIALIZE SOME IMPORTANT INFORMATION
74 C ABOUT THE LOCAL MACHINE (IN CASE IT HAS NOT YET BEEN CALLED)
75 C ---------------------------------------------------------------
76 
77  CALL wrdlen
78 
79  DO i=1,5
80  jdate(i) = -1
81  jdump(i) = -1
82  ENDDO
83 
84 C SEE IF THE FILE IS ALREADY OPEN TO BUFR INTERFACE (A NO-NO)
85 C -----------------------------------------------------------
86 
87  CALL status(lunit,lun,jl,jm)
88  IF(jl.NE.0) GOTO 900
89  call openbf(lunit,'INX',lunit)
90 
91 C READ PAST ANY DICTIONARY MESSAGES
92 C ---------------------------------
93 
94 1 CALL rdmsgw(lunit,mgwa,ier)
95  IF(ier.LT.0) GOTO 200
96  IF(idxmsg(mgwa).EQ.1) GOTO 1
97 
98 C DUMP CENTER YY,MM,DD,HH,MM IS IN THE FIRST EMPTY MESSAGE
99 C --------------------------------------------------------
100 C i.e. the first message containing zero subsets
101 
102  IF(iupbs3(mgwa,'NSUB').NE.0) GOTO 200
103 
104  igd = igetdate(mgwa,jdate(1),jdate(2),jdate(3),jdate(4))
105  jdate(5) = iupbs01(mgwa,'MINU')
106 
107 C DUMP CLOCK YY,MM,DD,HH,MM IS IN THE SECOND EMPTY MESSAGE
108 C --------------------------------------------------------
109 C i.e. the second message containing zero subsets
110 
111  CALL rdmsgw(lunit,mgwa,ier)
112  IF(ier.LT.0) GOTO 200
113 
114  IF(iupbs3(mgwa,'NSUB').NE.0) GOTO 200
115 
116  igd = igetdate(mgwa,jdump(1),jdump(2),jdump(3),jdump(4))
117  jdump(5) = iupbs01(mgwa,'MINU')
118 
119  CALL closbf(lunit)
120  GOTO 100
121 
122 200 IF(iprt.GE.1 .AND. (jdate(1).EQ.-1.OR.jdump(1).EQ.-1)) THEN
123  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
124  IF(jdate(1).EQ.-1) THEN
125  errstr = 'BUFRLIB: DUMPBF - FIRST EMPTY BUFR MESSAGE '//
126  . 'SECTION 1 DATE COULD NOT BE LOCATED - RETURN WITH '//
127  . 'JDATE = 5*-1'
128  CALL errwrt(errstr)
129  ENDIF
130  IF(jdump(1).EQ.-1) THEN
131  errstr = 'BUFRLIB: DUMPBF - SECOND EMPTY BUFR MESSAGE '//
132  . 'SECTION 1 DATE COULD NOT BE LOCATED - RETURN WITH '//
133  . 'JDUMP = 5*-1'
134  CALL errwrt(errstr)
135  ENDIF
136  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
137  CALL errwrt(' ')
138  ENDIF
139 
140 C EXITS
141 C -----
142 
143 100 RETURN
144 900 CALL bort
145  . ('BUFRLIB: DUMPBF - INPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
146  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive subroutine closbf(LUNIT)
Close the connection between logical unit LUNIT and the NCEPLIBS-bufr software.
Definition: closbf.f:24
recursive subroutine dumpbf(LUNIT, JDATE, JDUMP)
Read the Section 1 date-time from the first two "dummy" messages of an NCEP dump file.
Definition: dumpbf.f:45
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
recursive function idxmsg(MESG)
Check whether a BUFR message contains DX BUFR tables information.
Definition: idxmsg.f:23
recursive function igetdate(MBAY, IYR, IMO, IDY, IHR)
This function returns the date-time from within Section 1 of a BUFR message.
Definition: igetdate.f:30
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 iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:30
This module contains a declaration for an array used by various subroutines and functions to hold a t...
integer, dimension(:), allocatable mgwa
Temporary working copy of BUFR message.
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 openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
subroutine rdmsgw(lunit, mesg, iret)
Read the next BUFR message from logical unit lunit as an array of integer words.
Definition: rdmsgw.F90:16
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 wrdlen
Determine important information about the local machine.
Definition: wrdlen.F:25
subroutine x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19