NCEPLIBS-bufr  12.0.1
setblock.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Specify the use of IEEE Fortran control words when writing
3 C> BUFR messages.
4 C>
5 C> @author J. Woollen @date 2012-09-15
6 
7 C> Specify whether BUFR messages output by
8 C> future calls to [message-writing subroutines](@ref hierarchy)
9 C> should be encapsulated with IEEE Fortran control words when being
10 C> written to output files.
11 C>
12 C> If control words are requested, then one 4-byte control word is
13 C> written to the output file prior to the start of each BUFR message,
14 C> and a second 4-byte control word is written to the output file after
15 C> the end of each BUFR message. Each of these control words contains
16 C> the byte count for the enclosed BUFR message, and they can be
17 C> written using either big-endian or little-endian byte ordering,
18 C> regardless of the native endianness of the local machine.
19 C>
20 C> This subroutine can be called at any time after the first call
21 C> to subroutine openbf(), and the specified value for IBLK will remain
22 C> in effect for all future calls to
23 C> [message-writing subroutines](@ref hierarchy) for all Fortran logical
24 C> units that are open for output within the application program,
25 C> unless a subsequent call is made to this subroutine to reset the
26 C> value of IBLK again. If this subroutine is never called, a default
27 C> value of 0 is used for IBLK, as set within subroutine bfrini().
28 C>
29 C> @remarks
30 C> - This subroutine can be used to generate BUFR files consistent
31 C> with historical archives, dating back to older versions of the
32 C> BUFRLIB software which used Fortran to directly read/write
33 C> BUFR messages from/to files. Standard Fortran historically
34 C> didn't have a way to read/write binary data streams without
35 C> control words, so as a result many historical archives contain
36 C> these by default. However, newer versions of the BUFRLIB software
37 C> use C to directly read/write BUFR messages from/to files
38 C> (including historical archives), so control words are no longer
39 C> necessary and are therefore now disabled by default when writing
40 C> BUFR messages to output files.
41 C>
42 C> @param[in] IBLK -- integer: Flag indicating whether future BUFR
43 C> output messages should be encapsulated with
44 C> control words
45 C> - -1 = Yes, using little-endian control words
46 C> - 0 = No (the default)
47 C> - 1 = Yes, using big-endian control words
48 C>
49 C> @author J. Woollen @date 2012-09-15
50  RECURSIVE SUBROUTINE setblock(IBLK)
51 
52  USE modv_im8b
53 
54  COMMON /endord/ iblock,iordbe(4),iordle(4)
55 
56 C-----------------------------------------------------------------------
57 C-----------------------------------------------------------------------
58 
59 C Check for I8 integers.
60 
61  IF(im8b) THEN
62  im8b=.false.
63 
64  CALL x84(iblk,my_iblk,1)
65  CALL setblock(my_iblk)
66 
67  im8b=.true.
68  RETURN
69  ENDIF
70 
71  CALL openbf(0,'FIRST',0)
72  iblock=iblk
73 
74  RETURN
75  END
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 ...
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
recursive subroutine setblock(IBLK)
Specify whether BUFR messages output by future calls to message-writing subroutines should be encapsu...
Definition: setblock.f:51
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19