HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WriteText.c
Go to the documentation of this file.
1 
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <basic.h>
9 #include <arrayfunctions.h>
10 
28  int ndims,
29  int nvars,
30  int *dim,
32  double *x,
34  double *u,
36  char *f,
37  int *index
38  )
39 {
40  FILE *out;
41  out = fopen(f,"w");
42  if (!out) {
43  fprintf(stderr,"Error: could not open %s for writing.\n",f);
44  return(1);
45  }
46 
47  int done = 0; _ArraySetValue_(index,ndims,0);
48  while (!done) {
49  int i, p;
50  _ArrayIndex1D_(ndims,dim,index,0,p);
51  for (i=0; i<ndims; i++) fprintf(out,"%4d ",index[i]);
52  for (i=0; i<ndims; i++) {
53  int j,offset = 0; for (j=0; j<i; j++) offset += dim[j];
54  fprintf(out,"%+1.16E ",x[offset+index[i]]);
55  }
56  for (i=0; i<nvars; i++) fprintf(out,"%+1.16E ",u[nvars*p+i]);
57  fprintf(out,"\n");
58  _ArrayIncrementIndex_(ndims,dim,index,done);
59  }
60  fclose(out);
61  return(0);
62 }
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Some basic definitions and macros.
int WriteText(int, int, int *, double *, double *, char *, int *)
Definition: WriteText.c:27
Contains macros and function definitions for common array operations.