📄 display.c
字号:
/*-----------------------------------------
Display the Value of Field Component
--- Implemented by Calling GNUPLOT
-------------------------------------------
*/
# include "Display.h"
void Display_Data(MODULE *pModule,int time, double ****Ez)
{
int i,j,N_R_Time;
int NEzx,NEzy,NEzz;
int fda[2];
double tmp;
FILE *fp;
NEzx=Nx+1; NEzy=Ny+1; NEzz=Nz;
N_R_Time=time%20;
if(N_R_Time!=0) return;
if(pipe(fda)==-1)
{
printf("Creating Pipe error \n");
exit(-1);
}
switch(fork())
{
case -1:
printf("Forking Child Process error \n");
exit(-1);
break;
case 0: /* child process */
close(fda[1]);
fp=fopen("1.dat","w+");
for(i=0; i<NEzx; i++)
{
for(j=0; j<NEzy; j++)
{
read(fda[0],&tmp,sizeof(double));
fprintf(fp,"%d\t%d\t%lf\n",i,j,tmp);
}
fprintf(fp,"\n");
}
fclose(fp);
close(fda[0]);
execlp("gnuplot","gnuplot","1.dem",0);
break;
default: /* Parent process */
close(fda[0]);
for(i=0;i<NEzx; i++)
{
for(j=0; j<NEzy; j++)
{
write(fda[1],&Ez[0][i][j][1],sizeof(double));
}
}
close(fda[1]);
signal(SIGCHLD,SIG_IGN);
wait(-1);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -