NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
pktdd.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE STORES INFORMATION ABOUT A "CHILD"
5 C> MNEMONIC WITHIN THE INTERNAL BUFR TABLE D ENTRY (IN MODULE
6 C> TABABD) FOR A TABLE D SEQUENCE ("PARENT") MNEMONIC WHEN THE
7 C> "CHILD" MNEMONIC IS CONTAINED WITHIN THE SEQUENCE REPRESENTED BY
8 C> THE "PARENT" MNEMONIC (AS DETERMINED WITHIN BUFR ARCHIVE LIBRARY
9 C> SUBROUTINE SEQSDX).
10 C>
11 C> PROGRAM HISTORY LOG:
12 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
13 C> 1995-06-28 J. WOOLLEN -- INCREASED THE SIZE OF INTERNAL BUFR TABLE
14 C> ARRAYS IN ORDER TO HANDLE BIGGER FILES
15 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
16 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
17 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
18 C> BUFR FILES UNDER THE MPI)
19 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
20 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
21 C> INTERDEPENDENCIES
22 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
23 C> DOCUMENTATION; ADDED MORE COMPLETE
24 C> DIAGNOSTIC INFO WHEN UNUSUAL THINGS HAPPEN
25 C> 2009-04-21 J. ATOR -- USE ERRWRT
26 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
27 C>
28 C> USAGE: CALL PKTDD (ID, LUN, IDN, IRET)
29 C> INPUT ARGUMENT LIST:
30 C> ID - INTEGER: POSITIONAL INDEX OF PARENT MNEMONIC WITHIN
31 C> INTERNAL BUFR TABLE D ARRAY TABD(*,*)
32 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
33 C> IDN - INTEGER: BIT-WISE REPRESENTATION OF FXY VALUE
34 C> CORRESPONDING TO CHILD MNEMONIC
35 C> 0 = delete all information about all child
36 C> mnemonics from within TABD(ID,LUN)
37 C>
38 C> OUTPUT ARGUMENT LIST:
39 C> IRET - INTEGER: TOTAL NUMBER OF CHILD MNEMONICS STORED THUS
40 C> FAR (INCLUDING IDN) FOR THE PARENT MNEMONIC GIVEN BY
41 C> TABD(ID,LUN)
42 C> 0 = information was cleared from TABD(ID,LUN)
43 C> because input IDN value was 0
44 C> -1 = bad counter value or maximum number of
45 C> child mnemonics already stored for this
46 C> parent mnemonic
47 C>
48 C> REMARKS:
49 C> THIS ROUTINE CALLS: ERRWRT IPKM IUPM
50 C> THIS ROUTINE IS CALLED BY: DXINIT SEQSDX STBFDX STSEQ
51 C> Normally not called by any application
52 C> programs.
53 C>
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 
66 C-----------------------------------------------------------------------
67 C-----------------------------------------------------------------------
68 
69  ldd = ldxd(idxv+1)+1
70 
71 C LDD points to the byte within TABD(ID,LUN) which contains (in
72 C packed integer format) a count of the number of child mnemonics
73 C stored thus far for this parent mnemonic.
74 
75 C ZERO THE COUNTER IF IDN IS ZERO
76 C -------------------------------
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 
84 C UPDATE THE STORED DESCRIPTOR COUNT FOR THIS TABLE D ENTRY
85 C ---------------------------------------------------------
86 
87  nd = iupm(tabd(id,lun)(ldd:ldd),8)
88 
89 C ND is the (unpacked) count of the number of child mnemonics
90 C 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 
117 C PACK AND STORE THE DESCRIPTOR
118 C -----------------------------
119 
120  idm = ldd+1 + (nd-1)*2
121 
122 C IDM points to the starting byte within TABD(ID,LUN) at which
123 C the IDN value for this child mnemonic will be stored (as a
124 C packed integer of width = 2 bytes).
125 
126  CALL ipkm(tabd(id,lun)(idm:idm),2,idn)
127 
128 C EXIT
129 C ----
130 
131 100 RETURN
132  END
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 contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
subroutine ipkm(CBAY, NBYT, N)
This subroutine encodes an integer value within a specified number of bytes of a character string...
Definition: ipkm.f:29
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39
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:54
This module declares and initializes the MAXCD variable.
Definition: modv_MAXCD.F:16