PLUTO
write_tab.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Write tabulated 1D or 2D ascii data files.
5 
6  WriteTabArray() provides ascii output for 2-D and 1-D data
7  in tabulated multi-column format:
8  \verbatim
9  . . . . .
10  . . . . .
11  . . . . .
12  x1(i) x2(j) var_1(i,j) var_2(i,j) var_3(i,j) ...
13  . . . . .
14  . . . . .
15  . . . . .
16  \endverbatim
17 
18  Blocks with different x2 coordinates are separated by a blank row
19  (in more than 1D).
20  One file (with all variables) per output is written to disk.
21  This format does not work in parallel mode and can be used for simple
22  serial runs.
23 
24  \author A. Mignone (mignone@ph.unito.it)
25  \date June 27, 2014
26 */
27 /* ///////////////////////////////////////////////////////////////////// */
28 #include "pluto.h"
29 
30 /* ********************************************************************* */
31 void WriteTabArray (Output *output, char *filename, Grid *grid)
32 /*!
33  * Write tabulated array.
34  *
35  * \param [in] output a pointer to the output structure corresponding
36  * to the tab format
37  * \param [in] filename the output file name
38  * \param [in] grid pointer to an array of Grid structures
39  *********************************************************************** */
40 {
41  int nv, i, j, k;
42  FILE *fout;
43 
44  #ifdef PARALLEL
45  print1 ("! WriteTabArray: tab output not supported in parallel\n");
46  return;
47  #endif
48 
49  #if DIMENSIONS == 3
50  print1 ("! WriteTabArray: tab output not supported in 3D\n");
51  return;
52  #endif
53 
54 /* ------------------------------------------
55  dump arrays in ascii format to disk
56  ------------------------------------------ */
57 
58  fout = fopen (filename, "w");
59  k = 0;
60  IDOM_LOOP (i){
61  JDOM_LOOP(j){
62  fprintf (fout, "%f %f ", grid[IDIR].x[i], grid[JDIR].x[j]);
63  for (nv = 0; nv < output->nvar; nv++) {
64  if (output->dump_var[nv])
65  fprintf (fout, "%12.6e ", output->V[nv][k][j][i]);
66  }
67  fprintf (fout, "\n"); /* newline */
68  }
69  #if DIMENSIONS > 1
70  fprintf (fout, "\n"); /* skip one more empty line in 2D */
71  #endif
72  }
73  fclose (fout);
74 }
void WriteTabArray(Output *output, char *filename, Grid *grid)
Definition: write_tab.c:31
double *** V[64]
pointer to arrays being written - same for all
Definition: structs.h:247
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
#define JDOM_LOOP(j)
Definition: macros.h:35
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int nvar
tot.
Definition: structs.h:234
int * dump_var
select vars being written - one per output
Definition: structs.h:240
PLUTO main header file.
int i
Definition: analysis.c:2
#define JDIR
Definition: pluto.h:194
#define IDOM_LOOP(i)
Definition: macros.h:34