NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
chrtrna.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Copy a specified number of characters from an array into
3 C> a string.
4 
5 C> This subroutine copies a specified number of characters from an
6 C> array of characters into a character string.
7 C>
8 C> <p>The characters in the input array CHR are assumed to be ASCII,
9 C> so for cases where the native machine is EBCDIC, an
10 C> ASCII-to-EBCDIC translation is done on the final character string
11 C> before it is output as STR.
12 C>
13 C> @author J. Woollen
14 C> @date 1994-01-06
15 C>
16 C> @param[in] CHR -- character(*): Array of characters in ASCII
17 C> @param[in] N -- integer: Number of characters to be copied
18 C> from CHR, starting from the beginning of
19 C> the array
20 C> @param[out] STR -- character*(*): Character string in ASCII or
21 C> EBCDIC, depending on native machine
22 C>
23 C> @remarks
24 C> - The determination as to whether the native machine is ASCII or
25 C> EBCDIC is made via an internal call to subroutine wrdlen().
26 C>
27 C> <b>Program history log:</b>
28 C> | Date | Programmer | Comments |
29 C> | -----|------------|----------|
30 C> | 1994-01-06 | J. Woollen | Original author |
31 C> | 2003-11-04 | J. Ator | Added documentation |
32 C>
33  SUBROUTINE chrtrna(STR,CHR,N)
34 
35  COMMON /charac/ iascii,iatoe(0:255),ietoa(0:255)
36 
37  CHARACTER*(*) str
38  CHARACTER*1 chr(n)
39 
40 C----------------------------------------------------------------------
41 C----------------------------------------------------------------------
42 
43 C Loop on N characters of CHR
44 
45  DO i=1,n
46  str(i:i) = chr(i)
47 
48 C If this is an EBCDIC machine, then translate the character
49 C from ASCII -> EBCDIC.
50 
51  IF(iascii.EQ.0) CALL ipkm(str(i:i),1,iatoe(iupm(str(i:i),8)))
52  ENDDO
53  RETURN
54  END
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 ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string...
Definition: ipkm.f:27
subroutine chrtrna(STR, CHR, N)
This subroutine copies a specified number of characters from an array of characters into a character ...
Definition: chrtrna.f:33