NCEPLIBS-bufr  12.0.0
irev.F
Go to the documentation of this file.
1 C> @file
2 C> @brief Return a copy of an input integer word with
3 C> the bytes reversed.
4 C>
5 C> @author Woollen @date 1994-01-06
6 
7 C> This function will, when the local machine is "little-endian" (i.e.,
8 C> when it uses a right to left scheme for numbering the bytes
9 C> within a machine word), return a copy of an input integer word with
10 C> the bytes reversed. Although, by definition (within WMO Manual
11 C> 306), a BUFR message is a stream of individual octets (i.e., bytes)
12 C> that is independent of any particular machine representation, the
13 C> BUFR archive library software often needs to interpret all or parts
14 C> of two or more adjacent bytes in order to construct an integer
15 C> word. By default, the software uses the "big-endian" (left to
16 C> right) scheme for numbering bytes. By reversing the bytes, irev()
17 C> allows the integer word to be properly read or written (depending
18 C> on whether input or output operations, respectively, are being
19 C> performed) on "little-endian" machines. If the local machine is
20 C> "big-endian", irev() simply returns a copy of the same integer that was
21 C> input.
22 C>
23 C> @param[in] N - integer: integer word with bytes ordered according
24 C> to the "big-endian" numbering scheme
25 C>
26 C> @return - integer: integer word with bytes ordered according to
27 C> the numbering scheme of the local machine (either
28 C> "big-endian" or "little-endian"; if "big-endian" then
29 C> this is just a direct copy of N).
30 C>
31 C> @author Woollen @date 1994-01-06
32  FUNCTION irev(N)
33 
34  COMMON /hrdwrd/ nbytw,nbitw,iord(8)
35 
36  CHARACTER*8 cint,dint
37  equivalence(cint,int)
38  equivalence(dint,jnt)
39 
40 C----------------------------------------------------------------------
41 C----------------------------------------------------------------------
42 
43 #ifdef BIG_ENDIAN
44  irev = n
45 #else
46  int = n
47  DO i=1,nbytw
48  dint(i:i) = cint(iord(i):iord(i))
49  ENDDO
50  irev = jnt
51 #endif
52 
53  RETURN
54  END
function irev(N)
This function will, when the local machine is "little-endian" (i.e., when it uses a right to left sch...
Definition: irev.F:33