NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
hold4wlc.f
Go to the documentation of this file.
1 C> @file
2 C> @author ATOR @date 2014-02-05
3 
4 C> NORMALLY, A LONG CHARACTER STRING (I.E. LONGER THAN 8
5 C> BYTES) IS STORED IN AN UNCOMPRESSED BUFR SUBSET FOR OUTPUT VIA A
6 C> CALL TO BUFR ARCHIVE LIBRARY SUBROUTINE WRITLC, AT A POINT AFTER THE
7 C> CALL TO BUFR ARCHIVE LIBRARY SUBROUTINE WRITSB (OR WRITSA) HAS
8 C> ALREADY BEEN MADE FOR THE SUBSET IN QUESTION. THIS WORKS FINE FOR
9 C> ALL CASES EXCEPT WHEN WRITSB (OR WRITSA) FLUSHES THE MESSAGE
10 C> CONTAINING THE SUBSET IN QUESTION TO THE BUFR OUTPUT STREAM DURING
11 C> THE SAME CALL TO WRITSB (OR WRITSA), SUCH AS WHEN A SUBSET HAS A
12 C> BYTE COUNT > 65530 BYTES. WHEN THIS HAPPENS, THERE IS NO LONGER ANY
13 C> WAY FOR A SUBSEQUENT WRITLC CALL TO STORE A LONG CHARACTER STRING IN
14 C> THE SUBSET, BECAUSE THE SUBSET HAS ALREADY BEEN FLUSHED FROM
15 C> INTERNAL MEMORY TO THE OUTPUT STREAM. THIS SUBROUTINE GETS AROUND
16 C> THAT PROBLEM, BY ALLOWING A LONG CHARACTER STRING TO BE SPECIFIED
17 C> AHEAD OF TIME (I.E. BEFORE CALLING WRITSB OR WRITSB), AND THE
18 C> CORRESPONDING VALUE WILL BE HELD AND STORED AUTOMATICALLY (VIA AN
19 C> INTERNAL CALL TO WRITLC) AT THE PROPER TIME DURING THE SUBSEQUENT
20 C> CALL TO WRITSB (OR WRITSA). IF MULTIPLE LONG CHARACTER STRINGS NEED
21 C> TO BE STORED IN A SUBSET, THEN A SEPARATE CALL TO THIS SUBROUTINE
22 C> SHOULD BE MADE FOR EACH SUCH STRING.
23 C>
24 C> PROGRAM HISTORY LOG:
25 C> 2014-02-05 J. ATOR -- ORIGINAL AUTHOR
26 C>
27 C> USAGE: CALL HOLD4WLC(LUNIT,CHR,STR)
28 C> INPUT ARGUMENT LIST:
29 C> LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
30 C> CHR - CHARACTER*(*): UNPACKED CHARACTER STRING (I.E.,
31 C> CHARACTER DATA ELEMENT GREATER THAN EIGHT BYTES)
32 C> STR - CHARACTER*(*): MNEMONIC ASSOCIATED WITH STRING IN CHR
33 C>
34 C> REMARKS:
35 C> THIS ROUTINE CALLS: ERRWRT STRSUC
36 C> THIS ROUTINE IS CALLED BY: None
37 C> Normally called only by application
38 C> programs.
39 C>
40  SUBROUTINE hold4wlc(LUNIT,CHR,STR)
41 
42  USE moda_h4wlc
43 
44  COMMON /quiet/ iprt
45 
46  CHARACTER*(*) chr,str
47 
48  CHARACTER*128 errstr
49  CHARACTER*14 mystr
50 
51 C-----------------------------------------------------------------------
52 C-----------------------------------------------------------------------
53 
54  CALL strsuc( str, mystr, lens )
55  IF ( lens .EQ. -1 ) RETURN
56 
57  lenc = min( len( chr ), 120 )
58 
59 C IF THIS SUBROUTINE HAS ALREADY BEEN CALLED WITH THIS MNEMONIC FOR
60 C THIS PARTICULAR SUBSET, THEN OVERWRITE THE CORRESPONDING ENTRY IN
61 C THE INTERNAL HOLDING AREA.
62 
63  IF ( nh4wlc .GT. 0 ) THEN
64  DO i = 1, nh4wlc
65  IF ( ( lunit .EQ. luh4wlc(i) ) .AND.
66  . ( mystr(1:lens) .EQ. sth4wlc(i)(1:lens) ) ) THEN
67  chh4wlc(i) = ''
68  chh4wlc(i)(1:lenc) = chr(1:lenc)
69  RETURN
70  ENDIF
71  ENDDO
72  ENDIF
73 
74 C OTHERWISE, USE THE NEXT AVAILABLE UNUSED ENTRY IN THE HOLDING AREA.
75 
76  IF ( nh4wlc .GE. mxh4wlc ) THEN
77  IF(iprt.GE.0) THEN
78  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
79  WRITE ( unit=errstr, fmt='(A,A,I3)' )
80  . 'BUFRLIB: HOLD4WLC - THE MAXIMUM NUMBER OF LONG CHARACTER ',
81  . 'STRINGS THAT CAN BE HELD INTERNALLY IS ', mxh4wlc
82  CALL errwrt(errstr)
83  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
84  ENDIF
85  ELSE
86  nh4wlc = nh4wlc + 1
87  luh4wlc(nh4wlc) = lunit
88  sth4wlc(nh4wlc) = ''
89  sth4wlc(nh4wlc)(1:lens) = mystr(1:lens)
90  chh4wlc(nh4wlc) = ''
91  chh4wlc(nh4wlc)(1:lenc) = chr(1:lenc)
92  ENDIF
93 
94  RETURN
95  END
subroutine strsuc(STR1, STR2, LENS)
THIS SUBROUTINE REMOVES LEADING AND TRAILING BLANKS FROM A STRING.
Definition: strsuc.f:34
subroutine hold4wlc(LUNIT, CHR, STR)
NORMALLY, A LONG CHARACTER STRING (I.E.
Definition: hold4wlc.f:40
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39