NCEPLIBS-bufr  12.0.0
x48.F
Go to the documentation of this file.
1 C> @file
2 C> @brief Encode one or more 4-byte integer values as 8-byte integer values.
3 C>
4 C> @author J. Woollen @date 2022-10-12
5 
6 C> Encode one or more 4-byte integer values as 8-byte integer values.
7 C>
8 C> @note IIN4 and IOUT8 may be the same array, as long as the underlying
9 C> memory contains sufficient space for the equivalent number of 8-byte
10 C> integer values.
11 C>
12 C> @param[in] IIN4 - integer(*): Value(s) encoded as 4-byte integers
13 C> @param[out] IOUT8 - integer(*): Value(s) from IIN4 now re-encoded as 8-byte integers
14 C> @param[in] NVAL - integer: Number of values in IIN4 to be re-encoded
15 C>
16 C> @author J. Woollen @date 2022-10-12
17 
18  SUBROUTINE x48(IIN4,IOUT8,NVAL)
19 
20  INTEGER IIN4(*),IOUT8(*)
21 
22  INTEGER ONES /-1/
23  INTEGER ZERO / 0/
24 
25 C Call subroutine WRDLEN, in case it hasn't already been called.
26 
27  CALL wrdlen
28 
29 C IHI points to the first byte of the high-order (i.e. most
30 C significant) 4-byte integer word within an 8-byte integer word.
31 C ILO points to the first byte of the low-order (i.e. least
32 C significant) 4-byte integer word within an 8-byte integer word.
33 
34 #ifdef BIG_ENDIAN
35  ihi=1
36  ilo=5
37 #else
38  ihi=5
39  ilo=1
40 #endif
41 
42 C Re-encode the 4-byte values as 8-byte values.
43 
44  DO k = nval,1,-1
45  l=2*k-1
46  CALL mvb(iin4(k),1,itmp,ilo,4)
47  iout8(l)=itmp
48  IF(iout8(l)<0) THEN
49  CALL mvb(ones,1,iout8(l),ihi,4)
50  ELSE
51  CALL mvb(zero,1,iout8(l),ihi,4)
52  ENDIF
53  END DO
54 
55  RETURN
56  END
subroutine mvb(IB1, NB1, IB2, NB2, NBM)
This subroutine copies a specified number of bytes from one packed binary array to another.
Definition: mvb.f:18
subroutine wrdlen
Determine important information about the local machine.
Definition: wrdlen.F:25
subroutine x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19