C @(#)chvxi.f 1.1 02/19/98 C subroutine chvxi (number, ch, nbase) c !---------------------------------- c CHaracters_Right_justified_eX_Integer (displayed in nbase) c An integer*4 is supplied in NUMBER, this routine will plant it c into the CH character string - right justified c Will put in stars if number is too large c CHVXI uses blanks to left fill c CHVXI0 uses zeros to left fill c CHVXIS uses blanks to left fill and will put in a plus sign character*(*) ch, plant*1, sign*1 character*6 chival character*4 cols character*12 toobig character*36 sets character*1 set(0:35) equivalence (set,sets) data sets/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'/ plant = ' ' sign = ' ' go to 8 entry chvxis (number, ch, nbase) c ------------------------- plant = ' ' sign = '+' go to 8 entry chvxi0 (number, ch, nbase) c ------------------------- plant = '0' sign = ' ' 8 if (nbase .lt. 2 .or. nbase .gt. 36) 2 call abort ('Number base '//chival(nbase)//' invalid') if (number .lt. 0) then sign = '-' else if (number .eq. 0) then sign = ' ' end if numb = iabs (number) now = len (ch) ch (now:now) = set(mod(numb,nbase)) do while (numb .ge. nbase .and. now .gt. 1) numb = numb/nbase now = now - 1 ch (now:now) = set(mod(numb,nbase)) end do if (numb .ge. nbase 2 .or. (sign .ne. ' ' .and. now .eq. 1)) then c Number overflows space available do i = 1, len(ch) ch (i:i) = '*' end do write (toobig, '(i12)') number write (cols, '(i4)') len(ch) call warn (toobig//' is too big for'//cols 2 //' columns, filled with *') else c Put in sign if required if (sign .ne. ' ') then c zero fill to column two of field if (plant .eq. '0') then do while (now .gt. 2) now = now - 1 ch (now:now) = '0' end do end if now = now - 1 ch (now:now) = sign end if c Left fill with zero or blank characters do while (now .gt. 1) now = now - 1 ch (now:now) = plant end do end if return end