NCEPLIBS-bufr  12.0.0
atrcpt.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Add a tank receipt time to a BUFR message.
3 C> @author J. Ator @date 2009-03-23
4 
5 C> This subroutine reads an input message and outputs an equivalent
6 C> BUFR message with a tank receipt time added to Section 1.
7 C>
8 C> The tank receipt time to be added must have been specified via
9 C> a previous call to subroutine strcpt(). This subroutine performs
10 C> the same function as subroutine strcpt() when the latter is called
11 C> with CF = 'Y', except that the latter subroutine operates on BUFR
12 C> messages internally within the software, whereas this subroutine
13 C> operates on a single BUFR message passed in via a memory array.
14 C>
15 C> @remarks
16 C> - MSGIN and MSGOT must be separate arrays.
17 C> - MSGOT will be longer in length than MSGIN, so the user must allow
18 C> for extra space when allocating MSGOT within the application program.
19 C>
20 C> @param[in] MSGIN - integer(*): BUFR message
21 C> @param[in] LMSGOT - integer: Dimensioned size (in integers) of
22 C> MSGOT; used by the subroutine to ensure that
23 C> it doesn't overflow the MSGOT array
24 C> @param[out] MSGOT - integer(*): Copy of MSGIN with a tank
25 C> receipt time added to Section 1
26 C>
27 C> @author J. Ator @date 2009-03-23
28 
29  RECURSIVE SUBROUTINE atrcpt(MSGIN,LMSGOT,MSGOT)
30 
31  USE modv_im8b
32 
33  dimension msgin(*), msgot(*)
34 
35  COMMON /hrdwrd/ nbytw,nbitw,iord(8)
36  COMMON /tnkrcp/ itryr,itrmo,itrdy,itrhr,itrmi,ctrt
37 
38  CHARACTER*1 ctrt
39 
40 C-----------------------------------------------------------------------
41 C-----------------------------------------------------------------------
42 
43 C Check for I8 integers.
44 
45  IF(im8b) THEN
46  im8b=.false.
47 
48  CALL x84 ( lmsgot, my_lmsgot, 1 )
49  CALL atrcpt ( msgin, my_lmsgot*2, msgot )
50 
51  im8b=.true.
52  RETURN
53  ENDIF
54 
55 C Get some section lengths and addresses from the input message.
56 
57  CALL getlens(msgin,1,len0,len1,l2,l3,l4,l5)
58 
59  iad1 = len0
60  iad2 = iad1 + len1
61 
62  lenm = iupbs01(msgin,'LENM')
63 
64 C Check for overflow of the output array. Note that the new
65 C message will be 6 bytes longer than the input message.
66 
67  lenmot = lenm + 6
68  IF(lenmot.GT.(lmsgot*nbytw)) GOTO 900
69 
70  len1ot = len1 + 6
71 
72 C Write Section 0 of the new message into the output array.
73 
74  CALL mvb ( msgin, 1, msgot, 1, 4 )
75  ibit = 32
76  CALL pkb ( lenmot, 24, msgot, ibit )
77  CALL mvb ( msgin, 8, msgot, 8, 1 )
78 
79 C Store the length of the new Section 1.
80 
81  ibit = iad1*8
82  CALL pkb ( len1ot, 24, msgot, ibit )
83 
84 C Copy the remainder of Section 1 from the input array to the
85 C output array.
86 
87  CALL mvb ( msgin, iad1+4, msgot, (ibit/8)+1, len1-3 )
88 
89 C Append the tank receipt time data to the new Section 1.
90 
91  ibit = iad2*8
92  CALL pkb ( itryr, 16, msgot, ibit )
93  CALL pkb ( itrmo, 8, msgot, ibit )
94  CALL pkb ( itrdy, 8, msgot, ibit )
95  CALL pkb ( itrhr, 8, msgot, ibit )
96  CALL pkb ( itrmi, 8, msgot, ibit )
97 
98 C Copy Sections 2, 3, 4 and 5 from the input array to the
99 C output array.
100 
101  CALL mvb ( msgin, iad2+1, msgot, (ibit/8)+1, lenm-iad2 )
102 
103  RETURN
104 900 CALL bort('BUFRLIB: ATRCPT - OVERFLOW OF OUTPUT MESSAGE '//
105  . 'ARRAY; TRY A LARGER DIMENSION FOR THIS ARRAY')
106  END
recursive subroutine atrcpt(MSGIN, LMSGOT, MSGOT)
This subroutine reads an input message and outputs an equivalent BUFR message with a tank receipt tim...
Definition: atrcpt.f:30
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive subroutine getlens(MBAY, LL, LEN0, LEN1, LEN2, LEN3, LEN4, LEN5)
This subroutine reads the lengths of all of the individual sections of a given BUFR message,...
Definition: getlens.f:36
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
subroutine mvb(IB1, NB1, IB2, NB2, NBM)
This subroutine copies a specified number of bytes from one packed binary array to another.
Definition: mvb.f:18
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
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:28
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19