NCEPLIBS-bufr 11.7.1
ipkm.f
Go to the documentation of this file.
1C> @file
2C> @brief Encode an integer value within a character string.
3
4C> This subroutine encodes an integer value within a specified
5C> number of bytes of a character string, up to a maximum of 8
6C> bytes.
7C>
8C> @author J. Woollen
9C> @date 1994-01-06
10C>
11C> @param[in] N -- integer: Value to be encoded
12C> @param[in] NBYT -- integer: Number of bytes of CBAY (up to a
13C> maximum of 8) within which to encode N
14C> @param[out] CBAY -- character*(*): String of length NBYT bytes
15C> containing encoded integer N
16C>
17C> <b>Program history log:</b>
18C> | Date | Programmer | Comments |
19C> | -----|------------|----------|
20C> | 1994-01-06 | J. Woollen | Original author |
21C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine ABORT with call to new internal routine bort() |
22C> | 2003-11-04 | J. Woollen | Modified to be endian-independent |
23C> | 2003-11-04 | J. Ator | Added documentation |
24C> | 2003-11-04 | S. Bender | Added remarks and routine interdependencies |
25C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added documentation; outputs more complete diagnostic info when routine terminates abnormally |
26C>
27 SUBROUTINE ipkm(CBAY,NBYT,N)
28
29 COMMON /hrdwrd/ nbytw,nbitw,iord(8)
30
31 CHARACTER*128 BORT_STR
32 CHARACTER*8 CBAY,CINT
33 equivalence(cint,int)
34
35C----------------------------------------------------------------------
36C----------------------------------------------------------------------
37
38 IF(nbyt.GT.nbytw) GOTO 900
39
40C Note that the widths of input variable N and local variable INT
41C will both be equal to the default size of an integer (= NBYTW),
42C since they aren't specifically declared otherwise.
43
44 int = irev(ishft(n,(nbytw-nbyt)*8))
45 DO i=1,nbyt
46 cbay(i:i) = cint(i:i)
47 ENDDO
48
49C EXITS
50C -----
51
52 RETURN
53900 WRITE(bort_str,'("BUFRLIB: IPKM - NUMBER OF BYTES BEING PACKED '//
54 . ', NBYT (",I4,"), IS > THE INTEGER WORD LENGTH ON THIS '//
55 . 'MACHINE, NBYTW (",I3,")")') nbyt,nbytw
56 CALL bort(bort_str)
57 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string,...
Definition: ipkm.f:28
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