/* * *************************************************************************** * Routine: Vmp_size * * Purpose: Return the number of processors involved. * * Author: Michael Holst * *************************************************************************** */ VPUBLIC int Vmp_size(Vmp *thee) { # if defined(USE_VCOM) return Vcom_size( (Vcom*)thee ); # else return Vmpi_size( (Vmpi*)thee ); # endif }
void apbsinitial_(int dime[3], double grid[3], double gcent[3], double cgrid[3], double cgcent[3], double fgrid[3], double fgcent[3], double *pdie, double *sdie, double *srad, double *swin, double *sdens, double *kelvin, int *ionn, double ionc[maxion], int ionq[maxion], double ionr[maxion], char *pbtypef, int *pbtypelen, char *pbsolnf, int *pbsolnlen, char *bcflf, int *bcfllen, char *chgmf, int *chgmlen, char *srfmf, int *srfmlen, int fortranAppendedPbtypeLen, int fortranAppendedPbsolnLen, int fortranAppendedBfclLen, int fortranAppendedChgmLen, int fortranAppendedSrfmLen) { /* All character strings passed from FORTRAN result in an integer appended to the list of arguments, each equal to the static length specified in the TINKER common block 'pb.i' (20). Further below the FORTRAN strings will be converted into null terminated C-strings. */ char pbtype[21]; // lpbe char pbsoln[21]; // mg-manual or mg-auto char bcfl[21]; // zero, sdh, mdh char chgm[21]; // spl4 char srfm[21]; // mol, smol, spl2 /* Bogus argc and argv variables used for Vcom constructor. */ int argc = 0; char **argv; /* CPU info */ int rank, size; /* APBS "input file" is a character buffer */ char buff[4096]; char tmp[1024]; /* Loop index */ int i; /* Start the timer - although keep in mind it is not stopped until apbsfinal is called. */ Vnm_tstart(APBS_TIMER_WALL_CLOCK, "APBS WALL CLOCK"); /* Convert FORTRAN strings to null-terminated C-String */ strncpy(pbtype, pbtypef, *pbtypelen); strncpy(pbsoln, pbsolnf, *pbsolnlen); strncpy(bcfl, bcflf, *bcfllen); strncpy(chgm, chgmf, *chgmlen); strncpy(srfm, srfmf, *srfmlen); pbtype[*pbtypelen] = '\0'; pbsoln[*pbsolnlen] = '\0'; bcfl[*bcfllen] = '\0'; chgm[*chgmlen] = '\0'; srfm[*srfmlen] = '\0'; /* Rather than require an APBS input file, a character buffer is loaded with two ELEC statements: (1) The homogeneous calculation. (2) The solvated calculation. Many options for partial charge systems are not yet supported for AMOEBA (or are not appropriate). The subset of ELEC options that can be modified are configured using TINKER keywords. Initialization of the "nosh" input data structure then proceeds using the buffer data. If the syntax of the ELEC statement changes, then corresponding changes will be needed to be made below. */ /* Homogeneous */ strcpy(buff,"ELEC NAME HOMOGENEOUS\n"); sprintf(tmp,"\t%s\n",pbsoln); strcat(buff,tmp); sprintf(tmp,"\t%s\n",pbtype); strcat(buff,tmp); sprintf(tmp,"\tDIME\t%3i %3i %3i\n",dime[0],dime[1],dime[2]); strcat(buff,tmp); // MG-AUTO if (strcmp(pbsoln,"MG-AUTO") == 0) { sprintf(tmp,"\tCGLEN %10.6f %10.6f %10.6f\n", dime[0]*cgrid[0], dime[1]*cgrid[1], dime[2]*cgrid[2]); strcat(buff,tmp); sprintf(tmp,"\tCGCENT %10.6f %10.6f %10.6f\n", cgcent[0], cgcent[1],cgcent[2]); strcat(buff,tmp); sprintf(tmp,"\tFGLEN %10.6f %10.6f %10.6f\n", dime[0]*fgrid[0], dime[1]*fgrid[1], dime[2]*fgrid[2]); strcat(buff,tmp); sprintf(tmp,"\tFGCENT %10.6f %10.6f %10.6f\n", fgcent[0], fgcent[1], fgcent[2]); strcat(buff,tmp); } else { // MG-MANUAL sprintf(tmp,"\tGLEN %10.6f %10.6f %10.6f\n", dime[0]*grid[0], dime[1]*grid[1], dime[2]*grid[2]); strcat(buff,tmp); sprintf(tmp,"\tGCENT %10.6f %10.6f %10.6f\n", gcent[0], gcent[1], gcent[2]); strcat(buff,tmp); } strcat(buff,"\tMOL\t1\n"); sprintf(tmp,"\tBCFL\t%s\n", bcfl); strcat(buff,tmp); sprintf(tmp,"\tPDIE %10.6f\n", *pdie); strcat(buff,tmp); sprintf(tmp,"\tSDIE %10.6f\n", *pdie); strcat(buff,tmp); sprintf(tmp,"\tCHGM\t%s\n", chgm); strcat(buff,tmp); sprintf(tmp,"\tSRFM\t%s\n", srfm); strcat(buff,tmp); sprintf(tmp,"\tSRAD %10.6f\n", *srad); strcat(buff,tmp); sprintf(tmp,"\tSWIN %10.6f\n", *swin); strcat(buff,tmp); sprintf(tmp,"\tSDENS %10.6f\n", *sdens); strcat(buff,tmp); sprintf(tmp,"\tTEMP %10.6f\n", *kelvin); strcat(buff,tmp); strcat(buff,"END\n\n"); /* Solvated */ strcat(buff,"ELEC NAME SOLVATED\n"); sprintf(tmp,"\t%s\n",pbsoln); strcat(buff,tmp); sprintf(tmp,"\t%s\n",pbtype); strcat(buff,tmp); sprintf(tmp,"\tDIME\t%3i %3i %3i\n",dime[0],dime[1],dime[2]); strcat(buff,tmp); // MG-AUTO if (strcmp(pbsoln,"MG-AUTO") == 0) { sprintf(tmp,"\tCGLEN %10.6f %10.6f %10.6f\n", dime[0]*cgrid[0], dime[1]*cgrid[1], dime[2]*cgrid[2]); strcat(buff,tmp); sprintf(tmp,"\tCGCENT %10.6f %10.6f %10.6f\n", cgcent[0], cgcent[1], cgcent[2]); strcat(buff,tmp); sprintf(tmp,"\tFGLEN %10.6f %10.6f %10.6f\n", dime[0]*fgrid[0], dime[1]*fgrid[1], dime[2]*fgrid[2]); strcat(buff,tmp); sprintf(tmp,"\tFGCENT %10.6f %10.6f %10.6f\n", fgcent[0], fgcent[1], fgcent[2]); strcat(buff,tmp); } else { // MG-MANUAL sprintf(tmp,"\tGLEN %10.6f %10.6f %10.6f\n", dime[0]*grid[0], dime[1]*grid[1], dime[2]*grid[2]); strcat(buff,tmp); sprintf(tmp,"\tGCENT %10.6f %10.6f %10.6f\n", gcent[0], gcent[1], gcent[2]); strcat(buff,tmp); } strcat(buff,"\tMOL\t1\n"); sprintf(tmp,"\tBCFL\t%s\n", bcfl); strcat(buff,tmp); sprintf(tmp,"\tPDIE %10.6f\n", *pdie); strcat(buff,tmp); sprintf(tmp,"\tSDIE %10.6f\n", *sdie); strcat(buff,tmp); sprintf(tmp,"\tCHGM\t%s\n", chgm); strcat(buff,tmp); sprintf(tmp,"\tSRFM\t%s\n", srfm); strcat(buff,tmp); sprintf(tmp,"\tSRAD %10.6f\n", *srad); strcat(buff,tmp); sprintf(tmp,"\tSWIN %10.6f\n", *swin); strcat(buff,tmp); sprintf(tmp,"\tSDENS %10.6f\n", *sdens); strcat(buff,tmp); sprintf(tmp,"\tTEMP %10.6f\n", *kelvin); strcat(buff,tmp); for (i=0; i < *ionn; i++) { sprintf(tmp,"\tION\t%2i %10.6f %10.6f\n", ionq[i], ionc[i], ionr[i]); strcat(buff,tmp); } strcat(buff,"END\n"); strcat(buff,"\nQUIT\n"); /* Misc. initializations */ for (i=0; i<NOSH_MAXMOL; i++) { alist[i] = VNULL; dielXMap[i] = VNULL; dielYMap[i] = VNULL; dielZMap[i] = VNULL; kappaMap[i] = VNULL; potMap[i] = VNULL; chargeMap[i] = VNULL; } for (i=0; i<2; i++) { permU[i] = VNULL; indU[i] = VNULL; nlIndU[i] = VNULL; } /* Initialization of Vcom, Vmem, and Nosh (via Vio). */ VASSERT(Vcom_init(&argc, &argv)); com = Vcom_ctor(1); rank = Vcom_rank(com); size = Vcom_size(com); startVio(); Vnm_setIoTag(rank, size); mem = Vmem_ctor("MAIN"); /* Print (to io.mc) and then parse the input buffer. */ Vnm_tprint(0, "\n********* TINKER generated input buffer *********\n\n"); Vnm_tprint(0, "%s", buff); Vnm_tprint(0, "\n*************************************************\n\n"); nosh = NOsh_ctor(rank, size); sock = Vio_ctor("BUFF", "ASC", VNULL, "BUFFER", "r"); Vio_bufTake(sock, buff, strlen(buff)); if (!NOsh_parseInput(nosh, sock)) { Vnm_tprint( 2, "Error while parsing input file.\n"); return; } /* Release the buffer and kill Vio */ Vio_bufGive(sock); Vio_dtor(&sock); }
int main(int argc, char *argv[]) { int i, testi, testj; int myrank; int nproc; char string[100]; Vcom *vcom; VASSERT( Vcom_init(&argc,&argv) ); vcom = Vcom_ctor(1); myrank = Vcom_rank(vcom); nproc = Vcom_size(vcom); printf("PE %d: Starting test program with %d total PEs.\n",myrank,nproc); /* Character send/recv test */ if (myrank == 0) { printf("\n\nPE %d: STARTING SEND/RECV TEST.\n",myrank); printf("PE %d: Sending non-blocked messages.\n",myrank); for (i=1; i<nproc; i++) { sprintf(&(string[0]), "non-blocked message (PE %d --> %d)", myrank, i); printf( "PE %d: Sent non-blocked message to PE %d\n", myrank, i); assert(Vcom_send(vcom,i,string,100,3,0)); } printf("PE %d: Sending blocked messages.\n",myrank); for (i=1; i<nproc; i++) { sprintf(&(string[0]),"blocked message (PE %d --> %d)",i,nproc); printf( "PE %d: Sent blocked message to PE %d\n", myrank, i); assert(Vcom_send(vcom,i,string,100,3,1)); } } else { printf("PE %d: Recving blocked message from PE 0.\n",myrank); /* Get blocked sent messages */ assert(Vcom_recv(vcom,0,string,100,3,1)); printf( "PE %d: Blocked message is: '%s'\n",myrank,string); /* Get blocked sent messages */ printf("PE %d: Recving non-blocked message from PE 0.\n",myrank); assert(Vcom_recv(vcom,0,string,100,3,1)); printf( "PE %d: Non-blocked message is: '%s'\n",myrank,string); } fflush(stdout); Vcom_barr(vcom); /* Barrier test */ if (myrank == 0) printf("\n\nPE %d: STARTING BARRIER TEST.\n",myrank); printf("PE %d: Hit barrier\n", myrank); Vcom_barr(vcom); printf("PE %d: Passed barrier\n", myrank); fflush(stdout); Vcom_barr(vcom); /* getCount test */ if (myrank == 0) { printf("\n\nPE %d: STARTING PROBE TEST.\n",myrank); printf("PE %d: Sending string of length 100\n", myrank); for (i=1; i<nproc; i++) assert(Vcom_send(vcom,i,string,100,3,0)); } else { Vcom_getCount(vcom, 0, &testi, 3); printf("PE %d: Probed for string of length %d\n", myrank, testi); } fflush(stdout); Vcom_barr(vcom); /* Reduction test */ testi = 4; if (myrank == 0) { printf("\n\nPE %d: STARTING REDUCTION TEST.\n",myrank); printf("PE %d: All %d PEs have the number %d.\n", myrank, nproc, testi); printf("PE %d: Performing global sum reduction.\n", myrank); } Vcom_reduce(vcom, &testi, &testj, 1, 1, 0); printf("PE %d: Global sum = %d\n", myrank, testj); fflush(stdout); Vcom_barr(vcom); testi = 4; if (myrank == 0) { testj = 8; printf("PE %d: PE %d has the number %d; all others have %d.\n", myrank, myrank, testj, testi); testi = testj; printf("PE %d: Performing global max reduction.\n", myrank); } Vcom_reduce(vcom, &testi, &testj, 1, 1, 3); printf("PE %d: Global max = %d\n", myrank, testj); fflush(stdout); Vcom_barr(vcom); /* Resize the communicator */ printf("PE %d: Resizing communicator from %d to %d.\n", myrank, nproc, (int)(nproc/2)); Vcom_resize(vcom, (int)(nproc/2)); myrank = Vcom_rank(vcom); if (Vcom_rank(vcom) != -1) printf("PE %d: Hello world from resized communicator\n", myrank); Vcom_barr(vcom); /* Finish up */ printf("PE %d: Exiting test program.\n",myrank); fflush(stdout); Vcom_dtor(&vcom); VASSERT( Vcom_finalize() ); return 0; }