Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > [C/Fortran] wri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 20 Topic 8538 of 8908
Post > Topic >>

[C/Fortran] writing "big" binary files issue...

by fred <fredantispam@[EMAIL PROTECTED] > Jul 22, 2008 at 05:28 PM

Hi,

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.


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')

  !!! GNU compilo
!!$  open(unit=20, file='input.sep', form='unformatted', access='stream')
!!$  open(unit=21, file='a.sep', form='unformatted', access='stream')
  
  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 ?

What am I doing wrong in the fortran version ?


TIA.


Cheers,

-- 
Fred
 




 20 Posts in Topic:
[C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-22 17:28:50 
Re: [C/Fortran] writing "big" binary files issue...
"Dr Ivan D. Reid&quo  2008-07-22 16:52:00 
Re: [C/Fortran] writing "big" binary files issue...
"Dr Ivan D. Reid&quo  2008-07-22 19:08:48 
Re: [C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-23 09:40:11 
Re: [C/Fortran] writing "big" binary files issue...
Steve Lionel <Steve.Li  2008-07-22 13:50:25 
Re: [C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-23 09:41:49 
Re: [C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-23 09:48:38 
Re: [C/Fortran] writing "big" binary files issue...
Gary Scott <garylscott  2008-07-23 06:51:53 
Re: [C/Fortran] writing "big" binary files issue...
Paul van Delst <Paul.v  2008-07-23 09:18:05 
Re: [C/Fortran] writing "big" binary files issue...
Steve Lionel <Steve.Li  2008-07-23 09:46:32 
Re: [C/Fortran] writing "big" binary files issue...
glen herrmannsfeldt <g  2008-07-23 10:04:52 
Re: [C/Fortran] writing "big" binary files issue...
"James Van Buskirk&q  2008-07-23 09:58:04 
Re: [C/Fortran] writing "big" binary files issue...
Steve Lionel <Steve.Li  2008-07-23 15:40:47 
Re: [C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-27 16:28:26 
Re: [C/Fortran] writing "big" binary files issue...
Steve Lionel <steve.li  2008-07-28 00:30:57 
Re: [C/Fortran] writing "big" binary files issue...
fred <fredantispam@[EM  2008-07-28 16:41:34 
Re: writing "big" binary files issue...
GaryScott <garylscott@  2008-07-23 10:11:12 
Re: writing "big" binary files issue...
glen herrmannsfeldt <g  2008-07-23 10:29:54 
Re: writing "big" binary files issue...
Colin Paul Gloster <Co  2008-07-24 15:54:22 
Re: [C/Fortran] writing "big" binary files issue...
Ron Ford <ron@[EMAIL P  2008-07-22 19:24:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 9:20:37 CST 2008.