NCEPLIBS-bufr  12.0.1
cpdxmm.f
Go to the documentation of this file.
1 C> @file
2 C> Read embedded DX BUFR table into internal arrays.
3 C>
4 C> @author J. Ator @date 2009-03-23
5 
6 C> This subroutine reads an entire DX BUFR table from a specified
7 C> file into internal arrays.
8 C>
9 C> @param[in] LUNIT -- integer: Fortran logical unit number for BUFR
10 C> file
11 C>
12 C> @author J. Ator @date 2009-03-23
13  SUBROUTINE cpdxmm( LUNIT )
14 
15  use bufrlib
16 
17  USE modv_mxdxts
18 
19  USE moda_mgwa
20  USE moda_msgmem
21 
22  COMMON /quiet/ iprt
23 
24  CHARACTER*128 ERRSTR
25 
26  LOGICAL DONE
27 
28 C-----------------------------------------------------------------------
29 C-----------------------------------------------------------------------
30 
31  IF ( ndxts .GE. mxdxts ) GOTO 900
32 
33  ict = 0
34  done = .false.
35  CALL status(lunit,lun,il,im)
36 
37 C Read a complete dictionary table from LUNIT, as a set of one or
38 C more DX dictionary messages.
39 
40  DO WHILE ( .NOT. done )
41  CALL rdmsgw ( lunit, mgwa, ier )
42  IF ( ier .EQ. -1 ) THEN
43 
44 C Don't abort for an end-of-file condition, since it may be
45 C possible for a file to end with dictionary messages.
46 C Instead, backspace the file pointer and let the calling
47 C routine diagnose the end-of-file condition and deal with
48 C it as it sees fit.
49 
50  CALL backbufr_c(lun)
51  done = .true.
52  ELSE IF ( ier .EQ. -2 ) THEN
53  GOTO 901
54  ELSE IF ( idxmsg(mgwa) .NE. 1 ) THEN
55 
56 C This is a non-DX dictionary message. Assume we've reached
57 C the end of the dictionary table, and backspace LUNIT so that
58 C the next read (e.g. in the calling routine) will get this
59 C same message.
60 
61  CALL backbufr_c(lun)
62  done = .true.
63  ELSE IF ( iupbs3(mgwa,'NSUB') .EQ. 0 ) THEN
64 
65 C This is a DX dictionary message, but it doesn't contain any
66 C actual dictionary information. Assume we've reached the end
67 C of the dictionary table.
68 
69  done = .true.
70  ELSE
71 
72 C Store this message into MODULE MSGMEM.
73 
74  ict = ict + 1
75  IF ( ( ndxm + ict ) .GT. mxdxm ) GOTO 902
76  ipdxm(ndxm+ict) = ldxm + 1
77  lmem = nmwrd(mgwa)
78  IF ( ( ldxm + lmem ) .GT. mxdxw ) GOTO 903
79  DO j = 1, lmem
80  mdx(ldxm+j) = mgwa(j)
81  ENDDO
82  ldxm = ldxm + lmem
83  ENDIF
84  ENDDO
85 
86 C Update the table information within MODULE MSGMEM.
87 
88  IF ( ict .GT. 0 ) THEN
89  ifdxts(ndxts+1) = ndxm + 1
90  icdxts(ndxts+1) = ict
91  ipmsgs(ndxts+1) = msgp(0) + 1
92  ndxm = ndxm + ict
93  ndxts = ndxts + 1
94  IF ( iprt .GE. 2 ) THEN
95  CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++')
96  WRITE ( unit=errstr, fmt='(A,I3,A,I3,A)')
97  . 'BUFRLIB: CPDXMM - STORED NEW DX TABLE #', ndxts,
98  . ' CONSISTING OF ', ict, ' MESSAGES'
99  CALL errwrt(errstr)
100  CALL errwrt('+++++++++++++++++++++++++++++++++++++++++++++')
101  CALL errwrt(' ')
102  ENDIF
103  ENDIF
104 
105  RETURN
106  900 CALL bort('BUFRLIB: CPDXMM - MXDXTS OVERFLOW')
107  901 CALL bort('BUFRLIB: CPDXMM - UNEXPECTED READ ERROR')
108  902 CALL bort('BUFRLIB: CPDXMM - MXDXM OVERFLOW')
109  903 CALL bort('BUFRLIB: CPDXMM - MXDXW OVERFLOW')
110  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine cpdxmm(LUNIT)
This subroutine reads an entire DX BUFR table from a specified file into internal arrays.
Definition: cpdxmm.f:14
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
recursive function idxmsg(MESG)
Check whether a BUFR message contains DX BUFR tables information.
Definition: idxmsg.f:23
recursive function iupbs3(MBAY, S3MNEM)
This function returns a specified value from within Section 3 of a BUFR message.
Definition: iupbs3.f:30
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Definition: bufrlib.F90:11
This module contains a declaration for an array used by various subroutines and functions to hold a t...
integer, dimension(:), allocatable mgwa
Temporary working copy of BUFR message.
This module contains array and variable declarations used to store the contents of one or more BUFR f...
integer, dimension(:), allocatable msgp
Pointers to the beginning of each message within msgs (up to a maximum of MAXMSG, and where array ele...
integer, dimension(:), allocatable ipmsgs
Pointers to first message within msgs for which each DX BUFR table applies.
integer, dimension(:), allocatable icdxts
Number of consecutive messages within mdx which constitute each DX BUFR table, beginning with the cor...
integer mxdxm
Maximum number of DX BUFR table messages that can be stored within mdx.
integer, dimension(:), allocatable ifdxts
Pointers to the beginning of each DX BUFR table within mdx.
integer ndxm
Number of DX BUFR table messages stored within mdx (up to a maximum of MXDXM).
integer ldxm
Number of array elements filled within mdx (up to a maximum of MXDXW).
integer ndxts
Number of DX BUFR tables represented by the messages within mdx (up to a maximum of MXDXTS).
integer, dimension(:), allocatable mdx
DX BUFR table messages read from one or more BUFR files, for use in decoding the messages in msgs.
integer mxdxw
Maximum number of entries that can be stored within mdx.
integer, dimension(:), allocatable ipdxm
Pointers to the beginning of each message within mdx.
This module declares and initializes the MXDXTS variable.
integer mxdxts
Maximum number of dictionary tables that can be stored for use with BUFR messages in internal memory.
recursive function nmwrd(MBAY)
Given an integer array containing Section 0 from a BUFR message, this function determines the array s...
Definition: nmwrd.f:24
subroutine rdmsgw(lunit, mesg, iret)
Read the next BUFR message from logical unit lunit as an array of integer words.
Definition: rdmsgw.F90:16
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