NCEPLIBS-bufr  12.0.0
string.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Check whether a string is in the string cache.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine checks to see if a user-specified character
7 c> string is in the string cache (arrays in common blocks /stcach/ and
8 c> /stords/). If it is not in the cache, it must call the bufr
9 c> archive library parsing subroutine parusr() to perform the task of
10 c> separating and checking the individual "pieces" (i.e., mnemonics)
11 c> so that it can then be added to the cache. If it is already in the
12 c> cache, then this extra work does not need to be performed. The
13 c> mnemonic string cache is a performance enhancing device which saves
14 c> time when the same mnemonic strings are encountered in a user
15 c> program, over and over again (the typical scenario).
16 C>
17 C> @param[in] STR - character*(*): string of blank-separated mnemonics.
18 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
19 C> @param[out] I1 - integer: a number greater than or equal to the number
20 C> of blank-separated mnemonics in STR.
21 C> @param[in] IO - integer: status indicator for BUFR file associated
22 C> with LUN:
23 C> - 0 input file
24 C> - 1 output file
25 C>
26 C> @author Woollen @date 1994-01-06
27  SUBROUTINE string(STR,LUN,I1,IO)
28 
29  USE modv_mxs
30  USE moda_msgcwd
31 
32  parameter(jcons=52)
33 
34  COMMON /stcach/ mstr,nstr,lstr,lux(mxs,2),usr(mxs),icon(jcons,mxs)
35  COMMON /usrstr/ jcon(jcons)
36  COMMON /stords/ iord(mxs),iorx(mxs)
37 
38  CHARACTER*(*) STR
39  CHARACTER*128 BORT_STR1,BORT_STR2
40  CHARACTER*80 USR,UST
41 
42 C----------------------------------------------------------------------
43 C----------------------------------------------------------------------
44 
45  nxt = 0
46  ust = str
47  ind = inode(lun)
48  IF(len(str).GT.80) GOTO 900
49 
50 C Note that LSTR, MSTR and NSTR were initialized via a prior call to
51 C subroutine STRCLN, which itself was called by subroutine MAKESTAB.
52 
53 C SEE IF STRING IS IN THE CACHE
54 C -----------------------------
55 
56  DO n=1,nstr
57  IF(lux(iord(n),2).EQ.ind) THEN
58  iorx(nxt+1) = iord(n)
59  nxt = nxt+1
60  ENDIF
61  ENDDO
62  DO n=1,nxt
63  IF(ust.EQ.usr(iorx(n)))goto1
64  ENDDO
65  goto2
66 
67 C IF IT IS IN THE CACHE, COPY PARAMETERS FROM THE CACHE
68 C -----------------------------------------------------
69 
70 1 DO j=1,jcons
71  jcon(j) = icon(j,iorx(n))
72  ENDDO
73  GOTO 100
74 
75 C IF IT IS NOT IN THE CACHE, PARSE IT AND PUT IT THERE
76 C ----------------------------------------------------
77 
78 2 CALL parusr(str,lun,i1,io)
79  lstr = max(mod(lstr+1,mstr+1),1)
80  nstr = min(nstr+1,mstr)
81 c .... File
82  lux(lstr,1) = lun
83 c .... Table A entry
84  lux(lstr,2) = ind
85  usr(lstr) = str
86  DO j=1,jcons
87  icon(j,lstr) = jcon(j)
88  ENDDO
89 
90 C REARRANGE THE CACHE ORDER AFTER AN UPDATE
91 C -----------------------------------------
92 
93  DO n=nstr,2,-1
94  iord(n) = iord(n-1)
95  ENDDO
96  iord(1) = lstr
97 
98 100 IF(jcon(1).GT.i1) GOTO 901
99 
100 C EXITS
101 C -----
102 
103  RETURN
104 900 WRITE(bort_str1,'("BUFRLIB: STRING - INPUT STRING (",A,") HAS")')
105  . str
106  WRITE(bort_str2,'(18X,"LENGTH (",I4,"), > LIMIT OF 80 CHAR.")')
107  . len(str)
108  CALL bort2(bort_str1,bort_str2)
109 901 WRITE(bort_str1,'("BUFRLIB: STRING - INPUT STRING (",A,")")') str
110  WRITE(bort_str2,'(18X,"HAS",I5," STORE NODES (MNEMONICS) - THE '//
111  . 'LIMIT (THIRD INPUT ARGUMENT) IS",I5)') jcon(1),i1
112  CALL bort2(bort_str1,bort_str2)
113  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
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 declares and initializes the MXS variable.
integer, parameter, public mxs
Maximum number of entries in the internal string cache.
subroutine parusr(STR, LUN, I1, IO)
Initate the process to parse out mnemonics from a character string.
Definition: parusr.f:26
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