Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between the two write statements

Status
Not open for further replies.

rajabadsha

Programmer
May 4, 2006
11
CA
Hi,
Can you please tell me how do you interpret the write statement below ( in C) as opposed to the other write statement,
write(29) ((um(i,k),k=1,ndz-nwt,2),i=nwt+1,ndx-nwt,2)
as opposed to
write(6,*) it," of ",nt," time steps",umax,esum
 
1) Note that fortran arrays start at 1 by default. To make life easier, add 1 to your array size initially
Code:
for (i = nwt + 1; i <= (ndx-nwt); i += 2)
{
   for (k = 1; k <= (ndz-nwt); n += 2)
      fwrite (&um[i][k], sizeof (um[0][0]), 1, channel29);
}
You could also do a fwrite of the whole array in one go.
2)
Code:
printf ("%d of %d time steps %d %d\n", it,nt,umax,esum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top