Debian Codegraph @

packages/seacas/libraries/suplib/intstr.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE INTSTR (NNUM, LNGSTR, INUM, ISTR, LSTR)
9 C=======================================================================
10
11 C --*** INTSTR *** (STRLIB) Convert integer numbers to strings
12 C -- Written by Amy Gilkey - revised 03/14/88
13 C --
14 C --INTSTR converts a set of integer numbers into a consistent set of
15 C --strings of the same length (right justified).
16 C --
17 C --Parameters:
18 C -- NNUM - IN - the number of integers numbers in the set
19 C -- LNGSTR - IN - the number of digits in the string; <= 0 if length
20 C -- of longest integer
21 C -- INUM - IN - the array of integers to be converted
22 C -- ISTR - OUT - the set of integer strings
23 C -- LSTR - OUT - the maximum length of the number strings
24
25 INTEGER NNUM
26 INTEGER LNGSTR
27 INTEGER INUM(*)
28 CHARACTER*(*) ISTR(*)
29 INTEGER LSTR
30
31 CHARACTER*20 SCISTR
32 CHARACTER*5 FFMT
33
34 IF ((NNUM .EQ. 1) .AND. (LNGSTR .LE. 0)) THEN
35
36 C --Handle special case of single number, smallest length
37
38 WRITE (FFMT, 10000, IOSTAT=IDUM) LEN (ISTR(1))
39
40 WRITE (ISTR(1), FFMT, IOSTAT=IDUM) INUM(1)
41 CALL SQZSTR (ISTR(1), LSTR)
42
43 ELSE
44
45 C --Determine smallest length of largest number string
46
47 IF (LNGSTR .LE. 0) THEN
48 MINE = 0
49 MAXE = 0
50 DO 100 I = 1, NNUM
51 MINE = MIN (MINE, INUM(I))
52 MAXE = MAX (MAXE, INUM(I))
53 100 CONTINUE
54
55 MM = MAX (IABS (MAXE), IABS (MINE))
56 IF (MM .EQ. IABS (MINE)) MM = -MM
57 WRITE (SCISTR, '(I12)', IOSTAT=IDUM) MM
58 CALL SQZSTR (SCISTR, LSTR)
59
60 ELSE
61 LSTR = LNGSTR
62 END IF
63
64 LSTR = MIN (LSTR, LEN (ISTR(1)))
65
66 C --Convert all integers to string of given length
67
68 WRITE (FFMT, 10000, IOSTAT=IDUM) LSTR
69 10000 FORMAT ('(I', I2.2, ')')
70
71 DO 110 I = 1, NNUM
72 WRITE (ISTR(I), FFMT, IOSTAT=IDUM) INUM(I)
73 110 CONTINUE
74 END IF
75
76 RETURN
77 END