18 static int WriteArraySerial (
int,
int,
int*,
int*,
int,
double*,
double*,
void*,
void*,
char*);
20 static int WriteArrayParallel (
int,
int,
int*,
int*,
int,
double*,
double*,
void*,
void*,
char*);
52 solver,mpi,fname_root);
CHECKERR(ierr);
56 solver,mpi,fname_root);
CHECKERR(ierr);
99 for (d=0; d<ndims; d++) size_global *= dim_global[d];
100 ug = (
double*) calloc (size_global*nvars,
sizeof(
double));
104 for (d=0; d<ndims; d++) size_global += dim_global[d];
105 xg = (
double*) calloc (size_global,
sizeof(
double));
118 int offset_global, offset_local;
119 offset_global = offset_local = 0;
120 for (d=0; d<ndims; d++) {
122 &x[offset_local+ghosts],
124 offset_global += dim_global[d];
125 offset_local += dim_local [d] + 2*ghosts;
131 strcat(filename,fname_root);
133 strcat(filename,
"_");
137 printf(
"Writing solution file %s.\n",filename);
213 static int count = 0;
216 strcpy(filename_root,fname_root);
218 if (!mpi->
rank) printf(
"Writing solution file %s.xxxx (parallel mode).\n",filename_root);
221 int sizex = 0;
for (d=0; d<ndims; d++) sizex += dim_local[d];
222 int sizeu = nvars;
for (d=0; d<ndims; d++) sizeu *= dim_local[d];
225 double *buffer = (
double*) calloc (sizex+sizeu,
sizeof(
double));
228 int offset1 = 0, offset2 = 0;
229 for (d = 0; d < ndims; d++) {
230 _ArrayCopy1D_((x+offset1+ghosts),(buffer+offset2),dim_local[d]);
231 offset1 += (dim_local[d]+2*ghosts);
232 offset2 += dim_local[d];
242 double *write_buffer = NULL;
243 int write_size_x, write_size_u, write_total_size;
244 int is[ndims], ie[ndims];
256 out = fopen(filename,
"wb");
258 fprintf(stderr,
"Error in WriteArrayParallel(): File %s could not be opened for writing.\n",filename);
263 out = fopen(filename,
"ab");
265 fprintf(stderr,
"Error in WriteArrayParallel(): File %s could not be opened for appending.\n",filename);
271 out = fopen(filename,
"wb");
273 fprintf(stderr,
"Error in WriteArrayParallel(): File %s could not be opened for writing.\n",filename);
280 bytes = fwrite(buffer,
sizeof(
double),(sizex+sizeu),out);
281 if (bytes != (sizex+sizeu)) {
282 fprintf(stderr,
"Error in WriteArrayParallel(): Failed to write data to file %s.\n",filename);
288 for (proc=mpi->
GroupStartRank+1; proc<mpi->GroupEndRank; proc++) {
292 write_size_x = 0;
for (d=0; d<ndims; d++) write_size_x += (ie[d]-is[d]);
293 write_size_u = nvars;
for (d=0; d<ndims; d++) write_size_u *= (ie[d]-is[d]);
294 write_total_size = write_size_x + write_size_u;
295 write_buffer = (
double*) calloc (write_total_size,
sizeof(
double));
297 MPI_Request req = MPI_REQUEST_NULL;
298 MPI_Irecv(write_buffer,write_total_size,MPI_DOUBLE,proc,1449,mpi->
world,&req);
299 MPI_Wait(&req,MPI_STATUS_IGNORE);
301 bytes = fwrite(write_buffer,
sizeof(
double),write_total_size,out);
302 if (bytes != write_total_size) {
303 fprintf(stderr,
"Error in WriteArrayParallel(): Failed to write data to file %s.\n",filename);
315 MPI_Request req = MPI_REQUEST_NULL;
316 MPI_Isend(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->
IORank,1449,mpi->
world,&req);
317 MPI_Wait(&req,MPI_STATUS_IGNORE);
MPI related function definitions.
Some basic definitions and macros.
char output_mode[_MAX_STRING_SIZE_]
int MPIGatherArraynD(int, void *, double *, double *, int *, int *, int, int)
Structure containing all solver-specific variables and functions.
#define _MAX_STRING_SIZE_
int MPIGatherArray1D(void *, double *, double *, int, int, int, int)
void MPIGetFilename(char *, void *, char *)
Contains structure definition for hypar.
char op_overwrite[_MAX_STRING_SIZE_]
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
char solnfilename_extn[_MAX_STRING_SIZE_]
#define _ArraySetValue_(x, size, value)
int MPILocalDomainLimits(int, int, void *, int *, int *, int *)
int(* WriteOutput)(int, int, int *, double *, double *, char *, int *)
Structure of MPI-related variables.
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.
static int WriteArrayParallel(int, int, int *, int *, int, double *, double *, void *, void *, char *)
int WriteArray(int ndims, int nvars, int *dim_global, int *dim_local, int ghosts, double *x, double *u, void *s, void *m, char *fname_root)
static int WriteArraySerial(int, int, int *, int *, int, double *, double *, void *, void *, char *)