NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
valx.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS FUNCTION DECODES A REAL NUMBER FROM A CHARACTER
5 C> STRING. IF THE DECODE FAILS, THEN THE VALUE BMISS IS
6 C> RETURNED. NOTE THAT, UNLIKE FOR SUBROUTINE STRNUM, THE INPUT
7 C> STRING MAY CONTAIN A LEADING SIGN CHARACTER (E.G. '+', '-').
8 C>
9 C> PROGRAM HISTORY LOG:
10 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
11 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
12 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
13 C> ROUTINE "BORT"
14 C> 1999-11-18 J. WOOLLEN -- RENAMED THIS FUNCTION FROM "VAL$" TO "VALX"
15 C> TO REMOVE THE POSSIBILITY OF THE "$" SYMBOL
16 C> CAUSING PROBLEMS ON OTHER PLATFORMS
17 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
18 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
19 C> INTERDEPENDENCIES
20 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
21 C> DOCUMENTATION; OUTPUTS MORE COMPLETE
22 C> DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
23 C> ABNORMALLY; CHANGED CALL FROM BORT TO BORT2
24 C> 2009-04-21 J. ATOR -- USE ERRWRT
25 C>
26 C> USAGE: VALX (STR)
27 C> INPUT ARGUMENT LIST:
28 C> STR - CHARACTER*(*): STRING CONTAINING ENCODED REAL VALUE
29 C>
30 C> OUTPUT ARGUMENT LIST:
31 C> VALX - REAL: DECODED VALUE
32 C>
33 C> REMARKS:
34 C> THIS ROUTINE CALLS: BORT2 ERRWRT RJUST
35 C> THIS ROUTINE IS CALLED BY: GETTBH NEMTBB UPFTBV
36 C> Normally not called by any application
37 C> programs but it could be.
38 C>
39  FUNCTION valx(STR)
40 
41  USE modv_bmiss
42 
43  CHARACTER*(*) str
44  CHARACTER*128 bort_str1,bort_str2
45  CHARACTER*99 bstr
46  CHARACTER*8 fmt
47 
48  COMMON /quiet / iprt
49 
50 C----------------------------------------------------------------------
51 C----------------------------------------------------------------------
52 
53  lens = len(str)
54  IF(lens.GT.99) goto 900
55  bstr(1:lens) = str
56  rj = rjust(bstr(1:lens))
57  WRITE(fmt,'(''(F'',I2,''.0)'')') lens
58  valx = bmiss
59  READ(bstr,fmt,err=800) val
60  valx = val
61  goto 100
62 800 IF(iprt.GE.0) THEN
63  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
64  CALL errwrt('BUFRLIB: VALX - ERROR READING STRING:')
65  CALL errwrt(bstr(1:lens))
66  CALL errwrt('RETURN WITH VALX = MISSING')
67  CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
68  CALL errwrt(' ')
69  ENDIF
70 
71 C EXITS
72 C -----
73 
74 100 RETURN
75 900 WRITE(bort_str1,'("STRING IS: ",A)') str
76  WRITE(bort_str2,'("BUFRLIB: VALX - STRING LENGTH EXCEEDS LIMIT '//
77  . ' OF 99 CHARACTERS")')
78  CALL bort2(bort_str1,bort_str2)
79  END
function rjust(STR)
THIS FUNCTION RIGHT JUSTIFIES A CHARACTER STRING.
Definition: rjust.f:29
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:20
function valx(STR)
THIS FUNCTION DECODES A REAL NUMBER FROM A CHARACTER STRING.
Definition: valx.f:39
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:39