SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

READ FORMAT (SET)

Name:
    READ FORMAT (SET)
Type:
    Subcommand under SET
Purpose:
    Sets the (optional) Fortran format for the READ and SERIAL READ commands. Unformatted Fortran files are now also supported (see NOTE section below).
Description:
    The default format for the READ and SERIAL READ command is free-format. This allows the analyst to input data into Dataplot without having to worry about how the data is residing out on the file. On the other hand, if the data happens to reside on the file in a structured format, and if the analyst knows what the format is, then the analyst can optionally specify to Dataplot this format information. The advantage of this is speed since formatted READs and SERIAL READs are 10 to 15 times faster. For small data sets (less than a few hundred lines), there is little to gain. However, if your data file is large (say more than 500 lines) and formatted, then the time for I/O can be drastically reduced by making use of such format information. Any Fortran-like format must contain only F (floating-point), E (or D) (exponential), and X (blanks) specifications. I (integer), H (hollerith), A (character) etc. specifications are not permitted. The restriction against I format is no restriction at all. Simply use the corresponding F format (e.g., I2 becomes F2.0, I8 becomes F8.0).
Syntax:
    SET READ FORMAT <s> where <s> is a Fortran format-like string.
Examples:
    SET READ FORMAT 4F10.0
    SET READ FORMAT 5X,F6.0,F6.2,4X,2F5.0
    SET READ FORMAT 10X,3E12.4,5X,F10.0
    SET READ FORMAT DEFAULT

    SET READ FORMAT 3F10.0
    READ CALIB.DAT X Y Z

Note:
    If you are not familiar with Fortran formats, these are the basic constructs supported for the Dataplot SET READ FORMAT.

    • The X format specifies blank spaces, so 18X means to skip 18 columns.

    • The F format is used to read real numbers. So 3F12.2 specifies that the width of the field is 12 columns and there are 2 digits to the right of the decimal point and this format will be repeated for 3 numbers.

    • The E (or D) format is used to read real numbers in exponential notation. That is, the numbers look like

       
                  0.7575006E+00
                 -0.9003274E+00
                  0.2525207E+01
                 

      So 3E15.7 specifies that the width of the field is 15 columns and there are 7 digits to the right of the decimal point and this format will be repeated 3 times.

    The E, F and X specifications may be repeated as many times as needed. There should be no spaces in the string given for the SET READ FORMAT.

Note:
    Fortran formats expect the data to be aligned by the decimal point. That is,

      2.34 4.16
      5.81 9.22

    Spreadsheets typically either left or right justify the entire field when exporting to an ASCII file so that the decimal points are not aligned. If you have a large file that is not aligned by the decimal point and you anticipate needing to read the file frequently, it may be worthwhile to read the file once in free-format and save it using a SET WRITE FORMAT to have a version of the file that is aligned on the decimal point. Then in subsequent reading of the file, you can use the SET READ FORMAT with the version of the file that is aligned on the decimal point.

Note:
    Dataplot does no error checking on the specified format string. An improperly specified format will either result in an error on the READ or generate unexpected results.
Note:
    Support was added for reading Fortran unformatted data files. This was done primarily to accommodate reading very large data files. Note that in most cases using a SET READ FORMAT will provide sufficient performance. However, there may be cases where very large data sets that are read frequently may benefit from creating an unformatted version of the file.

    The advantage of unformatted reads is that the data files are much smaller (typically by a factor of 10 or more) and reading the data is significantly faster (e.g., even reading large data files almost instantaneous). The disadvantage is that unformatted files are binary and thus cannot be modified or viewed with a standard text editor. Also, Fortran unformatted files are not transportable across different computer systems.

    An unformatted read is performed by entering the command:

      SET READ FORMAT UNFORMATTED

    and then entering a standard READ command. For example,

      READ LARGE.DAT X1 X2 X3

    There are 2 ways to create the unformatted file in Fortran. For example, suppose X and Y are to be written to an unformatted file. The WRITE can be generated by:

    • WRITE(IUNIT) (X(I),Y(I),I=1,N)

    • WRITE(IUNIT) X,Y

    The distinction is that the first method stores the data as X(1), Y(1), X(2), Y(2), ..., X(N), Y(N) while the second method stores all of X then all of Y. There is no inherent advantage in either method in terms of performance or file size. The SET READ FORMAT UNFORMATTED command assumes the first method. To specify the second method, enter the command:

      SET READ FORMAT COLUMNWISE (or UNFORMATTEDCOLUMNWISE)

    Unformatted reading is supported only for variables or matrices (i.e., not for parameters, strings or character data). Also, it only applies when reading from a file. The limits for the maximum number of rows and columns for a matrix still apply. When reading a matrix, the number of columns must be specified via the SET UNFORMATTED COLUMNS command. For example,

      SET READ FORMAT UNFORMATTED
      SET UNFORMATTED COLUMNS 25
      READ MATRIX.DAT M

    The maximum size of the file that Dataplot can read is equal to the workspace size on your implementation (2,000,000 rows by 10 columns on most installations). For larger files, it will read up to this number of data values.

    The data is assumed to be a rectangular grid of data written in a single chunk. Only single precision real numbers are supported. By default, the entire file (up to the maximum number of points) is read. Dataplot provides two commands to allow some control of what portion of the file is read:

      SET UNFORMATTED OFFSET <value>
      SET UNFORMATTED RECORDS <value>

    The OFFSET specifies the number of data values at the begining of the file to skip. This is useful for skipping header lines (similar to a SKIP command for reading ASCII files) and other miscellaneous values. The RECORDS value is useful for reading part of a larger file.

    Be aware that Fortran unformatted files are not transportable across systems. This is due to the fact that the file contains various header bytes (the Fortran standard leaves implementation of this up to vendor) that are not standard. Also, the storage of real numbers can vary between platforms. This means that the SET READ FORMAT UNFORMATTED command can not be used to read raw binary files (as might be produced by a C program) and it cannot, in general, be used to read unformatted Fortran files created on systems other than the one you are running Dataplot on.

Default:
    Free-format (i.e., no format).
Synonyms:
    None
Related Commands:
    READ = Carries out a column-wise input of data.
    SERIAL READ = Carries out a line-wise input of data.
Applications:
    Input/Output
Implementation Date:
    1988/03
    1995/04: support for reading unformatted Fortran files
Program:
     
    SKIP 25
    SET READ FORMAT 3F7.0
    READ ELLIOTTR.DAT RED ROWID COLID
    SET READ FORMAT
        
Date created: 06/07/2024
Last updated: 06/07/2024

Please email comments on this WWW page to [email protected].