NCEPLIBS-bufr  12.0.0
jstnum.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Left-justify a character string containing an encoded integer
3 C>
4 C> @author J. Woollen @date 1994-01-06
5 
6 C> This subroutine left-justifies a character string containing an
7 C> encoded integer, by removing all leading blanks and any leading
8 C> sign ('+' or '-') character. The string is modified in place, and
9 C> the sign is returned as a separate parameter. If the input string
10 C> contains only blank characters, then a call is made to subroutine
11 C> bort().
12 C>
13 C> @param[in,out] STR -- character*(*): String
14 C> @param[out] SIGN -- character*1: Sign of encoded integer value
15 C> - '+' = positive value
16 C> - '-' = negative value
17 C> @param[out] IRET -- integer: return code
18 C> - 0 = normal return
19 C> - -1 = input string contained non-blank
20 C> characters which were also non-numeric
21 C>
22 C> @author J. Woollen @date 1994-01-06
23  SUBROUTINE jstnum(STR,SIGN,IRET)
24 
25  CHARACTER*(*) STR
26 
27  CHARACTER*128 ERRSTR
28  CHARACTER*1 SIGN
29 
30  COMMON /quiet / iprt
31 
32 C-----------------------------------------------------------------------
33 C-----------------------------------------------------------------------
34 
35  iret = 0
36 
37  IF(str.EQ.' ') GOTO 900
38 
39  str = adjustl(str)
40  lstr = len(str)
41  IF(str(1:1).EQ.'+') THEN
42  str = str(2:lstr)
43  sign = '+'
44  ELSEIF(str(1:1).EQ.'-') THEN
45  str = str(2:lstr)
46  sign = '-'
47  ELSE
48  sign = '+'
49  ENDIF
50 
51  CALL strnum(str,num,ier)
52  IF(ier.LT.0) THEN
53  IF(iprt.GE.0) THEN
54  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
55  errstr = 'BUFRLIB: JSTNUM: ENCODED VALUE WITHIN RESULTANT '//
56  . 'CHARACTER STRING (' // str // ') IS NOT AN INTEGER - '//
57  . 'RETURN WITH IRET = -1'
58  CALL errwrt(errstr)
59  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
60  CALL errwrt(' ')
61  ENDIF
62  iret = -1
63  ENDIF
64 
65 C EXITS
66 C -----
67 
68  RETURN
69 900 CALL bort('BUFRLIB: JSTNUM - INPUT BLANK CHARACTER STRING NOT '//
70  . 'ALLOWED')
71  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
subroutine jstnum(STR, SIGN, IRET)
This subroutine left-justifies a character string containing an encoded integer, by removing all lead...
Definition: jstnum.f:24
recursive subroutine strnum(str, num, iret)
Decode an integer from a character string.
Definition: strnum.F90:24