/*########################################################## # description: put some data in a 2d field and print it # in a two different 3D formats #########################################################*/ #include #include #include #include #define PI 3.1415926535897932 void **alloc2d(int, int, int); void free2d(void **, int, int); int main() { float **XZfield; int i, j; int Nx, Nz; float Xmax=10., Zmax=10.; float dX=0.1, dZ=0.1; FILE *fd1, *fd2; Nx = (int) Xmax/dX; Nz = (int) Zmax/dZ; // allocate 2D matrix for the data XZfield = (float **) alloc2d( Nx, Nz, sizeof(float) ); // make sure allocation was ok if ( XZfield == NULL ) { printf("error allocating memory\n"); exit(1); } // put zeros all around the edges of the grid for (i=0; i