1 SUBROUTINE PARSTR
(STR
,TAGS
,MTAG
,NTAG
,SEP
,LIMIT80
)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: J. ATOR ORG: NP12 DATE: 2007-01-19
8 C ABSTRACT: THIS SUBROUTINE PARSES A STRING CONTAINING ONE OR MORE
9 C SUBSTRINGS INTO AN ARRAY OF SUBSTRINGS. THE SEPARATOR FOR THE
10 C SUBSTRINGS IS SPECIFIED DURING INPUT, AND MULTIPLE ADJACENT
11 C OCCURRENCES OF THIS CHARACTER WILL BE TREATED AS A SINGLE
12 C OCCURRENCE WHEN THE STRING IS ACTUALLY PARSED.
14 C PROGRAM HISTORY LOG:
15 C 2007-01-19 J. ATOR -- BASED UPON SUBROUTINE PARSEQ
17 C USAGE: CALL PARSTR (STR, TAGS, MTAG, NTAG, SEP, LIMIT80)
18 C INPUT ARGUMENT LIST:
19 C STR - CHARACTER*(*): STRING
20 C MTAG - INTEGER: MAXIMUM NUMBER OF SUBSTRINGS TO BE PARSED
22 C SEP - CHARACTER*1: SEPARATOR CHARACTER FOR SUBSTRINGS
23 C LIMIT80 - LOGICAL: .TRUE. IF AN ABORT SHOULD OCCUR WHEN STR IS
24 C LONGER THAN 80 CHARACTERS; INCLUDED FOR HISTORICAL
25 C CONSISTENCY WITH OLD SUBROUTINE PARSEQ
27 C OUTPUT ARGUMENT LIST:
28 C TAGS - CHARACTER*(*): MTAG-WORD ARRAY OF SUBSTRINGS (FIRST
30 C NTAG - INTEGER: NUMBER OF SUBSTRINGS RETURNED
33 C THIS ROUTINE CALLS: BORT2
34 C THIS ROUTINE IS CALLED BY: GETNTBE GETTAGPR GETTBH GETVALNB
35 C PARUSR READLC SEQSDX SNTBBE
36 C UFBSEQ UFBTAB UFBTAM WRITLC
37 C Normally not called by any application
38 C programs but it could be.
41 C LANGUAGE: FORTRAN 77
42 C MACHINE: PORTABLE TO ALL PLATFORMS
46 CHARACTER*
(*) STR
,TAGS
(MTAG
)
47 CHARACTER*128 BORT_STR1
,BORT_STR2
49 LOGICAL SUBSTR
,LIMIT80
51 C-----------------------------------------------------------------------
52 C-----------------------------------------------------------------------
56 IF( LIMIT80
.AND
. (LSTR
.GT
.80) ) GOTO 900
63 IF( .NOT
.SUBSTR
.AND
. (STR
(I
:I
).NE
.SEP
) ) THEN
65 IF(NTAG
.GT
.MTAG
) GOTO 901
69 IF( SUBSTR
.AND
. (STR
(I
:I
).EQ
.SEP
) ) NCHR
= 0
70 SUBSTR
= STR
(I
:I
).NE
.SEP
74 IF(NCHR
.GT
.LTAG
) GOTO 902
75 TAGS
(NTAG
)(NCHR
:NCHR
) = STR
(I
:I
)
84 900 WRITE(BORT_STR1
,'("BUFRLIB: PARSTR - INPUT STRING (",A,") HAS ")')
86 WRITE(BORT_STR2
,'(18X,"LENGTH (",I4,"), > LIMIT OF 80 CHAR.")')
88 CALL BORT2
(BORT_STR1
,BORT_STR2
)
89 901 WRITE(BORT_STR1
,'("BUFRLIB: PARSTR - INPUT STRING (",A,") '//
90 . 'CONTAINS",I4)') STR
,NTAG
91 WRITE(BORT_STR2
,'(18X,"SUBSTRINGS, EXCEEDING THE LIMIT {",I4,'//
92 . '" - THIRD (INPUT) ARGUMENT}")') MTAG
93 CALL BORT2
(BORT_STR1
,BORT_STR2
)
94 902 WRITE(BORT_STR1
,'("BUFRLIB: PARSTR - INPUT STRING (",A,") ")') STR
95 WRITE(BORT_STR2
,'(18X,"CONTAINS A PARSED SUBSTRING WITH LENGTH '//
96 . 'EXCEEDING THE MAXIMUM OF",I4," CHARACTERS")') LTAG
97 CALL BORT2
(BORT_STR1
,BORT_STR2
)