NCEPLIBS-bufr  12.0.0
ufbovr.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Overwrite one or more data values within a data subset.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine writes over specified values which exist
7 C> in current internal BUFR subset arrays in a file open for output.
8 C> The data values correspond to mnemonics which are part of a
9 C> delayed-replication sequence, or for which there is no replication
10 C> at all. Either BUFR archive library subroutine openmg() or openmb()
11 C> must have been previously called to open and initialize a BUFR
12 C> message within memory for this lunit. In addition, BUFR archive
13 C> library subroutine writsb() or invmrg() must have been called to
14 C> store data in the internal output subset arrays.
15 C>
16 C> @param[in] LUNIT - integer: Fortran logical unit number for BUFR file.
17 C> @param[in] USR - real*8(*,*): data values
18 C> @param[in] I1 - integer: First dimension of USR as allocated within
19 C> the calling program.
20 C> @param[in] I2 - integer: Number of replications of STR that are to
21 C> be written into the data subset.
22 C> @param[out] IRET - integer: Number of replications of STR that were
23 C> written into the data subset.
24 C> @param[in] STR - character*(*): string of blank-separated Table B
25 C> mnemonics in one-to-one correspondence with first dimension of USR.
26 C>
27 C> @author Woollen @date 1994-01-06
28  RECURSIVE SUBROUTINE ufbovr(LUNIT,USR,I1,I2,IRET,STR)
29 
30  USE modv_im8b
31 
32  USE moda_usrint
33  USE moda_msgcwd
34 
35  COMMON /quiet / iprt
36 
37  CHARACTER*128 bort_str1,bort_str2,errstr
38  CHARACTER*(*) str
39  real*8 usr(i1,i2)
40 
41  DATA ifirst1/0/,ifirst2/0/
42 
43  SAVE ifirst1, ifirst2
44 
45 C----------------------------------------------------------------------
46 C----------------------------------------------------------------------
47 
48 C CHECK FOR I8 INTEGERS
49 C ---------------------
50 
51  IF(im8b) THEN
52  im8b=.false.
53 
54  CALL x84(lunit,my_lunit,1)
55  CALL x84(i1,my_i1,1)
56  CALL x84(i2,my_i2,1)
57  CALL ufbovr(my_lunit,usr,my_i1,my_i2,iret,str)
58  CALL x48(iret,iret,1)
59 
60  im8b=.true.
61  RETURN
62  ENDIF
63 
64  iret = 0
65 
66 C CHECK THE FILE STATUS AND I-NODE
67 C --------------------------------
68 
69  CALL status(lunit,lun,il,im)
70  IF(il.EQ.0) GOTO 900
71  IF(il.LT.0) GOTO 901
72  IF(im.EQ.0) GOTO 902
73  IF(inode(lun).NE.inv(1,lun)) GOTO 903
74 
75 C .... DK: Why check, isn't IO always 1 here?
76  io = min(max(0,il),1)
77 
78  IF(i1.LE.0) THEN
79  IF(iprt.GE.0) THEN
80  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
81  errstr = .LE.'BUFRLIB: UFBOVR - 3rd ARG. (INPUT) IS 0, ' //
82  . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
83  CALL errwrt(errstr)
84  CALL errwrt(str)
85  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
86  CALL errwrt(' ')
87  ENDIF
88  GOTO 100
89  ELSEIF(i2.LE.0) THEN
90  IF(iprt.EQ.-1) ifirst1 = 1
91  IF(io.EQ.0 .OR. ifirst1.EQ.0 .OR. iprt.GE.1) THEN
92  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
93  errstr = .LE.'BUFRLIB: UFBOVR - 4th ARG. (INPUT) IS 0, ' //
94  . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
95  CALL errwrt(errstr)
96  CALL errwrt(str)
97  IF(iprt.EQ.0 .AND. io.EQ.1) THEN
98  errstr = 'Note: Only the first occurrence of this WARNING ' //
99  . 'message is printed, there may be more. To output all ' //
100  . 'such messages,'
101  CALL errwrt(errstr)
102  errstr = 'modify your application program to add ' //
103  . '"CALL OPENBF(0,''QUIET'',1)" prior to the first call ' //
104  . 'to a BUFRLIB routine.'
105  CALL errwrt(errstr)
106  ENDIF
107  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
108  CALL errwrt(' ')
109  ifirst1 = 1
110  ENDIF
111  GOTO 100
112  ENDIF
113 
114 C PARSE OR RECALL THE INPUT STRING - READ/WRITE VALUES
115 C ----------------------------------------------------
116 
117  CALL string(str,lun,i1,io)
118  CALL trybump(lun,usr,i1,i2,io,iret)
119 
120  IF(io.EQ.1 .AND. iret.NE.i2) GOTO 904
121 
122  IF(iret.EQ.0) THEN
123  IF(iprt.EQ.-1) ifirst2 = 1
124  IF(ifirst2.EQ.0 .OR. iprt.GE.1) THEN
125  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
126  errstr = 'BUFRLIB: UFBOVR - NO SPECIFIED VALUES WRITTEN OUT, ' //
127  . 'SO RETURN WITH 5th ARG. (IRET) = 0; 6th ARG. (STR) ='
128  CALL errwrt(errstr)
129  CALL errwrt(str)
130  CALL errwrt('MAY NOT BE IN THE BUFR TABLE(?)')
131  IF(iprt.EQ.0) THEN
132  errstr = 'Note: Only the first occurrence of this WARNING ' //
133  . 'message is printed, there may be more. To output all ' //
134  . 'such messages,'
135  CALL errwrt(errstr)
136  errstr = 'modify your application program to add ' //
137  . '"CALL OPENBF(0,''QUIET'',1)" prior to the first call ' //
138  . 'to a BUFRLIB routine.'
139  CALL errwrt(errstr)
140  ENDIF
141  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
142  CALL errwrt(' ')
143  ifirst2 = 1
144  ENDIF
145  ENDIF
146 
147 C EXITS
148 C -----
149 
150 100 RETURN
151 900 CALL bort('BUFRLIB: UFBOVR - OUTPUT BUFR FILE IS CLOSED, IT '//
152  . 'MUST BE OPEN FOR OUTPUT')
153 901 CALL bort('BUFRLIB: UFBOVR - OUTPUT BUFR FILE IS OPEN FOR '//
154  . 'INPUT, IT MUST BE OPEN FOR OUTPUT')
155 902 CALL bort('BUFRLIB: UFBOVR - A MESSAGE MUST BE OPEN IN OUTPUT '//
156  . 'BUFR FILE, NONE ARE')
157 903 CALL bort('BUFRLIB: UFBOVR - LOCATION OF INTERNAL TABLE FOR '//
158  . 'OUTPUT BUFR FILE DOES NOT AGREE WITH EXPECTED LOCATION IN '//
159  . 'INTERNAL SUBSET ARRAY')
160 904 WRITE(bort_str1,'("BUFRLIB: UFBOVR - MNEMONIC STRING READ IN IS'//
161  . ': ",A)') str
162  WRITE(bort_str2,'(18X,"THE NUMBER OF ''LEVELS'' ACTUALLY '//
163  . 'WRITTEN (",I3,") DOES NOT EQUAL THE NUMBER REQUESTED (",I3,")'//
164  . ' - INCOMPLETE WRITE")') iret,i2
165  CALL bort2(bort_str1,bort_str2)
166  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
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 ...
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine string(STR, LUN, I1, IO)
This subroutine checks to see if a user-specified character string is in the string cache (arrays in ...
Definition: string.f:28
subroutine trybump(LUN, USR, I1, I2, IO, IRET)
This subroutine checks the first node associated with a character string (parsed into arrays in commo...
Definition: trybump.f:38
recursive subroutine ufbovr(LUNIT, USR, I1, I2, IRET, STR)
This subroutine writes over specified values which exist in current internal BUFR subset arrays in a ...
Definition: ufbovr.f:29
subroutine x48(IIN4, IOUT8, NVAL)
Encode one or more 4-byte integer values as 8-byte integer values.
Definition: x48.F:19
subroutine x84(IIN8, IOUT4, NVAL)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x84.F:19