home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / fortran / 2800 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.5 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!wupost!cs.utexas.edu!torn!cunews!nrcnet0!cu23.crl.aecl.ca!wl.aecl.ca!harrisp
  2. From: harrisp@wl.aecl.ca
  3. Newsgroups: comp.lang.fortran
  4. Subject: RE: real to string conversion
  5. Message-ID: <22JUL92.10505201@wl.aecl.ca>
  6. Date: 22 Jul 92 16:50:52 GMT
  7. References: <1992Jul22.040204.18446@samba.oit.unc.edu>
  8. Sender: news@cu23.crl.aecl.ca (USENET News System)
  9. Organization: AECL RESEARCH
  10. Lines: 35
  11. Nntp-Posting-Host: wc4.wl.aecl.ca
  12.  
  13.  
  14.     The standard way to do this is through "internal" files (at least
  15. on PC's and on VAX mainframes). You use the name of the character variable
  16. as the file unit, and write to it as though it was a file. I hope the 
  17. following code fragment helps:
  18.  
  19.     character*10 carray
  20.     real*4 val
  21.  
  22.     val=3.1416
  23.     write(carray,1000) val
  24.  1000    format(f10.4)
  25.     print*,carray
  26.  
  27.  
  28. The results of executing this code would print
  29.  
  30.     3.1416
  31.  
  32. Note that this requires that you are going to know the range of the
  33. numbers before hand ie. the previous code would print drivel once
  34. val was greater than 10^6 or less than 10^-4. You could get around this
  35. using exponential formatting, or runtime formats. 
  36.  
  37. I would imagine there would be something in the index of your fortran
  38. manual under internal files. If not, check out the area on IO statments,
  39. specifically WRITE statements
  40.  
  41.  
  42. hope this helps
  43.  
  44. Phil Harris                |  Imagination is more
  45. Whiteshell Laboratories            |  important than knowledge.
  46. Atomic Energy of Canada            |           Albert Einstein
  47. HARRISP@WL.AECL.CA            | 
  48.