NCEPLIBS-bufr  12.0.0
parusr.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Initate the process to parse out mnemonics from a character string.
3 C>
4 C> @author Woollen @date 1994-01-06
5 
6 C> Initate the process to parse out mnemonics from a character string.
7 C>
8 C> This subroutine initates the process to parse out mnemonics
9 C> (nodes) from a user-specified character string, and separates them
10 C> into store and condition nodes. Information about the string
11 C> "pieces" (i.e., the mnemonics) is stored in arrays in common block
12 C> /usrstr/. Condition nodes are sorted in the order expected in the
13 C> internal jump/link tables and several checks are performed on the
14 C> nodes.
15 C>
16 C> @param[in] STR - character*(*): string of blank-separated mnemonics.
17 C> @param[in] LUN - integer: File ID.
18 C> @param[in] I1 - integer: a number greater than or equal to the number of
19 C> blank-separated mnemonics in STR.
20 C> @param[in] IO - integer: status indicator for BUFR file associated with LUN:
21 C> - 0 input file
22 C> - 1 output file
23 C>
24 C> @author Woollen @date 1994-01-06
25  SUBROUTINE parusr(STR,LUN,I1,IO)
26 
27  COMMON /usrstr/ nnod,ncon,nods(20),nodc(10),ivls(10),kons(10)
28  COMMON /acmode/ iac
29 
30  CHARACTER*(*) STR
31  CHARACTER*128 BORT_STR1,BORT_STR2
32  CHARACTER*80 UST
33  CHARACTER*20 UTG(30)
34  LOGICAL BUMP
35 
36  DATA maxusr /30/
37  DATA maxnod /20/
38  DATA maxcon /10/
39 
40 C----------------------------------------------------------------------
41 C----------------------------------------------------------------------
42 
43  ust = str
44  IF(len(str).GT.80) GOTO 900
45 
46  ncon = 0
47  nnod = 0
48 
49 C PARSE OUT STRING PIECES(S) (UTG's or MNEMONICS)
50 C -----------------------------------------------
51 
52  CALL parstr(ust,utg,maxusr,ntot,' ',.true.)
53 
54  DO n=1,ntot
55 
56 C DETERMINE IF THIS UTG IS A CONDITION NODE OR A STORE NODE
57 C ---------------------------------------------------------
58 
59  CALL parutg(lun,io,utg(n),nod,kon,val)
60  IF(kon.NE.0) THEN
61 c .... it is a condition node
62  ncon = ncon+1
63  IF(ncon.GT.maxcon) GOTO 901
64  nodc(ncon) = nod
65  kons(ncon) = kon
66  ivls(ncon) = nint(val)
67  ELSE
68 c .... it is a store node
69  nnod = nnod+1
70  IF(nnod.GT.maxnod) GOTO 902
71  nods(nnod) = nod
72  ENDIF
73  ENDDO
74 
75 C SORT CONDITION NODES IN JUMP/LINK TABLE ORDER
76 C ---------------------------------------------
77 
78  DO i=1,ncon
79  DO j=i+1,ncon
80  IF(nodc(i).GT.nodc(j)) THEN
81  nod = nodc(i)
82  nodc(i) = nodc(j)
83  nodc(j) = nod
84 
85  kon = kons(i)
86  kons(i) = kons(j)
87  kons(j) = kon
88 
89  val = ivls(i)
90  ivls(i) = ivls(j)
91  ivls(j) = nint(val)
92  ENDIF
93  ENDDO
94  ENDDO
95 
96 C CHECK ON SPECIAL RULES FOR CONDITIONAL NODES THAT ARE BUMP NODES
97 C ----------------------------------------------------------------
98 
99  bump = .false.
100 
101  DO n=1,ncon
102  IF(kons(n).EQ.5) THEN
103  IF(io.EQ.0) GOTO 903
104  IF(n.NE.ncon) GOTO 904
105  bump = .true.
106  ENDIF
107  ENDDO
108 
109 C CHECK STORE NODE COUNT AND ALIGNMENT
110 C ------------------------------------
111 
112  IF(.NOT.bump .AND. nnod.EQ.0) GOTO 905
113  IF(nnod.GT.i1) GOTO 906
114 
115  irpc = -1
116  DO i=1,nnod
117  IF(nods(i).GT.0) THEN
118  IF(irpc.LT.0) irpc = lstjpb(nods(i),lun,'RPC')
119  IF(irpc.NE.lstjpb(nods(i),lun,'RPC').AND.iac.EQ.0) GOTO 907
120  ENDIF
121  ENDDO
122 
123 C EXITS
124 C -----
125 
126  RETURN
127 900 WRITE(bort_str1,'("BUFRLIB: PARUSR - INPUT STRING (",A,") HAS ")')
128  . str
129  WRITE(bort_str2,'(18X,"LENGTH (",I4,"), > LIMIT OF 80 CHAR.")')
130  . len(str)
131  CALL bort2(bort_str1,bort_str2)
132 901 WRITE(bort_str1,'("BUFRLIB: PARUSR - THE NUMBER OF CONDITION '//
133  . 'NODES IN INPUT STRING")')
134  WRITE(bort_str2,'(18X,A,") EXCEEDS THE MAXIMUM (",I3,")")')
135  . str,maxcon
136  CALL bort2(bort_str1,bort_str2)
137 902 WRITE(bort_str1,'("BUFRLIB: PARUSR - THE NUMBER OF STORE NODES '//
138  . 'IN INPUT STRING")')
139  WRITE(bort_str2,'(18X,A,") EXCEEDS THE MAXIMUM (",I3,")")')
140  . str,maxnod
141  CALL bort2(bort_str1,bort_str2)
142 903 WRITE(bort_str1,'("BUFRLIB: PARUSR - BUMP NODE (^ IN INPUT '//
143  . 'STRING ",A)') str
144  WRITE(bort_str2,'(18X,"IS SPECIFIED FOR A BUFR FILE OPEN FOR '//
145  . 'INPUT, THE BUFR FILE MUST BE OPEN FOR OUTPUT")')
146  CALL bort2(bort_str1,bort_str2)
147 904 WRITE(bort_str1,'("BUFRLIB: PARUSR - INPUT STRING (",A,") '//
148  . 'CONTAINS")') str
149  WRITE(bort_str2,'(18X,"CONDITIONAL NODES IN ADDITION TO BUMP '//
150  . 'NODE - THE BUMP MUST BE ON THE INNER NODE")')
151  CALL bort2(bort_str1,bort_str2)
152 905 WRITE(bort_str1,'("BUFRLIB: PARUSR - INPUT STRING (",A,") HAS")')
153  . str
154  WRITE(bort_str2,'(18X,"NO STORE NODES")')
155  CALL bort2(bort_str1,bort_str2)
156 906 WRITE(bort_str1,'("BUFRLIB: PARUSR - INPUT STRING (",A,")")') str
157  WRITE(bort_str2,'(18X,"HAS",I5," STORE NODES (MNEMONICS) - THE '//
158  . 'LIMIT {THIRD (INPUT) ARGUMENT} IS",I5)') nnod,i1
159  CALL bort2(bort_str1,bort_str2)
160 907 WRITE(bort_str1,'("BUFRLIB: PARUSR - INPUT STRING (",A,") '//
161  . 'CONTAINS")') str
162  WRITE(bort_str2,'(18X,"STORE NODES (MNEMONICS) THAT ARE IN MORE'//
163  . ' THAN ONE REPLICATION GROUP")')
164  CALL bort2(bort_str1,bort_str2)
165  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
function lstjpb(NODE, LUN, JBTYP)
This function searches backwards, beginning from a given node within the jump/link table,...
Definition: lstjpb.f:30
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
Parse a string containing one or more substrings into an array of substrings.
Definition: parstr.f:24
subroutine parusr(STR, LUN, I1, IO)
Initate the process to parse out mnemonics from a character string.
Definition: parusr.f:26
subroutine parutg(LUN, IO, UTG, NOD, KON, VAL)
Parse a mnemonic from a character string.
Definition: parutg.f:83