⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tracet.c

📁 Parallel programming/Lou Baker, Bradley J.Smith .—New York:McGraw-Hill Book Co.
💻 C
字号:
/* Main program for parallel version of SPH */

/* modified into a testbed for trace(PICL)

L. Baker Dagonet Software
Copyright 1993 L. Baker

*/

#define TESTMPI

#include "all.h"

#ifdef TESTMPI
void TestMPI(int argc,char **argv);
#endif


void sigcatch(int signo)
{
char msg[80];
sprintf(msg,"Signal %d caughtRank %d\n",signo,Rank);
ReportError(msg,TRUE);
}


int
main(int argc,char **argv)
{
 Problem prob;


/* MPI test program */
#ifdef TESTMPI
 TestMPI(argc,argv);
 Exit(0);
 return(0);
#else /* TESTMPI */


 /* Initialize the MPI message system and variables */
 InitMPISystem(argc, argv);
 signal(SIGINT, sigcatch);
 signal(SIGQUIT,sigcatch);
 signal(SIGFPE,sigcatch);
 signal(SIGABRT,sigcatch);
 signal(SIGHUP,sigcatch);
 signal(SIGEGV,sigcatch);
 signal(SIGSYS,sigcatch);
 /* Initilize basic variables */
 if(!InitProblem(&prob))
 	Exit(0);
#ifdef NOTDONE

traceenable( "/home/baker/trace.out",1);

 /* Create particles */
 if(!GenParticles(&prob))
	Exit(0);

 /* Run the required problem */
 Run(&prob);

 /* Clean up */
 DeleteProblem(&prob);

#endif /* NOTDONE */
 Debug("Exiting PSPH Normally\n");
 Exit(0);
 traceclose();
 return(0);

#endif /* NOT TESTMPI */
}

void
Run(PProblem prob)
 {
 }


#ifdef TESTMPI
void
TestMPI(int argc, char **argv)
{
 int n,rank,i;
 MPI_Comm comm;
 float out,in;

 comm = MPI_COMM_WORLD;
/*
 MPI_Init(argc,argv);
 MPI_Comm_size(comm, &n);
 MPI_Comm_rank(comm, &rank);
 */
 InitMPISystem(argc,argv);/* like above but sets Rank,NProc, AllDest*/
 n=NProc;
 rank=Rank;

 Debug("PVM Initialized rank=%d\n",rank);
 traceenable( "trace.out",1);
 Debug(" traceenable returned\n");
 if(rank)tracenode(20,1,0); 
 else tracenode(20,1,0);
 Debug(" tracenode returned rank=%d\n",rank);
 in = (float) rank+ 1.0;
 Debug(" before reduce MIN rank=%d\n",rank);
 MPI_Reduce(&in, &out, 1, MPI_FLOAT, MPI_MIN, 0, comm); 
 Debug(" after reduce MIN rank=%d\n",rank);
 if(rank == 0)
	Debug("MIN of float ranks is %f\n", out);

 MPI_Reduce(&in, &out, 1, MPI_FLOAT, MPI_MAX, 0, comm); 
 if(rank == 0)
	Debug("MAX of float ranks is %f\n", out);
 
 MPI_Reduce(&in, &out, 1, MPI_FLOAT, MPI_SUM, 0, comm); 
 if(rank == 0)
	Debug("SUM of float ranks is %f\n", out);

 MPI_Reduce(&in, &out, 1, MPI_FLOAT, MPI_PROD, 0, comm); 
 if(rank == 0)
	Debug("PROD of float ranks is %f\n", out);
 Debug(" before BARRIER rank=%d\n",rank);
 MPI_Barrier(comm);
 Debug("Exiting psph\n");

 traceexit();
 Exit(0);
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -