-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoutput.cpp
108 lines (100 loc) · 2.55 KB
/
output.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "fdtd.h"
using namespace std;
void output_gather()
{
int it;
FILE *fp;
char filename[30];
char dir[MAX_NAME_LEN] = "./";
sprintf(filename, "gather_%02d.dat", myRank);
fp=fopen(strcat(dir, filename), "w+");
//ofstream fout("./gather.dat");
if(fp==NULL)
{
printf("File open error in output_gather!");
exit(1);
}
for(ii=0; ii<nrec; ++ii)
{
for(it=0; it<nt; ++it)
{
fprintf(fp, "%e ", gather(ii,it));
}
fprintf(fp, "\n");
}
fclose(fp);
}
void output_slice(int it,double *EH_total)
{
char xfilename[30],yfilename[30],zfilename[30];
char xdir[MAX_NAME_LEN] = "./Output/";
char ydir[MAX_NAME_LEN] = "./Output/";
char zdir[MAX_NAME_LEN] = "./Output/";
sprintf(xfilename, "xSlice%05d_%d.dat", it,NUM_OF_PROCESS);
sprintf(yfilename, "ySlice%05d_%d.dat", it,NUM_OF_PROCESS);
sprintf(zfilename, "zSlice%05d_%d.dat", it,NUM_OF_PROCESS);
//ofstream fout(filename);
FILE *fp;
fp=fopen(strcat(xdir, xfilename), "w+");
//fp=fopen(xfilename, "w+");
if(fp==NULL)
{
printf("File open error in output_slice!");
exit(1);
}
if(nxslice != 0){
for(i=0;i<nxslice;++i){
for(j=0;j<ny;++j){
for(k=0;k<nz;++k){
fprintf(fp, "%e ", EH_total(slicex[i]+order,j,k));
}}}}
fclose(fp);
fp=fopen(strcat(ydir, yfilename), "w+");
if(fp==NULL)
{
printf("File open error");
}
if(nyslice !=0){
for(j=0;j<nyslice;++j){
for(i=0;i<nx;++i){
for(k=0;k<nz;++k){
fprintf(fp, "%e ", EH_total(i+order,slicey[j],k));
}}}}
fclose(fp);
fp=fopen(strcat(zdir, zfilename), "w+");
if(fp==NULL)
{
printf("File open error");
}
if(nzslice != 0){
for(k=0;k<nzslice;++k){
for(i=0;i<nx;++i){
for(j=0;j<ny;++j){
fprintf(fp, "%e ", EH_total(i+order,j,slicez[k]));
}}}}
fclose(fp);
}
void output_wavefield(int it)
{
char filename[30];
char dir[MAX_NAME_LEN] = "./Output/";
sprintf(filename, "Wavefield%05d.dat", it);
FILE *fp;
fp=fopen(strcat(dir,filename), "w+");
if(fp==NULL)
{
printf("File open error in output_wavefield!");
exit(1);
}
for(i=0;i<nx;i+=output_step_x_of_wavefield)
{
for(j=0;j<ny;j+=output_step_x_of_wavefield)
{
for(k=0;k<nz;k+=output_step_x_of_wavefield)
{
fprintf(fp, "%e ", Ex(i,j,k));
}
}
}
fclose(fp);
}