First of all, I need to thank all friends helping me here. Those days I learn a lot from your advices.
The basic idea of my code is to read velocity file into domain.velocity[k].
Start!!!
If I have a struct
typedef struct
{int nx, ny, nz;
float *velocity, *pwave, *qwave;
float *derivatives1, *derivatives2*;
}Model;
Model Domain;
In my case, I have struct from Domain[0], Domain[1], Domain[2]... Domain. and in each Domain, I have Domain.velocity[k], Domain.pwave[k], domain.qwave[k],....k = nx*ny*nz. All I did is in 3D case, that why I have nx*ny*nz.
How can I allocate memory for them? Do I need to allocate dynamic memory for them? How to do it?
I am sure "Segmentation fault" come from allocation memory, but I have no idea to figure it out. Hope you guys can give me a clear direction. Thanks in advance.