NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
valx.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Decode a real number from a character string
3 
4 C> This function decodes a real number from a character string.
5 C> The string may contain a leading sign ('+' or '-') character.
6 C> If the decode fails for any reason, then the current placeholder
7 C> value for "missing" data is returned.
8 C>
9 C> @author J. Woollen
10 C> @date 1994-01-06
11 C>
12 C> @param[in] STR -- character*(*): String
13 C> @returns VALX -- real: Value decoded from STR
14 C>
15 C> <b>Program History Log:</b>
16 C> | Date | Programmer | Comments |
17 C> | -----|------------|----------|
18 C> | 1994-01-06 | J. Woollen | Original author |
19 C> | 1998-07-08 | J. Woollen | Replaced call to CRAY library routine "ABORT" with call to new internal routine bort() |
20 C> | 1999-11-18 | J. Woollen | Renamed from val$ to valx because the $ symbol causes problems on certain platforms |
21 C> | 2003-11-04 | D. Keyser | Use bort2() instead of bort() |
22 C> | 2009-04-21 | J. Ator | Use errwrt() |
23 C> | 2021-09-30 | J. Ator | Replace rjust with Fortran intrinsic adjustr |
24 C>
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 
36 C----------------------------------------------------------------------
37 C----------------------------------------------------------------------
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
47 800 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 
56 C EXITS
57 C -----
58 
59 100 RETURN
60 900 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:22
function valx(STR)
This function decodes a real number from a character string.
Definition: valx.f:25
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:41