NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3ai19.f
Go to the documentation of this file.
1C> @file
2C> @brief Blocker Subroutine.
3C> @author Robert Allard @date 1997-04-15
4
5C> Fills a record block with logical records or lines of information.
6C>
7C> Program history log:
8C> - Robeert Allard 1974-02-01
9C> - Ralph Jones 1990-09-15 Convert from ibm370 assembler to microsoft
10C> fortran 5.0.
11C> - Ralph Jones 1990-10-07 Convert to sun fortran 1.3.
12C> - Ralph Jones 1991-07-20 Convert to silicongraphics 3.3 fortran 77.
13C> - Ralph Jones 1993-03-29 Add save statement.
14C> - Ralph Jones 1994-04-22 Add xmovex and xstore to move and
15C> store character data faster on the cray.
16C> - Bob Hollern 1997-04-15 Corrected the problem of iniializing nblk
17C> to @'s instead of blanks.
18C>
19C> @param[in] LINE Array address of logical record to be blocked.
20C> @param[in] L Number of characters in line to be blocked.
21C> @param[in] N Maximum character size of nblk.
22C> @param[inout] NEXT (in) flag, initialized to 0. (out) character count, error indicator.
23C> @param[out] NBLK Block filled with logical records.
24C>
25C> Exit states:
26C> - NEXT = -1 Line will not fit into remainder of block;
27C> otherwise, next is set to (next + l).
28C> - NEXT = -2 N is zero or less.
29C> - NEXT = -3 L is zero or less.
30C>
31C> @author Robert Allard @date 1997-04-15
32 SUBROUTINE w3ai19(LINE, L, NBLK, N, NEXT)
33C
34C METHOD:
35C
36C THE USER MUST SET NEXT = 0 EACH TIME NBLK IS TO BE FILLED WITH
37C LOGICAL RECORDS.
38C
39C W3AI19 WILL THEN MOVE THE LINE OF INFORMATION INTO NBLK, STORE
40C BLANK CHARACTERS IN THE REMAINDER OF THE BLOCK, AND SET NEXT = NEXT
41C + L.
42C
43C EACH TIME W3AI19 IS ENTERED, ONE LINE IS BLOCKED AND NEXT INCRE-
44C MENTED UNTIL A LINE WILL NOT FIT THE REMAINDER OF THE BLOCK. THEN
45C W3AI19 WILL SET NEXT = -1 AS A FLAG FOR THE USER TO DISPOSE OF THE
46C BLOCK. THE USER SHOULD BE AWARE THAT THE LAST LOGICAL RECORD WAS NOT
47C BLOCKED.
48C
49 INTEGER L
50 INTEGER N
51 INTEGER NEXT
52 INTEGER(8) WBLANK
53C
54 CHARACTER * 1 LINE(*)
55 CHARACTER * 1 NBLK(*)
56 CHARACTER * 1 BLANK
57C
58 SAVE
59C
60 DATA wblank/z'2020202020202020'/
61C
62C TEST VALUE OF NEXT.
63C
64 IF (next.LT.0) THEN
65 RETURN
66C
67C TEST N FOR ZERO OR LESS
68C
69 ELSE IF (n.LE.0) THEN
70 next = -2
71 RETURN
72C
73C TEST L FOR ZERO OR LESS
74C
75 ELSE IF (l.LE.0) THEN
76 next = -3
77 RETURN
78C
79C TEST TO SEE IF LINE WILL FIT IN BLOCK.
80C
81 ELSE IF ((l + next).GT.n) THEN
82 next = -1
83 RETURN
84C
85C FILL BLOCK WITH BLANK CHARACTERS IF NEXT EQUAL ZERO.
86C BLANK IS EBCDIC BLANK, 40 HEX, OR 64 DECIMAL
87C
88 ELSE IF (next.EQ.0) THEN
89 CALL w3fi01(lw)
90 iwords = n / lw
91 CALL xstore(nblk,wblank,iwords)
92 IF (mod(n,lw).NE.0) THEN
93 nwords = iwords * lw
94 ibytes = n - nwords
95 DO i = 1,ibytes
96 nblk(nwords+i) = char(32)
97 END DO
98 END IF
99 END IF
100C
101C MOVE LINE INTO BLOCK.
102C
103C DO 20 I = 1,L
104C NBLK(I + NEXT) = LINE(I)
105C20 CONTINUE
106 CALL xmovex(nblk(next+1),line,l)
107C
108C ADJUST VALUE OF NEXT.
109C
110 next = next + l
111C
112 RETURN
113C
114 END
subroutine w3ai19(line, l, nblk, n, next)
Fills a record block with logical records or lines of information.
Definition w3ai19.f:33
subroutine w3fi01(lw)
Determines the number of bytes in a full word for the particular machine (IBM or cray).
Definition w3fi01.f:19
subroutine xmovex(out, in, ibytes)
Definition xmovex.f:21
subroutine xstore(cout, con, mwords)
Stores an 8-byte (fullword) value through consecutive storage locations.
Definition xstore.f:29