2-11  INTERNAL FILES AND ASCII/BINARY CONVERSION 
 ************************************************

 FORTRAN provides a mechanism similar to formatted I/O statements for 
 files, that allows you to convert numeric data from internal binary 
 representation to 'formatted' representation and visa versa.

 The 'internal file' conversion mechanism takes character strings, 
 or arrays of character strings, and formally treats them as if 
 they were real files.

 Internal arrays can be thought of as files that resides in main memory, 
 instead of on disk. They can have more than one 'record' if you use an 
 array of strings, they may allow some file oriented statements like
 REWIND.

 Of course when your program exits, the contents of all internal files 
 is lost.

 The syntax of internal file statements is like that of formatted read
 and write, the only difference is that instead of the LOGICAL UNIT you
 put the string (string array) name.
 
 The following examples are for INTEGER variables, but of course you
 can use other types of variables (with proper formats).

 Converting a string to integer
 ------------------------------

      INTEGER*4         INTVAR
      CHARACTER         STRING*80
      ......................................
      READ(UNIT=STRING, FMT='(I5)') INTVAR


 Converting an integer to string
 -------------------------------

      INTEGER*4         INTVAR
      CHARACTER         STRING*80
      ......................................
      WRITE(UNIT=STRING, FMT='(I5)') INTVAR


  +---------------------------------------------+
  |    INTERNAL FILES ARE A STANDARD FORTRAN    |
  |     METHOD FOR ASCII/BINARY CONVERSIONS     |
  +---------------------------------------------+

Return to contents page