NCEPLIBS-bufr  12.0.0
nmsub.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Get the number of data subsets from a BUFR message.
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> This function returns the total number of data subsets available
7 C> within the BUFR message that was most recently opened for reading
8 C> via a call to one of the other
9 C> [message-reading subroutines](@ref hierarchy)
10 C> for a specified Fortran logical unit.
11 C>
12 C> The data subsets themselves do not need to have already been
13 C> read via previous calls to any of the
14 C> [subset-reading subroutines](@ref hierarchy).
15 C>
16 C> @param[in] LUNIT -- integer: Fortran logical unit number for
17 C> BUFR file
18 C> @returns nmsub -- integer: Number of data subsets
19 C>
20 C> @author J. Woollen @date 1994-01-06
21  RECURSIVE FUNCTION nmsub(LUNIT) RESULT(IRET)
22 
23  USE modv_im8b
24 
25  USE moda_msgcwd
26 
27 C-----------------------------------------------------------------------
28 C-----------------------------------------------------------------------
29 
30 C CHECK FOR I8 INTEGERS
31 C ---------------------
32 
33  IF(im8b) THEN
34  im8b=.false.
35 
36  CALL x84(lunit,my_lunit,1)
37  iret=nmsub(my_lunit)
38 
39  im8b=.true.
40  RETURN
41  ENDIF
42 
43  iret = 0
44 
45 C CHECK THE FILE STATUS
46 C ---------------------
47 
48  CALL status(lunit,lun,il,im)
49  IF(il.EQ.0) GOTO 900
50  IF(il.GT.0) GOTO 901
51  IF(im.EQ.0) GOTO 902
52 
53  iret = msub(lun)
54 
55 C EXITS
56 C -----
57 
58  RETURN
59 900 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS CLOSED, IT MUST '//
60  . 'BE OPEN FOR INPUT')
61 901 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS OPEN FOR OUTPUT,'//
62  . ' IT MUST BE OPEN FOR INPUT')
63 902 CALL bort('BUFRLIB: NMSUB - A MESSAGE MUST BE OPEN IN INPUT '//
64  . 'BUFR FILE, NONE ARE')
65  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 msub
Total number of data subsets in 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 function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:22
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 x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19