NCEPLIBS-bufr 11.7.1
msgini.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE INITIALIZES, WITHIN THE INTERNAL ARRAYS, A
5C> NEW BUFR MESSAGE FOR OUTPUT. ARRAYS ARE FILLED IN COMMON BLOCKS
6C> /MSGPTR/ AND MODULES MSGCWD AND BITBUF.
7C>
8C> PROGRAM HISTORY LOG:
9C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
10C> 1996-12-11 J. WOOLLEN -- MODIFIED TO ALLOW INCLUSION OF MINUTES IN
11C> WRITING THE MESSAGE DATE INTO A BUFR
12C> MESSAGE
13C> 1997-07-29 J. WOOLLEN -- MODIFIED TO UPDATE THE CURRENT BUFR VERSION
14C> WRITTEN IN SECTION 0 FROM 2 TO 3
15C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
16C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
17C> ROUTINE "BORT"; MODIFIED TO MAKE Y2K
18C> COMPLIANT
19C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
20C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
21C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
22C> BUFR FILES UNDER THE MPI)
23C> 2000-09-19 J. WOOLLEN -- MAXIMUM MESSAGE LENGTH INCREASED FROM
24C> 10,000 TO 20,000 BYTES
25C> 2002-05-14 J. WOOLLEN -- REMOVED ENTRY POINT MINIMG (IT BECAME A
26C> SEPARATE ROUTINE IN THE BUFRLIB TO
27C> INCREASE PORTABILITY TO OTHER PLATFORMS)
28C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
29C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
30C> INTERDEPENDENCIES
31C> 2003-11-04 D. KEYSER -- MAXJL (MAXIMUM NUMBER OF JUMP/LINK ENTRIES)
32C> INCREASED FROM 15000 TO 16000 (WAS IN
33C> VERIFICATION VERSION); UNIFIED/PORTABLE FOR
34C> WRF; ADDED HISTORY DOCUMENTATION; OUTPUTS
35C> MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
36C> TERMINATES ABNORMALLY
37C> 2004-08-09 J. ATOR -- MAXIMUM MESSAGE LENGTH INCREASED FROM
38C> 20,000 TO 50,000 BYTES
39C> 2005-11-29 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 12
40C> 2009-05-07 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 13
41C> 2009-08-11 J. WOOLLEN -- ADD COMMON UFBCPL TO INITIALIZE LUNCPY
42C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
43C> 2019-05-21 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 29
44C> 2021-05-14 J. ATOR -- CHANGED DEFAULT MASTER TABLE VERSION TO 36
45C>
46C> USAGE: CALL MSGINI (LUN)
47C> INPUT ARGUMENT LIST:
48C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
49C>
50C> REMARKS:
51C> THIS ROUTINE CALLS: BORT NEMTAB NEMTBA PKB
52C> PKC
53C> THIS ROUTINE IS CALLED BY: CPYUPD MSGUPD OPENMB OPENMG
54C> Normally not called by any application
55C> programs.
56C>
57 SUBROUTINE msgini(LUN)
58
59 USE moda_msgcwd
60 USE moda_ufbcpl
61 USE moda_bitbuf
62 USE moda_tables
63
64 COMMON /padesc/ ibct,ipd1,ipd2,ipd3,ipd4
65 COMMON /msgptr/ nby0,nby1,nby2,nby3,nby4,nby5
66
67 CHARACTER*128 BORT_STR
68 CHARACTER*8 SUBTAG
69 CHARACTER*4 BUFR,SEVN
70 CHARACTER*1 TAB
71
72 DATA bufr/'BUFR'/
73 DATA sevn/'7777'/
74
75C-----------------------------------------------------------------------
76C-----------------------------------------------------------------------
77
78C GET THE MESSAGE TAG AND TYPE, AND BREAK UP THE DATE
79C ---------------------------------------------------
80
81 subtag = tag(inode(lun))
82c .... Given SUBSET, NEMTBA returns MTYP,MSBT,INOD
83 CALL nemtba(lun,subtag,mtyp,msbt,inod)
84 IF(inode(lun).NE.inod) GOTO 900
85 CALL nemtab(lun,subtag,isub,tab,iret)
86 IF(iret.EQ.0) GOTO 901
87
88C DATE CAN BE YYMMDDHH OR YYYYMMDDHH
89C ----------------------------------
90
91 mcen = mod(idate(lun)/10**8,100)+1
92 mear = mod(idate(lun)/10**6,100)
93 mmon = mod(idate(lun)/10**4,100)
94 mday = mod(idate(lun)/10**2,100)
95 mour = mod(idate(lun) ,100)
96 mmin = 0
97
98c .... DK: Can this happen?? (investigate)
99 IF(mcen.EQ.1) GOTO 902
100
101 IF(mear.EQ.0) mcen = mcen-1
102 IF(mear.EQ.0) mear = 100
103
104C INITIALIZE THE MESSAGE
105C ----------------------
106
107 mbit = 0
108 nby0 = 8
109 nby1 = 18
110 nby2 = 0
111 nby3 = 20
112 nby4 = 4
113 nby5 = 4
114 nbyt = nby0+nby1+nby2+nby3+nby4+nby5
115
116C SECTION 0
117C ---------
118
119 CALL pkc(bufr , 4 , mbay(1,lun),mbit)
120 CALL pkb(nbyt , 24 , mbay(1,lun),mbit)
121 CALL pkb( 3 , 8 , mbay(1,lun),mbit)
122
123C SECTION 1
124C ---------
125
126 CALL pkb(nby1 , 24 , mbay(1,lun),mbit)
127 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
128 CALL pkb( 3 , 8 , mbay(1,lun),mbit)
129 CALL pkb( 7 , 8 , mbay(1,lun),mbit)
130 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
131 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
132 CALL pkb(mtyp , 8 , mbay(1,lun),mbit)
133 CALL pkb(msbt , 8 , mbay(1,lun),mbit)
134 CALL pkb( 36 , 8 , mbay(1,lun),mbit)
135 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
136 CALL pkb(mear , 8 , mbay(1,lun),mbit)
137 CALL pkb(mmon , 8 , mbay(1,lun),mbit)
138 CALL pkb(mday , 8 , mbay(1,lun),mbit)
139 CALL pkb(mour , 8 , mbay(1,lun),mbit)
140 CALL pkb(mmin , 8 , mbay(1,lun),mbit)
141 CALL pkb(mcen , 8 , mbay(1,lun),mbit)
142
143C SECTION 3
144C ---------
145
146 CALL pkb(nby3 , 24 , mbay(1,lun),mbit)
147 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
148 CALL pkb( 0 , 16 , mbay(1,lun),mbit)
149 CALL pkb(2**7 , 8 , mbay(1,lun),mbit)
150 CALL pkb(ibct , 16 , mbay(1,lun),mbit)
151 CALL pkb(isub , 16 , mbay(1,lun),mbit)
152 CALL pkb(ipd1 , 16 , mbay(1,lun),mbit)
153 CALL pkb(ipd2 , 16 , mbay(1,lun),mbit)
154 CALL pkb(ipd3 , 16 , mbay(1,lun),mbit)
155 CALL pkb(ipd4 , 16 , mbay(1,lun),mbit)
156 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
157
158C SECTION 4
159C ---------
160
161 CALL pkb(nby4 , 24 , mbay(1,lun),mbit)
162 CALL pkb( 0 , 8 , mbay(1,lun),mbit)
163
164C SECTION 5
165C ---------
166
167 CALL pkc(sevn , 4 , mbay(1,lun),mbit)
168
169C DOUBLE CHECK INITIAL MESSAGE LENGTH
170C -----------------------------------
171
172 IF(mod(mbit,8).NE.0) GOTO 903
173 IF(mbit/8.NE.nbyt ) GOTO 904
174
175 nmsg(lun) = nmsg(lun)+1
176 nsub(lun) = 0
177 mbyt(lun) = nbyt
178
179 luncpy(lun)=0
180
181C EXITS
182C -----
183
184 RETURN
185900 WRITE(bort_str,'("BUFRLIB: MSGINI - MISMATCH BETWEEN INODE (=",'//
186 . 'I7,") & POSITIONAL INDEX, INOD (",I7,") OF SUBTAG (",A,") IN '//
187 . 'DICTIONARY")') inode(lun),inod,subtag
188 CALL bort(bort_str)
189901 WRITE(bort_str,'("BUFRLIB: MSGINI - TABLE A MESSAGE TYPE '//
190 . 'MNEMONIC ",A," NOT FOUND IN INTERNAL TABLE D ARRAYS")') subtag
191 CALL bort(bort_str)
192902 CALL bort
193 . ('BUFRLIB: MSGINI - BUFR MESSAGE DATE (IDATE) is 0000000000')
194903 CALL bort('BUFRLIB: MSGINI - INITIALIZED MESSAGE DOES NOT END '//
195 . 'ON A BYTE BOUNDARY')
196904 WRITE(bort_str,'("BUFRLIB: MSGINI - NUMBER OF BYTES STORED FOR '//
197 . 'INITIALIZED MESSAGE (",I6,") IS NOT THE SAME AS FIRST '//
198 . 'CALCULATED, NBYT (",I6)') mbit/8,nbyt
199 CALL bort(bort_str)
200 END
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
subroutine msgini(LUN)
THIS SUBROUTINE INITIALIZES, WITHIN THE INTERNAL ARRAYS, A NEW BUFR MESSAGE FOR OUTPUT.
Definition: msgini.f:58
This module contains array and variable declarations used to store BUFR messages internally for multi...
Definition: moda_bitbuf.F:10
integer, dimension(:), allocatable mbyt
Length (in bytes) of current BUFR message for each internal I/O stream.
Definition: moda_bitbuf.F:25
integer, dimension(:,:), allocatable mbay
Current BUFR message for each internal I/O stream.
Definition: moda_bitbuf.F:26
This module contains array and variable declarations used to store the internal jump/link table.
Definition: moda_tables.F:13
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
Definition: moda_tables.F:132
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
This subroutine returns information about a descriptor from the internal DX BUFR tables,...
Definition: nemtab.f:45
subroutine nemtba(LUN, NEMO, MTYP, MSBT, INOD)
This subroutine searches for a descriptor within Table A of the internal DX BUFR tables.
Definition: nemtba.f:36
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:39
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:41