updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / external / bufr / closbf.f
blob3f9d2d311efdf16fe01b0738954ff8b551cee74f
1 SUBROUTINE CLOSBF(LUNIT)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: CLOSBF
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE IS CALLED IN ORDER TO TERMINATE BUFR
9 C ARCHIVE LIBRARY SOFTWARE ACCESS TO A LOGICAL UNIT LUNIT FOR INPUT
10 C OR OUTPUT OPERATIONS (PREVIOUSLY OPENED BY A FORTRAN "OPEN" ON THE
11 C LOGICAL UNIT AND BY BUFR ARCHIVE LIBRARY SUBROUTINE OPENBF).
12 C CLOSBF MUST BE CALLED WHEN LUNIT IS CONNECTED TO A BUFR FILE OPEN
13 C FOR OUTPUT IN ORDER TO PROPERLY CLOSE AND WRITE ANY CURRENT BUFR
14 C MESSAGE WHICH MAY STILL EXIST IN INTERNAL MEMORY (AND MOST LIKELY
15 C NOT BE FULL). IT IS NOT MANDATORY THAT CLOSBF BE CALLED WHEN LUNIT
16 C IS CONNECTED TO A BUFR FILE OPEN FOR INPUT, BUT IT IS STILL A GOOD
17 C IDEA TO DO SO.
19 C PROGRAM HISTORY LOG:
20 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
21 C 2003-11-04 J. ATOR -- DON'T CLOSE LUNIT IF OPENED AS A NULL FILE
22 C BY OPENBF {NULL(LUN) = 1 IN NEW COMMON
23 C BLOCK /NULBFR/} (WAS IN DECODER VERSION)
24 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
25 C INTERDEPENDENCIES
26 C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
27 C DOCUMENTATION (INCLUDING HISTORY)
28 C 2012-09-15 J. WOOLLEN -- MODIFIED FOR C/I/O/BUFR INTERFACE;
29 C -- ADDED CALL TO CLOSFB TO CLOSE C FILES
31 C USAGE: CALL CLOSBF (LUNIT)
32 C INPUT ARGUMENT LIST:
33 C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
35 C INPUT FILES:
36 C UNIT "LUNIT" - BUFR FILE
38 C OUTPUT FILES:
39 C UNIT "LUNIT" - BUFR FILE
41 C REMARKS:
42 C THIS ROUTINE CALLS: CLOSFB CLOSMG STATUS WTSTAT
43 C THIS ROUTINE IS CALLED BY: COPYBF MESGBF UFBINX UFBMEM
44 C UFBMEX UFBTAB
45 C Also called by application programs.
47 C ATTRIBUTES:
48 C LANGUAGE: FORTRAN 77
49 C MACHINE: PORTABLE TO ALL PLATFORMS
51 C$$$
53 INCLUDE 'bufrlib.prm'
55 COMMON /NULBFR/ NULL(NFILES)
57 CALL STATUS(LUNIT,LUN,IL,IM)
58 IF(IL.GT.0 .AND. IM.NE.0) CALL CLOSMG(LUNIT)
59 if(IL.NE.0 .AND. NULL(LUN).EQ.0) call closfb(lun)
60 CALL WTSTAT(LUNIT,LUN,0,0)
62 C CLOSE fortran UNIT IF NULL(LUN) = 0
63 C -----------------------------------
65 IF(NULL(LUN).EQ.0) CLOSE(LUNIT)
67 RETURN
68 END