NCEPLIBS-bufr  11.5.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>
29 C> USAGE: CALL DXMINI (LUN, MBAY, MBYT, MB4, MBA, MBB, MBD)
30 C> INPUT ARGUMENT LIST:
31 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
32 C>
33 C> OUTPUT ARGUMENT LIST:
34 C> MBAY - INTEGER: (MXMSGLD4)-WORD PACKED BINARY ARRAY
35 C> CONTAINING BUFR MESSAGE
36 C> MBYT - INTEGER: LENGTH OF BUFR MESSAGE (BYTES)
37 C> MB4 - INTEGER: BYTE NUMBER IN MESSAGE OF FIRST BYTE IN
38 C> SECTION 4
39 C> MBA - INTEGER: BYTE NUMBER IN MESSAGE OF FOURTH BYTE IN
40 C> SECTION 4
41 C> MBB - INTEGER: BYTE NUMBER IN MESSAGE OF FIFTH BYTE IN
42 C> SECTION 4
43 C> MBD - INTEGER: BYTE NUMBER IN MESSAGE OF SIXTH BYTE IN
44 C> SECTION 4
45 C>
46 C> REMARKS:
47 C> ARGUMENT LUN IS NOT REFERENCED IN THIS SUBROUTINE. IT IS LEFT
48 C> HERE IN CASE AN APPLICATION PROGRAM CALLS THIS SUBROUTINE.
49 C>
50 C> THIS ROUTINE CALLS: BORT IUPM PKB PKC
51 C> THIS ROUTINE IS CALLED BY: WRDXTB
52 C> Normally not called by any application
53 C> programs.
54 C>
55  SUBROUTINE dxmini(LUN,MBAY,MBYT,MB4,MBA,MBB,MBD)
56 
57  USE modv_mxmsgl
58 
59  COMMON /dxtab / maxdx,idxv,nxstr(10),ldxa(10),ldxb(10),ldxd(10),
60  . ld30(10),dxstr(10)
61 
62  CHARACTER*128 bort_str
63  CHARACTER*56 dxstr
64  dimension mbay(*)
65 
66 C-----------------------------------------------------------------------
67 C-----------------------------------------------------------------------
68 
69 c .... The local message subtype is set to the version number of the
70 c local tables (here = 1)
71  msbt = idxv
72 
73 C INITIALIZE THE MESSAGE
74 C ----------------------
75 
76  mbit = 0
77  DO i=1,mxmsgld4
78  mbay(i) = 0
79  ENDDO
80 
81 C For dictionary messages, the Section 1 date is simply zeroed out.
82 C (Note that there is logic in function IDXMSG which relies on this!)
83 
84  ih = 0
85  id = 0
86  im = 0
87  iy = 0
88 
89 c Dictionary messages get type 11 (see WMO Table A)
90  mtyp = 11
91  nsub = 1
92 
93  idxs = idxv+1
94  ldxs = nxstr(idxs)
95 
96  nby0 = 8
97  nby1 = 18
98  nby2 = 0
99  nby3 = 7 + nxstr(idxs) + 1
100  nby4 = 7
101  nby5 = 4
102  mbyt = nby0+nby1+nby2+nby3+nby4+nby5
103 
104  IF(mod(nby3,2).NE.0) goto 900
105 
106 C SECTION 0
107 C ---------
108 
109  CALL pkc('BUFR' , 4 , mbay,mbit)
110  CALL pkb( mbyt , 24 , mbay,mbit)
111  CALL pkb( 3 , 8 , mbay,mbit)
112 
113 C SECTION 1
114 C ---------
115 
116  CALL pkb( nby1 , 24 , mbay,mbit)
117  CALL pkb( 0 , 8 , mbay,mbit)
118  CALL pkb( 3 , 8 , mbay,mbit)
119  CALL pkb( 7 , 8 , mbay,mbit)
120  CALL pkb( 0 , 8 , mbay,mbit)
121  CALL pkb( 0 , 8 , mbay,mbit)
122  CALL pkb( mtyp , 8 , mbay,mbit)
123  CALL pkb( msbt , 8 , mbay,mbit)
124  CALL pkb( 29 , 8 , mbay,mbit)
125  CALL pkb( idxv , 8 , mbay,mbit)
126  CALL pkb( iy , 8 , mbay,mbit)
127  CALL pkb( im , 8 , mbay,mbit)
128  CALL pkb( id , 8 , mbay,mbit)
129  CALL pkb( ih , 8 , mbay,mbit)
130  CALL pkb( 0 , 8 , mbay,mbit)
131  CALL pkb( 0 , 8 , mbay,mbit)
132 
133 C SECTION 3
134 C ---------
135 
136  CALL pkb( nby3 , 24 , mbay,mbit)
137  CALL pkb( 0 , 8 , mbay,mbit)
138  CALL pkb( 1 , 16 , mbay,mbit)
139  CALL pkb( 2**7 , 8 , mbay,mbit)
140  DO i=1,ldxs
141  CALL pkb(iupm(dxstr(idxs)(i:i),8),8,mbay,mbit)
142  ENDDO
143  CALL pkb( 0 , 8 , mbay,mbit)
144 
145 C SECTION 4
146 C ---------
147 
148  mb4 = mbit/8+1
149  CALL pkb(nby4 , 24 , mbay,mbit)
150  CALL pkb( 0 , 8 , mbay,mbit)
151  mba = mbit/8+1
152  CALL pkb( 0 , 8 , mbay,mbit)
153  mbb = mbit/8+1
154  CALL pkb( 0 , 8 , mbay,mbit)
155  mbd = mbit/8+1
156  CALL pkb( 0 , 8 , mbay,mbit)
157 
158  IF(mbit/8+nby5.NE.mbyt) goto 901
159 
160 C EXITS
161 C -----
162 
163  RETURN
164 900 CALL bort
165  . ('BUFRLIB: DXMINI - LENGTH OF SECTION 3 IS NOT A MULTIPLE OF 2')
166 901 WRITE(bort_str,'("BUFRLIB: DXMINI - NUMBER OF BYTES STORED FOR '//
167  . 'A MESSAGE (",I6,") IS NOT THE SAME AS FIRST CALCULATED, MBYT '//
168  . '(",I6)') mbit/8+nby5,mbyt
169  CALL bort(bort_str)
170  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:42
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
This module declares and initializes the MXMSGL variable.
Definition: modv_MXMSGL.F:16
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:55
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
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:40