NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
parstr.f
Go to the documentation of this file.
1 C> @file
2 C> @author J @date 2007-01-19
3 
4 C> THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE
5 C> SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS. THE SEPARATOR FOR THE
6 C> SUBSTRINGS IS SPECIFIED DURING INPUT, AND MULTIPLE ADJACENT
7 C> OCCURRENCES OF THIS CHARACTER WILL BE TREATED AS A SINGLE
8 C> OCCURRENCE WHEN THE STRING IS ACTUALLY PARSED.
9 C>
10 C> PROGRAM HISTORY LOG:
11 C> 2007-01-19 J. ATOR -- BASED UPON SUBROUTINE PARSEQ
12 C>
13 C> USAGE: CALL PARSTR (STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
14 C> INPUT ARGUMENT LIST:
15 C> STR - CHARACTER*(*): STRING
16 C> MTAG - INTEGER: MAXIMUM NUMBER OF SUBSTRINGS TO BE PARSED
17 C> FROM STRING
18 C> SEP - CHARACTER*1: SEPARATOR CHARACTER FOR SUBSTRINGS
19 C> LIMIT80 - LOGICAL: .TRUE. IF AN ABORT SHOULD OCCUR WHEN STR IS
20 C> LONGER THAN 80 CHARACTERS; INCLUDED FOR HISTORICAL
21 C> CONSISTENCY WITH OLD SUBROUTINE PARSEQ
22 C>
23 C> OUTPUT ARGUMENT LIST:
24 C> TAGS - CHARACTER*(*): MTAG-WORD ARRAY OF SUBSTRINGS (FIRST
25 C> NTAG WORDS FILLED)
26 C> NTAG - INTEGER: NUMBER OF SUBSTRINGS RETURNED
27 C>
28 C> REMARKS:
29 C> THIS ROUTINE CALLS: BORT2
30 C> THIS ROUTINE IS CALLED BY: FSTAG GETCFMNG GETNTBE GETTBH
31 C> PARUSR READLC SEQSDX SNTBBE
32 C> SNTBDE SNTBFE UFBSEQ UFBTAB
33 C> UFBTAM WRITLC
34 C> Normally not called by any application
35 C> programs but it could be.
36 C>
37  SUBROUTINE parstr(STR,TAGS,MTAG,NTAG,SEP,LIMIT80)
38 
39 
40 
41  CHARACTER*(*) str,tags(mtag)
42  CHARACTER*128 bort_str1,bort_str2
43  CHARACTER*1 sep
44  LOGICAL substr,limit80
45 
46 C-----------------------------------------------------------------------
47 C-----------------------------------------------------------------------
48 
49  lstr = len(str)
50  ltag = len(tags(1))
51  IF( limit80 .AND. (lstr.GT.80) ) goto 900
52  ntag = 0
53  nchr = 0
54  substr = .false.
55 
56  DO i=1,lstr
57 
58  IF( .NOT.substr .AND. (str(i:i).NE.sep) ) THEN
59  ntag = ntag+1
60  IF(ntag.GT.mtag) goto 901
61  tags(ntag) = ' '
62  ENDIF
63 
64  IF( substr .AND. (str(i:i).EQ.sep) ) nchr = 0
65  substr = str(i:i).NE.sep
66 
67  IF(substr) THEN
68  nchr = nchr+1
69  IF(nchr.GT.ltag) goto 902
70  tags(ntag)(nchr:nchr) = str(i:i)
71  ENDIF
72 
73  ENDDO
74 
75 C EXITS
76 C -----
77 
78  RETURN
79 900 WRITE(bort_str1,'("BUFRLIB: PARSTR - INPUT STRING (",A,") HAS ")')
80  . str
81  WRITE(bort_str2,'(18X,"LENGTH (",I4,"), > LIMIT OF 80 CHAR.")')
82  . lstr
83  CALL bort2(bort_str1,bort_str2)
84 901 WRITE(bort_str1,'("BUFRLIB: PARSTR - INPUT STRING (",A,") '//
85  . 'CONTAINS",I4)') str,ntag
86  WRITE(bort_str2,'(18X,"SUBSTRINGS, EXCEEDING THE LIMIT {",I4,'//
87  . '" - THIRD (INPUT) ARGUMENT}")') mtag
88  CALL bort2(bort_str1,bort_str2)
89 902 WRITE(bort_str1,'("BUFRLIB: PARSTR - INPUT STRING (",A,") ")') str
90  WRITE(bort_str2,'(18X,"CONTAINS A PARSED SUBSTRING WITH LENGTH '//
91  . 'EXCEEDING THE MAXIMUM OF",I4," CHARACTERS")') ltag
92  CALL bort2(bort_str1,bort_str2)
93  END
subroutine parstr(STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS...
Definition: parstr.f:37
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:22