NCEPLIBS-w3emc  2.11.0
w3ai15.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Converts a set of binary numbers to an equivalent set
3 C> of ascii number fields in core.
4 C> @author R. Allard @date 1974-01
5 
6 C> Converts a set of binary numbers to an equivalent set
7 C> of ascii number fields in core. This is an alternate procedure
8 C> to the use of the 360/195 version of encode.
9 C>
10 C> Program history log:
11 C> - R. Allard 1974-01-15
12 C> - Ralph Jones 1989-02-06 Change from assembler to fortran
13 C> this subroutine should be rewritten in intel 8088 assembly language.
14 C> - Ralph Jones 1990-08-13 Change to cray cft77 fortran.
15 C> - Boi Vuong 2012-11-05 Change variable zero fill for little-endian.
16 C>
17 C> @param[in] NBUFA Input array (integer*4).
18 C> @param[in] N1 Number of integers in nbufa to be converted.
19 C> @param[in] N2 Desired character width of ascii number field.
20 C> @param[in] MINUS Character to be inserted in the high order position
21 C> of a negative number field.
22 C> @param[out] NBUFB Output array (integer*4).
23 C>
24 C> @note If n2 is greater than 4, allow two words (eight characters)
25 C> in the nbufb array for each ascii number field. A number field
26 C> is left adjusted with blank fill to the right if needed.
27 C> Likewise, if n2 is less than 4, the result is left adjusted
28 C> with blank fill to the right.
29 C>
30 C> @note N2 can be specified in the range 1-8. An eight digit positive
31 C> integer can be converted or a seven digit negative integer
32 C> and a sign. Zero fill is used for high order positions in a
33 C> number field. The user should be aware that w3ai15 does not
34 C> verify that the value of n2 is in the correct range.
35 C>
36 C> @note The minus sign can be inserted as a literal in the call
37 C> sequence or defined in a data statement. 1h- and 1h+ are the
38 C> two most likely negative signs. Unfortunately the ascii plus
39 C> character is the negative sign required in most transmissions.
40 C> The minus sign will always be in the high order position of a
41 C> negative number field.
42 C>
43 C> @note If a number contains more digits than the n2 specification
44 C> allows, the excess high order digits are lost.
45 C>
46 C> @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)
55 C
56  CHARACTER*1 BLANK
57  CHARACTER*1 JTEMP(8)
58  CHARACTER*1 MINUS
59  CHARACTER*1 NUM(0:9)
60 C
61  LOGICAL ISIGN
62 C
63  equivalence(btemp,jtemp(1))
64 C
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'/
68 C 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 
74 C FOR BIG_ENDIAN
75 c DATA ZERO /Z'3020202020202020',Z'3030202020202020',
76 c & Z'3030302020202020',Z'3030303020202020',
77 c & Z'3030303030202020',Z'3030303030302020',
78 c & Z'3030303030303020',Z'3030303030303030'/
79 C
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
113 C
114  nbufb(i) = btemp
115 C
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