Reading fortran "unformatted" files from C on the 4D.

John D. McCalpin mccalpin at masig3.masig3.ocean.fsu.edu
Thu Oct 26 08:54:40 AEST 1989


Martin Knoblauch writes:
> for(iz=0;iz<max;iz++){
>   nitem = fread(&dummy,4,1,fp);
>   fread(&i1,sizeof(int),1,fp);
>   fread(&i2,sizeof(int),1,fp);
>   fread(&i3,sizeof(int),1,fp);
>   fread(&farr[0],sizeof(float),3,fp);
>   nitem = fread(&dummy,4,1,fp);
>   }

In article <8910251818.aa09277 at VAT.BRL.MIL>  jra at BRL.MIL ("John R.
Anderson", VLD/ASB) replies:
>Note that although this will work on an IRIS 4D, not all fortran
>compilers create "unforamtted" files with  the record length repeated
>at the beginning and end of the record. I have seen some that only
>include the record length at the start of each record. So depending
>on this will create non-portable code.
>				-John

That's why you have to use the same C routines to write the data,
too....  Having IEEE binary compatibility does not do you any good if
the record structures differ, and only C allows you to be absolutely
specific about what you are writing and reading....

By the way, on the 4D machines, the control words can be eliminated by
writing the file as "access='direct'" rather than "access='sequential'".
Of course all the records have to be the same length in this case....
Direct access files have _no_ record marks of any type -- they are
just like the "form='binary'" files on the IRIS 3000, and in fact are
transportable between FORTRAN applications on the two families of
machines....
--
John D. McCalpin - mccalpin at masig1.ocean.fsu.edu
		   mccalpin at scri1.scri.fsu.edu
		   mccalpin at delocn.udel.edu



More information about the Comp.sys.sgi mailing list