NCEPLIBS-bufr  12.0.0
ufbcnt.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get the current message number and data subset number within
3 C> a BUFR file.
4 C>
5 C> @author J. Woollen @date 1994-01-06
6 
7 C> Get the current message number and data subset number within
8 C> a BUFR file.
9 C>
10 C> This subroutine returns the current location of the file pointer
11 C> within a BUFR file, in terms of a message number counting from the
12 C> beginning of the file, and a data subset number counting from the
13 C> beginning of that message.
14 C>
15 C> @remarks
16 C> - Logical unit LUNIT should have already been opened via a previous
17 C> call to subroutine openbf(). If LUNIT was opened for input
18 C> operations, then KMSG is incremented with each call to any of the
19 C> [message-reading subroutines](@ref hierarchy), and KSUB is
20 C> incremented with each call to any of the
21 C> [subset-reading subroutines](@ref hierarchy) for that message.
22 C> Otherwise, if LUNIT was opened for output operations, then KMSG is
23 C> incremented with each call to any of the
24 C> [message-writing subroutines](@ref hierarchy), and KSUB is
25 C> incremented with each call to any of the
26 C> [subset-writing subroutines](@ref hierarchy) for that message.
27 C> - The value returned for KMSG does <b>not</b> include any messages
28 C> which contain DX BUFR tables information.
29 C>
30 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file.
31 C> @param[out] KMSG - integer: Ordinal number of current message,
32 C> counting from the beginning of the BUFR file, but
33 C> not counting any messages which contain DX BUFR
34 C> tables information.
35 C> @param[out] KSUB - integer: Ordinal number of current data subset
36 C> within (KMSG)th message, counting from the
37 C> beginning of the message.
38 C>
39 C> @author J. Woollen @date 1994-01-06
40  RECURSIVE SUBROUTINE ufbcnt(LUNIT,KMSG,KSUB)
41 
42  USE moda_msgcwd
43  USE modv_im8b
44 
45 C-----------------------------------------------------------------------
46 C-----------------------------------------------------------------------
47 
48 C CHECK FOR I8 INTEGERS
49 C ---------------------
50 
51  IF(im8b) THEN
52  im8b=.false.
53 
54  CALL x84(lunit,my_lunit,1)
55  CALL ufbcnt(my_lunit,kmsg,ksub)
56  CALL x48(kmsg,kmsg,1)
57  CALL x48(ksub,ksub,1)
58 
59  im8b=.true.
60  RETURN
61  ENDIF
62 
63 C CHECK THE FILE STATUS - RETURN THE MESSAGE AND SUBSET COUNTERS
64 C --------------------------------------------------------------
65 
66  CALL status(lunit,lun,il,im)
67  IF(il.EQ.0) GOTO 900
68  kmsg = nmsg(lun)
69  ksub = nsub(lun)
70 
71 C EXITS
72 C -----
73 
74  RETURN
75 900 CALL bort('BUFRLIB: UFBCNT - BUFR FILE IS CLOSED, IT MUST BE '//
76  . 'OPEN FOR EITHER INPUT OR OUTPUT')
77  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable nmsg
Current message pointer within logical unit.
integer, dimension(:), allocatable nsub
Current subset pointer within message.
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
recursive subroutine ufbcnt(LUNIT, KMSG, KSUB)
Get the current message number and data subset number within a BUFR file.
Definition: ufbcnt.f:41
subroutine x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19