Reading sequential, unformatted data files 
Author Message
 Reading sequential, unformatted data files

I have lots of fortran-77 sequential, unformatted data files created on
a MASSCOMP system (Motorola 680x0) that I want to read using g77 on an
Intel system (80x86).  Each MASSCOMP FORTRAN-77 record is preceeded and
followed by a 4-byte integer that indicates the record's length in
bytes.

I can properly read the data from these files by byte swapping the
values that are read, but only after first processing each data file to
swap the bytes of the 4-byte integer record marks (using a C program I
wrote).  Otherwise the program locks up at runtime because presumably it
is trying to skip forward a gazillion bytes to the next record instead
of 16 bytes, since the 4-byte integer 00 00 00 0F (in hex format) is
interpreted as 16 by the Motorola system and 268,435,456 by the Intel
system.  Having to preprocess each data file before reading it is
cumbersome because of the extra step involved and because I now have
multiple copies of each data file sitting around on my hard disk.

Is there a method by which I can directly read the original MASSCOMP
data files without going through this preprocessing step.  I would like
to continue using my original FORTRAN data processing programs (with the
added byte swapping calls) instead of doing something drastic like
completely rewriting them in C.  The files were originally created with
a statement like
      OPEN (35, ERR=2000, STATUS='NEW', ACCESS='SEQUENTIAL',
     &      FORM='UNFORMATTED', FILE=FileName)
and are opened for reading with a statement like
      OPEN (35, ERR=2000, STATUS='OLD', ACCESS='SEQUENTIAL',
     &  FORM='UNFORMATTED', FILE=FileName)

Thanks in advance for any help on this matter.



Sat, 08 Nov 2003 22:32:37 GMT  
 Reading sequential, unformatted data files

<snip>

Quote:

>Is there a method by which I can directly read the original MASSCOMP
>data files without going through this preprocessing step.  I would like
>to continue using my original FORTRAN data processing programs (with the
>added byte swapping calls) instead of doing something drastic like
>completely rewriting them in C.  The files were originally created with
>a statement like
>      OPEN (35, ERR=2000, STATUS='NEW', ACCESS='SEQUENTIAL',
>     &  FORM='UNFORMATTED', FILE=FileName)
>and are opened for reading with a statement like
>      OPEN (35, ERR=2000, STATUS='OLD', ACCESS='SEQUENTIAL',
>     &  FORM='UNFORMATTED', FILE=FileName)

>Thanks in advance for any help on this matter.

   I don't use g77, but WATCOM will read (or write) "true" binary
(i.e. as many bytes as you want at a time without losing any)
with
   open( ... form='unformatted',recordtype='fixed')

Compaq Alpha (VMS) can also be used - except the only way I
found was to read in 512 byte records and  strip off the real
record length as you go along -- painful to program, but once
it's done, it's done. To write "true" binary, you have
to specify the record length, and write that much each time.
I haven't found any way to write variable length true binary
in VMS

 Possibly there is some similar feature in g77 - you just have to play
with the OPEN options;

Chris



Sun, 09 Nov 2003 18:58:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. fortran program to read a unformatted sequential file

2. Reading unformatted sequential file on Sun SparcStation

3. reading unformatted sequential UNIX fiile on a PC

4. help: how to read unformatted data file

5. Lahey unformatted sequential file format

6. fseek and unformatted sequential files

7. Skipping records in a sequential-access unformatted file

8. end-of-file during read using unformatted reading

9. Reading sequential data from Ada.Text_Io.Standard_Input?

10. Read VFP data files into Clipper data files

11. Reading Unformatted data

12. How to read unformatted data from stdin?

 

 
Powered by phpBB® Forum Software