NCEPLIBS-bufr 11.7.1
openmg.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 openmb(), except that it
25C> will always open a new message for output, regardless of the values
26C> of SUBSET and JDATE. Any existing message within the internal
27C> arrays will be automatically flushed and written to logical unit LUNIT
28C> via an internal call to subroutine closmg().
29C>
30C> <b>Program history log:</b>
31C> | Date | Programmer | Comments |
32C> | -----|------------|----------|
33C> | 1994-01-06 | J. Woollen | Original author |
34C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine "ABORT" with call to new internal routine bort(); modified to make Y2K compliant |
35C> | 1999-11-18 | J. Woollen | The number of BUFR files which can be opened at one time increased from 10 to 32 |
36C> | 2003-11-04 | J. Ator | Added documentation |
37C> | 2003-11-04 | S. Bender | Added remarks and routine interdependencies |
38C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added documentation; outputs more complete diagnostic info when routine terminates abnormally |
39C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
40C>
41 SUBROUTINE openmg(LUNIT,SUBSET,JDATE)
42
43 USE moda_msgcwd
44
45 CHARACTER*(*) SUBSET
46
47C-----------------------------------------------------------------------
48C-----------------------------------------------------------------------
49
50C CHECK THE FILE STATUS
51C ---------------------
52
53 CALL status(lunit,lun,il,im)
54 IF(il.EQ.0) GOTO 900
55 IF(il.LT.0) GOTO 901
56 IF(im.NE.0) CALL closmg(lunit)
57 CALL wtstat(lunit,lun,il, 1)
58
59C GET SOME SUBSET PARTICULARS
60C ---------------------------
61
62c .... Given SUBSET, returns MTYP,MSTB,INOD
63 CALL nemtba(lun,subset,mtyp,mstb,inod)
64c .... Set pos. index for new Tbl A mnem.
65 inode(lun) = inod
66c .... Set date for new message
67 idate(lun) = i4dy(jdate)
68
69C INITIALIZE THE OPEN MESSAGE
70C ---------------------------
71
72 CALL msgini(lun)
73 CALL usrtpl(lun,1,1)
74
75C EXITS
76C -----
77
78 RETURN
79900 CALL bort('BUFRLIB: OPENMG - OUTPUT BUFR FILE IS CLOSED, IT '//
80 . 'MUST BE OPEN FOR OUTPUT')
81901 CALL bort('BUFRLIB: OPENMG - OUTPUT BUFR FILE IS OPEN FOR '//
82 . 'INPUT, IT MUST BE OPEN FOR OUTPUT')
83 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 openmg(LUNIT, SUBSET, JDATE)
This subroutine opens and initializes a new BUFR message within internal arrays, for eventual output ...
Definition: openmg.f:42
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