1      subroutine util_print_centered(unit, string, center, ounder)
2C$Id$
3      implicit none
4#include "inp.fh"
5      integer unit              ! [input] fortran unit for output
6      character*(*) string      ! [input] string to print
7      integer center            ! [input] column to center on
8      logical ounder            ! [input] if true then underline
9c
10c     write the string to speficied fortran unit centered about
11c     the given column.  optionally underline.
12c
13#define BLNKLGTH 80
14      character*BLNKLGTH blank, underline
15      integer empty, length, i
16c
17      do i=1,BLNKLGTH
18         blank(i:i) = ' '
19      enddo
20      length = inp_strlen(string)
21      empty = center - length/2
22      if (empty .lt. 0) empty = 0
23      if (empty .gt. BLNKLGTH) empty = BLNKLGTH
24      write(unit, 1) blank(1:empty), string(1:length)
25    1 format(1x,a,a)
26      if (ounder) then
27         length = min(80,length)
28         do i = 1, length
29            underline(i:i) = '-'
30         enddo
31         write(unit, 1) blank(1:empty), underline(1:length)
32      endif
33c
34      end
35