NCEPLIBS-bufr  12.0.1
isize.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Compute the number of characters
3 C> needed to encode an integer as a string.
4 C>
5 C> @author Ator @date 2009-03-23
6 
7 C> This function computes and returns the number of characters
8 C> needed to encode the input integer NUM as a string. It does not
9 C> actually encode the string but rather only figures out the required
10 C> size. NUM must be an integer in the range of 0 to 99999.
11 C>
12 C> @param[in] NUM - integer: number to be encoded
13 C>
14 C> @return - integer: number of characters necessary to encode NUM
15 C> as a string
16 C>
17 C> @author Ator @date 2009-03-23
18  INTEGER FUNCTION isize (NUM)
19 
20  CHARACTER*128 bort_str
21 
22 C-----------------------------------------------------------------------
23 C-----------------------------------------------------------------------
24 
25  IF ( num .GE. 0 ) THEN
26  DO isize = 1, 5
27  IF ( num .LT. 10**isize ) RETURN
28  ENDDO
29  ENDIF
30  WRITE(bort_str,'("BUFRLIB: ISIZE - INPUT NUMBER (",I7,'//
31  . '") IS OUT OF RANGE")') num
32  CALL bort(bort_str)
33 
34  RETURN
35  END
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
integer function isize(NUM)
This function computes and returns the number of characters needed to encode the input integer NUM as...
Definition: isize.f:19