On Tue, 22 Jul 2008 17:28:50 +0200, fred <fredantispam@[EMAIL PROTECTED]
>
wrote in <87tzeiuedp.fsf@[EMAIL PROTECTED]
>:
> Using this code as an example:
> int main(int argc, char *argv[])
> {
> int i, j, k;
> int nx=600, ny=800, nz=720;
> float x;
> FILE *file_in, *file_out;
> file_in = fopen("input.sep", "rb");
> file_out = fopen("a.sep", "wb");
> for (i=0; i<nx; i++)
> for (j=0; j<ny; j++)
> for (k=0; k<nz; k++)
> {
> fread(&x, 1, sizeof(float), file_in);
> fwrite(&x, 1, sizeof(float), file_out);
> }
> fclose(file_out);
> fclose(file_in);
> return(0);
> }
> takes 1 mn to dump the file.
I'm surprised, it looks horribly inefficient.
> Using this code to do the same thing:
> integer :: i, j, k
> integer :: nx, ny, nz
> real :: x
> nx = 600; ny = 800; nz = 720
> !!! intel compilo
> open(unit=20, file='input.sep', form='binary')
> open(unit=21, file='a.sep', form='binary')
> do i = 1, nx
> do j = 1, ny
> do k = 1, nz
> read(20) x
> write(21) x
> end do
> end do
> end do
> close(20)
> close(21)
> is... endless :-(
> What's going on ?
I'd imagine there's something different in the buffering.
> What am I doing wrong in the fortran version ?
Have you tried something like:
integer :: i, j, k
integer :: nx, ny, nz
real :: x(720)
nx = 600; ny = 800; nz = 720
open(unit=20, file='input.sep', form='binary')
open(unit=21, file='a.sep', form='binary')
do i = 1, nx
do j = 1, ny
read(20) x
write(21) x
end do
end do
?
--
Ivan Reid, School of Engineering & Design, _____________ CMS
Collaboration,
Brunel University. Ivan.Reid@[EMAIL PROTECTED]
|cern.ch] Room 40-1-B12,
CERN
KotPT -- "for stupidity above and beyond the call of duty".


|