NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
strsuc.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE REMOVES LEADING AND TRAILING BLANKS FROM A
5 C> STRING.
6 C>
7 C> PROGRAM HISTORY LOG:
8 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
9 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
10 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
11 C> INTERDEPENDENCIES
12 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
13 C> DOCUMENTATION; ADDED MORE COMPLETE
14 C> DIAGNOSTIC INFO WHEN UNUSUAL THINGS HAPPEN
15 C> 2009-04-21 J. ATOR -- USE ERRWRT
16 C>
17 C> USAGE: CALL STRSUC (STR1, STR2, LENS)
18 C> INPUT ARGUMENT LIST:
19 C> STR1 - CHARACTER*(*): STRING
20 C>
21 C> OUTPUT ARGUMENT LIST:
22 C> STR2 - CHARACTER*(*): COPY OF STR1 WITH LEADING AND TRAILING
23 C> BLANKS REMOVED
24 C> LENS - INTEGER: LENGTH OF STR2:
25 C> -1 = STR1 contained embedded blanks
26 C>
27 C> REMARKS:
28 C> THIS ROUTINE CALLS: ERRWRT
29 C> THIS ROUTINE IS CALLED BY: DXDUMP GETTAGRE HOLD4WLC MTFNAM
30 C> MTINFO NEMSPECS STRNUM UFDUMP
31 C> Normally not called by any application
32 C> programs but it could be.
33 C>
34  SUBROUTINE strsuc(STR1,STR2,LENS)
35 
36 
37 
38  CHARACTER*(*) str1,str2
39 
40  COMMON /quiet / iprt
41 
42 C-----------------------------------------------------------------------
43 C-----------------------------------------------------------------------
44 
45  lens = 0
46  lstr = len(str1)
47 
48 C FIND THE FIRST NON-BLANK IN THE INPUT STRING
49 C --------------------------------------------
50 
51  DO i=1,lstr
52  IF(str1(i:i).NE.' ') goto 2
53  ENDDO
54  goto 100
55 
56 C Now, starting with the first non-blank in the input string,
57 C copy characters from the input string into the output string
58 C until reaching the next blank in the input string.
59 
60 2 DO j=i,lstr
61  IF(str1(j:j).EQ.' ') goto 3
62  lens = lens+1
63  str2(lens:lens) = str1(j:j)
64  ENDDO
65  goto 100
66 
67 C Now, continuing on within the input string, make sure that
68 C there are no more non-blank characters. If there are, then
69 C the blank at which we stopped copying from the input string
70 C into the output string was an embedded blank.
71 
72 3 DO i=j,lstr
73  IF(str1(i:i).NE.' ') lens = -1
74  ENDDO
75 
76  IF(lens.EQ.-1 .AND. iprt.GE.0) THEN
77  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
78  CALL errwrt('BUFRLIB: STRSUC - INPUT STRING:')
79  CALL errwrt(str1)
80  CALL errwrt('CONTAINS ONE OR MORE EMBEDDED BLANKS')
81  CALL errwrt('++++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++++')
82  CALL errwrt(' ')
83  ENDIF
84 
85 C EXIT
86 C ----
87 
88 100 RETURN
89  END
subroutine strsuc(STR1, STR2, LENS)
THIS SUBROUTINE REMOVES LEADING AND TRAILING BLANKS FROM A STRING.
Definition: strsuc.f:34
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39