NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3ai15.f
Go to the documentation of this file.
1C> @file
2C> @brief Converts a set of binary numbers to an equivalent set
3C> of ascii number fields in core.
4C> @author R. Allard @date 1974-01
5
6C> Converts a set of binary numbers to an equivalent set
7C> of ascii number fields in core. This is an alternate procedure
8C> to the use of the 360/195 version of encode.
9C>
10C> Program history log:
11C> - R. Allard 1974-01-15
12C> - Ralph Jones 1989-02-06 Change from assembler to fortran
13C> this subroutine should be rewritten in intel 8088 assembly language.
14C> - Ralph Jones 1990-08-13 Change to cray cft77 fortran.
15C> - Boi Vuong 2012-11-05 Change variable zero fill for little-endian.
16C>
17C> @param[in] NBUFA Input array (integer*4).
18C> @param[in] N1 Number of integers in nbufa to be converted.
19C> @param[in] N2 Desired character width of ascii number field.
20C> @param[in] MINUS Character to be inserted in the high order position
21C> of a negative number field.
22C> @param[out] NBUFB Output array (integer*4).
23C>
24C> @note If n2 is greater than 4, allow two words (eight characters)
25C> in the nbufb array for each ascii number field. A number field
26C> is left adjusted with blank fill to the right if needed.
27C> Likewise, if n2 is less than 4, the result is left adjusted
28C> with blank fill to the right.
29C>
30C> @note N2 can be specified in the range 1-8. An eight digit positive
31C> integer can be converted or a seven digit negative integer
32C> and a sign. Zero fill is used for high order positions in a
33C> number field. The user should be aware that w3ai15 does not
34C> verify that the value of n2 is in the correct range.
35C>
36C> @note The minus sign can be inserted as a literal in the call
37C> sequence or defined in a data statement. 1h- and 1h+ are the
38C> two most likely negative signs. Unfortunately the ascii plus
39C> character is the negative sign required in most transmissions.
40C> The minus sign will always be in the high order position of a
41C> negative number field.
42C>
43C> @note If a number contains more digits than the n2 specification
44C> allows, the excess high order digits are lost.
45C>
46C> @author R. Allard @date 1974-01
47 SUBROUTINE w3ai15 (NBUFA,NBUFB,N1,N2,MINUS)
48
49 INTEGER ATEMP
50 INTEGER BTEMP
51 INTEGER IDIV(8)
52 INTEGER NBUFA(*)
53 INTEGER NBUFB(*)
54 INTEGER*8 ZERO(8)
55C
56 CHARACTER*1 BLANK
57 CHARACTER*1 JTEMP(8)
58 CHARACTER*1 MINUS
59 CHARACTER*1 NUM(0:9)
60C
61 LOGICAL ISIGN
62C
63 equivalence(btemp,jtemp(1))
64C
65 DATA blank /' '/
66 DATA idiv /1,10,100,1000,10000,100000,1000000,10000000/
67 DATA num /'0','1','2','3','4','5','6','7','8','9'/
68C FOR LITTLE_ENDIAN
69 DATA zero /z'2020202020202030',z'2020202020203030',
70 & z'2020202020303030',z'2020202030303030',
71 & z'2020203030303030',z'2020303030303030',
72 & z'2030303030303030',z'3030303030303030'/
73
74C FOR BIG_ENDIAN
75c DATA ZERO /Z'3020202020202020',Z'3030202020202020',
76c & Z'3030302020202020',Z'3030303020202020',
77c & Z'3030303030202020',Z'3030303030302020',
78c & Z'3030303030303020',Z'3030303030303030'/
79C
80 DO 100 i = 1,n1
81 IF (nbufa(i).EQ.0) THEN
82 nbufb(i) = zero(n2)
83 GO TO 100
84 ENDIF
85 atemp = nbufa(i)
86 isign = .false.
87 IF (atemp.LT.0) THEN
88 isign = .true.
89 atemp = iabs(atemp)
90 ENDIF
91 IF (.NOT.isign) THEN
92 DO 10 j = 1,8
93 IF (j.LE.n2) THEN
94 i1 = mod(atemp/idiv(n2-j+1),10)
95 jtemp(j) = num(i1)
96 ELSE
97 jtemp(j) = blank
98 ENDIF
99 10 CONTINUE
100
101 ELSE
102
103 jtemp(1) = minus
104 DO 20 j = 2,8
105 IF (j.LE.n2) THEN
106 i1 = mod(atemp/idiv(n2-j+1),10)
107 jtemp(j) = num(i1)
108 ELSE
109 jtemp(j) = blank
110 ENDIF
111 20 CONTINUE
112 ENDIF
113C
114 nbufb(i) = btemp
115C
116 100 CONTINUE
117 RETURN
118 END
subroutine w3ai15(nbufa, nbufb, n1, n2, minus)
Converts a set of binary numbers to an equivalent set of ascii number fields in core.
Definition w3ai15.f:48