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