NCEPLIBS-bufr  11.7.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> | Date | Programmer | Comments |
53 C> | -----|------------|----------|
54 C> | 2002-05-14 | J. Woollen | Original author |
55 C> | 2003-11-04 | S. Bender | Added remarks and routine interdependencies
56 C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added history documentation; outputs more complete diagnostic info when routine terminates abnormally |
57 C> | 2005-03-04 | J. Ator | Updated documentation |
58 C> | 2014-09-08 | J. Ator | Increase NDRF limit from 100 to 200 |
59 C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
60 C> | 2018-06-07 | J. Ator | Increase NDRF limit from 200 to 2000 |
61 C>
62  SUBROUTINE drfini(LUNIT,MDRF,NDRF,DRFTAG)
63 
64  USE moda_usrint
65  USE moda_tables
66 
67  CHARACTER*(*) drftag
68  CHARACTER*128 bort_str
69  dimension mdrf(ndrf)
70 
71 C-----------------------------------------------------------------------
72 C-----------------------------------------------------------------------
73 
74  IF(ndrf.GT.2000) goto 900
75 
76  CALL status(lunit,lun,il,im)
77 
78 C COMFORM THE TEMPLATES TO THE DELAYED REPLICATION FACTORS
79 C --------------------------------------------------------
80 
81  m = 0
82  n = 0
83 
84 10 DO n=n+1,nval(lun)
85  node = inv(n,lun)
86  IF(itp(node).EQ.1 .AND. tag(node).EQ.drftag) THEN
87  m = m+1
88  CALL usrtpl(lun,n,mdrf(m))
89  goto 10
90  ENDIF
91  ENDDO
92 
93 C EXITS
94 C -----
95 
96  RETURN
97  900 WRITE(bort_str,'("BUFRLIB: DRFINI - THE NUMBER OF DELAYED '//
98  . 'REPLICATION FACTORS (",I5,") EXCEEDS THE LIMIT (2000)")') ndrf
99  CALL bort(bort_str)
100  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:62
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:55
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22