NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
upc.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE UNPACKS AND RETURNS A CHARACTER STRING OF
5 C> LENGTH NCHR CONTAINED WITHIN NCHR BYTES OF IBAY, STARTING WITH BIT
6 C> (IBIT+1). ON OUTPUT, IBIT IS UPDATED TO POINT TO THE LAST BIT THAT
7 C> WAS UNPACKED. NOTE THAT THE STRING TO BE UNPACKED DOES NOT
8 C> NECESSARILY NEED TO BE ALIGNED ON A BYTE BOUNDARY WITHIN IBAY.
9 C>
10 C> PROGRAM HISTORY LOG:
11 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
12 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
13 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
14 C> INTERDEPENDENCIES
15 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
16 C> DOCUMENTATION
17 C> 2009-03-23 J. ATOR -- TREAT NULL CHARACTERS AS BLANKS;
18 C> PREVENT OVERFLOW OF CHR
19 C> 2014-11-19 J. ATOR -- ADD CNVNULL ARGUMENT
20 C>
21 C> USAGE: CALL UPC (CHR, NCHR, IBAY, IBIT, CNVNULL)
22 C> INPUT ARGUMENT LIST:
23 C> NCHR - INTEGER: NUMBER OF BYTES OF IBAY WITHIN WHICH TO
24 C> UNPACK CHR (I,E, THE NUMBER OF CHARACTERS IN CHR)
25 C> IBAY - INTEGER: *-WORD PACKED BINARY ARRAY CONTAINING PACKED
26 C> CHR
27 C> IBIT - INTEGER: BIT POINTER WITHIN IBAY INDICATING BIT AFTER
28 C> WHICH TO START UNPACKING
29 C> CNVNULL - LOGICAL: .TRUE. IF NULL CHARACTERS SHOULD BE
30 C> CONVERTED TO BLANKS
31 C>
32 C> OUTPUT ARGUMENT LIST:
33 C> CHR - CHARACTER*(*): UNPACKED CHARACTER STRING OF LENGTH
34 C> NCHR
35 C> IBIT - INTEGER: BIT POINTER WITHIN IBAY INDICATING LAST BIT
36 C> THAT WAS UNPACKED
37 C>
38 C> REMARKS:
39 C> THIS SUBROUTINE IS THE INVERSE OF BUFR ARCHIVE LIBRARY ROUTINE
40 C> PKC.
41 C>
42 C> THIS ROUTINE CALLS: IPKM IUPM UPB
43 C> THIS ROUTINE IS CALLED BY: RDCMPS RDTREE READLC STBFDX
44 C> STNDRD UFBGET UFBTAB UFBTAM
45 C> WRCMPS
46 C> Normally not called by any application
47 C> programs.
48 C>
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 
63 C----------------------------------------------------------------------
64 C----------------------------------------------------------------------
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 upb(NVAL, NBITS, IBAY, IBIT)
THIS SUBROUTINE UNPACKS AND RETURNS A BINARY INTEGER CONTAINED WITHIN NBITS BITS OF IBAY...
Definition: upb.f:49
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
Definition: iupm.f:40
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:49
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string...
Definition: ipkm.f:29