NCEPLIBS-bufr  12.0.0
rdusdx.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Read a complete DX BUFR table.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> Read a complete DX BUFR table.
7 C>
8 C> This subroutine reads and parses a file containing a user-
9 c> supplied DX BUFR table in character format, and then stores
10 c> this information into internal arrays in module @ref moda_tababd.
11 c> This subroutine performs
12 c> a function similar to BUFR archive library subroutine rdbfdx(),
13 c> except that rdbfdx() reads the DX BUFR table directly from messages at
14 c> the beginning of an input BUFR file.
15 C>
16 C> @param[in] LUNDX - integer: Fortran logical unit number for user-
17 C> supplied DX BUFR table in character format.
18 C> @param[in] LUN - integer: File ID.
19 C>
20 C> @author Woollen @date 1994-01-06
21  SUBROUTINE rdusdx(LUNDX,LUN)
22 
23  USE moda_tababd
24 
25  CHARACTER*128 BORT_STR1
26  CHARACTER*156 BORT_STR2
27  CHARACTER*80 CARD
28  CHARACTER*8 NEMO
29  CHARACTER*6 NUMB,NMB2
30 
31 C-----------------------------------------------------------------------
32 C-----------------------------------------------------------------------
33 
34 C INITIALIZE THE DICTIONARY TABLE CONTROL WORD PARTITION ARRAYS
35 C WITH APRIORI TABLE B AND D ENTRIES
36 C --------------------------------------------------------------
37 
38  CALL dxinit(lun,1)
39  rewind lundx
40 
41 C READ USER CARDS UNTIL THERE ARE NO MORE
42 C ---------------------------------------
43 
44 1 READ(lundx,'(A80)',END=200,ERR=200) card
45 
46 C REREAD IF NOT A DEFINITION CARD
47 C -------------------------------
48 
49 c .... This is a comment line
50  IF(card(1: 1).EQ. '*') GOTO 1
51 c .... This is a separation line
52  IF(card(3:10).EQ.'--------') GOTO 1
53 c .... This is a blank line
54  IF(card(3:10).EQ.' ') GOTO 1
55 c .... This is a header line
56  IF(card(3:10).EQ.'MNEMONIC') GOTO 1
57 c .... This is a header line
58  IF(card(3:10).EQ.'TABLE D') GOTO 1
59 c .... This is a header line
60  IF(card(3:10).EQ.'TABLE B') GOTO 1
61 
62 C PARSE A DESCRIPTOR DEFINITION CARD
63 C ----------------------------------
64 
65  IF(card(12:12).EQ.'|' .AND. card(21:21).EQ.'|') THEN
66 
67 c .... NEMO is the 8-character mnemonic name
68  nemo = card(3:10)
69  iret=nemock(nemo)
70  IF(iret.EQ.-2) GOTO 901
71 
72 c .... NUMB is the 6-character FXY value corresponding to NEMO
73  numb = card(14:19)
74  nmb2 = numb
75  IF(nmb2(1:1).EQ.'A') nmb2(1:1) = '3'
76  iret=numbck(nmb2)
77  IF(iret.EQ.-1) GOTO 902
78  IF(iret.EQ.-2) GOTO 903
79  IF(iret.EQ.-3) GOTO 904
80  IF(iret.EQ.-4) GOTO 905
81 
82 C TABLE A DESCRIPTOR FOUND
83 C ------------------------
84 
85  IF(numb(1:1).EQ.'A') THEN
86  n = igetntbi( lun, 'A' )
87  CALL stntbia ( n, lun, numb, nemo, card(23:) )
88  IF ( idna(n,lun,1) .EQ. 11 ) GOTO 906
89 c .... Replace "A" with "3" so Table D descriptor will be found in
90 c .... card as well (see below)
91  numb(1:1) = '3'
92  ENDIF
93 
94 C TABLE B DESCRIPTOR FOUND
95 C ------------------------
96 
97  IF(numb(1:1).EQ.'0') THEN
98  CALL stntbi ( igetntbi(lun,'B'), lun, numb, nemo, card(23:) )
99  GOTO 1
100  ENDIF
101 
102 C TABLE D DESCRIPTOR FOUND
103 C ------------------------
104 
105  IF(numb(1:1).EQ.'3') THEN
106  CALL stntbi ( igetntbi(lun,'D'), lun, numb, nemo, card(23:) )
107  GOTO 1
108  ENDIF
109 
110 c .... First character of NUMB is not 'A', '0' or '3'
111  GOTO 902
112 
113  ENDIF
114 
115 C PARSE A SEQUENCE DEFINITION CARD
116 C --------------------------------
117 
118  IF(card(12:12).EQ.'|' .AND. card(19:19).NE.'|') THEN
119  CALL seqsdx(card,lun)
120  GOTO 1
121  ENDIF
122 
123 C PARSE AN ELEMENT DEFINITION CARD
124 C --------------------------------
125 
126  IF(card(12:12).EQ.'|' .AND. card(19:19).EQ.'|') THEN
127  CALL elemdx(card,lun)
128  GOTO 1
129  ENDIF
130 
131 C CAN'T FIGURE OUT WHAT KIND OF CARD IT IS
132 C ----------------------------------------
133 
134  GOTO 907
135 
136 C NORMAL ENDING
137 C -------------
138 
139 200 CALL makestab
140 
141 C EXITS
142 C -----
143 
144  RETURN
145 901 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
146  WRITE(bort_str2,'(18X,"MNEMONIC ",A," IN USER DICTIONARY HAS '//
147  . 'INVALID CHARACTERS")') nemo
148  CALL bort2(bort_str1,bort_str2)
149 902 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
150  WRITE(bort_str2,'(18X,"DESCRIPTOR NUMBER ",A," IN USER '//
151  . 'DICTIONARY HAS AN INVALID FIRST CHARACTER (F VALUE) - MUST BE'//
152  . ' A, 0 OR 3")') numb
153  CALL bort2(bort_str1,bort_str2)
154 903 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
155  WRITE(bort_str2,'(18X,"DESCRIPTOR NUMBER ",A," IN USER '//
156  . 'DICTIONARY HAS NON-NUMERIC VALUES IN CHARACTERS 2-6 (X AND Y '//
157  . 'VALUES)")') numb
158  CALL bort2(bort_str1,bort_str2)
159 904 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
160  WRITE(bort_str2,'(18X,"DESCRIPTOR NUMBER ",A," IN USER '//
161  . 'DICTIONARY HAS INVALID NUMBER IN CHARACTERS 2-3 (X VALUE) - '//
162  . 'MUST BE BETWEEN 00 AND 63")') numb
163  CALL bort2(bort_str1,bort_str2)
164 905 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
165  WRITE(bort_str2,'(18X,"DESCRIPTOR NUMBER ",A," IN USER '//
166  . 'DICTIONARY HAS INVALID NUMBER IN CHARACTERS 4-6 (Y VALUE) - '//
167  . 'MUST BE BETWEEN 000 AND 255")') numb
168  CALL bort2(bort_str1,bort_str2)
169 906 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
170  WRITE(bort_str2,'(18X,"USER-DEFINED MESSAGE TYPE ""011"" IS '//
171  . 'RESERVED FOR DICTIONARY MESSAGES")')
172  CALL bort2(bort_str1,bort_str2)
173 907 WRITE(bort_str1,'("BUFRLIB: RDUSDX - CARD READ IN IS: ",A)') card
174  WRITE(bort_str2,'(18X,"THIS CARD HAS A BAD FORMAT - IT IS NOT '//
175  . 'RECOGNIZED BY THIS SUBROUTINE")')
176  CALL bort2(bort_str1,bort_str2)
177 
178  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
subroutine dxinit(LUN, IOI)
This subroutine initializes the internal arrays (in module moda_tababd) holding the DX BUFR table.
Definition: dxinit.f:18
subroutine elemdx(CARD, LUN)
This subroutine decodes the scale factor, reference value, bit width and units (i....
Definition: elemdx.f:20
function igetntbi(LUN, CTB)
This function returns the next available index for storing an entry within a specified internal DX BU...
Definition: igetntbi.f:22
subroutine makestab
This subroutine constructs the internal jump/link table within module tables, using all of the intern...
Definition: makestab.f:24
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
function nemock(NEMO)
This function checks a mnemonic to verify that it has a length of between 1 and 8 characters and that...
Definition: nemock.f:18
function numbck(NUMB)
This function checks the input character string to determine whether it contains a valid FXY (descrip...
Definition: numbck.f:20
subroutine rdusdx(LUNDX, LUN)
Read a complete DX BUFR table.
Definition: rdusdx.f:22
subroutine seqsdx(CARD, LUN)
Decode the sequence information from a Table D mnemonic definition.
Definition: seqsdx.f:21
subroutine stntbi(N, LUN, NUMB, NEMO, CELSQ)
Store a new entry within the internal BUFR Table B or D.
Definition: stntbi.f:20
subroutine stntbia(N, LUN, NUMB, NEMO, CELSQ)
This subroutine stores a new entry within internal BUFR Table A.
Definition: stntbia.f:15