NCEPLIBS-bufr  12.0.0
openmg.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Open a new message for output in a BUFR file that was
3 C> previously opened for writing.
4 C>
5 C> @author J. Woollen @date 1994-01-06
6 
7 C> This subroutine opens and initializes a new BUFR message within
8 C> internal arrays, for eventual output to logical unit LUNIT.
9 C>
10 C> Logical unit LUNIT should have already been opened for output
11 C> operations via a previous call to subroutine openbf().
12 C>
13 C> This subroutine is similar to subroutine openmb(), except that it
14 C> will always open a new message for output, regardless of the values
15 C> of SUBSET and JDATE. Any existing message within the internal
16 C> arrays will be automatically flushed and written to logical unit LUNIT
17 C> via an internal call to subroutine closmg().
18 C>
19 C> @param[in] LUNIT -- integer: Fortran logical unit number for BUFR
20 C> file
21 C> @param[in] SUBSET -- character*(*): Table A mnemonic for type of
22 C> BUFR message to be opened
23 C> (see [DX BUFR Tables](@ref dfbftab) for
24 C> further information about Table A mnemonics)
25 C> @param[in] JDATE -- integer: Date-time to be stored within Section 1
26 C> of BUFR message being opened, in format of either
27 C> YYMMDDHH or YYYYMMDDHH
28 C>
29 C> @author J. Woollen @date 1994-01-06
30  RECURSIVE SUBROUTINE openmg(LUNIT,SUBSET,JDATE)
31 
32  USE moda_msgcwd
33  USE modv_im8b
34 
35  CHARACTER*(*) subset
36 
37 C-----------------------------------------------------------------------
38 C-----------------------------------------------------------------------
39 
40 C CHECK FOR I8 INTEGERS
41 C ---------------------
42 
43  IF(im8b) THEN
44  im8b=.false.
45 
46  CALL x84(lunit,my_lunit,1)
47  CALL x84(jdate,my_jdate,1)
48  CALL openmg(my_lunit,subset,my_jdate)
49 
50  im8b=.true.
51  RETURN
52  ENDIF
53 
54 C CHECK THE FILE STATUS
55 C ---------------------
56 
57  CALL status(lunit,lun,il,im)
58  IF(il.EQ.0) GOTO 900
59  IF(il.LT.0) GOTO 901
60  IF(im.NE.0) CALL closmg(lunit)
61  CALL wtstat(lunit,lun,il, 1)
62 
63 C GET SOME SUBSET PARTICULARS
64 C ---------------------------
65 
66 c .... Given SUBSET, returns MTYP,MSTB,INOD
67  CALL nemtba(lun,subset,mtyp,mstb,inod)
68 c .... Set pos. index for new Tbl A mnem.
69  inode(lun) = inod
70 c .... Set date for new message
71  idate(lun) = i4dy(jdate)
72 
73 C INITIALIZE THE OPEN MESSAGE
74 C ---------------------------
75 
76  CALL msgini(lun)
77  CALL usrtpl(lun,1,1)
78 
79 C EXITS
80 C -----
81 
82  RETURN
83 900 CALL bort('BUFRLIB: OPENMG - OUTPUT BUFR FILE IS CLOSED, IT '//
84  . 'MUST BE OPEN FOR OUTPUT')
85 901 CALL bort('BUFRLIB: OPENMG - OUTPUT BUFR FILE IS OPEN FOR '//
86  . 'INPUT, IT MUST BE OPEN FOR OUTPUT')
87  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive subroutine closmg(LUNIN)
This subroutine closes the BUFR message that is currently open for writing within internal arrays ass...
Definition: closmg.f:26
recursive 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:24
subroutine msgini(LUN)
This subroutine initializes, within the internal arrays, a new uncompressed BUFR message for output.
Definition: msgini.f:14
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
integer, dimension(:), allocatable idate
Section 1 date-time of 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 ...
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:25
recursive subroutine openmg(LUNIT, SUBSET, JDATE)
This subroutine opens and initializes a new BUFR message within internal arrays, for eventual output ...
Definition: openmg.f:31
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 usrtpl(LUN, INVN, NBMP)
Store the subset template into internal arrays.
Definition: usrtpl.f:22
subroutine wtstat(LUNIT, LUN, IL, IM)
Update file status in library internals.
Definition: wtstat.f:37
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19