updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / external / bufr / ufbcnt.f
bloba0656c1715b2ed42c77f1469d0ab22cd152b840a
1 SUBROUTINE UFBCNT(LUNIT,KMSG,KSUB)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: UFBCNT
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE RETURNS A COUNT OF THE CURRENT MESSAGE
9 C NUMBER AND SUBSET NUMBER, WHERE THE MESSAGE NUMBER IS RELATIVE TO
10 C ALL MESSAGES IN THE BUFR FILE AND THE SUBSET NUMBER IS RELATIVE TO
11 C ALL SUBSETS IN THE MESSAGE. IF THE MESSAGE/SUBSET ARE BEING READ,
12 C THE MESSAGE COUNT ADVANCES EACH TIME BUFR ARCHIVE LIBRARY
13 C SUBROUTINE READMG (OR EQUIVALENT) IS CALLED AND THE SUBSET COUNT
14 C ADVANCES EACH TIME BUFR ARCHIVE LIBRARY SUBROUTINE READSB (OR
15 C EQUIVALENT) IS CALLED FOR A PARTICULAR MESSAGE. IF THE MESSAGE/
16 C SUBSET ARE BEING WRITTEN, THE MESSAGE COUNT ADVANCES EACH TIME
17 C BUFR ARCHIVE LIBRARY SUBROUTINE OPENMG (OR EQUIVALENT) IS CALLED
18 C AND THE SUBSET COUNT ADVANCES EACH TIME BUFR ARCHIVE LIBRARY
19 C SUBROUTINE WRITSB (OR EQUIVALENT) IS CALLED.
21 C PROGRAM HISTORY LOG:
22 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
23 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
24 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
25 C ROUTINE "BORT"
26 C 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
27 C OPENED AT ONE TIME INCREASED FROM 10 TO 32
28 C (NECESSARY IN ORDER TO PROCESS MULTIPLE
29 C BUFR FILES UNDER THE MPI)
30 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
31 C INTERDEPENDENCIES
32 C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
33 C DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
34 C MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
35 C TERMINATES ABNORMALLY
37 C USAGE: CALL UFBCNT (LUNIT, KMSG, KSUB)
38 C INPUT ARGUMENT LIST:
39 C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
41 C OUTPUT ARGUMENT LIST:
42 C KMSG - INTEGER: POINTER TO MESSAGE COUNT IN BUFR FILE
43 C (INCLUDING MESSAGE CURRENTLY OPEN FOR READING/WRITING)
44 C KSUB - INTEGER: POINTER TO SUBSET COUNT IN BUFR MESSAGE
45 C (INCLUDING SUBSET CURRENTLY OPEN FOR READING/WRITING)
47 C REMARKS:
48 C IF AN APPLICATION PROGRAM DESIRES TO KNOW THE NUMBER OF SUBSETS IN
49 C A BUFR MESSAGES JUST OPENED, IT MUST USE THE FUNCTION NMSUB RATHER
50 C THAN THIS SUBROUTINE BECAUSE KSUB ONLY INCREMENTS BY ONE FOR EACH
51 C CALL TO READSB (I.E., KSUB = 0 IMMEDIATELY AFTER READMG IS
52 C CALLED).
54 C THIS ROUTINE CALLS: BORT STATUS
55 C THIS ROUTINE IS CALLED BY: UFBPOS
56 C Also called by application programs.
58 C ATTRIBUTES:
59 C LANGUAGE: FORTRAN 77
60 C MACHINE: PORTABLE TO ALL PLATFORMS
62 C$$$
64 INCLUDE 'bufrlib.prm'
66 COMMON /MSGCWD/ NMSG(NFILES),NSUB(NFILES),MSUB(NFILES),
67 . INODE(NFILES),IDATE(NFILES)
69 C-----------------------------------------------------------------------
70 C-----------------------------------------------------------------------
72 C CHECK THE FILE STATUS - RETURN THE MESSAGE AND SUBSET COUNTERS
73 C --------------------------------------------------------------
75 CALL STATUS(LUNIT,LUN,IL,IM)
76 IF(IL.EQ.0) GOTO 900
77 KMSG = NMSG(LUN)
78 KSUB = NSUB(LUN)
80 C EXITS
81 C -----
83 RETURN
84 900 CALL BORT('BUFRLIB: STATUS - BUFR FILE IS CLOSED, IT MUST BE '//
85 . 'OPEN FOR EITHER INPUT OR OUTPUT')
86 END