NCEPLIBS-bufr 11.7.1
writsb.f
Go to the documentation of this file.
1C> @file
2C> @brief Write a data subset into a BUFR message.
3
4C> This subroutine writes a complete data subset
5C> into a BUFR message, for eventual output to logical unit LUNIT.
6C>
7C> @author J. Woollen
8C> @date 1994-01-06
9C>
10C> @param[in] LUNIT -- integer: Fortran logical unit number for BUFR file
11C>
12C> <p>This subroutine is called to indicate to the BUFRLIB software that
13C> all necessary values for a data subset (i.e. report) have been written,
14C> and thus that the subset is ready to be encoded and packed into the
15C> current message for the BUFR file associated with logical unit LUNIT.
16C> Logical unit LUNIT should have already been opened for output
17C> operations via a previous call to subroutine openbf(), and
18C> a BUFR message should already be open for output within internal
19C> arrays via a previous call to one of the BUFRLIB
20C> [message-writing subroutines](@ref hierarchy).
21C> Furthermore, all of the values for the data subset should have
22C> already been written into internal arrays via calls to any of the
23C> BUFRLIB [values-writing subroutines](@ref hierarchy)
24C>
25C> @remarks
26C> - There is a maximum size for any BUFR message that can be written
27C> by the BUFRLIB software. This maximum message size is initially set
28C> to an internal default value within subroutine bfrini(), but it can
29C> be changed to a different value via a separate prior call to
30C> subroutine maxout().
31C> - This subroutine will always check to ensure that the data subset,
32C> when encoded and packed, will fit into the current BUFR message that
33C> is already open within the internal arrays associated with logical
34C> unit LUNIT. If adding the data subset to the current message would
35C> cause the maximum message size to be exceeded, then the subroutine will
36C> automatically flush the current message to logical unit LUNIT, then
37C> open and initialize a new internal message using the same SUBSET and
38C> JDATE values that were specified in the most recent call to one of
39C> the [message-writing subroutines](@ref hierarchy) for LUNIT, then
40C> encode and pack the data subset into that new message.
41C>
42C> <b>Program history log:</b>
43C> | Date | Programmer | Comments |
44C> | -----|------------|----------|
45C> | 1994-01-06 | J. Woollen | Original author |
46C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine "ABORT" with call to new internal routine bort() |
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> | 2005-03-09 | J. Ator | Added capability for compressed messages |
51C>
52 SUBROUTINE writsb(LUNIT)
53
54 COMMON /msgcmp/ ccmf
55
56 CHARACTER*1 CCMF
57
58C-----------------------------------------------------------------------
59C-----------------------------------------------------------------------
60
61C CHECK THE FILE STATUS
62C ---------------------
63
64 CALL status(lunit,lun,il,im)
65 IF(il.EQ.0) GOTO 900
66 IF(il.LT.0) GOTO 901
67 IF(im.EQ.0) GOTO 902
68
69C PACK UP THE SUBSET AND PUT IT INTO THE MESSAGE
70C ----------------------------------------------
71
72 CALL wrtree(lun)
73 IF( ccmf.EQ.'Y' ) THEN
74 CALL wrcmps(lunit)
75 ELSE
76 CALL msgupd(lunit,lun)
77 ENDIF
78
79C EXITS
80C -----
81
82 RETURN
83900 CALL bort('BUFRLIB: WRITSB - OUTPUT BUFR FILE IS CLOSED, IT '//
84 . 'MUST BE OPEN FOR OUTPUT')
85901 CALL bort('BUFRLIB: WRITSB - OUTPUT BUFR FILE IS OPEN FOR '//
86 . 'INPUT, IT MUST BE OPEN FOR OUTPUT')
87902 CALL bort('BUFRLIB: WRITSB - A MESSAGE MUST BE OPEN IN OUTPUT '//
88 . 'BUFR FILE, NONE ARE')
89 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine msgupd(LUNIT, LUN)
THIS SUBROUTINE PACKS UP THE CURRENT SUBSET WITHIN MEMORY (ARRAY IBAY IN MODULE BITBUF) AND THEN TRIE...
Definition: msgupd.f:60
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 wrcmps(LUNIX)
THIS SUBROUTINE PACKS UP THE CURRENT SUBSET WITHIN MEMORY (ARRAY IBAY IN MODULE BITBUF),...
Definition: wrcmps.f:81
subroutine writsb(LUNIT)
This subroutine writes a complete data subset into a BUFR message, for eventual output to logical uni...
Definition: writsb.f:53
subroutine wrtree(LUN)
THIS SUBROUTINE CONVERTS USER NUMBERS INTO SCALED INTEGERS AND PACKS THE USER ARRAY INTO THE SUBSET B...
Definition: wrtree.f:51