NCEPLIBS-bufr  12.0.1
exitbufr.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Reset the NCEPLIBS-bufr software for potential dynamic
3 C> reallocation of memory.
4 C>
5 C> @author J. Ator @date 2015-03-02
6 
7 C> This subroutine frees all dynamically-allocated memory,
8 C> closes all logical units that are open within the
9 C> NCEPLIBS-bufr software, and resets the library to all of its
10 C> default settings as though it had never been called.
11 C>
12 C> @remarks
13 C> - Calling this subroutine allows an application program to
14 C> potentially resize arrays and reallocate memory all over again
15 C> with a new subsequent series of calls to subroutines isetprm()
16 C> and openbf(). However, if and when this subroutine is called,
17 C> there is no longer any internal memory available within the
18 C> NCEPLIBS-bufr software, and the remainder of the library becomes
19 C> essentially unusable within the application program, unless
20 C> and until subroutine openbf() is called once again to
21 C> dynamically allocate new array space. This may be a useful
22 C> capability for application programs that are finished with
23 C> using the NCEPLIBS-bufr software and wish to move on to other
24 C> unrelated tasks without continuing to tie up all of the
25 C> allocated memory space within the library. Otherwise, and
26 C> unless there's a need to change parameter sizes following the
27 C> first call to subroutine openbf(), then there's no need to ever
28 C> call this subroutine within an application program, since all
29 C> allocated memory will automatically get freed anyway by the
30 C> operating system once the application program terminates.
31 C>
32 C> @author J. Ator @date 2015-03-02
33  RECURSIVE SUBROUTINE exitbufr
34 
35  use bufrlib
36 
37  USE modv_im8b
38  USE modv_ifopbf
39  USE modv_nfiles
40 
41  USE moda_stbfr
42  USE moda_s01cm
43 
44  COMMON /tablef/ cdmf
45 
46  CHARACTER*1 cdmf
47 
48 C-----------------------------------------------------------------------
49 C-----------------------------------------------------------------------
50 
51 C Check for I8 integers.
52 
53  IF (im8b) THEN
54  im8b = .false.
55 
56  CALL exitbufr
57 
58  im8b = .true.
59  RETURN
60  END IF
61 
62 C Close any logical units that are open to the library.
63 
64  DO jj = 1, nfiles
65  IF ( iolun(jj) .NE. 0 ) CALL closbf( abs(iolun(jj)) )
66  END DO
67 
68 C Deallocate all allocated memory.
69 
70  CALL ardllocf
71 
72  IF ( cdmf .EQ. 'Y' ) CALL dlloctbf_c
73 
74 C Reset the library.
75 
76  ns01v = 0
77  ifopbf = 0
78 
79  RETURN
80  END
subroutine ardllocf
This subroutine frees any memory that was dynamically allocated during a previous call to subroutine ...
Definition: ardllocf.f:12
recursive subroutine closbf(LUNIT)
Close the connection between logical unit LUNIT and the NCEPLIBS-bufr software.
Definition: closbf.f:24
recursive subroutine exitbufr
This subroutine frees all dynamically-allocated memory, closes all logical units that are open within...
Definition: exitbufr.f:34
Wrap C NCEPLIBS-bufr functions so they can be called from within the Fortran part of the library.
Definition: bufrlib.F90:11
This module contains array and variable declarations used to store custom values for certain mnemonic...
integer ns01v
Number of custom values stored.
This module contains array declarations used to store file and message status indicators for all logi...
integer, dimension(:), allocatable iolun
File status indicators.
This module declares and initializes the IFOPBF variable.
integer, public ifopbf
Status indicator to keep track of whether subroutine openbf() has already been called:
This module declares and initializes the IM8B variable.
logical, public im8b
Status indicator to keep track of whether all future calls to BUFRLIB subroutines and functions from ...
This module declares and initializes the NFILES variable.
integer, public nfiles
Maximum number of BUFR files that can be connected to the BUFRLIB software (for reading or writing) a...