NCEPLIBS-bufr  12.0.0
drfini.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Initialize replication factors for delayed replication
3 C> sequences.
4 C>
5 C> @author J. Woollen @date 2002-05-14
6 
7 C> Initialize replication factors for delayed replication sequences.
8 C>
9 C> This subroutine explicitly initializes delayed replication factors
10 C> and allocates a corresponding amount of space within internal arrays,
11 C> thereby allowing the subsequent use of subroutine ufbseq() to write
12 C> data into delayed replication sequences.
13 C>
14 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file.
15 C> @param[in] MDRF - integer(*): Array of delayed replication factors,
16 C> in one-to-one correspondence with the number of occurrences of DRFTAG
17 C> within the overall subset definition, and explicitly defining how much
18 C> space (i.e. how many replications) to allocate within each successive
19 C> occurrence.
20 C> @param[in] NDRF - integer: Number of delayed replication factors
21 C> within MDRF.
22 C> @param[in] DRFTAG - character*(*): Table D sequence mnemonic, bracketed
23 C> by appropriate delayed replication notation (e.g. {}, () OR <>)
24 C>
25 C> Logical unit LUNIT should have already been opened for output
26 C> operations (i.e. writing/encoding BUFR) via a previous call to
27 C> subroutine openbf(), and a message for output should have already
28 C> been opened via a previous call to one of the
29 C> [message-writing subroutines].
30 C>
31 C> The use of this subroutine is only required when writing data
32 C> into delayed replication sequences using ufbseq(), or for cases
33 C> where ufbint() or ufbrep() are being used to write data into
34 C> delayed replication sequences which occur more than once within
35 C> an overall subset definition. In such cases, the use of this
36 C> subroutine allows the application code to explicitly specify how
37 C> many replications of the sequence are to be allocated to each
38 C> occurrence of the delayed replication sequence within the overall
39 C> subset definition, prior to storing all of the actual data values
40 C> themselves via a single subsequent call to ufbint() or ufbrep().
41 C> In contrast, the use of this subroutine is not required when
42 C> ufbint() or ufbrep() are to be called to store data values
43 C> for a delayed replication sequence which only occurs one time
44 C> within an overall subset definition, because in that case the
45 C> same type of initialization and space allocation functionality
46 C> will be automatically handled internally within subroutine
47 C> ufbint() or ufbrep().
48 C>
49 C> @author J. Woollen @date 2002-05-14
50  RECURSIVE SUBROUTINE drfini(LUNIT,MDRF,NDRF,DRFTAG)
51 
52  USE moda_usrint
53  USE moda_tables
54  USE modv_im8b
55 
56  parameter( mxdrf = 2000 )
57 
58  CHARACTER*(*) drftag
59  CHARACTER*128 bort_str
60  dimension mdrf(*),lunit(*),ndrf(*)
61  dimension my_mdrf(mxdrf),my_lunit(1),my_ndrf(1)
62 
63 C-----------------------------------------------------------------------
64 C-----------------------------------------------------------------------
65 
66 C CHECK FOR I8 INTEGERS
67 C ---------------------
68 
69  IF(im8b) THEN
70  im8b=.false.
71 
72  CALL x84(lunit,my_lunit,1)
73  CALL x84(ndrf,my_ndrf,1)
74  CALL x84(mdrf,my_mdrf,my_ndrf(1))
75  CALL drfini(my_lunit,my_mdrf,my_ndrf,drftag)
76 
77  im8b=.true.
78  RETURN
79  ENDIF
80 
81  IF(ndrf(1).GT.mxdrf) GOTO 900
82 
83  CALL status(lunit,lun,il,im)
84 
85 C COMFORM THE TEMPLATES TO THE DELAYED REPLICATION FACTORS
86 C --------------------------------------------------------
87 
88  m = 0
89  n = 0
90 
91 10 DO n=n+1,nval(lun)
92  node = inv(n,lun)
93  IF(itp(node).EQ.1 .AND. tag(node).EQ.drftag) THEN
94  m = m+1
95  CALL usrtpl(lun,n,mdrf(m))
96  GOTO 10
97  ENDIF
98  ENDDO
99 
100 C EXITS
101 C -----
102 
103  RETURN
104  900 WRITE(bort_str,'("BUFRLIB: DRFINI - THE NUMBER OF DELAYED '//
105  . 'REPLICATION FACTORS (",I5,") EXCEEDS THE LIMIT (",I5,")")')
106  . ndrf(1),mxdrf
107  CALL bort(bort_str)
108  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
recursive subroutine drfini(LUNIT, MDRF, NDRF, DRFTAG)
Initialize replication factors for delayed replication sequences.
Definition: drfini.f:51
This module contains array and variable declarations used to store the internal jump/link table.
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
integer, dimension(:), allocatable itp
Integer type values corresponding to typ:
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
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 ...
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine usrtpl(LUN, INVN, NBMP)
Store the subset template into internal arrays.
Definition: usrtpl.f:22
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19