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