Re: Error in reading large Fortran unformatted files [message #75062] |
Wed, 16 February 2011 05:16  |
OM
Messages: 12 Registered: February 2011
|
Junior Member |
|
|
There's really not much to it...
I do it all from the command line:
f='name_of_file'
d=FLTARR(1024,1024,1024)
OPENR, 1, f, /F77_UNFORMATTED
READU, 1, d
At that point I get the error. Again, for 512 this worked fine.
Ofer.
On Feb 16, 3:11 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> Can you show the IDL code you are using to read the file?
>
> On Feb 16, 10:00 am, OM <metu...@gmail.com> wrote:
>
>> Hello everyone,
>
>> I'm new to this group, but I hope I won't look too silly...
>> I've recently started doing calculations in Fortran that result in
>> files containing an n^3 real (single precision) array. As long as n
>> was up to 512, everything worked fine, and I could read the result
>> file with IDL just fine. As long as I switched to n=1024, though...
>> (array sizes must be powers of 2, for the FFT that is yet to come).
>> I can open the file, and I can assign an array of the proper size, but
>> as soon as I try to read the file into the array, I get the error:
>> % READU: Corrupted f77 unformatted file detected. Unit: 2
>
>> I checked, and according to here (http://www.physics.nyu.edu/grierlab/
>> idl_html_help/files10.html) the size of the file should be within
>> limits (it's too big for 32 bit systems, but I made sure that I'm
>> running a 64 bit version of IDL on a 64 bit machine). It's not a
>> question of endianess, since I'm running the same Fortran code on the
>> same dataset, and the only thing that changes is the size of the grid.
>> Just to be sure of that point, I also made sure I can read the result
>> file correctly with Fortran and tried opening the file with the /
>> SWAP_ENDIAN and /SWAP_IF_LITTLE_ENDIAN keywords (not at the same time,
>> of course), and I still get the same error.
>> I'm out of ideas by this point... I'll really appreciate any kind of
>> help.
>
>> Thanks,
>> Ofer.
>
>
|
|
|
Re: Error in reading large Fortran unformatted files [message #75063 is a reply to message #75062] |
Wed, 16 February 2011 05:11   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
Can you show the IDL code you are using to read the file?
On Feb 16, 10:00 am, OM <metu...@gmail.com> wrote:
> Hello everyone,
>
> I'm new to this group, but I hope I won't look too silly...
> I've recently started doing calculations in Fortran that result in
> files containing an n^3 real (single precision) array. As long as n
> was up to 512, everything worked fine, and I could read the result
> file with IDL just fine. As long as I switched to n=1024, though...
> (array sizes must be powers of 2, for the FFT that is yet to come).
> I can open the file, and I can assign an array of the proper size, but
> as soon as I try to read the file into the array, I get the error:
> % READU: Corrupted f77 unformatted file detected. Unit: 2
>
> I checked, and according to here (http://www.physics.nyu.edu/grierlab/
> idl_html_help/files10.html) the size of the file should be within
> limits (it's too big for 32 bit systems, but I made sure that I'm
> running a 64 bit version of IDL on a 64 bit machine). It's not a
> question of endianess, since I'm running the same Fortran code on the
> same dataset, and the only thing that changes is the size of the grid.
> Just to be sure of that point, I also made sure I can read the result
> file correctly with Fortran and tried opening the file with the /
> SWAP_ENDIAN and /SWAP_IF_LITTLE_ENDIAN keywords (not at the same time,
> of course), and I still get the same error.
> I'm out of ideas by this point... I'll really appreciate any kind of
> help.
>
> Thanks,
> Ofer.
|
|
|
Re: Error in reading large Fortran unformatted files [message #75155 is a reply to message #75062] |
Wed, 16 February 2011 07:44  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article
<69299e37-2172-46f3-ade9-3a04fa2115d7@s11g2000yqc.googlegroups.com>,
OM <metukio@gmail.com> wrote:
> There's really not much to it...
> I do it all from the command line:
> f='name_of_file'
> d=FLTARR(1024,1024,1024)
> OPENR, 1, f, /F77_UNFORMATTED
> READU, 1, d
>
> At that point I get the error. Again, for 512 this worked fine.
>
I have always had better luck not setting the /F77_UNFORMATTED
flag and reading the length words myself.
That is,
nb1 = 0
nb2 = 0
OPENR, 1, f
READU, 1, nb1, f, nb2
In any case, I suspect that you have a 64-bit filesystem, but that
Fortran only writes 32-bit record lengths. In this case, your variable
is 4 GB, which will not fit into 32 bits.
The file may be OK, and you can just ignore nb1 and nb2, since
you know how big the record is in the file.
Have a look at nb1 and nb2 and see what you find.
Ken Bowman
|
|
|