home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8710 / 14 / number.f < prev    next >
Encoding:
Text File  |  1990-07-13  |  1.4 KB  |  61 lines

  1.       subroutine number (xpage, ypage, height, fpn, angle, ndec)
  2.       real               xpage, ypage, height, fpn, angle
  3.       integer                                              ndec
  4. C
  5. C   Convert floating point number into numbers on graph
  6. C
  7. C   Limit: f19.9 maximum number printable
  8. C    If this limit is raised, string lengths and formats must be changed
  9. C
  10. C   Basic method:  build proper string, hand to symbol
  11. C
  12. C   Rex Sanders, USGS, 3/87
  13. C
  14.     character*19 floats
  15.     character* 7 formts
  16.     integer    maxnpl,     maxnpr
  17.     parameter (maxnpl = 9, maxnpr = 9)
  18.  
  19.     real    afpn
  20.     integer    npl, npr, nchar, ntrunc, inum
  21.  
  22.     afpn    = abs (fpn)
  23. C
  24. C   First cut on # places left of decimal point
  25. C
  26.     if      (fpn .eq. 0) then
  27.         npl = 1
  28.     else if (fpn .gt. 0) then
  29.         npl = max (int (log10 (fpn)), 0)  + 1
  30.     else if (fpn .lt. 0) then
  31.         npl = max (int (log10 (afpn)), 0) + 2
  32.     endif
  33. C
  34. C   Guaranteed a decimal point
  35. C
  36.     if (ndec .ge. 0) then
  37.         npl = min (npl,  maxnpl)
  38.         npr = min (ndec, maxnpr)
  39.         nchar = npl + npr + 1
  40.         write(formts, 101) nchar, npr
  41. 101        format('(f', i2, '.', i1, ')')
  42.         write(floats, formts) fpn
  43. C
  44. C   No decimal point, write as integer
  45. C
  46.     else
  47.         ntrunc = abs (ndec) - 1
  48.         npl = max (min (npl - ntrunc, maxnpl), 1)
  49.         write(formts, 102) npl
  50. 102        format('(i', i1, ')')
  51.         
  52.         inum = nint(fpn/(10**ntrunc))
  53.         write(floats, formts) inum
  54.         nchar = npl
  55.     endif
  56.  
  57.     call symbol (xpage, ypage, height, floats, angle, nchar)
  58.  
  59.     return
  60.     end
  61.