NCEPLIBS-bufr  12.0.0
wtstat.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Update file status in library internals.
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> Update file status in library internals.
7 C>
8 C> This subroutine can be used to connect or disconnect a specified
9 C> Fortran logical unit number to/from the BUFRLIB software, and it
10 C> can also be used to set or reset the internal message status
11 C> associated with that logical unit number.
12 C>
13 C> @note Before this subroutine is called to connect any LUNIT to the
14 C> software, a previous call should have been made to subroutine
15 C> status() to confirm that internal space is available to connect
16 C> the associated file, as well as to obtain an LUN value to use
17 C> in connecting it. Once a file is connected, the corresponding
18 C> LUNIT and LUN values remain linked to each other for as
19 C> long as the file is connected to the software.
20 C>
21 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file
22 C> @param[in] LUN - integer: Internal I/O stream index associated with LUNIT
23 C> @param[in] IL - integer: File status update option
24 C> - 0 Disconnect LUNIT from the software
25 C> - 1 Connect LUNIT to the software for output operations
26 C> (i.e. writing/encoding BUFR), if not already connected
27 C> - -1 Connect LUNIT to the software for input operations
28 C> (i.e. reading/decoding BUFR), if not already connected
29 C> @param[in] IM - integer: Message status update option, indicating
30 C> whether a message is currently open within the internal arrays for LUNIT
31 C> - 0 No
32 C> - 1 Yes
33 C>
34 C> @author J. Woollen @date 1994-01-06
35 
36  SUBROUTINE wtstat(LUNIT,LUN,IL,IM)
37 
38  USE moda_stbfr
39 
40  CHARACTER*128 BORT_STR
41 
42 C-----------------------------------------------------------------------
43 C-----------------------------------------------------------------------
44 
45 C CHECK ON THE ARGUMENTS
46 C ----------------------
47 
48  IF(lunit.LE.0) GOTO 900
49  IF(lun .LE.0) GOTO 901
50  IF(il.LT.-1 .OR. il.GT.1) GOTO 902
51  IF(im.LT. 0 .OR. im.GT.1) GOTO 903
52 
53 C CHECK ON LUNIT-LUN COMBINATION
54 C ------------------------------
55 
56  IF(abs(iolun(lun)).NE.lunit) THEN
57  IF(iolun(lun).NE.0) GOTO 905
58  ENDIF
59 
60 C RESET THE FILE STATUSES
61 C -----------------------
62 
63  IF(il.NE.0) THEN
64  iolun(lun) = sign(lunit,il)
65  iomsg(lun) = im
66  ELSE
67  iolun(lun) = 0
68  iomsg(lun) = 0
69  ENDIF
70 
71 C EXITS
72 C -----
73 
74  RETURN
75 900 WRITE(bort_str,'("BUFRLIB: WTSTAT - INVALID UNIT NUMBER PASSED '//
76  . ' INTO FIRST ARGUMENT (INPUT) (=",I3,")")') lunit
77  CALL bort(bort_str)
78 901 WRITE(bort_str,'("BUFRLIB: WTSTAT - INVALID I/O STREAM INDEX '//
79  . 'PASSED INTO SECOND ARGUMENT (INPUT) (=",I3,")")') lun
80  CALL bort(bort_str)
81 902 WRITE(bort_str,'("BUFRLIB: WTSTAT - INVALID LOGICAL UNIT STATUS'//
82  . ' INDICATOR PASSED INTO THIRD ARGUMENT (INPUT) (=",I4,")")') il
83  CALL bort(bort_str)
84 903 WRITE(bort_str,'("BUFRLIB: WTSTAT - INVALID BUFR MESSAGE STATUS'//
85  . ' INDICATOR PASSED INTO FOURTH ARGUMENT (INPUT) (=",I4,")")') im
86  CALL bort(bort_str)
87 905 WRITE(bort_str,'("BUFRLIB: WTSTAT - ATTEMPTING TO REDEFINE '//
88  . 'EXISTING FILE UNIT (LOGICAL UNIT NUMBER ",I3,")")') iolun(lun)
89  CALL bort(bort_str)
90  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
This module contains array declarations used to store file and message status indicators for all logi...
integer, dimension(:), allocatable iolun
File status indicators.
integer, dimension(:), allocatable iomsg
Message status indicator corresponding to iolun, denoting whether a BUFR message is currently open wi...
subroutine wtstat(LUNIT, LUN, IL, IM)
Update file status in library internals.
Definition: wtstat.f:37