NCEPLIBS-bufr  11.6.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> | Date | Programmer | Comments |
23 C> | -----|------------|----------|
24 C> | 1994-01-06 | J. Woollen | Original author |
25 C> | 1998-07-08 | J. Woollen | Replaced call to Cray library routine ABORT with call to new internal routine bort() |
26 C> | 1999-11-18 | J. Woollen | The number of BUFR files which can be opened at one time increased from 10 to 32 |
27 C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
28 C>
29  FUNCTION nmsub(LUNIT)
30 
31  USE moda_msgcwd
32 
33 C-----------------------------------------------------------------------
34 C-----------------------------------------------------------------------
35 
36  nmsub = 0
37 
38 C CHECK THE FILE STATUS
39 C ---------------------
40 
41  CALL status(lunit,lun,il,im)
42  IF(il.EQ.0) goto 900
43  IF(il.GT.0) goto 901
44  IF(im.EQ.0) goto 902
45 
46  nmsub = msub(lun)
47 
48 C EXITS
49 C -----
50 
51  RETURN
52 900 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS CLOSED, IT MUST '//
53  . 'BE OPEN FOR INPUT')
54 901 CALL bort('BUFRLIB: NMSUB - INPUT BUFR FILE IS OPEN FOR OUTPUT,'//
55  . ' IT MUST BE OPEN FOR INPUT')
56 902 CALL bort('BUFRLIB: NMSUB - A MESSAGE MUST BE OPEN IN INPUT '//
57  . 'BUFR FILE, NONE ARE')
58  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:55
function nmsub(LUNIT)
This function returns the total number of data subsets available within the BUFR message that was mos...
Definition: nmsub.f:29
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:22