42 char filename[512], sline[512];
43 static int last_computed_var = -1;
57 print1 (
"> Writing file #%d (%s) to disk...", output->
nfile, output->
ext);
60 MPI_Barrier (MPI_COMM_WORLD);
61 if (
prank == 0) time(&tbeg);
101 single_file = strcmp(output->
mode,
"single_file") == 0;
102 dsize =
sizeof(double);
106 sprintf (filename,
"%s/data.%04d.%s", output->
dir,output->
nfile,
112 for (nv = 0; nv < output->
nvar; nv++) {
113 if (!output->
dump_var[nv])
continue;
117 Vpt = (
void *)output->
V[nv][0][0];
118 }
else if (output->
stag_var[nv] == 0) {
120 Vpt = (
void *)(output->
V[nv][0][0]-1);
121 }
else if (output->
stag_var[nv] == 1) {
123 Vpt = (
void *)output->
V[nv][0][-1];
124 }
else if (output->
stag_var[nv] == 2) {
126 Vpt = (
void *)output->
V[nv][-1][0];
144 for (nv = 0; nv < output->
nvar; nv++) {
145 if (!output->
dump_var[nv])
continue;
146 sprintf (filename,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
151 Vpt = (
void *)output->
V[nv][0][0];
152 }
else if (output->
stag_var[nv] == 0) {
154 Vpt = (
void *)(output->
V[nv][0][0]-1);
155 }
else if (output->
stag_var[nv] == 1) {
157 Vpt = (
void *)output->
V[nv][0][-1];
158 }
else if (output->
stag_var[nv] == 2) {
160 Vpt = (
void *)output->
V[nv][-1][0];
174 single_file = strcmp(output->
mode,
"single_file") == 0;
177 sprintf (filename,
"%s/data.%04d.%s", output->
dir, output->
nfile,
180 for (nv = 0; nv < output->
nvar; nv++) {
181 if (!output->
dump_var[nv])
continue;
184 Vpt = (
void *)Vpt3[0][0];
194 for (nv = 0; nv < output->
nvar; nv++) {
195 if (!output->
dump_var[nv])
continue;
196 sprintf (filename,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
202 Vpt = (
void *)Vpt3[0][0];
219 print1 (
"! WriteData: HDF5 library not available\n");
233 single_file = strcmp(output->
mode,
"single_file") == 0;
234 sprintf (filename,
"%s/data.%04d.%s", output->
dir, output->
nfile,
241 for (nv = 0; nv < output->
nvar; nv++) {
254 for (nv = 0; nv < output->
nvar; nv++) {
263 for (nv = 0; nv < output->
nvar; nv++) {
265 if (strcmp(output->
var_name[nv],
"vx1") == 0) {
266 sprintf (filename,
"%s/vfield.%04d.%s", output->
dir, output->
nfile,
268 }
else if (strcmp(output->
var_name[nv],
"bx1") == 0) {
269 sprintf (filename,
"%s/bfield.%04d.%s", output->
dir, output->
nfile,
272 print1 (
"! WriteData: unknown vector type in VTK output\n");
283 for (nv = 0; nv < output->
nvar; nv++) {
285 sprintf (filename,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
308 sprintf (filename,
"%s/data.%04d.%s", output->
dir, output->
nfile,
319 for (nv = 0; nv < output->
nvar; nv++) {
320 if (!output->
dump_var[nv])
continue;
321 sprintf (filename,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
334 for (nv = 0; nv < output->
nvar; nv++) {
335 if (!output->
dump_var[nv])
continue;
336 sprintf (filename,
"%s/%s.%04d.%s", output->
dir, output->
var_name[nv],
341 print1 (
"! PNG library not available\n");
351 sprintf (filename,
"%s/%s.out",output->
dir, output->
ext);
354 if (output->
nfile == 0) {
355 fout = fopen (filename,
"w");
357 fout = fopen (filename,
"r+");
358 for (nv = 0; nv < output->
nfile; nv++) fgets (sline, 512, fout);
359 fseek (fout, ftell(fout), SEEK_SET);
364 fprintf (fout,
"%d %12.6e %12.6e %ld ",
367 if (single_file) fprintf (fout,
"single_file ");
368 else fprintf (fout,
"multiple_files ");
371 else fprintf (fout,
"big ");
373 for (nv = 0; nv < output->
nvar; nv++) {
382 MPI_Barrier (MPI_COMM_WORLD);
385 print1 (
" [%5.2f sec]",difftime(tend,tbeg));
393 static float ****Vflt;
394 static int perf_output[16] = {0};
396 void Async_BegWriteData (
const Data *d,
Output *output,
Grid *grid)
411 static int last_computed_var = -1;
418 print1 (
"> Writing file #%d (%s) to disk [async: beg]...\n",
435 dsize =
sizeof(double);
438 dsize =
sizeof(float);
442 sprintf (filename,
"%s/data.%04d.%s", output->
dir, output->
nfile,
448 if (dsize ==
sizeof(
double)){
452 if (dsize ==
sizeof(
float)){
459 for (nv = 0; nv < output->
nvar; nv++){
460 DOM_LOOP(k,j,i) Vflt[nv][k][j][i] = (
float)output->V[nv][k][j][i];
463 output->stag_var, output->dump_var, output->nvar);
468 void Async_EndWriteData (
Runtime *ini)
480 char filename[128], sline[512];
486 output = ini->output + 0;
487 print1 (
"> Writing file #%d (%s) to disk [async: end]...\n",
492 sprintf (filename,
"%s.out",output->
ext);
494 if (output->
nfile == 0) {
495 fout = fopen (filename,
"w");
497 fout = fopen (filename,
"r+");
498 for (nv = 0; nv < output->
nfile; nv++) fgets (sline, 512, fout);
499 fseek (fout, ftell(fout), SEEK_SET);
503 fprintf (fout,
"%d %8.3e %8.3e %ld ", output->
nfile,
g_time,
505 fprintf (fout,
"single_file ");
508 else fprintf (fout,
"big ");
510 for (nv = 0; nv < output->
nvar; nv++) {
519 output =ini->output + 1;
520 print1 (
"> Writing file #%d (%s) to disk [async: end]...\n",
526 sprintf (filename,
"%s.out",output->
ext);
528 if (output->
nfile == 0) {
529 fout = fopen (filename,
"w");
531 fout = fopen (filename,
"r+");
532 for (nv = 0; nv < output->
nfile; nv++) fgets (sline, 512, fout);
533 fseek (fout, ftell(fout), SEEK_SET);
537 fprintf (fout,
"%d %8.3e %8.3e %ld ",
539 fprintf (fout,
"single_file ");
542 else fprintf (fout,
"big ");
544 for (nv = 0; nv < output->
nvar; nv++) {
572 #if PHYSICS == RHD || PHYSICS == RMHD
577 EXPAND(u[
VX1] = unit_velocity; ,
578 u[
VX2] = unit_velocity; ,
579 u[
VX3] = unit_velocity;)
581 EXPAND(u[
BX1] = unit_mag; ,
586 u[PRS] = unit_pressure;
596 if (
prank != 0)
return;
601 for (nv = 0; nv < output->
nvar; nv++){
602 if (!output->
dump_var[nv])
continue;
606 sprintf (filename,
"data.%04d.bov",output->
nfile);
607 fp = fopen (filename,
"w");
608 fprintf (fp,
"TIME: %f\n",
g_time);
609 fprintf (fp,
"DATA_FILE: %s\n",fdata);
610 fprintf (fp,
"DATA_SIZE: %ld %ld %ld\n",
NX1,
NX2,
NX3);
611 fprintf (fp,
"DATA_FORMAT: FLOAT\n");
612 fprintf (fp,
"VARIABLE: Density\n");
613 fprintf (fp,
"DATA_ENDIAN: LITTLE\n");
614 fprintf (fp,
"CENETRING: zonal\n");
615 fprintf (fp,
"BRICK_ORIGIN: %f %f %f\n",
617 fprintf (fp,
"BRICK_SIZE: %f %f %f\n",
622 fprintf (fp,
"DATA_COMPONENTS: %d\n", 2);
void WritePNG(double ***, char *, char *, Grid *)
int AL_Write_array_begin(void *, int, int *, int *, int)
#define UNIT_DENSITY
Unit density in gr/cm^3.
double *** V[64]
pointer to arrays being written - same for all
long long AL_Get_offset(int sz_ptr)
long int NX1
Number of interior zones in the X1 directions (boundaries excluded) for the local processor...
void print1(const char *fmt,...)
FILE * OpenBinaryFile(char *filename, int sz, char *mode)
int nfile
current number being saved - one per output
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
void GetCGSUnits(double *u)
double g_dt
The current integration time step.
int AL_Set_offset(int sz_ptr, long long offset)
void WriteVTK_Scalar(FILE *, double ***, double, char *, Grid *)
void WriteHDF5(Output *output, Grid *grid)
char dir[256]
output directory name
#define CONST_c
Speed of Light.
void WriteVTK_Vector(FILE *, Data_Arr, double, char *, Grid *)
int AL_File_open(char *filename, int sz_ptr)
void WriteVTK_Header(FILE *, Grid *)
float *** Convert_dbl2flt(double ***Vdbl, double unit, int swap_endian)
int cgs
when set to 1 saves data in c.g.s units
char ext[8]
output extension
int AL_Write_array_end(void *, int)
void ComputeUserVar(const Data *, Grid *)
#define UNIT_VELOCITY
Unit velocity in cm/sec.
long int g_stepNumber
Gives the current integration step number.
long int NX2
Number of interior zones in the X2 directions (boundaries excluded) for the local processor...
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
void WritePPM(double ***, char *, char *, Grid *)
#define ARRAY_4D(nx, ny, nz, nv, type)
double g_domBeg[3]
Lower limits of the computational domain.
void WriteData(const Data *d, Output *output, Grid *grid)
int AL_File_close(int sz_ptr)
int * dump_var
select vars being written - one per output
double g_time
The current integration time.
char mode[32]
single or multiple files - one per output
int type
output format (DBL, FLT, ...) - one per output
int * stag_var
centered or staggered variable - same for all
static void BOV_Header(Output *output, char *fdata)
double g_domEnd[3]
Upper limits of the computational domain.
void WriteTabArray(Output *, char *, Grid *)
double **** Vuser
Array storing user-defined supplementary variables written to disk.
int CloseBinaryFile(FILE *fbin, int sz)
#define QUIT_PLUTO(e_code)
void WriteBinaryArray(void *V, size_t dsize, int sz, FILE *fl, int istag)
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
long int NX3
Number of interior zones in the X3 directions (boundaries excluded) for the local processor...
char ** var_name
variable names - same for all