NCEPLIBS-bufr 11.7.1
irev.F
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS FUNCTION WILL, WHEN THE LOCAL MACHINE IS "LITTLE-
5C> ENDIAN" (I.E., USES A RIGHT TO LEFT SCHEME FOR NUMBERING THE BYTES
6C> WITHIN A MACHINE WORD), RETURN A COPY OF AN INPUT INTEGER WORD WITH
7C> THE BYTES REVERSED. ALTHOUGH, BY DEFINITION (WITHIN WMO MANUAL
8C> 306), A BUFR MESSAGE IS A STREAM OF INDIVIDUAL OCTETS (I.E., BYTES)
9C> THAT IS INDEPENDENT OF ANY PARTICULAR MACHINE REPRESENTATION, THE
10C> BUFR ARCHIVE LIBRARY SOFTWARE OFTEN NEEDS TO INTERPRET ALL OR PARTS
11C> OF TWO OR MORE ADJACENT BYTES IN ORDER TO CONSTRUCT AN INTEGER
12C> WORD. BY DEFAULT, THE SOFTWARE USES THE "BIG-ENDIAN" (LEFT TO
13C> RIGHT) SCHEME FOR NUMBERING BYTES. BY REVERSING THE BYTES, IREV
14C> ALLOWS THE INTEGER WORD TO BE PROPERLY READ OR WRITTEN (DEPENDING
15C> ON WHETHER INPUT OR OUTPUT OPERATIONS, RESPECTIVELY, ARE BEING
16C> PERFORMED) ON LITTLE-ENDIAN MACHINES. IF THE LOCAL MACHINE IS
17C> BIG-ENDIAN, IREV SIMPLY RETURNS A COPY OF THE SAME INTEGER THAT WAS
18C> INPUT.
19C>
20C> PROGRAM HISTORY LOG:
21C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
22C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
23C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
24C> INTERDEPENDENCIES
25C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
26C> DOCUMENTATION
27C> 2007-01-19 J. ATOR -- BIG-ENDIAN VS. LITTLE-ENDIAN IS NOW
28C> DETERMINED AT COMPILE TIME AND CONFIGURED
29C> WITHIN BUFRLIB VIA CONDITIONAL COMPILATION
30C> DIRECTIVES
31C>
32C> USAGE: IREV (N)
33C> INPUT ARGUMENT LIST:
34C> N - INTEGER: INTEGER WORD WITH BYTES ORDERED ACCORDING TO
35C> THE "BIG-ENDIAN" NUMBERING SCHEME
36C>
37C> OUTPUT ARGUMENT LIST:
38C> IREV - INTEGER: INTEGER WORD WITH BYTES ORDERED ACCORDING TO
39C> THE NUMBERING SCHEME OF THE LOCAL MACHINE (EITHER
40C> "BIG-ENDIAN" OR "LITTLE-ENDIAN", IF "BIG-ENDIAN THEN
41C> THIS IS JUST A DIRECT COPY OF N)
42C>
43C> REMARKS:
44C> THIS ROUTINE CALLS: None
45C> THIS ROUTINE IS CALLED BY: IPKM IUPM PKB PKC
46C> UPBB
47C> Normally not called by any application
48C> programs.
49C>
50 FUNCTION irev(N)
51
52
53
54 COMMON /hrdwrd/ nbytw,nbitw,iord(8)
55
56 CHARACTER*8 cint,dint
57 equivalence(cint,int)
58 equivalence(dint,jnt)
59
60C----------------------------------------------------------------------
61C----------------------------------------------------------------------
62
63#ifdef BIG_ENDIAN
64 irev = n
65#else
66 int = n
67 DO i=1,nbytw
68 dint(i:i) = cint(iord(i):iord(i))
69 ENDDO
70 irev = jnt
71#endif
72
73 RETURN
74 END
function irev(N)
THIS FUNCTION WILL, WHEN THE LOCAL MACHINE IS "LITTLE- ENDIAN" (I.E., USES A RIGHT TO LEFT SCHEME ...
Definition: irev.F:51