Okay, I just wanted to make sure that it makes sense for you to be using a single variable to store an entire file, but it sounds like it does. Maybe -- is this just a bunch of floats strung together? If so, it may *not* make that much sense to do that.
Anyway, you can still buffer the file in (and out) in chunks, which will at least make it easier to determine what is going wrong. Something like:
Code:
int all=nx*nz*nt*sizeof(float), part=nt*sizeof(float), got, total=0, i, j;
unsigned char file[all];
unsigned char buffer[part];
while ((got=read(fd,buffer,part))>0) {
j=0;
for (i=total, i<total+got; i++) { file[i]=buffer[j]; j++; }
total+=got;
}
The integrity of the file is preserved, and there is much more flexibility here to stick some printf's in to debug the problem.