NCEPLIBS-bufr 11.7.1
pktdd.f
Go to the documentation of this file.
1C> @file
2C> @author WOOLLEN @date 1994-01-06
3
4C> THIS SUBROUTINE STORES INFORMATION ABOUT A "CHILD"
5C> MNEMONIC WITHIN THE INTERNAL BUFR TABLE D ENTRY (IN MODULE
6C> TABABD) FOR A TABLE D SEQUENCE ("PARENT") MNEMONIC WHEN THE
7C> "CHILD" MNEMONIC IS CONTAINED WITHIN THE SEQUENCE REPRESENTED BY
8C> THE "PARENT" MNEMONIC (AS DETERMINED WITHIN BUFR ARCHIVE LIBRARY
9C> SUBROUTINE SEQSDX).
10C>
11C> PROGRAM HISTORY LOG:
12C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
13C> 1995-06-28 J. WOOLLEN -- INCREASED THE SIZE OF INTERNAL BUFR TABLE
14C> ARRAYS IN ORDER TO HANDLE BIGGER FILES
15C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
16C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
17C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
18C> BUFR FILES UNDER THE MPI)
19C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
20C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
21C> INTERDEPENDENCIES
22C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
23C> DOCUMENTATION; ADDED MORE COMPLETE
24C> DIAGNOSTIC INFO WHEN UNUSUAL THINGS HAPPEN
25C> 2009-04-21 J. ATOR -- USE ERRWRT
26C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
27C>
28C> USAGE: CALL PKTDD (ID, LUN, IDN, IRET)
29C> INPUT ARGUMENT LIST:
30C> ID - INTEGER: POSITIONAL INDEX OF PARENT MNEMONIC WITHIN
31C> INTERNAL BUFR TABLE D ARRAY TABD(*,*)
32C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
33C> IDN - INTEGER: BIT-WISE REPRESENTATION OF FXY VALUE
34C> CORRESPONDING TO CHILD MNEMONIC
35C> 0 = delete all information about all child
36C> mnemonics from within TABD(ID,LUN)
37C>
38C> OUTPUT ARGUMENT LIST:
39C> IRET - INTEGER: TOTAL NUMBER OF CHILD MNEMONICS STORED THUS
40C> FAR (INCLUDING IDN) FOR THE PARENT MNEMONIC GIVEN BY
41C> TABD(ID,LUN)
42C> 0 = information was cleared from TABD(ID,LUN)
43C> because input IDN value was 0
44C> -1 = bad counter value or maximum number of
45C> child mnemonics already stored for this
46C> parent mnemonic
47C>
48C> REMARKS:
49C> THIS ROUTINE CALLS: ERRWRT IPKM IUPM
50C> THIS ROUTINE IS CALLED BY: DXINIT SEQSDX STBFDX STSEQ
51C> Normally not called by any application
52C> programs.
53C>
54 SUBROUTINE pktdd(ID,LUN,IDN,IRET)
55
56 USE modv_maxcd
57 USE moda_tababd
58
59 COMMON /dxtab / maxdx,idxv,nxstr(10),ldxa(10),ldxb(10),ldxd(10),
60 . ld30(10),dxstr(10)
61 COMMON /quiet / iprt
62
63 CHARACTER*128 ERRSTR
64 CHARACTER*56 DXSTR
65
66C-----------------------------------------------------------------------
67C-----------------------------------------------------------------------
68
69 ldd = ldxd(idxv+1)+1
70
71C LDD points to the byte within TABD(ID,LUN) which contains (in
72C packed integer format) a count of the number of child mnemonics
73C stored thus far for this parent mnemonic.
74
75C ZERO THE COUNTER IF IDN IS ZERO
76C -------------------------------
77
78 IF(idn.EQ.0) THEN
79 CALL ipkm(tabd(id,lun)(ldd:ldd),1,0)
80 iret = 0
81 GOTO 100
82 ENDIF
83
84C UPDATE THE STORED DESCRIPTOR COUNT FOR THIS TABLE D ENTRY
85C ---------------------------------------------------------
86
87 nd = iupm(tabd(id,lun)(ldd:ldd),8)
88
89C ND is the (unpacked) count of the number of child mnemonics
90C stored thus far for this parent mnemonic.
91
92 IF(nd.LT.0 .OR. nd.EQ.maxcd) THEN
93 IF(iprt.GE.0) THEN
94 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
95 IF(nd.LT.0) THEN
96 WRITE ( unit=errstr, fmt='(A,I4,A)' )
97 . 'BUFRLIB: PKTDD - BAD COUNTER VALUE (=', nd,
98 . ') - RETURN WITH IRET = -1'
99 ELSE
100 WRITE ( unit=errstr, fmt='(A,I4,A,A)' )
101 . 'BUFRLIB: PKTDD - MAXIMUM NUMBER OF CHILD MNEMONICS (=',
102 . maxcd, ') ALREADY STORED FOR THIS PARENT - RETURN WITH ',
103 . 'IRET = -1'
104 ENDIF
105 CALL errwrt(errstr)
106 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
107 CALL errwrt(' ')
108 ENDIF
109 iret = -1
110 GOTO 100
111 ELSE
112 nd = nd+1
113 CALL ipkm(tabd(id,lun)(ldd:ldd),1,nd)
114 iret = nd
115 ENDIF
116
117C PACK AND STORE THE DESCRIPTOR
118C -----------------------------
119
120 idm = ldd+1 + (nd-1)*2
121
122C IDM points to the starting byte within TABD(ID,LUN) at which
123C the IDN value for this child mnemonic will be stored (as a
124C packed integer of width = 2 bytes).
125
126 CALL ipkm(tabd(id,lun)(idm:idm),2,idn)
127
128C EXIT
129C ----
130
131100 RETURN
132 END
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string,...
Definition: ipkm.f:28
function iupm(CBAY, NBITS)
THIS FUNCTION UNPACKS AND RETURNS A BINARY INTEGER WORD CONTAINED WITHIN NBITS BITS OF A CHARACTER ST...
Definition: iupm.f:41
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
character *600, dimension(:,:), allocatable tabd
Table D entries for each internal I/O stream.
Definition: moda_tababd.F:60
This module declares and initializes the MAXCD variable.
Definition: modv_MAXCD.f90:12
integer, public maxcd
Maximum number of child descriptors that can be included within the sequence definition of a Table D ...
Definition: modv_MAXCD.f90:18
subroutine pktdd(ID, LUN, IDN, IRET)
THIS SUBROUTINE STORES INFORMATION ABOUT A "CHILD" MNEMONIC WITHIN THE INTERNAL BUFR TABLE D ENTRY (I...
Definition: pktdd.f:55