Re: Read a fortran unformatted sequential file

From: Rick Grubin (grubin AT XXXXXX)
Date: Tue May 18 2004 - 08:15:37 MDT

  • Next message: YangJing: "about eof function"

    Hi Qing,

    > Because I usually ftp data between Linux and AIX, I use
    > 'ifc8.0 -convert big_endian' to compile programs. Could you tell me
    > which NCL function can deal with binary sequential data on
    > Linux.("fbinrecread " does work only in the little_endian format.)
    > My NCL version is 4.2.0.a031.

    As you've determined, the NCL function to read from binary data that
    was written using unformatted sequential access is fbinrecread().

    It's important to note, as you have, that files written on different
    computing architectures ('little-endian' and 'big-endian') will have
    differing binary formats. Regardless of architecture, your data file
    must match the "endian-ness" of the host on which you're trying to read
    it.

    On a Linux host ('little-endian'), you would use fbinrecread(), making
    certain your data file is in 'little-endian' format. If, on your Linux
    host, you need to convert your data from 'big-endian' format, you can use
    functions in the contributed.ncl file:
        fbinseqSwap1()
    or
        fbinseqSwap2()

    Note the following requirements to use these functions:

    ; This is for Fortran SEQUENTIAL files that need to be byte swapped. This
    ; requires *all* records in the file to be the same type and dimension size.
    ; It also requires that the user provide the dimensionality of each record.
    ; The number of records is *not* necessary. If you input wrong dimensions
    ; for each record it *will* screw up the data.
    ;
    ; Output file will be a Fortran sequential access file.

    -Rick.

    --
    Rick Grubin                     Visualization + Enabling Technologies
    Scientific Computing Division   National Center for Atmospheric Research   
    grubin@ucar.edu                 303.497.1832
    

    _______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Tue May 18 2004 - 07:54:44 MDT