NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
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 
5 C> This subroutine explicitly initializes delayed replication factors
6 C> and allocates a corresponding amount of space within internal arrays,
7 C> thereby allowing the subsequent use of subroutine ufbseq() to write
8 C> data into delayed replication sequences.
9 C>
10 C> @author J. Woollen
11 C> @date 2002-05-14
12 C>
13 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR
14 C> file
15 C> @param[in] MDRF - integer(*): Array of delayed replication factors,
16 C> in one-to-one correspondence with the number
17 C> of occurrences of DRFTAG within the overall
18 C> subset definition, and explicitly defining
19 C> how much space (i.e. how many replications)
20 C> to allocate within each successive occurrence
21 C> @param[in] NDRF - integer: Number of delayed replication factors
22 C> within MDRF
23 C> @param[in] DRFTAG - character*(*): Table D sequence mnemonic,
24 C> bracketed by appropriate delayed replication
25 C> notation (e.g. {}, () OR <>)
26 C>
27 C> <p>Logical unit LUNIT should have already been opened for output
28 C> operations (i.e. writing/encoding BUFR) via a previous call to
29 C> subroutine openbf(), and a message for output should have already
30 C> been opened via a previous call to one of the
31 C> [message-writing subroutines].
32 C>
33 C> <p>The use of this subroutine is only required when writing data
34 C> into delayed replication sequences using ufbseq(), or for cases
35 C> where ufbint() or ufbrep() are being used to write data into
36 C> delayed replication sequences which occur more than once within
37 C> an overall subset definition. In such cases, the use of this
38 C> subroutine allows the application code to explicitly specify how
39 C> many replications of the sequence are to be allocated to each
40 C> occurrence of the delayed replication sequence within the overall
41 C> subset definition, prior to storing all of the actual data values
42 C> themselves via a single subsequent call to ufbint() or ufbrep().
43 C> In contrast, the use of this subroutine is not required when
44 C> ufbint() or ufbrep() are to be called to store data values
45 C> for a delayed replication sequence which only occurs one time
46 C> within an overall subset definition, because in that case the
47 C> same type of initialization and space allocation functionality
48 C> will be automatically handled internally within subroutine
49 C> ufbint() or ufbrep().
50 C>
51 C> <b>Program history log:</b>
52 C> - 2002-05-14 J. Woollen -- Original author
53 C> - 2003-11-04 S. Bender -- Added remarks and routine interdependencies
54 C> - 2003-11-04 D. Keyser -- Unified/portable for WRF; added history
55 C> documentation; outputs more complete
56 C> diagnostic info when routine terminates
57 C> abnormally
58 C> - 2005-03-04 J. Ator -- Updated documentation
59 C> - 2014-09-08 J. Ator -- Increase NDRF limit from 100 to 200
60 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
61 C> - 2018-06-07 J. Ator -- Increase NDRF limit from 200 to 2000
62 C>
63  SUBROUTINE drfini(LUNIT,MDRF,NDRF,DRFTAG)
64 
65  USE moda_usrint
66  USE moda_tables
67 
68  CHARACTER*(*) drftag
69  CHARACTER*128 bort_str
70  dimension mdrf(ndrf)
71 
72 C-----------------------------------------------------------------------
73 C-----------------------------------------------------------------------
74 
75  IF(ndrf.GT.2000) goto 900
76 
77  CALL status(lunit,lun,il,im)
78 
79 C COMFORM THE TEMPLATES TO THE DELAYED REPLICATION FACTORS
80 C --------------------------------------------------------
81 
82  m = 0
83  n = 0
84 
85 10 DO n=n+1,nval(lun)
86  node = inv(n,lun)
87  IF(itp(node).EQ.1 .AND. tag(node).EQ.drftag) THEN
88  m = m+1
89  CALL usrtpl(lun,n,mdrf(m))
90  goto 10
91  ENDIF
92  ENDDO
93 
94 C EXITS
95 C -----
96 
97  RETURN
98  900 WRITE(bort_str,'("BUFRLIB: DRFINI - THE NUMBER OF DELAYED '//
99  . 'REPLICATION FACTORS (",I5,") EXCEEDS THE LIMIT (2000)")') ndrf
100  CALL bort(bort_str)
101  END
subroutine usrtpl(LUN, INVN, NBMP)
THIS SUBROUTINE STORES THE SUBSET TEMPLATE INTO INTERNAL SUBSET ARRAYS IN MODULE USRINT FOR CASES OF ...
Definition: usrtpl.f:51
subroutine drfini(LUNIT, MDRF, NDRF, DRFTAG)
This subroutine explicitly initializes delayed replication factors and allocates a corresponding amou...
Definition: drfini.f:63
This module contains array and variable declarations used to store the internal jump/link table...
Definition: moda_tables.F:13
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:61
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23