#include #include "include.h" #include "run.h" #include "usempi.h" /* this is for the prototypes in this file */ #if !ONE_PROCESSOR_SPECTRUM #define MS_PRINT 0 /* flag to print out debugging information to files */ #define PRINTSLAVE 0 /* print statements associated with slaves */ #define PRINTMASTER 0 /* print statements associated with master */ static MPI_Datatype mpisectors; void slave(void) { integer nfig=EDIGITS; /* number of significant digits in eigenvalues */ static sectors x, y; int nvals, globalkt, my_id, death=1; element *val, *vec, couplings[NPARAMS], angle[HINDEX+2]; #if 0 size_t gmb; int gme; #endif #if MS_PRINT FILE *fp; char out[10]; int i, j; #endif MPI_Comm_rank(MPI_COMM_WORLD,&my_id); #if MS_PRINT /* open debugging file with name based on rank */ sprintf(out,"p%i.tmp",my_id); if((fp = fopen(out,"w")) == NULL) { fprintf(stderr,"Can't open file %s in pusempi.c, exiting\n",out); goto error; } #endif /* on CRAY, be more carefull about memory management. */ #ifdef _CRAY mallopt(M_LOWFIT,1); #endif /* Main loop of program */ for(;;) { MPI_Barrier(MPI_COMM_WORLD); MPI_Bcast(&death, 1, MPI_INT, MASTER, MPI_COMM_WORLD); /* Stop program */ if(death==0) goto exit; /* Receive coupling constants and global kt. */ else { MPI_Bcast(couplings, NPARAMS, MPI_DOUBLE, MASTER, MPI_COMM_WORLD); MPI_Bcast(&globalkt, 1, MPI_INT, MASTER, MPI_COMM_WORLD); #if MS_PRINT /* diagnostic print to debugging file*/ fprintf(fp,"couplings= "); for(i=0; i1||x.o<-1||x.o>1 || y.cyclic<0||y.cyclic>1||y.o<-1||y.o>1) { fprintf(stderr,"error in values sent, exiting\n"); goto error; } #endif /* construct one or two bases. The order for makebasis() and rebasis() is important for memory fragmentation problems on the CRAY. mapcouplings should have already been run. */ /* Now calculate the actual spectrum */ #if PRINTSLAVE printf("\n%d Slaves -- Going into spectrum2\n", my_id); #endif spectrum2(&x, &y, &val, &vec, nvals, couplings, angle, globalkt, nfig); #if PRINTSLAVE printf("\n%d Slaves -- returning from spectrum2\n", my_id); #endif if(val==NULL) { fprintf(stderr,"slave() %i detecting an error in spectrum()\n", my_id); goto error; } /* Now, for the J^++ sector, we need to order the 0++* and 2++ according to particle number content */ shuffle(&x, &y, vec, val, nvals); #if MS_PRINT /* diagnositic print */ fprintf(fp," values: "); for(i=0; i