NCEPLIBS-bufr 11.7.1
openmb.f
Go to the documentation of this file.
1C> @file
2C> @brief Open a new message for output in a BUFR file that was
3C> previously opened for writing.
4
5C> This subroutine opens and initializes a new BUFR message within
6C> internal arrays, for eventual output to logical unit LUNIT.
7C>
8C> @author J. Woollen
9C> @date 1994-01-06
10C>
11C> @param[in] LUNIT -- integer: Fortran logical unit number for BUFR
12C> file
13C> @param[in] SUBSET -- character*(*): Table A mnemonic for type of
14C> BUFR message to be opened
15C> (see [DX BUFR Tables](@ref dfbftab) for
16C> further information about Table A mnemonics)
17C> @param[in] JDATE -- integer: Date-time to be stored within Section 1
18C> of BUFR message being opened, in format of either
19C> YYMMDDHH or YYYYMMDDHH
20C>
21C> <p>Logical unit LUNIT should have already been opened for output
22C> operations via a previous call to subroutine openbf().
23C>
24C> <p>This subroutine is similar to subroutine openmg(), except that it
25C> will only open a new message if either SUBSET or JDATE has changed
26C> since the previous call to this subroutine. Otherwise, it will
27C> leave the existing internal message unchanged so that the next data
28C> subset can be written into the same internal message, thereby
29C> improving overall storage efficiency by allowing the maximum number
30C> of data subsets to be stored within each output BUFR message. For
31C> this reason, openmb() is much more widely used than openmg().
32C>
33C> <p>If this subroutine does need to open and initialize a new BUFR
34C> message for output (e.g. if the value of SUBSET or JDATE has changed
35C> since the previous call to this subroutine), then any existing
36C> message within the internal arrays will be automatically flushed and
37C> written to logical unit LUNIT via an internal call to subroutine
38C> closmg(). In this case, the behavior of this subroutine then
39C> becomes exactly like that of subroutine openmg().
40C>
41C> <b>Program history log:</b>
42C> | Date | Programmer | Comments |
43C> | -----|------------|----------|
44C> | 1994-01-06 | J. Woollen | Original author |
45C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine "ABORT" with call to new internal routine bort(); modified to make Y2K compliant |
46C> | 1999-11-18 | J. Woollen | The number of BUFR files which can be opened at one time increased from 10 to 32 |
47C> | 2003-11-04 | J. Ator | Added documentation |
48C> | 2003-11-04 | S. Bender | Added remarks and routine interdependencies |
49C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added documentation; outputs more complete diagnostic info when routine terminates abnormally |
50C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
51C>
52 SUBROUTINE openmb(LUNIT,SUBSET,JDATE)
53
54 USE moda_msgcwd
55
56 CHARACTER*(*) SUBSET
57 LOGICAL OPEN
58
59C-----------------------------------------------------------------------
60C-----------------------------------------------------------------------
61
62C CHECK THE FILE STATUS
63C ---------------------
64
65 CALL status(lunit,lun,il,im)
66 IF(il.EQ.0) GOTO 900
67 IF(il.LT.0) GOTO 901
68
69C GET SOME SUBSET PARTICULARS
70C ---------------------------
71
72c .... Given SUBSET, returns MTYP,MSTB,INOD
73 CALL nemtba(lun,subset,mtyp,mstb,inod)
74 OPEN = im.EQ.0.OR.inod.NE.inode(lun).OR.i4dy(jdate).NE.idate(lun)
75
76C MAYBE(?) OPEN A NEW OR DIFFERENT TYPE OF MESSAGE
77C ------------------------------------------------
78
79 IF(open) THEN
80 CALL closmg(lunit)
81 CALL wtstat(lunit,lun,il, 1)
82c .... Set pos. index for new Tbl A mnem.
83 inode(lun) = inod
84c .... Set date for new message
85 idate(lun) = i4dy(jdate)
86
87C INITIALIZE THE OPEN MESSAGE
88C ---------------------------
89
90 CALL msgini(lun)
91 CALL usrtpl(lun,1,1)
92 ENDIF
93
94C EXITS
95C -----
96
97 RETURN
98900 CALL bort('BUFRLIB: OPENMB - OUTPUT BUFR FILE IS CLOSED, IT '//
99 . 'MUST BE OPEN FOR OUTPUT')
100901 CALL bort('BUFRLIB: OPENMB - OUTPUT BUFR FILE IS OPEN FOR '//
101 . 'INPUT, IT MUST BE OPEN FOR OUTPUT')
102 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine closmg(LUNIN)
This subroutine closes the BUFR message that is currently open for writing within internal arrays ass...
Definition: closmg.f:41
function i4dy(IDATE)
This function converts a date-time with a 2-digit year (YYMMDDHH) to a date-time with a 4-digit year ...
Definition: i4dy.f:32
subroutine msgini(LUN)
THIS SUBROUTINE INITIALIZES, WITHIN THE INTERNAL ARRAYS, A NEW BUFR MESSAGE FOR OUTPUT.
Definition: msgini.f:58
subroutine nemtba(LUN, NEMO, MTYP, MSBT, INOD)
This subroutine searches for a descriptor within Table A of the internal DX BUFR tables.
Definition: nemtba.f:36
subroutine openmb(LUNIT, SUBSET, JDATE)
This subroutine opens and initializes a new BUFR message within internal arrays, for eventual output ...
Definition: openmb.f:53
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 usrtpl(LUN, INVN, NBMP)
THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL SUBSET ARRAYS IN MODULE USRINT FOR CASES OF ...
Definition: usrtpl.f:52
subroutine wtstat(LUNIT, LUN, IL, IM)
This subroutine can be used to connect or disconnect a specified Fortran logical unit number to/from ...
Definition: wtstat.f:53