NCEPLIBS-bufr 11.7.1
parstr.f
Go to the documentation of this file.
1C> @file
2C> @author J @date 2007-01-19
3
4C> THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE
5C> SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS. THE SEPARATOR FOR THE
6C> SUBSTRINGS IS SPECIFIED DURING INPUT, AND MULTIPLE ADJACENT
7C> OCCURRENCES OF THIS CHARACTER WILL BE TREATED AS A SINGLE
8C> OCCURRENCE WHEN THE STRING IS ACTUALLY PARSED.
9C>
10C> PROGRAM HISTORY LOG:
11C> 2007-01-19 J. ATOR -- BASED UPON SUBROUTINE PARSEQ
12C>
13C> USAGE: CALL PARSTR (STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
14C> INPUT ARGUMENT LIST:
15C> STR - CHARACTER*(*): STRING
16C> MTAG - INTEGER: MAXIMUM NUMBER OF SUBSTRINGS TO BE PARSED
17C> FROM STRING
18C> SEP - CHARACTER*1: SEPARATOR CHARACTER FOR SUBSTRINGS
19C> LIMIT80 - LOGICAL: .TRUE. IF AN ABORT SHOULD OCCUR WHEN STR IS
20C> LONGER THAN 80 CHARACTERS; INCLUDED FOR HISTORICAL
21C> CONSISTENCY WITH OLD SUBROUTINE PARSEQ
22C>
23C> OUTPUT ARGUMENT LIST:
24C> TAGS - CHARACTER*(*): MTAG-WORD ARRAY OF SUBSTRINGS (FIRST
25C> NTAG WORDS FILLED)
26C> NTAG - INTEGER: NUMBER OF SUBSTRINGS RETURNED
27C>
28C> REMARKS:
29C> THIS ROUTINE CALLS: BORT2
30C> THIS ROUTINE IS CALLED BY: FSTAG GETCFMNG GETNTBE GETTBH
31C> PARUSR READLC SEQSDX SNTBBE
32C> SNTBDE SNTBFE UFBSEQ UFBTAB
33C> UFBTAM WRITLC
34C> Normally not called by any application
35C> programs but it could be.
36C>
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
46C-----------------------------------------------------------------------
47C-----------------------------------------------------------------------
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
75C EXITS
76C -----
77
78 RETURN
79900 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)
84901 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)
89902 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 bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:23
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:38