NCEPLIBS-bufr  11.5.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> - 1994-01-06 J. Woollen -- Original author
29 C> - 2003-11-04 J. Ator -- Added documentation
30 C>
31  SUBROUTINE chrtrna(STR,CHR,N)
32 
33  COMMON /charac/ iascii,iatoe(0:255),ietoa(0:255)
34 
35  CHARACTER*(*) str
36  CHARACTER*1 chr(n)
37 
38 C----------------------------------------------------------------------
39 C----------------------------------------------------------------------
40 
41 C Loop on N characters of CHR
42 
43  DO i=1,n
44  str(i:i) = chr(i)
45 
46 C If this is an EBCDIC machine, then translate the character
47 C from ASCII -> EBCDIC.
48 
49  IF(iascii.EQ.0) CALL ipkm(str(i:i),1,iatoe(iupm(str(i:i),8)))
50  ENDDO
51  RETURN
52  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:29
subroutine chrtrna(STR, CHR, N)
This subroutine copies a specified number of characters from an array of characters into a character ...
Definition: chrtrna.f:31