📄 mdump.c
字号:
/* PSPH Parallel SPH Program
* Bradley Smith, and Lou Baker, Dagonet Software
* dump.c: routines for processing dumpfiles
* ReadSPHDumpFile the opposite of WriteSPHDumpFile in io.c
* may be used with restart or with loading of file to transmit data
*
* use PVM to read dumpfile and send across network
*
*/
/* static char sccs_id[]="%Z% %P% %I% %D%"; */
#define DEBUG
#include "all.h"
/* ultimately, move below to tag.h! */
#define DUMP_CSPTAG (TAG_BASE + 17)
#define DUMP_FSPTAG (TAG_BASE + 18)
#define DUMP_ISPTAG (TAG_BASE + 19)
#define DUMP_CMATTAG (TAG_BASE + 20)
#define DUMP_IMATTAG (TAG_BASE + 21)
extern int *PVM_tid;
/* MASTER */
FILE *fn;
#ifdef DEBUG
FILE *diagn;
#endif
main(int argc,char **argv)
{
int From, numt,mytid,flag;
char **sargv,where[20],direction, name[20];
if(argc <4)
{
fprintf(stdout," usage: mdump fromfilename where tofilename [r|s]\n");
exit(0);
}
#ifdef DEBUG
diagn=fopen("master.dia","w");
fprintf(diagn," master starting\n");
printf(" direction=%s where=%s ffilename=%s\n",argv[4],argv[2],argv[1]);
#endif
flag=1;/* specific host*/
strncpy(where,argv[2],20);
if(strlen(where)<=0) flag=0;
/* above defaults to "most appropriate" host for spawn
this will NOT in general be useful
*/
strncpy(name,"sdump",20);
sargv = (char **)malloc( 4* sizeof( char *));
sargv[0]=(argv[1]);
sargv[1]="s";/*default*/
sargv[2]=NULL;
direction = *(argv[4]);
if(direction == 'r')
{/*get other guy to send */
#ifdef DEBUG
printf(" master receiving\n");
#endif
numt=PVM_GInit(name,sargv,flag,where,2);
/*numt=pvm_spawn("sdump",sargv,flag,where,1,&tids);*/
#ifdef DEBUG
printf(" master after PVM_GInit=%d %d %d\n",numt, PVM_tid[0],PVM_tid[1]);
#endif
/*From=PVM_tid[1]; slave tid */
From=1;/* From=1 used to look up PVM_tid[From] by SendBuf/RevBuf*/
printf(" tid of spawned task %d\n",From);
if((fn=fopen(argv[3],"wb"))==NULL)
{fprintf(stderr," cant open output dump file %s\n",argv[3]);exit(0);}
RecvDumpFile(fn, From);
}
else
{/* get other guy to receive */
#ifdef DEBUG
printf(" master sending spawning=%s at %s flag%d\n", name,where,flag);
#endif
sargv[0]=(argv[3]);/* needs to know name of file to create*/
sargv[1]="r";
numt=PVM_GInit(name,sargv,flag,where,2);
/*numt=pvm_spawn("sdump",sargv,flag,where,1,&tids);*/
#ifdef DEBUG
printf(" master after PVM_GInit=%d %d %d\n",numt, PVM_tid[0],PVM_tid[1]);
#endif
From=1;
printf(" tid of spawned task=%d\n",From);
if((fn=fopen(argv[1],"r"))==NULL)
{fprintf(stderr," cant open dump file %s to send\n",argv[1]);exit(0);}
SendDumpFile(fn, From);
}
fclose(fn);
pvm_exit();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -