NCEPLIBS-bufr 11.7.1
valx.f
Go to the documentation of this file.
1C> @file
2C> @brief Decode a real number from a character string
3
4C> This function decodes a real number from a character string.
5C> The string may contain a leading sign ('+' or '-') character.
6C> If the decode fails for any reason, then the current placeholder
7C> value for "missing" data is returned.
8C>
9C> @author J. Woollen
10C> @date 1994-01-06
11C>
12C> @param[in] STR -- character*(*): String
13C> @returns VALX -- real: Value decoded from STR
14C>
15C> <b>Program History Log:</b>
16C> | Date | Programmer | Comments |
17C> | -----|------------|----------|
18C> | 1994-01-06 | J. Woollen | Original author |
19C> | 1998-07-08 | J. Woollen | Replaced call to CRAY library routine "ABORT" with call to new internal routine bort() |
20C> | 1999-11-18 | J. Woollen | Renamed from val$ to valx because the $ symbol causes problems on certain platforms |
21C> | 2003-11-04 | D. Keyser | Use bort2() instead of bort() |
22C> | 2009-04-21 | J. Ator | Use errwrt() |
23C> | 2021-09-30 | J. Ator | Replace rjust with Fortran intrinsic adjustr |
24C>
25 FUNCTION valx(STR)
26
27 USE modv_bmiss
28
29 CHARACTER*(*) str
30 CHARACTER*128 bort_str1,bort_str2
31 CHARACTER*99 bstr
32 CHARACTER*8 fmt
33
34 COMMON /quiet / iprt
35
36C----------------------------------------------------------------------
37C----------------------------------------------------------------------
38
39 lens = len(str)
40 IF(lens.GT.99) GOTO 900
41 bstr(1:lens) = adjustr(str)
42 WRITE(fmt,'(''(F'',I2,''.0)'')') lens
43 valx = bmiss
44 READ(bstr,fmt,err=800) val
45 valx = val
46 GOTO 100
47800 IF(iprt.GE.0) THEN
48 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
49 CALL errwrt('BUFRLIB: VALX - ERROR READING STRING:')
50 CALL errwrt(bstr(1:lens))
51 CALL errwrt('RETURN WITH VALX = MISSING')
52 CALL errwrt('+++++++++++++++++++++WARNING+++++++++++++++++++++++')
53 CALL errwrt(' ')
54 ENDIF
55
56C EXITS
57C -----
58
59100 RETURN
60900 WRITE(bort_str1,'("STRING IS: ",A)') str
61 WRITE(bort_str2,'("BUFRLIB: VALX - STRING LENGTH EXCEEDS LIMIT '//
62 . ' OF 99 CHARACTERS")')
63 CALL bort2(bort_str1,bort_str2)
64 END
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:23
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:42
This module declares and initializes the BMISS variable.
Definition: modv_BMISS.f90:9
real *8, public bmiss
Current placeholder value to represent "missing" data when reading from or writing to BUFR files; thi...
Definition: modv_BMISS.f90:15
function valx(STR)
This function decodes a real number from a character string.
Definition: valx.f:26