NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
jstnum.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 ALL LEADING BLANKS FROM A CHARACTER
5 C> STRING CONTAINING AN ENCODED INTEGER VALUE. IF THE VALUE HAS A
6 C> LEADING SIGN CHARACTER ('+' OR '-'), THEN THIS CHARACTER IS ALSO
7 C> REMOVED AND IS RETURNED SEPARATELY WITHIN SIGN. IF THE RESULTANT
8 C> STRING CONTAINS ANY NON-NUMERIC CHARACTERS, THAN AN APPROPRIATE
9 C> CALL IS MADE TO TO BUFR ARCHIVE LIBRARY SUBROUTINE BORT.
10 C>
11 C> PROGRAM HISTORY LOG:
12 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR (ENTRY POINT IN JSTIFY)
13 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
14 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
15 C> ROUTINE "BORT" (IN PARENT ROUTINE JSTIFY)
16 C> 2002-05-14 J. WOOLLEN -- CHANGED FROM AN ENTRY POINT TO INCREASE
17 C> PORTABILITY TO OTHER PLATFORMS (JSTIFY WAS
18 C> THEN REMOVED BECAUSE IT WAS JUST A DUMMY
19 C> ROUTINE WITH ENTRIES)
20 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
21 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
22 C> INTERDEPENDENCIES
23 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
24 C> DOCUMENTATION; OUTPUTS MORE COMPLETE
25 C> DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
26 C> ABNORMALLY OR UNUSUAL THINGS HAPPEN
27 C> 2009-04-21 J. ATOR -- USE ERRWRT
28 C>
29 C> USAGE: CALL JSTNUM (STR, SIGN, IRET)
30 C> INPUT ARGUMENT LIST:
31 C> STR - CHARACTER*(*): STRING CONTAINING ENCODED INTEGER VALUE
32 C>
33 C> OUTPUT ARGUMENT LIST:
34 C> STR - CHARACTER*(*): COPY OF INPUT STR WITH LEADING BLANKS
35 C> AND SIGN CHARACTER REMOVED
36 C> SIGN - CHARACTER*1: SIGN OF ENCODED INTEGER VALUE:
37 C> '+' = positive value
38 C> '-' = negative value
39 C> IRET - INTEGER: RETURN CODE:
40 C> 0 = normal return
41 C> -1 = encoded value within STR was not an integer
42 C>
43 C> REMARKS:
44 C> THIS ROUTINE CALLS: BORT ERRWRT STRNUM
45 C> THIS ROUTINE IS CALLED BY: ELEMDX
46 C> Normally not called by any application
47 C> programs but it could be.
48 C>
49  SUBROUTINE jstnum(STR,SIGN,IRET)
50 
51 
52 
53  CHARACTER*(*) str
54 
55  CHARACTER*128 errstr
56  CHARACTER*1 sign
57 
58  COMMON /quiet / iprt
59 
60 C-----------------------------------------------------------------------
61 C-----------------------------------------------------------------------
62 
63  iret = 0
64 
65  IF(str.EQ.' ') goto 900
66 
67  lstr = len(str)
68 2 IF(str(1:1).EQ.' ') THEN
69  str = str(2:lstr)
70  goto 2
71  ENDIF
72  IF(str(1:1).EQ.'+') THEN
73  str = str(2:lstr)
74  sign = '+'
75  ELSEIF(str(1:1).EQ.'-') THEN
76  str = str(2:lstr)
77  sign = '-'
78  ELSE
79  sign = '+'
80  ENDIF
81 
82  CALL strnum(str,num)
83  IF(num.LT.0) THEN
84  IF(iprt.GE.0) THEN
85  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
86  errstr = 'BUFRLIB: JSTNUM: ENCODED VALUE WITHIN RESULTANT '//
87  . 'CHARACTER STRING (' // str // ') IS NOT AN INTEGER - '//
88  . 'RETURN WITH IRET = -1'
89  CALL errwrt(errstr)
90  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
91  CALL errwrt(' ')
92  ENDIF
93  iret = -1
94  ENDIF
95 
96 C EXITS
97 C -----
98 
99  RETURN
100 900 CALL bort('BUFRLIB: JSTNUM - INPUT BLANK CHARACTER STRING NOT '//
101  . 'ALLOWED')
102  END
subroutine jstnum(STR, SIGN, IRET)
THIS SUBROUTINE REMOVES ALL LEADING BLANKS FROM A CHARACTER STRING CONTAINING AN ENCODED INTEGER VALU...
Definition: jstnum.f:49
subroutine strnum(STR, NUM)
THIS SUBROUTINE DECODES AN INTEGER FROM A CHARACTER STRING.
Definition: strnum.f:33
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23