52 fprintf(stderr,
"Error: could not open %s for writing.\n",f);
57 bytes = fwrite(&ndims,
sizeof(
int),1,out);
58 if ((
int)bytes != 1) {
59 fprintf(stderr,
"Error in WriteBinary(): Unable to write ndims to output file.\n");
61 bytes = fwrite(&nvars,
sizeof(
int),1,out);
62 if ((
int)bytes != 1) {
63 fprintf(stderr,
"Error in WriteBinary(): Unable to write nvars to output file.\n");
67 bytes = fwrite(dim,
sizeof(
int),ndims,out);
68 if ((
int)bytes != ndims) {
69 fprintf(stderr,
"Error in WriteBinary(): Unable to write dimensions to output file.\n");
74 for (d = 0; d < ndims; d++) size += dim[d];
75 bytes = fwrite(x,
sizeof(
double),size,out);
76 if ((
int)bytes != size) {
77 fprintf(stderr,
"Error in WriteBinary(): Unable to write grid to output file.\n");
82 for (d = 0; d < ndims; d++) size *= dim[d]; size *= nvars;
83 bytes = fwrite(u,
sizeof(
double),size,out);
84 if ((
int)bytes != size) {
85 fprintf(stderr,
"Error in WriteBinary(): Unable to write solution to output file.\n");
Some basic definitions and macros.
int WriteBinary(int ndims, int nvars, int *dim, double *x, double *u, char *f, int *index)
Contains macros and function definitions for common array operations.