NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3fi66.f
Go to the documentation of this file.
1C> @file
2C> @brief Office note 29 report blocker.
3C> @author L. Marx @date 1990-01
4
5C> Blocks reports which have been packed into nmc office
6C> note 29 character format into fixed-length records. A report
7C> cannot span two records; If there is not enough room to fit
8C> the current report in the record, the subroutine returns to
9C> the calling program without any movement of data.
10C>
11C> Program history log:
12C> - L. Marx 1990-01 Converted code from assembler
13C> to vs fortran; Expanded error return codes in 'NFLAG'.
14C> - Dennis Keyser 1991-08-23 Use same arguments as w3ai05();
15C> streamlined code; Docblocked and commented; diag-
16C> nostic print for errors.
17C> - Dennis Keyser 1992-06-29 Convert to cray cft77 fortran.
18C>
19C> @param[in] COCBUF Array containing a single packed report
20C> in office note 29/124 format.
21C> @param[in] NFLAG Marker indicating relative location (in bytes)
22C> of end of last report in COCBLK. Exception:
23C> NFLAG must be set to zero prior to blocking the first
24C> packed report into a new block. Subsequently, the
25C> value of NFLAG returned by the previous call to w3fi66()
26C> should be used as input. (see output argument list
27C> below.) If NFLAG is negative, w3fi66() will return
28C> immediately without action.
29C> @param[in] NSIZE Maximum number of characters in COCBLK array
30C> (should be a multiple of 4)
31C> @param[inout] COCBLK Array holding a block of packed reports
32C> up to and including the previous (IN) / current (OUT) one
33C> ag marker indicating relative location (in bytes)
34C> of end of current report in COCBLK. NFLAG
35C> will be set to -1 if w3fi66() cannot fit the current
36C> packed report into the remainder of the block (i.e.,
37C> the block is full). NFLAG will not change from its
38C> input argument value if the string "end report" is
39C> not found at the end of the current report. (current
40C> packed report has invalid length and is not blocked)
41C>
42C> @note The user must set NFLAG to zero each time the array is
43C> to be filled with packed reports in office note 29/124 format.
44C> w3fi66() will then insert the first report and fill the remainder
45C> of the output array COCBLK with the string 'end record'.
46C>
47C> An attempt is made to insert a report in the output array
48C> each time w3fi66() is called. If the remaining portion of the
49C> output array is not large enough to hold the current report,
50C> w3fi66() sets NFLAG to -1. The user should then output the
51C> blocked record, set NFLAG to zero, and call w3fi66() again with
52C> the same report in the input array.
53C>
54C> After a given report is successfully blocked into COCBLK,
55C> w3fi66() sets NFLAG as a pointer for the next report to be blocked.
56C> this pointer is a relative address and a character count.
57C>
58C> The three characters specifying the length of the report
59C> are checked for valid character numbers and the value is tested
60C> for pointing to the end of the report (string "end report"). If
61C> invalid, the report is not inserted into the block and there is
62C> an immediate return to the user. In this case, the value of
63C> NFLAG does not change from its input value.
64C>
65C> @note Entry w3ai05() duplicates processing in w3fi66() since no
66C> assembly language code in cray w3lib.
67C>
68C> @author L. Marx @date 1990-01
69 SUBROUTINE w3fi66(COCBUF,COCBLK,NFLAG,NSIZE)
70C
71 CHARACTER*10 COCBUF(*),COCBLK(*)
72C
73 SAVE
74C
75 entry w3ai05(cocbuf,cocblk,nflag,nsize)
76C
77 IF (nflag.LT.0) THEN
78 print 101
79 RETURN
80 END IF
81C N10WRD IS THE MAXIMUM NUMBER OF 10-CHARACTER WORDS AVAILABLE IN BLOCK
82 n10wrd = nsize/10
83C-----------------------------------------------------------------------
84 IF (nflag.EQ.0) THEN
85C 1ST TIME INTO NEW BLOCK, INTIALIZE ALL 10-CHAR. WORDS AS 'END RECORD'
86 DO 25 m = 1,n10wrd
87 cocblk(m) = 'END RECORD'
88 25 CONTINUE
89 END IF
90C-----------------------------------------------------------------------
91C READ IN THE NUMBER OF 10-CHARACTER WORDS IN THIS REPORT (NWDS)
92 READ(cocbuf(4)(8:10),30) nwds
93 30 FORMAT(i3)
94C NOW GET THE NUMBER OF CHARACTERS IN THIS REPORT (NCHARS)
95 nchars = nwds * 10
96C N01BYT IS THE MAXIMUM NUMBER OF CHARACTERS AVAILABLE FOR DATA IN BLOCK
97 n01byt = (n10wrd * 10) - 10
98 IF (nflag+nchars.GT.n01byt) THEN
99C THE REMAINING PORTION OF THE BLOCK IS NOT LARGE ENOUGH TO HOLD THIS
100C REPORT, RETURN WITH NFLAG = -1
101 nflag = -1
102 RETURN
103 END IF
104 IF (cocbuf(nwds).NE.'END REPORT') THEN
105C LAST 10-CHARACTER WORD IN REPORT IS NOT SET TO THE STRING "END REPORT"
106C -- INVALID RPT LENGTH, NOTE THIS AND RETURN TO USER W/O BLOCKING RPT
107 print 102, cocbuf(2)(1:6)
108 RETURN
109 END IF
110C TRANSFER PACKED REPORT INTO BLOCK
111 DO 100 n = 1,nwds
112 cocblk((nflag/10)+n) = cocbuf(n)
113 100 CONTINUE
114C RESET NFLAG
115 nflag = nflag + (nwds * 10)
116 RETURN
117 101 FORMAT(/' *** W3FI66 ERROR- INPUT ARGUMENT "NEXT" (NFLAG) IS ',
118 $ 'LESS THAN ZERO - RECORD IS FULL, WRITE IT OUT AND START FILLING'
119 $,' A NEW RECORD WITH CURRENT REPORT'/)
120 102 FORMAT(/' *** W3FI66 ERROR- REPORT: ',a6,' DOES NOT END WITH THE',
121 $ ' STRING "END REPORT" - INVALID REPORT LENGTH'/6x,'- CODE WILL ',
122 $ 'MOVE AHEAD TO NEXT REPORT WITHOUT BLOCKING THIS REPORT'/)
123 END
subroutine w3fi66(cocbuf, cocblk, nflag, nsize)
Blocks reports which have been packed into nmc office note 29 character format into fixed-length reco...
Definition w3fi66.f:70