NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
dxmini.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE INITIALIZES A BUFR TABLE (DICTIONARY)
5 C> MESSAGE, WRITING ALL THE PRELIMINARY INFORMATION INTO SECTIONS 0,
6 C> 1, 3, 4. BUFR ARCHIVE LIBRARY SUBROUTINE WRDXTB WILL WRITE THE
7 C> ACTUAL TABLE INFORMATION INTO THE MESSAGE.
8 C>
9 C> PROGRAM HISTORY LOG:
10 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11 C> 1997-07-29 J. WOOLLEN -- MODIFIED TO UPDATE THE CURRENT BUFR VERSION
12 C> WRITTEN IN SECTION 0 FROM 2 TO 3
13 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
14 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
15 C> ROUTINE "BORT"
16 C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
17 C> 10,000 TO 20,000 BYTES
18 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
19 C> INTERDEPENDENCIES
20 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
21 C> DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
22 C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
23 C> TERMINATES ABNORMALLY
24 C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
25 C> 20,000 TO 50,000 BYTES
26 C> 2005-11-29 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 12
27 C> 2009-05-07 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 13
28 C> 2019-05-21 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 29
29 C> 2021-05-14 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 36
30 C>
31 C> USAGE: CALL DXMINI (LUN, MBAY, MBYT, MB4, MBA, MBB, MBD)
32 C> INPUT ARGUMENT LIST:
33 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
34 C>
35 C> OUTPUT ARGUMENT LIST:
36 C> MBAY - INTEGER: (MXMSGLD4)-WORD PACKED BINARY ARRAY
37 C> CONTAINING BUFR MESSAGE
38 C> MBYT - INTEGER: LENGTH OF BUFR MESSAGE (BYTES)
39 C> MB4 - INTEGER: BYTE NUMBER IN MESSAGE OF FIRST BYTE IN
40 C> SECTION 4
41 C> MBA - INTEGER: BYTE NUMBER IN MESSAGE OF FOURTH BYTE IN
42 C> SECTION 4
43 C> MBB - INTEGER: BYTE NUMBER IN MESSAGE OF FIFTH BYTE IN
44 C> SECTION 4
45 C> MBD - INTEGER: BYTE NUMBER IN MESSAGE OF SIXTH BYTE IN
46 C> SECTION 4
47 C>
48 C> REMARKS:
49 C> ARGUMENT LUN IS NOT REFERENCED IN THIS SUBROUTINE. IT IS LEFT
50 C> HERE IN CASE AN APPLICATION PROGRAM CALLS THIS SUBROUTINE.
51 C>
52 C> THIS ROUTINE CALLS: BORT IUPM PKB PKC
53 C> THIS ROUTINE IS CALLED BY: WRDXTB
54 C> Normally not called by any application
55 C> programs.
56 C>
57  SUBROUTINE dxmini(LUN,MBAY,MBYT,MB4,MBA,MBB,MBD)
58 
59  USE modv_mxmsgl
60 
61  COMMON /dxtab / maxdx,idxv,nxstr(10),ldxa(10),ldxb(10),ldxd(10),
62  . ld30(10),dxstr(10)
63 
64  CHARACTER*128 bort_str
65  CHARACTER*56 dxstr
66  dimension mbay(*)
67 
68 C-----------------------------------------------------------------------
69 C-----------------------------------------------------------------------
70 
71 c .... The local message subtype is set to the version number of the
72 c local tables (here = 1)
73  msbt = idxv
74 
75 C INITIALIZE THE MESSAGE
76 C ----------------------
77 
78  mbit = 0
79  DO i=1,mxmsgld4
80  mbay(i) = 0
81  ENDDO
82 
83 C For dictionary messages, the Section 1 date is simply zeroed out.
84 C (Note that there is logic in function IDXMSG which relies on this!)
85 
86  ih = 0
87  id = 0
88  im = 0
89  iy = 0
90 
91 c Dictionary messages get type 11 (see WMO Table A)
92  mtyp = 11
93  nsub = 1
94 
95  idxs = idxv+1
96  ldxs = nxstr(idxs)
97 
98  nby0 = 8
99  nby1 = 18
100  nby2 = 0
101  nby3 = 7 + nxstr(idxs) + 1
102  nby4 = 7
103  nby5 = 4
104  mbyt = nby0+nby1+nby2+nby3+nby4+nby5
105 
106  IF(mod(nby3,2).NE.0) goto 900
107 
108 C SECTION 0
109 C ---------
110 
111  CALL pkc('BUFR' , 4 , mbay,mbit)
112  CALL pkb( mbyt , 24 , mbay,mbit)
113  CALL pkb( 3 , 8 , mbay,mbit)
114 
115 C SECTION 1
116 C ---------
117 
118  CALL pkb( nby1 , 24 , mbay,mbit)
119  CALL pkb( 0 , 8 , mbay,mbit)
120  CALL pkb( 3 , 8 , mbay,mbit)
121  CALL pkb( 7 , 8 , mbay,mbit)
122  CALL pkb( 0 , 8 , mbay,mbit)
123  CALL pkb( 0 , 8 , mbay,mbit)
124  CALL pkb( mtyp , 8 , mbay,mbit)
125  CALL pkb( msbt , 8 , mbay,mbit)
126  CALL pkb( 36 , 8 , mbay,mbit)
127  CALL pkb( idxv , 8 , mbay,mbit)
128  CALL pkb( iy , 8 , mbay,mbit)
129  CALL pkb( im , 8 , mbay,mbit)
130  CALL pkb( id , 8 , mbay,mbit)
131  CALL pkb( ih , 8 , mbay,mbit)
132  CALL pkb( 0 , 8 , mbay,mbit)
133  CALL pkb( 0 , 8 , mbay,mbit)
134 
135 C SECTION 3
136 C ---------
137 
138  CALL pkb( nby3 , 24 , mbay,mbit)
139  CALL pkb( 0 , 8 , mbay,mbit)
140  CALL pkb( 1 , 16 , mbay,mbit)
141  CALL pkb( 2**7 , 8 , mbay,mbit)
142  DO i=1,ldxs
143  CALL pkb(iupm(dxstr(idxs)(i:i),8),8,mbay,mbit)
144  ENDDO
145  CALL pkb( 0 , 8 , mbay,mbit)
146 
147 C SECTION 4
148 C ---------
149 
150  mb4 = mbit/8+1
151  CALL pkb(nby4 , 24 , mbay,mbit)
152  CALL pkb( 0 , 8 , mbay,mbit)
153  mba = mbit/8+1
154  CALL pkb( 0 , 8 , mbay,mbit)
155  mbb = mbit/8+1
156  CALL pkb( 0 , 8 , mbay,mbit)
157  mbd = mbit/8+1
158  CALL pkb( 0 , 8 , mbay,mbit)
159 
160  IF(mbit/8+nby5.NE.mbyt) goto 901
161 
162 C EXITS
163 C -----
164 
165  RETURN
166 900 CALL bort
167  . ('BUFRLIB: DXMINI - LENGTH OF SECTION 3 IS NOT A MULTIPLE OF 2')
168 901 WRITE(bort_str,'("BUFRLIB: DXMINI - NUMBER OF BYTES STORED FOR '//
169  . 'A MESSAGE (",I6,") IS NOT THE SAME AS FIRST CALCULATED, MBYT '//
170  . '(",I6)') mbit/8+nby5,mbyt
171  CALL bort(bort_str)
172  END
subroutine pkc(CHR, NCHR, IBAY, IBIT)
This subroutine encodes a character string within a specified number of bits of an integer array...
Definition: pkc.f:40
This module declares and initializes the MXMSGL variable.
Definition: modv_MXMSGL.f:13
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
Definition: iupm.f:40
subroutine dxmini(LUN, MBAY, MBYT, MB4, MBA, MBB, MBD)
THIS SUBROUTINE INITIALIZES A BUFR TABLE (DICTIONARY) MESSAGE, WRITING ALL THE PRELIMINARY INFORMATIO...
Definition: dxmini.f:57
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22
subroutine pkb(NVAL, NBITS, IBAY, IBIT)
This subroutine encodes an integer value within a specified number of bits of an integer array...
Definition: pkb.f:38