NCEPLIBS-bufr 11.7.1
dumpbf.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1996-12-11
3
4C> THIS SUBROUTINE RETURNS THE SECTION 1 DATE IN THE FIRST
5C> TWO NON-DICTIONARY BUFR MESSAGES IN LOGICAL UNIT LUNIT WHICH
6C> CONTAIN ZERO SUBSETS. NORMALLY, THESE "DUMMY" MESSAGES APPEAR
7C> ONLY IN DATA DUMP FILES AND ARE IMMEDIATELY AFTER THE DICTIONARY
8C> MESSAGES. THEY CONTAIN A DUMP "CENTER TIME" AND A DUMP FILE
9C> "PROCESSING TIME", RESPECTIVELY. LUNIT SHOULD NOT BE PREVIOUSLY
10C> OPENED TO THE BUFR INTERFACE.
11C>
12C> PROGRAM HISTORY LOG:
13C> 1996-12-11 J. WOOLLEN -- ORIGINAL AUTHOR
14C> 1996-12-17 J. WOOLLEN -- CORRECTED ERROR IN DUMP DATE READER
15C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
16C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
17C> ROUTINE "BORT"; MODIFIED TO MAKE Y2K
18C> COMPLIANT
19C> 2003-05-19 M. SHIREY -- REPLACED CALLS TO FORTRAN INSRINSIC
20C> FUNCTION ICHAR WITH THE NCEP W3LIB C-
21C> FUNCTION MOVA2I BECAUSE ICHAR DOES NOT WORK
22C> PROPERLY ON SOME MACHINES (E.G., IBM FROST/
23C> SNOW) (NOTE: ON 2003-??-??, MOVA2I WAS
24C> ADDED TO THE BUFRLIB AS A FORTRAN FUNCTION)
25C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
26C> INTERDEPENDENCIES
27C> 2003-11-04 D. KEYSER -- MODIFIED DATE CALCULATIONS TO NO LONGER
28C> USE FLOATING POINT ARITHMETIC SINCE THIS
29C> CAN LEAD TO ROUND OFF ERROR AND AN IMPROPER
30C> RESULTING DATE ON SOME MACHINES (E.G., NCEP
31C> IBM FROST/SNOW), INCREASES PORTABILITY;
32C> UNIFIED/PORTABLE FOR WRF; ADDED
33C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
34C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
35C> TERMINATES ABNORMALLY OR UNUSUAL THINGS
36C> HAPPEN
37C> 2004-08-18 J. ATOR -- MODIFIED 'BUFR' STRING TEST FOR PORTABILITY
38C> TO EBCDIC MACHINES
39C> 2004-12-20 D. KEYSER -- CALLS WRDLEN TO INITIALIZE LOCAL MACHINE
40C> INFORMATION (IN CASE IT HAS NOT YET BEEN
41C> CALLED), THIS ROUTINE DOES NOT REQUIRE IT
42C> BUT 2004-08-18 CHANGE CALLS OTHER ROUTINES
43C> THAT DO REQUIRE IT
44C> 2005-11-29 J. ATOR -- USE IUPBS01, IGETDATE, GETLENS AND RDMSGW
45C> 2009-03-23 J. ATOR -- USE IDXMSG, IUPBS3 AND ERRWRT
46C> 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
47C> USE NEW OPENBF TYPE 'INX' TO OPEN AND CLOSE
48C> THE C FILE WITHOUT CLOSING THE FORTRAN FILE
49C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
50C>
51C> USAGE: CALL DUMPBF (LUNIT, JDATE, JDUMP)
52C> INPUT ARGUMENT LIST:
53C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
54C>
55C> OUTPUT ARGUMENT LIST:
56C> JDATE - INTEGER: 5-WORD ARRAY CONTAINING THE YEAR
57C> (YYYY OR YY, DEPENDING ON DATELEN() VALUE),
58C> MONTH, DAY, HOUR AND MINUTE FROM SECTION 1 OF THE
59C> FIRST NON-DICTIONARY BUFR MESSAGE WITH ZERO SUBSETS
60C> (NORMALLY THE DATA DUMP CENTER TIME IN A DATA DUMP
61C> FILE); OR 5*-1 IF THIS COULD NOT BE LOCATED
62C> JDUMP - INTEGER: 5-WORD ARRAY CONTAINING THE YEAR
63C> (YYYY OR YY, DEPENDING ON DATELEN() VALUE),
64C> MONTH, DAY, HOUR AND MINUTE FROM SECTION 1 OF THE
65C> SECOND NON-DICTIONARY BUFR MESSAGE WITH ZERO SUBSETS
66C> (NORMALLY THE FILE PROCESSING TIME IN A DATA DUMP
67C> FILE); OR 5*-1 IF THIS COULD NOT BE LOCATED
68C>
69C> INPUT FILES:
70C> UNIT "LUNIT" - BUFR FILE
71C>
72C> REMARKS:
73C> THIS ROUTINE CALLS: BORT ERRWRT IDXMSG IGETDATE
74C> IUPBS01 IUPBS3 RDMSGW STATUS
75C> WRDLEN
76C> THIS ROUTINE IS CALLED BY: None
77C> Normally called only by application
78C> programs.
79C>
80 SUBROUTINE dumpbf(LUNIT,JDATE,JDUMP)
81
82 USE moda_mgwa
83
84 COMMON /quiet / iprt
85
86 dimension jdate(5),jdump(5)
87
88 CHARACTER*128 ERRSTR
89
90C-----------------------------------------------------------------------
91C-----------------------------------------------------------------------
92
93C CALL SUBROUTINE WRDLEN TO INITIALIZE SOME IMPORTANT INFORMATION
94C ABOUT THE LOCAL MACHINE (IN CASE IT HAS NOT YET BEEN CALLED)
95C ---------------------------------------------------------------
96
97 CALL wrdlen
98
99 DO i=1,5
100 jdate(i) = -1
101 jdump(i) = -1
102 ENDDO
103
104C SEE IF THE FILE IS ALREADY OPEN TO BUFR INTERFACE (A NO-NO)
105C -----------------------------------------------------------
106
107 CALL status(lunit,lun,jl,jm)
108 IF(jl.NE.0) GOTO 900
109 call openbf(lunit,'INX',lunit)
110
111C READ PAST ANY DICTIONARY MESSAGES
112C ---------------------------------
113
1141 CALL rdmsgw(lunit,mgwa,ier)
115 IF(ier.LT.0) GOTO 200
116 IF(idxmsg(mgwa).EQ.1) GOTO 1
117
118C DUMP CENTER YY,MM,DD,HH,MM IS IN THE FIRST EMPTY MESSAGE
119C --------------------------------------------------------
120C i.e. the first message containing zero subsets
121
122 IF(iupbs3(mgwa,'NSUB').NE.0) GOTO 200
123
124 igd = igetdate(mgwa,jdate(1),jdate(2),jdate(3),jdate(4))
125 jdate(5) = iupbs01(mgwa,'MINU')
126
127C DUMP CLOCK YY,MM,DD,HH,MM IS IN THE SECOND EMPTY MESSAGE
128C --------------------------------------------------------
129C i.e. the second message containing zero subsets
130
131 CALL rdmsgw(lunit,mgwa,ier)
132 IF(ier.LT.0) GOTO 200
133
134 IF(iupbs3(mgwa,'NSUB').NE.0) GOTO 200
135
136 igd = igetdate(mgwa,jdump(1),jdump(2),jdump(3),jdump(4))
137 jdump(5) = iupbs01(mgwa,'MINU')
138
139 call closbf(lunit)
140 GOTO 100
141
142200 IF(iprt.GE.1 .AND. (jdate(1).EQ.-1.OR.jdump(1).EQ.-1)) THEN
143 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
144 IF(jdate(1).EQ.-1) THEN
145 errstr = 'BUFRLIB: DUMPBF - FIRST EMPTY BUFR MESSAGE '//
146 . 'SECTION 1 DATE COULD NOT BE LOCATED - RETURN WITH '//
147 . 'JDATE = 4*-1'
148 CALL errwrt(errstr)
149 ENDIF
150 IF(jdump(1).EQ.-1) THEN
151 errstr = 'BUFRLIB: DUMPBF - SECOND EMPTY BUFR MESSAGE '//
152 . 'SECTION 1 DATE COULD NOT BE LOCATED - RETURN WITH '//
153 . 'JDUMP = 4*-1'
154 CALL errwrt(errstr)
155 ENDIF
156 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
157 CALL errwrt(' ')
158 ENDIF
159
160C EXITS
161C -----
162
163100 RETURN
164900 CALL bort
165 . ('BUFRLIB: DUMPBF - INPUT BUFR FILE IS OPEN, IT MUST BE CLOSED')
166 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.f:35
subroutine dumpbf(LUNIT, JDATE, JDUMP)
THIS SUBROUTINE RETURNS THE SECTION 1 DATE IN THE FIRST TWO NON-DICTIONARY BUFR MESSAGES IN LOGICAL U...
Definition: dumpbf.f:81
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
function idxmsg(MESG)
This function determines whether a given BUFR message contains DX BUFR tables information that was ge...
Definition: idxmsg.f:24
function igetdate(MBAY, IYR, IMO, IDY, IHR)
This function returns the date-time from within Section 1 of a BUFR message.
Definition: igetdate.f:35
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
function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:35
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
Definition: openbf.f:139
subroutine rdmsgw(LUNIT, MESG, IRET)
THIS SUBROUTINE READS THE NEXT BUFR MESSAGE FROM LOGICAL UNIT LUNIT AS AN ARRAY OF INTEGER WORDS.
Definition: rdmsgw.f:38
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:56
subroutine wrdlen
This subroutine figures out some important information about the local machine on which the BUFRLIB s...
Definition: wrdlen.F:36