NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3fi64.f
Go to the documentation of this file.
1C> @file
2C> @brief NMC office note 29 report unpacker.
3C> @author L. Marx @date 1990-01
4
5C> Unpacks an array of upper-air reports that are packed in
6C> the format described by NMC office note 29, or unpacks an array
7C> of surface reports that are packed in the format described by NMC
8C> office note 124. Input character data are converted to integer,
9C> real or character type as specified in the category tables below.
10C> Missing integer data are replaced with 99999, missing real data
11C> are replaced with 99999.0 and missing character data are replaced
12C> with blanks. This library is similar to w3ai02() except w3ai02()
13C> was written in assembler and could not handle internal read errors
14C> (program calling w3ai02() would fail in this case w/o explanation).
15C>
16C> Program history log:
17C> - L. Marx 1990-01 Converted code from assembler
18C> to vs fortran; Expanded error return codes in 'NEXT'
19C> - Dennis Keyser 1991-07-22 Use same arguments as w3ai02() ;
20C> Streamlined code; Docblocked and commented; Diag-
21C> nostic print for errors; Attempts to skip to NEXT
22C> report in same record rather than exiting record.
23C> - Dennis Keyser 1991-08-12 Slight changes to make sub-
24C> program more portable; Test for absence of end-
25C> of-record indicator, will gracefully exit record.
26C> - Dennis Keyser 1992-06-29 Convert to cray cft77 fortran
27C> - Dennis Keyser 1992-08-06 Corrected error which could
28C> lead to the length for a concatenation operator
29C> being less than 1 when an input parameter spans
30C> across two 10-character words.
31C>
32C> @param[in] COCBUF Character*10 array containing a block of packed
33C> reports in nmc office note 29/124 format.
34C> @param[in] NEXT Marker indicating relative location (in bytes) of
35C> end of last report in COCBUF. Exception: NEXT must
36C> be set to zero prior to unpacking the first report of
37C> a new block of reports. subsequently, the value of
38C> NEXT returned by the previous call to w3fi64 should
39C> be used as input. (see output argument list below.)
40C> if NEXT is negative, w3fi64 will return immediately
41C> without action.
42C> @param[out] LOCRPT Array containing one unpacked report with pointers
43C> and counters to direct the user. Locrpt() must begin
44C> on a fullword boundary. Format is mixed, user must
45C> equivalence real and character arrays to this array
46C> (see below and remarks for content).
47C>
48C> ***************************************************************
49C>
50C> |word | content | unit | format |
51C> | :---- | :---------------------- | :------------------- | :----- |
52C> | 1 | latitude | 0.01 degrees | real |
53C> | 2 | longitude | 0.01 degrees west | real |
54C> | 3 | unused | | |
55C> | 4 | observation time | 0.01 hours (utc) | real |
56C> | 5 | reserved (3rd byte is | 4-characters | char*8 |
57C> | | on29 "25'th char.; 4th | left-justified | |
58C> | |byte is on29 "26'th | | |
59C> | |char." (see on29) | | |
60C> | 6 |reserved (3rd byte is | 3-characters | char*8 |
61C> | |on29 "27'th char. (see |left-justified | |
62C> | |on29) | | |
63C> | 7 |station elevation |meters | real |
64C> | 8 |instrument type |on29 table r.2 | integer|
65C> | 9 |report type |on29 table r.1 or | integer|
66C> | |on124 table s.3 | | |
67C> | 10 |ununsed | | |
68C> | 11 |stn. id. (first 4 char.) | 4-characters | char*8 |
69C> | |left-justified | | |
70C> | 12 |stn. id. (last 2 char.) | 2-characters | char*8 |
71C> | |left-justified | | |
72C> | 13 |category 1, no. levels | count | integer|
73C> | 14 |category 1, data index | count | integer|
74C> | 15 |category 2, no. levels | count | integer|
75C> | 16 |category 2, data index | count | integer|
76C> | 17 |category 3, no. levels | count | integer|
77C> | 18 |category 3, data index | count | integer|
78C> | 19 |category 4, no. levels | count | integer|
79C> | 20 |category 4, data index | count | integer|
80C> | 21 |category 5, no. levels | count | integer|
81C> | 22 |category 5, data index | count | integer|
82C> | 23 |category 6, no. levels | count | integer|
83C> | 24 |category 6, data index | count | integer|
84C> | 25 |category 7, no. levels | count | integer|
85C> | 26 |category 7, data index | count | integer|
86C> | 27 |category 8, no. levels | count | integer|
87C> | 28 |category 8, data index | count | integer|
88C> | 29 |category 51, no. levels | count | integer|
89C> | 30 |category 51, data index | count | integer|
90C> | 31 |category 52, no. levels | count | integer|
91C> | 32 |category 52, data index | count | integer|
92C> | 33 |category 9, no. levels | count | integer|
93C> | 34 |category 9, data index | count | integer|
94C> | 35-42 | zeroed out - not used | | integer|
95C> | 43-end| unpacked data groups |(see remarks) | mixed|
96C>
97C> ***************************************************************
98C>
99C> NEXT: Marker indicating relative location (in bytes)
100C> of end of current report in COCBUF. NEXT will be
101C> set to -1 if w3fi64() encounters string 'end record'
102C> in place of the NEXT report. This is the end of the
103C> block. No unpacking takes place. NEXT is set to-2
104C> when internal (logic) errors have been detected.
105C> NEXT is set to -3 when data count check fails. In
106C> both of the latter cases some data (e.g., header
107C> information) may be unpacked into LOCRPT.
108C>
109C> @note After first reading and processing the office note 85
110C> (first) date record, the user's fortran program begins a read
111C> loop as follows. For each iteration a blocked input report is
112C> read into array COCBUF. Now test the first ten characters in
113C> COCBUF for the string 'endof file' (sic). This string signals
114C> the end of input. Otherwise, set the marker 'NEXT' to zero and
115C> begin the unpacking loop.
116C>
117C> Each iteration of the unpacking loop consists of a call to
118C> w3fi64() with the current value of 'NEXT'. If 'NEXT' is -1 upon
119C> returning from w3fi64(), it has reached the end of the input
120C> record, and the user's program should read the next record as
121C> above. If 'NEXT' is -2 or -3 upon returning, there is a grievous
122C> error in the current packed input record, and the user's program
123C> should print it for examination by automation division personnel.
124C> If 'NEXT' is positive, the output structure locrpt contains
125C> an unpacked report, and the user's program should process it at
126C> this point, subsequently repeating the unpacking loop.
127C>
128C> EXAMPLE:
129C> @code{.F}
130C> CHARACTER*10 COCBUF(644)
131C> CHARACTER*8 COCRPT(1608)
132C> CHARACTER*3 CQUMAN(20)
133C> INTEGER LOCRPT(1608)
134C> REAL ROCRPT(1608),GEOMAN(20),TMPMAN(20),DPDMAN(20),
135C> $ WDRMAN(20),WSPMAN(20)
136C> EQUIVALENCE (COCRPT,LOCRPT,ROCRPT)
137C>
138C> C READ AND PROCESS THE OFFICE NOTE 85 DATE RECORD
139C> ..........
140C> C --- BEGIN READ LOOP
141C> 10 CONTINUE
142C> READ (UNIT=INP, IOSTAT=IOS, NUM=NBUF) COCBUF
143C> IF(IOS .LT. 0) GO TO (END OF INPUT)
144C> IF(IOS .GT. 0) GO TO (INPUT ERROR)
145C> IF(NBUF .GT. 6432) GO TO (BUFFER OVERFLOW)
146C> IF(COCBUF(1).EQ.'ENDOF FILE') GO TO (END OF INPUT)
147C> NEXT = 0
148C> C ------ BEGIN UNPACKING LOOP
149C> 20 CONTINUE
150C> CALL W3FI64(COCBUF, LOCRPT, NEXT)
151C> IF(NEXT .EQ. -1) GO TO 10
152C> IF(NEXT .LT. -1) GO TO (OFFICE NOTE 29/124 ERROR)
153C> RLAT = 0.01 * ROCRPT(1) (LATITUDE)
154C> ..... ETC .....
155C> C --- BEGIN CATEGORY 1 FETCH -- MANDATORY LEVEL DATA
156C> IF(LOCRPT(13) .GT. 0) THEN
157C> NLVLS = MIN(20,LOCRPT(13))
158C> INDX = LOCRPT(14)
159C> DO 66 I = 1,NLVLS
160C> GEOMAN(I) = ROCRPT(INDX)
161C> TMPMAN(I) = 0.1 * ROCRPT(INDX+1)
162C> DPDMAN(I) = 0.1 * ROCRPT(INDX+2)
163C> WDRMAN(I) = ROCRPT(INDX+3)
164C> WSPMAN(I) = ROCRPT(INDX+4)
165C> CQUMAN(I) = COCRPT(INDX+5)
166C> INDX = INDX + 6
167C> 66 CONTINUE
168C> END IF
169C> ..... ETC .....
170C> GO TO 20
171C> ...............
172C> @endcode
173C>
174C> Data from the on29/124 record is unpacked into fixed locations
175C> in words 1-12 and into indexed locations in word 43 and
176C> following. Study on29 appendix c/on124 appendix s.2 carefully.
177C> Each category (or group of fields) in the packed report has a
178C> corresponding layout in locations in array LOCRPT that may be
179C> found by using the corresponding index amount from words 14, 16,
180C> ..., 34, in array LOCRPT. For instance, if a report contains
181C> one or more packed category 3 data groups (wind data at variable
182C> pressure levels) that data will be unpacked into binary and
183C> and character fields in one or more unpacked category 3 data
184C> groups as described below. The number of levels will be stored
185C> in word 17 and the index in fullwords of the first level of
186C> unpacked data in the output array will be stored in word 18.
187C> The second level, if any, will be stored beginning four words
188C> further on, and so forth until the count in word 17 is
189C> exhausted. The field layout in each category is given below...
190C>
191C> ***************************************************************
192C> - CATEGORY 1 - MANDATORY LEVEL DATA
193C> |WORD |PARAMETER |UNITS |FORMAT
194C> |:---- |:--------- |:----------------- |:-------------|
195C> | 1 |GEOPOTENTIAL |METERS |REAL|
196C> | 2 |TEMPERATURE |0.1 DEGREES C |REAL|
197C> | 3 |DEWPOINT DEPRESSION |0.1 DEGREES C |REAL|
198C> | 4 |WIND DIRECTION |DEGREES |REAL|
199C> | 5 |WIND SPEED |KNOTS |REAL|
200C> | 6 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
201C> | | |LEFT-JUSTIFIED| |
202C> | | GEOPOTENTIAL |ON29 TABLE Q.A| |
203C> | | TEMPERATURE |ON29 TABLE Q.A| |
204C> | | DEWPOINT DEPR. |ON29 TABLE Q.C| |
205C> | | WIND |ON29 TABLE Q.A| |
206C>
207C> ***************************************************************
208C> - CATEGORY 2 - TEMPERATURE AT VARIABLE PRESSURE
209C> |WORD |PARAMETER |UNITS | FORMAT|
210C> |---- |--------- |----------------- | -------------|
211C> | 1 |PRESSURE |0.1 MILLIBARS | REAL|
212C> | 2 |TEMPERATURE |0.1 DEGREES C | REAL|
213C> | 3 |DEWPOINT DEPRESSION |0.1 DEGREES C | REAL|
214C> | 4 |QUALITY MARKERS: |EACH 1-CHARACTER | CHAR*8|
215C> | | |LEFT-JUSTIFIED| |
216C> | | PRESSURE |ON29 TABLE Q.B| |
217C> | | TEMPERATURE |ON29 TABLE Q.A| |
218C> | | DEWPOINT DEPR. |ON29 TABLE Q.C| |
219C> | | NOT USED |BLANK| |
220C>
221C> ***************************************************************
222C> - CATEGORY 3 - WINDS AT VARIABLE PRESSURE
223C> |WORD |PARAMETER | UNITS | FORMAT|
224C> |---- |--------- | ----------------- | -------------|
225C> | 1 |PRESSURE | 0.1 MILLIBARS | REAL|
226C> | 2 |WIND DIRECTION | DEGREES | REAL|
227C> | 3 |WIND SPEED | KNOTS | REAL|
228C> | 4 |QUALITY MARKERS: | EACH 1-CHARACTER | CHAR*8|
229C> | | | LEFT-JUSTIFIED| |
230C> | | PRESSURE | ON29 TABLE Q.B| |
231C> | | WIND | ON29 TABLE Q.A| |
232C> | | NOT USED | BLANK| |
233C> | | NOT USED | BLANK| |
234C>
235C> ***************************************************************
236C> - CATEGORY 4 - WINDS AT VARIABLE HEIGHTS
237C> |WORD |PARAMETER |UNITS |FORMAT|
238C> |---- |--------- |----------------- |-------------|
239C> | 1 |GEOPOTENTIAL |METERS |REAL|
240C> | 2 |WIND DIRECTION |DEGREES |REAL|
241C> | 3 |WIND SPEED |KNOTS |REAL|
242C> | 4 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
243C> | | |LEFT-JUSTIFIED| |
244C> | | GEOPOTENTIAL |ON29 TABLE Q.B| |
245C> | | WIND |ON29 TABLE Q.A| |
246C> | | NOT USED |BLANK| |
247C> | | NOT USED |BLANK| |
248C>
249C> ***************************************************************
250C> - CATEGORY 5 - TROPOPAUSE DATA
251C> |WORD |PARAMETER |UNITS |FORMAT|
252C> |---- |--------- |----------------- |-------------|
253C> | 1 |GEOPOTENTIAL |METERS |REAL|
254C> | 2 |TEMPERATURE |0.1 DEGREES C |REAL|
255C> | 3 |DEWPOINT DEPRESSION |0.1 DEGREES C |REAL|
256C> | 4 |WIND DIRECTION |DEGREES |REAL|
257C> | 5 |WIND SPEED |KNOTS |REAL|
258C> | 6 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
259C> | | |LEFT-JUSTIFIED| |
260C> | | PRESSURE |ON29 TABLE Q.B| |
261C> | | TEMPERATURE |ON29 TABLE Q.A| |
262C> | | DEWPOINT DEPR. |ON29 TABLE Q.C| |
263C> | | WIND |ON29 TABLE Q.A| |
264C>
265C> ***************************************************************
266C> - CATEGORY 6 - CONSTANT-LEVEL DATA (AIRCRAFT, SAT. CLOUD-DRIFT)
267C> |WORD | PARAMETER |UNITS |FORMAT|
268C> |---- | --------- |----------------- |-------------|
269C> | 1 | PRESSURE ALTITUDE |METERS |REAL|
270C> | 2 | TEMPERATURE |0.1 DEGREES C |REAL|
271C> | 3 | DEWPOINT DEPRESSION |0.1 DEGREES C |REAL|
272C> | 4 | WIND DIRECTION |DEGREES |REAL|
273C> | 5 | WIND SPEED |KNOTS |REAL|
274C> | 6 | QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
275C> | | |LEFT-JUSTIFIED| |
276C> | | PRESSURE |ON29 TABLE Q.6| |
277C> | | TEMPERATURE |ON29 TABLE Q.6| |
278C> | | DEWPOINT DEPR. |ON29 TABLE Q.6| |
279C> | | WIND |ON29 TABLE Q.6C | |
280C>
281C> ***************************************************************
282C> - CATEGORY 7 - CLOUD COVER
283C> |WORD |PARAMETER |UNITS |FORMAT|
284C> |---- |--------- |----------------- |-------------|
285C> | 1 |PRESSURE |0.1 MILLIBARS |REAL|
286C> | 2 |AMOUNT OF CLOUDS |PER CENT |REAL|
287C> | 3 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
288C> | | |LEFT-JUSTIFIED| |
289C> | | PRESSURE |ON29 TABLE Q.7| |
290C> | | CLOUD AMOUNT |ON29 TABLE Q.7| |
291C> | | NOT USED |BLANK| |
292C> | | NOT USED |BLANK| |
293C>
294C> ***************************************************************
295C> - CATEGORY 8 - ADDITIONAL DATA
296C> |WORD |PARAMETER | UNITS |FORMAT|
297C> |---- |--------- | ----------------- |-------------|
298C> | 1 |SPECIFIED IN ON29 | VARIABLE |REAL|
299C> | |TABLE 101.1 OR | | |
300C> | |ON124 TABLE SM.8A.1 | | |
301C> | 2 |FORM OF ADD'L DATA |CODE FIGURE FROM |REAL|
302C> | | |ON29 TABLE 101 OR | |
303C> | | |ON124 TABLE SM.8A | |
304C> | 3 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
305C> | | |LEFT-JUSTIFIED | |
306C> | | VALUE 1 |ON29 TABLE Q.8 OR | |
307C> | | |ON124 TABLE SM.8B | |
308C> | | VALUE 2 |ON29 TABLE Q.8A OR | |
309C> | | |ON124 TABLE SM.8C | |
310C> | | NOT USED |BLANK | |
311C> | | NOT USED |BLANK | |
312C>
313C> ***************************************************************
314C> - CATEGORY 51 - SURFACE DATA
315C> |WORD |PARAMETER |UNITS |FORMAT|
316C> |---- |--------- |----------------- |-------------|
317C> | 1 |SEA-LEVEL PRESSURE |0.1 MILLIBARS |REAL|
318C> | 2 |STATION PRESSURE |0.1 MILLIBARS |REAL|
319C> | 3 |WIND DIRECTION |DEGREES |REAL|
320C> | 4 |WIND SPEED |KNOTS |REAL|
321C> | 5 |AIR TEMPERATURE |0.1 DEGREES C |REAL|
322C> | 6 |DEWPOINT DEPRESSION |0.1 DEGREES C |REAL|
323C> | 7 |MAXIMUM TEMPERATURE |0.1 DEGREES C |REAL|
324C> | 8 |MINIMUM TEMPERATURE |0.1 DEGREES C |REAL|
325C> | 9 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
326C> | | |LEFT-JUSTIFIED| |
327C> | | S-LEVEL PRESS. |ON124 TABLE SM.51| |
328C> | | STATION PRESS. |ON124 TABLE SM.51| |
329C> | | WIND |ON124 TABLE SM.51| |
330C> | | AIR TEMPERATURE |ON124 TABLE SM.51| |
331C> | 10 |QUALITY MARKERS: |EACH 1-CHARACTER |CHAR*8|
332C> | | |LEFT-JUSTIFIED| |
333C> | | DEWPOINT DEPR. |ON124 TABLE SM.51| |
334C> | | NOT USED |BLANK| |
335C> | | NOT USED |BLANK| |
336C> | | NOT USED |BLANK| |
337C> | 11 |HORIZ. VISIBILITY |WMO CODE TABLE 4300 |INTEGER|
338C> | 12 |PRESENT WEATHER |WMO CODE TABLE 4677 |INTEGER|
339C> | 13 |PAST WEATHER |WMO CODE TABLE 4561 |INTEGER|
340C> | 14 |TOTAL CLOUD COVER N |WMO CODE TABLE 2700 |INTEGER|
341C> | 15 |CLOUD COVER OF C/LN |WMO CODE TABLE 2700 |INTEGER|
342C> | 16 |CLOUD TYPE OF C/L |WMO CODE TABLE 0513 |INTEGER|
343C> | 17 |CLOUD HEIGHT OF C/L |WMO CODE TABLE 1600 |INTEGER|
344C> | 18 |CLOUD TYPE OF C/M |WMO CODE TABLE 0515 |INTEGER|
345C> | 19 |CLOUD TYPE OF C/H |WMO CODE TABLE 0509 |INTEGER|
346C> | 20 |CHARACTERISTIC OF |WMO CODE TABLE 0200 |INTEGER|
347C> | |3-HR PRESS TENDENCY | | |
348C> | 21 |AMT. PRESS TENDENCY |0.1 MILLIBARS | REAL|
349C> | |(50.0 WILL BE ADDED TO INDICATE 24-HR TENDENCY)| | |
350C>
351C> ***************************************************************
352C> - CATEGORY 52 - ADDITIONAL SURFACE DATA
353C> |WORD | PARAMETER |UNITS |FORMAT|
354C> |---- | --------- |----------------- |-------------|
355C> | 1 | 6-HR PRECIPITATION |0.01 INCH |INTEGER|
356C> | 2 | SNOW DEPTH |INCH |INTEGER|
357C> | 3 | 24-HR PRECIPITATION |0.01 INCH |INTEGER|
358C> | 4 | DURATION OF PRECIP. |NO. 6-HR PERIODS |INTEGER|
359C> | 5 | PERIOD OF WAVES |SECONDS |INTEGER|
360C> | 6 | HEIGHT OF WAVES |0.5 METERS |INTEGER|
361C> | 7 | SWELL DIRECTION |WMO CODE TABLE 0877 |INTEGER|
362C> | 8 | SWELL PERIOD |SECONDS |INTEGER|
363C> | 9 | SWELL HEIGHT |0.5 METERS |INTEGER|
364C> | 10 | SEA SFC TEMPERATURE |0.1 DEGREES C |INTEGER|
365C> | 11 | SPECIAL PHEN, GEN'L | |INTEGER|
366C> | 12 | SPECIAL PHEN, DET'L | |INTEGER|
367C> | 13 | SHIP'S COURSE |WMO CODE TABLE 0700 |INTEGER|
368C> | 14 | SHIP'S AVERAGE SPEED |WMO CODE TABLE 4451 |INTEGER|
369C> | 15 | WATER EQUIVALENT OF 0.01 INCH | |INTEGER|
370C> | | SNOW AND/OR ICE| | |
371C>
372C> ***************************************************************
373C> - CATEGORY 9 - PLAIN LANGUAGE DATA (ALPHANUMERIC TEXT)
374C> |WORD |BYTES |PARAMETER |FORMAT |
375C> |---- |----- |--------------------------------------- |-------- |
376C> | 1 | 1 |INDICATOR OF CONTENT (ON124 TABLE SM.9) |CHAR*8 |
377C> | | | (1 CHARACTER)| |
378C> | | 2-4 |PLAIN LANGUAGE DATA, TEXT CHARACTERS 1-3| |
379C> | | 4-8 |NOT USED (BLANK) | |
380C> | 2 | 1-4 |PLAIN LANGUAGE DATA, TEXT CHARACTERS 4-7 |CHAR*8 |
381C> | | 4-8 |NOT USED (BLANK)| |
382C> | 3 | 1-4 |PLAIN LANGUAGE DATA, TEXT CHARACTERS 8-11 |CHAR*8 |
383C> | | 4-8 |NOT USED (BLANK)| |
384C>
385C> @note One report may unpack into more than one category having
386C> multiple levels. The unused portion of LOCRPT is not cleared.
387C>
388C> @note Entry w3ai02() duplicates processing in w3fi64() since no
389C> assembly language code in cray w3lib.
390C>
391C> @author L. Marx @date 1990-01
392 SUBROUTINE w3fi64(COCBUF,LOCRPT,NEXT)
393C
394 CHARACTER*12 HOLD
395 CHARACTER*10 COCBUF(*)
396 CHARACTER*7 CNINES
397 CHARACTER*4 COCRPT(10000),BLANK
398 CHARACTER*2 KAT(11)
399C
400 INTEGER LOCRPT(*),KATGC(20,11),KATGL(20,11),KATL(11),KATO(11),
401 $ MOCRPT(5000)
402C
403 REAL ROCRPT(5000)
404C
405 equivalence(rocrpt,mocrpt,cocrpt)
406C
407 SAVE
408C
409 DATA blank/' '/,cnines/'9999999'/,imsg/99999/,xmsg/99999./
410 DATA katl/6,4,4,4,6,6,3,3,1,20,15/,kato/13,15,17,19,21,23,25,27,
411 $ 33,29,31/,irec/2/
412 DATA kat/'01','02','03','04','05','06','07','08','09','51','52'/
413 DATA katgc/ 5*2,4,14*0, 3*2,4,16*0, 3*2,4,16*0, 3*2,4,16*0,
414 $ 5*2,4,14*0, 5*2,4,14*0, 2*2,4,17*0, 2*2,4,17*0, 4,19*0,
415 $ 8*2,4,10*1,2, 15*1,5*0/
416 DATA katgl/ 5,4,3*3,4,14*0, 5,4,2*3,16*0, 5,2*3,2,16*0,
417 $ 5,2*3,2,16*0, 5,4,3*3,4,14*0, 5,4,3*3,4,14*0, 5,3,2,17*0,
418 $ 5,3,2,17*0, 12,19*0,
419 $ 2*5,2*3,4,3,2*4,5,2*3,7*2,1,3, 4,3,4,1,5*2,4,2*2,1,2,7,5*0/
420 DATA lwflag/0/
421C
422 entry w3ai02(cocbuf,locrpt,next)
423C
424 IF (lwflag.EQ.0) THEN
425C FIRST TIME CALLED, DETERMINE MACHINE WORD LG IN BYTES (=8 FOR CRAY)
426C DEPENDING ON WORD SIZE LW2*I-LW1 INDEXES THRU COCRPT
427C EITHER AS 1,2,3...I FOR LW = 4 OR
428C AS 1,3,5..2*I-1 FOR LW = 8 <------ HERE
429C NECESSITATED BY LEFT JUSTIFICATION OF EQUIVALENCE
430 CALL w3fi01(lw)
431 lw2 = lw/4
432 lw1 = lw/8
433 lwflag = 1
434 END IF
435 7000 CONTINUE
436 IF(next.LT.0) RETURN
437 nexto = next/10
438 n = next/10 + 1
439C
440 IF(cocbuf(n).EQ.'END RECORD'.OR.cocbuf(n).EQ.'XXXXXXXXXX') THEN
441C HIT END-OF-RECORD; RETURN WITH NEXT = -1
442 IF(cocbuf(n).EQ.'XXXXXXXXXX') print 109, irec
443 irec = irec + 1
444 next = -1
445 RETURN
446 END IF
447C INITIALIZE REPORT ID AS MISSING OR 0 FOR RESERVED WORDS
448 rocrpt(1) = xmsg
449 rocrpt(2) = xmsg
450 rocrpt(3) = 0.
451 rocrpt(4) = xmsg
452 cocrpt(lw2*5-lw1) = ' '
453 cocrpt(lw2*6-lw1) = ' '
454 rocrpt(7) = xmsg
455 mocrpt(8) = 99
456 mocrpt(9) = imsg
457 mocrpt(10) = 0.
458 cocrpt(lw2*11-lw1) = ' '
459 cocrpt(lw2*12-lw1) = ' '
460C INITIALIZE CATEGORY WORD PAIRS AS ZEROES
461 DO 100 mb = 13,42
462 mocrpt(mb) = 0
463 100 CONTINUE
464C WRITE OUT LATITUDE INTO WORD 1 (REAL)
465 m = 1
466 IF(cocbuf(n)(1:5).NE.'99999') READ(cocbuf(n)(1:5),51) rocrpt(m)
467C WRITE OUT LONGITUDE INTO WORD 2 (REAL)
468 m = 2
469 IF(cocbuf(n)(6:10).NE.'99999') READ(cocbuf(n)(6:10),51) rocrpt(m)
470C WORD 3 IS RESERVED (KEEP AS A REAL NUMBER OF 0.)
471C WRITE OUT STATION ID TO WORDS 11 AND 12 (CHAR*8)
472C (CHAR. 1-4 OF ID IN WORD 11, CHAR. 5-6 OF ID IN WORD 12, LEFT-JUSTIF.)
473 m = 11
474 n = n + 1
475 cocrpt(lw2*m-lw1) = cocbuf(n)(1:4)
476 m = 12
477 cocrpt(lw2*m-lw1) = cocbuf(n)(5:6)//' '
478C WRITE OUT OBSERVATION TIME INTO WORD 4 (REAL)
479 m = 4
480 IF(cocbuf(n)(7:10).NE.'9999') READ(cocbuf(n)(7:10),41) rocrpt(m)
481C WORD 5 IS RESERVED (CHAR*8) (4 CHARACTERS, LEFT-JUSTIF.)
482 m = 5
483 n = n + 1
484 cocrpt(lw2*m-lw1) = cocbuf(n)(3:6)
485C WORD 6 IS RESERVED (CHAR*8) (3 CHARACTERS, LEFT-JUSTIF.)
486 m = 6
487 cocrpt(lw2*m-lw1) = cocbuf(n)(1:2)//cocbuf(n)(7:7)//' '
488C WRITE OUT REPORT TYPE INTO WORD 9 (INTEGER)
489 m = 9
490 READ(cocbuf(n)(8:10),30) mocrpt(m)
491C WRITE OUT STATION ELEVATION INTO WORD 7 (REAL)
492 n = n + 1
493 m = 7
494 IF(cocbuf(n)(1:5).NE.'99999') READ(cocbuf(n)(1:5),51) rocrpt(m)
495C WRITE OUT INSTRUMENT TYPE INTO WORD 8 (INTEGER)
496 m = 8
497 IF(cocbuf(n)(6:7).NE.'99') READ(cocbuf(n)(6:7),20) mocrpt(m)
498C READ IN NWDS, THE TOTAL NO. OF 10-CHARACTER WORDS IN ENTIRE REPORT
499 READ(cocbuf(n)(8:10),30) nwds
500C 'MO' WILL BE STARTING LOCATION IN MOCRPT FOR THE DATA
501 mo = 43
502 n = n + 1
503 700 CONTINUE
504 IF(cocbuf(n).EQ.'END REPORT') THEN
505C-----------------------------------------------------------------------
506C HAVE HIT THE END OF THE REPORT
507 IF(n-nexto.EQ.nwds) THEN
508C EVERYTHING LOOKS GOOD, RETURN WITH NEXT SET TO LAST BYTE IN REPORT
509 next = n * 10
510 ELSE
511C PROBLEM, MAY EXIT WITH NEXT = -3
512 nextx = -3
513 print 101,
514 & cocrpt(lw2*11-lw1),cocrpt(lw2*12-lw1)(1:2),n-nexto,nwds
515 GO TO 99
516 END IF
517 mwords = mo - 1
518 DO 1001 i =1, mwords
519 locrpt(i) = mocrpt(i)
520 1001 CONTINUE
521 RETURN
522C-----------------------------------------------------------------------
523 END IF
524C READ IN NWDSC, THE RELATIVE POSITION IN RPT OF THE NEXT CATEGORY
525 READ(cocbuf(n)(3:5),30) nwdsc
526C READ IN LVLS, THE NUMBER OF LEVELS IN THE CURRENT CATEGORY
527 READ(cocbuf(n)(6:7),20) lvls
528C DETERMINE THE CATEGORY NUMBER OF THE CURRENT CATEGORY
529 DO 800 ncat = 1,11
530 IF(cocbuf(n)(1:2).EQ.kat(ncat)) GO TO 1000
531 800 CONTINUE
532C-----------------------------------------------------------------------
533C PROBLEM, CAT. CODE IN INPUT NOT VALID; MAY EXIT WITH NEXT = -2
534 nextx = -2
535 print 102,
536 $ cocrpt(lw2*11-lw1),cocrpt(lw2*12-lw1)(1:2),cocbuf(n)(1:2)
537 GO TO 99
538C-----------------------------------------------------------------------
539 1000 CONTINUE
540C 'M' IS THE WORD IN MOCRPT WHERE THE NO. OF LEVELS WILL BE WRITTEN
541 m = kato(ncat)
542C WRITE THIS CATEGORY WORD PAIR OUT
543 mocrpt(m) = lvls
544 mocrpt(m+1) = mo
545 n = n + 1
546 i = 1
547C***********************************************************************
548C LOOP THROUGH ALL THE LEVELS IN THE CURRENT CATEGORY
549C***********************************************************************
550 DO 2000 l = 1,lvls
551C NDG IS NO. OF OUTPUT PARAMETERS PER LEVEL IN THIS CATEGORY
552 ndg = katl(ncat)
553C-----------------------------------------------------------------------
554C LOOP THROUGH ALL THE PARAMETERS IN THE CURRENT LEVEL
555C-----------------------------------------------------------------------
556 DO 1800 k = 1,ndg
557C 'LL' IS THE NUMBER OF INPUT CHARACTERS PER PARAMETER FOR THIS CATEGORY
558 ll = katgl(k,ncat)
559C 'I' IS POINTER FOR BEGINNING BYTE IN C*10 WORD FOR NEXT PARAMETER
560C 'J' IS POINTER FOR ENDING BYTE IN C*10 WORD FOR NEXT PARAMETER
561 j = i + ll - 1
562 IF(j.GT.10) THEN
563C COME HERE IF INPUT PARAMETER SPANS ACROSS TWO C*10 WORDS
564 hold(1:ll) = cocbuf(n)(i:10)//cocbuf(n+1)(1:j-10)
565 n = n + 1
566 i = j - 9
567 IF(i.GE.11) THEN
568 n = n + 1
569 i = 1
570 END IF
571 ELSE
572 hold(1:ll) = cocbuf(n)(i:j)
573 i = j + 1
574 IF(i.GE.11) THEN
575 n = n + 1
576 i = 1
577 END IF
578 END IF
579C KATGC IS AN INDICATOR FOR THE OUTPUT FORMAT OF EACH INPUT PARAMETER
580C (=2 - REAL, =1 - INTEGER, =4 - CHARACTER*8)
581 IF(katgc(k,ncat).EQ.4) GO TO 1500
582 IF(katgc(k,ncat).NE.1.AND.katgc(k,ncat).NE.2) THEN
583C.......................................................................
584C PROBLEM IN INTERNAL READ; MAY EXIT WITH NEXT = -2
585 nextx = -2
586 print 104, cocrpt(lw2*11-lw1),cocrpt(lw2*12)(1:2)
587 GO TO 99
588C.......................................................................
589 END IF
590 IF(hold(1:ll).EQ.cnines(1:ll)) THEN
591C INPUT PARAMETER IS MISSING OR NOT APPLICABLE -- OUTPUT IT AS SUCH
592 IF(katgc(k,ncat).EQ.1) mocrpt(mo) = imsg
593 IF(katgc(k,ncat).EQ.2) rocrpt(mo) = xmsg
594 GO TO 1750
595 END IF
596 IF(ll.EQ.1) THEN
597C INPUT PARAMETER CONSISTS OF ONE CHARACTER
598 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),10) mocrpt(mo)
599 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),11) rocrpt(mo)
600 ELSE IF(ll.EQ.2) THEN
601C INPUT PARAMETER CONSISTS OF TWO CHARACTERS
602 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),20) mocrpt(mo)
603 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),21) rocrpt(mo)
604 ELSE IF(ll.EQ.3) THEN
605C INPUT PARAMETER CONSISTS OF THREE CHARACTERS
606 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),30) mocrpt(mo)
607 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),31) rocrpt(mo)
608 ELSE IF(ll.EQ.4) THEN
609C INPUT PARAMETER CONSISTS OF FOUR CHARACTERS
610 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),40) mocrpt(mo)
611 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),41) rocrpt(mo)
612 ELSE IF(ll.EQ.5) THEN
613C INPUT PARAMETER CONSISTS OF FIVE CHARACTERS
614 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),50) mocrpt(mo)
615 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),51) rocrpt(mo)
616 ELSE IF(ll.EQ.6) THEN
617C INPUT PARAMETER CONSISTS OF SIX CHARACTERS
618 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),60) mocrpt(mo)
619 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),61) rocrpt(mo)
620 ELSE IF(ll.EQ.7) THEN
621C INPUT PARAMETER CONSISTS OF SEVEN CHARACTERS
622 IF(katgc(k,ncat).EQ.1) READ(hold(1:ll),70) mocrpt(mo)
623 IF(katgc(k,ncat).EQ.2) READ(hold(1:ll),71) rocrpt(mo)
624 ELSE
625C.......................................................................
626C INPUT PARAMETER CONSISTS OF MORE THAN SEVEN CHARACTERS (NOT PERMITTED)
627 nextx = -2
628 print 108, cocrpt(lw2*11-lw1),cocrpt(lw2*12-lw1)(1:2)
629 GO TO 99
630C.......................................................................
631 END IF
632 GO TO 1750
633 1500 CONTINUE
634C.......................................................................
635C OUTPUT CHARACTER (MARKER) PROCESSING COMES HERE
636 IF(ll.LT.4) THEN
637C THERE ARE ONE, TWO OR THREE MARKERS IN THE INPUT WORD
638 cocrpt(lw2*mo-lw1)(1:4)=hold(1:ll)//blank(1:4-ll)
639 ELSE IF(ll.EQ.4) THEN
640C THERE ARE FOUR MARKERS IN THE INPUT WORD
641 cocrpt(lw2*mo-lw1)(1:4) = hold(1:ll)
642 ELSE
643C THERE ARE MORE THAN FOUR MARKERS IN THE INPUT WORD
644 ip = 1
645 1610 CONTINUE
646 jp = ip + 3
647 IF(jp.LT.ll) THEN
648C FILL FIRST FOUR MARKERS TO OUTPUT WORD
649 cocrpt(lw2*mo-lw1)(1:4) = hold(ip:jp)
650 mo = mo + 1
651 ip = jp + 1
652 GO TO 1610
653 ELSE IF(jp.EQ.ll) THEN
654C FILL FOUR REMAINING MARKERS TO NEXT OUTPUT WORD
655 cocrpt(lw2*mo-lw1)(1:4) = hold(ip:jp)
656 ELSE
657C FILL ONE, TWO, OR THREE REMAINING MARKERS TO NEXT OUTPUT WORD
658 cocrpt(lw2*mo-lw1)(1:4) = hold(ip:ll)//blank(1:jp-ll)
659 END IF
660 END IF
661C.......................................................................
662 1750 CONTINUE
663 mo = mo + 1
664 1800 CONTINUE
665C-----------------------------------------------------------------------
666 2000 CONTINUE
667C***********************************************************************
668 IF(i.GT.1) n = n + 1
669 IF(n-nexto.NE.nwdsc) THEN
670C-----------------------------------------------------------------------
671C PROBLEM, REL. LOCATION OF NEXT CAT. NOT WHAT'S EXPECTED; MAY EXIT
672C WITH NEXT = -3
673C ERROR - RELATIVE LOCATION OF NEXT CATEGORY NOT WHAT'S EXPECTED
674 nextx = -3
675 print 105, cocrpt(lw2*11-lw1),cocrpt(lw2*12-lw1)(1:2),
676 $ kat(ncat),n-nexto-1,
677 $ nwdsc-1
678 GO TO 99
679C-----------------------------------------------------------------------
680 END IF
681C GO ON TO NEXT CATEGORY
682 GO TO 700
683C-----------------------------------------------------------------------
684C ALL OF THE PROBLEM REPORTS END UP HERE -- ATTEMPT TO MOVE AHEAD TO
685C NEXT REPORT, IF NOT POSSIBLE THEN EXIT WITH NEXT = -2 OR -3 MEANING
686C THE REST OF THE RECORD IS BAD, GO ON TO NEXT RECORD
687 99 CONTINUE
688 DO 98 i = 1,644
689 n = n + 1
690 IF(n.GT.644) GO TO 97
691 IF(cocbuf(n).EQ.'END RECORD') GO TO 97
692 IF(cocbuf(n).EQ.'END REPORT') THEN
693C WE'VE MADE IT TO THE END OF THIS PROBLEM REPORT - START OVER WITH
694C NEXT ONE
695 print 106
696 next = n * 10
697 GO TO 7000
698 END IF
699 98 CONTINUE
700 97 CONTINUE
701C COULDN'T GET TO THE END OF THIS PROBLEM REPORT - RETURN WITH ORIGINAL
702C NEXT VALUE (-2 OR -3) MEANING USER MUST GO ON TO NEXT RECORD
703 next = nextx
704 print 107, next
705 mwords = mo - 1
706 DO 1002 i =1, mwords
707 locrpt(i) = mocrpt(i)
708 1002 CONTINUE
709 RETURN
710C-----------------------------------------------------------------------
711 10 FORMAT(i1)
712 11 FORMAT(f1.0)
713 20 FORMAT(i2)
714 21 FORMAT(f2.0)
715 30 FORMAT(i3)
716 31 FORMAT(f3.0)
717 40 FORMAT(i4)
718 41 FORMAT(f4.0)
719 50 FORMAT(i5)
720 51 FORMAT(f5.0)
721 60 FORMAT(i6)
722 61 FORMAT(f6.0)
723 70 FORMAT(i7)
724 71 FORMAT(f7.0)
725 101 FORMAT(/' *** W3FI64 ERROR- REPORT: ',a4,a2,'; ACTUAL NO. 10-CHAR'
726 $,' WORDS:',i10,' NOT EQUAL TO VALUE READ IN WITH REPORT:',i10/6x,
727 $ '- MAY BE DUE TO INTERNAL READ PROBLEM ASSOC. W/ EITHER ORIG. ',
728 $ 'PACKING OR TRANSFER OF FILE RESULTING IN UNPROCESSABLE INFO.'/6x
729 $,'- WILL ATTEMPT TO MOVE AHEAD TO NEXT REPORT, IF NOT POSSIBLE ',
730 $ 'WILL EXIT RECORD WITH NEXT = -3'/)
731 102 FORMAT(/' *** W3FI64 ERROR- REPORT: ',a4,a2,'; PACKED CATEGORY '
732 $,'CODE: ',a2,' IS NOT A VALID O.N. 29 CATEGORY'/6x,
733 $ '- MAY BE DUE TO INTERNAL READ PROBLEM ASSOC. W/ EITHER ORIG. ',
734 $ 'PACKING OR TRANSFER OF FILE RESULTING IN UNPROCESSABLE INFO.'/6x
735 $,'- WILL ATTEMPT TO MOVE AHEAD TO NEXT REPORT, IF NOT POSSIBLE ',
736 $ 'WILL EXIT RECORD WITH NEXT = -2'/)
737 104 FORMAT(/' *** W3FI64 ERROR- REPORT: ',a4,a2,'; INTERNAL READ ',
738 $ 'PROBLEM'/6x,'- EITHER ORIGINAL PACKING OF FILE OR TRANSFER ',
739 $ 'OF FILE HAS RESULTED IN UNPROCESSABLE INFORMATION'/6x,
740 $ '- WILL ATTEMPT TO MOVE AHEAD TO NEXT REPORT, IF NOT POSSIBLE ',
741 $ 'WILL EXIT RECORD WITH NEXT = -2'/)
742 105 FORMAT(/' *** W3FI64 ERROR- REPORT: ',a4,a2,'; ACTUAL NO. 10-CHAR'
743 $,' WORDS IN CAT. ',a2,',',i10,.NE.' TO VALUE READ IN WITH ',
744 $ 'REPORT:',i10/6x,
745 $ '- MAY BE DUE TO INTERNAL READ PROBLEM ASSOC. W/ EITHER ORIG. ',
746 $ 'PACKING OR TRANSFER OF FILE RESULTING IN UNPROCESSABLE INFO.'/6x
747 $,'- WILL ATTEMPT TO MOVE AHEAD TO NEXT REPORT, IF NOT POSSIBLE ',
748 $ 'WILL EXIT RECORD WITH NEXT = -3'/)
749 106 FORMAT(/' +++ IT WAS POSSIBLE TO MOVE TO NEXT REPORT IN THIS ',
750 $ 'RECORD -- CONTINUE WITH THE UNPACKING OF THIS NEW REPORT'/)
751 107 FORMAT(/' *** IT WAS NOT POSSIBLE TO MOVE TO NEXT REPORT IN THIS',
752 $ ' RECORD -- MUST EXIT THIS RECORD WITH NEXT =',i3/)
753 108 FORMAT(/' *** W3FI64 ERROR- REPORT: ',a4,a2,'; AN INPUT ',
754 $ 'PARAMETER CONSISTS OF MORE THAN SEVEN CHARACTERS'/6x,
755 $ '- MAY BE DUE TO INTERNAL READ PROBLEM ASSOC. W/ EITHER ORIG. ',
756 $ 'PACKING OR TRANSFER OF FILE RESULTING IN UNPROCESSABLE INFO.'/6x
757 $,'- WILL ATTEMPT TO MOVE AHEAD TO NEXT REPORT, IF NOT POSSIBLE ',
758 $ 'WILL EXIT RECORD WITH NEXT = -2'/)
759 109 FORMAT(/' *** W3FI64 ERROR- RECORD ',i4,' DOES NOT END WITH ',
760 $ '"END RECORD" BUT INSTEAD CONTAINS "X" FILLERS AFTER LAST ',
761 $ 'REPORT IN RECORD'/6x,'- WILL EXIT RECORD WITH NEXT = -1, NO ',
762 $ 'REPORTS SHOULD BE LOST'/)
763 END
subroutine w3fi01(lw)
Determines the number of bytes in a full word for the particular machine (IBM or cray).
Definition w3fi01.f:19
subroutine w3fi64(cocbuf, locrpt, next)
Unpacks an array of upper-air reports that are packed in the format described by NMC office note 29,...
Definition w3fi64.f:393