NCEPLIBS-bufr 11.7.1
closbf.f
Go to the documentation of this file.
1C> @file
2C> @brief Close a previously opened system file and disconnect it from
3C> the BUFRLIB software.
4
5C> This subroutine closes the connection between logical unit
6C> LUNIT and the BUFRLIB software.
7C>
8C> @authors J. Woollen
9C> @authors J. Ator
10C> @date 1994-01-06
11C>
12C> @param[in] LUNIT -- integer: Fortran logical unit number for BUFR file
13C>
14C> @remarks
15C> - This subroutine will execute a Fortran "CLOSE" on logical unit LUNIT,
16C> even though subroutine openbf() didn't previously handle the corresponding
17C> Fortran "OPEN" of the same file.
18C> - It's a good idea to call this subroutine for every LUNIT that was
19C> opened to the software via openbf(); however, it's especially
20C> important to do so when writing/encoding a BUFR file, in order to
21C> ensure that all output is properly flushed to LUNIT.
22C>
23C> <b>Program history log:</b>
24C> | Date | Programmer | Comments |
25C> | -----|------------|----------|
26C> | 1994-01-06 | J. Woollen | Original author |
27C> | 2003-11-04 | J. Ator | Don't close lunit if opened as a NULL file by openbf() |
28C> | 2003-11-04 | S. Bender | Added remarks and routine interdependencies |
29C> | 2003-11-04 | D. Keyser | Unified/portable for WRF; added history documentation |
30C> | 2012-09-15 | J. Woollen | Modified for C/I/O/BUFR interface; added call to closfb() to close C files |
31C> | 2014-12-10 | J. Ator | Use modules instead of COMMON blocks |
32C> | 2020-07-16 | J. Ator | Add sanity check to ensure that openbf() was previously called (needed for GSI) |
33C>
34 SUBROUTINE closbf(LUNIT)
35
36 USE moda_nulbfr
37
38 CHARACTER*128 ERRSTR
39
40C-----------------------------------------------------------------------
41C-----------------------------------------------------------------------
42
43 IF ( .NOT. ALLOCATED(null) ) THEN
44 CALL errwrt('++++++++++++++++++++WARNING++++++++++++++++++++++')
45 errstr = 'BUFRLIB: CLOSBF WAS CALLED WITHOUT HAVING ' //
46 . 'PREVIOUSLY CALLED OPENBF'
47 CALL errwrt(errstr)
48 CALL errwrt('++++++++++++++++++++WARNING++++++++++++++++++++++')
49 RETURN
50 ENDIF
51
52 CALL status(lunit,lun,il,im)
53 IF(il.GT.0 .AND. im.NE.0) CALL closmg(lunit)
54 IF(il.NE.0 .AND. null(lun).EQ.0) CALL closfb(lun)
55 CALL wtstat(lunit,lun,0,0)
56
57C CLOSE fortran UNIT IF NULL(LUN) = 0
58C -----------------------------------
59
60 IF(null(lun).EQ.0) CLOSE(lunit)
61
62 RETURN
63 END
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
Definition: closbf.f:35
subroutine closmg(LUNIN)
This subroutine closes the BUFR message that is currently open for writing within internal arrays ass...
Definition: closmg.f:41
void closfb(f77int *nfile)
This subroutine closes a previously opened BUFR file.
Definition: cread.c:116
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
Definition: status.f:56
subroutine wtstat(LUNIT, LUN, IL, IM)
This subroutine can be used to connect or disconnect a specified Fortran logical unit number to/from ...
Definition: wtstat.f:53