NCEPLIBS-bufr 11.7.1
upc.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE UNPACKS AND RETURNS A CHARACTER STRING OF
5C> LENGTH NCHR CONTAINED WITHIN NCHR BYTES OF IBAY, STARTING WITH BIT
6C> (IBIT+1). ON OUTPUT, IBIT IS UPDATED TO POINT TO THE LAST BIT THAT
7C> WAS UNPACKED. NOTE THAT THE STRING TO BE UNPACKED DOES NOT
8C> NECESSARILY NEED TO BE ALIGNED ON A BYTE BOUNDARY WITHIN IBAY.
9C>
10C> PROGRAM HISTORY LOG:
11C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
12C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
13C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
14C> INTERDEPENDENCIES
15C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
16C> DOCUMENTATION
17C> 2009-03-23 J. ATOR -- TREAT NULL CHARACTERS AS BLANKS;
18C> PREVENT OVERFLOW OF CHR
19C> 2014-11-19 J. ATOR -- ADD CNVNULL ARGUMENT
20C>
21C> USAGE: CALL UPC (CHR, NCHR, IBAY, IBIT, CNVNULL)
22C> INPUT ARGUMENT LIST:
23C> NCHR - INTEGER: NUMBER OF BYTES OF IBAY WITHIN WHICH TO
24C> UNPACK CHR (I,E, THE NUMBER OF CHARACTERS IN CHR)
25C> IBAY - INTEGER: *-WORD PACKED BINARY ARRAY CONTAINING PACKED
26C> CHR
27C> IBIT - INTEGER: BIT POINTER WITHIN IBAY INDICATING BIT AFTER
28C> WHICH TO START UNPACKING
29C> CNVNULL - LOGICAL: .TRUE. IF NULL CHARACTERS SHOULD BE
30C> CONVERTED TO BLANKS
31C>
32C> OUTPUT ARGUMENT LIST:
33C> CHR - CHARACTER*(*): UNPACKED CHARACTER STRING OF LENGTH
34C> NCHR
35C> IBIT - INTEGER: BIT POINTER WITHIN IBAY INDICATING LAST BIT
36C> THAT WAS UNPACKED
37C>
38C> REMARKS:
39C> THIS SUBROUTINE IS THE INVERSE OF BUFR ARCHIVE LIBRARY ROUTINE
40C> PKC.
41C>
42C> THIS ROUTINE CALLS: IPKM IUPM UPB
43C> THIS ROUTINE IS CALLED BY: RDCMPS RDTREE READLC STBFDX
44C> STNDRD UFBGET UFBTAB UFBTAM
45C> WRCMPS
46C> Normally not called by any application
47C> programs.
48C>
49 SUBROUTINE upc(CHR,NCHR,IBAY,IBIT,CNVNULL)
50
51
52
53 COMMON /charac/ iascii,iatoe(0:255),ietoa(0:255)
54 COMMON /hrdwrd/ nbytw,nbitw,iord(8)
55
56 CHARACTER*(*) CHR
57 CHARACTER*8 CVAL
58 dimension ibay(*),ival(2)
59 equivalence(cval,ival)
60
61 LOGICAL CNVNULL
62
63C----------------------------------------------------------------------
64C----------------------------------------------------------------------
65
66 lb = iord(nbytw)
67 cval = ' '
68
69 numchr = min(nchr,len(chr))
70 DO i=1,numchr
71 CALL upb(ival(1),8,ibay,ibit)
72 IF((ival(1).EQ.0).AND.(cnvnull)) THEN
73 chr(i:i) = ' '
74 ELSE
75 chr(i:i) = cval(lb:lb)
76 ENDIF
77 IF(iascii.EQ.0) CALL ipkm(chr(i:i),1,iatoe(iupm(chr(i:i),8)))
78 ENDDO
79
80 RETURN
81 END
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 iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
Definition: iupm.f:41
subroutine upb(NVAL, NBITS, IBAY, IBIT)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY,...
Definition: upb.f:50
subroutine upc(CHR, NCHR, IBAY, IBIT, CNVNULL)
THIS SUBROUTINE UNPACKS AND RETURNS A CHARACTER STRING OF LENGTH NCHR CONTAINED WITHIN NCHR BYTES OF ...
Definition: upc.f:50