NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
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 
4 C> This function returns the total number of data subsets available
5 C> within the BUFR message that was most recently opened for reading
6 C> via a call to one of the other
7 C> [message-reading subroutines](@ref hierarchy)
8 C> for a specified Fortran logical unit.
9 C>
10 C> <p>The data subsets themselves do not need to have already been
11 C> read via previous calls to any of the
12 C> [subset-reading subroutines](@ref hierarchy).
13 C>
14 C> @author J. Woollen
15 C> @date 1994-01-06
16 C>
17 C> @param[in] LUNIT - integer: Fortran logical unit number for
18 C> BUFR file
19 C> @returns nmsub - integer: Number of data subsets
20 C>
21 C> <b>Program history log:</b>
22 C> - 1994-01-06 J. Woollen -- Original author
23 C> - 1998-07-08 J. Woollen -- Replaced call to Cray library routine ABORT
24 C> with call to new internal routine bort()
25 C> - 1999-11-18 J. Woollen -- The number of BUFR files which can be
26 C> opened at one time increased from 10 to 32
27 C> (necessary in order to process multiple
28 C> BUFR files under the MPI)
29 C> - 2014-12-10 J. Ator -- Use modules instead of COMMON blocks
30 C>
31  FUNCTION nmsub(LUNIT)
32 
33  USE moda_msgcwd
34 
35 C-----------------------------------------------------------------------
36 C-----------------------------------------------------------------------
37 
38  nmsub = 0
39 
40 C CHECK THE FILE STATUS
41 C ---------------------
42 
43  CALL status(lunit,lun,il,im)
44  IF(il.EQ.0) goto 900
45  IF(il.GT.0) goto 901
46  IF(im.EQ.0) goto 902
47 
48  nmsub = msub(lun)
49 
50 C EXITS
51 C -----
52 
53  RETURN
54 900 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS CLOSED, IT MUST '//
55  . 'BE OPEN FOR INPUT')
56 901 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS OPEN FOR OUTPUT,'//
57  . ' IT MUST BE OPEN FOR INPUT')
58 902 CALL bort('BUFRLIB: NMSUB - A MESSAGE MUST BE OPEN IN INPUT '//
59  . 'BUFR FILE, NONE ARE')
60  END
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
function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:31
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23