git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11003 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
36
src/comm.cpp
36
src/comm.cpp
@ -1597,6 +1597,42 @@ int Comm::read_lines_from_file(FILE *fp, int nlines, int maxline, char *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
proc 0 reads Nlines from file into buf and bcasts buf to all procs
|
||||
caller allocates buf to max size needed
|
||||
each line is terminated by newline, even if last line in file is not
|
||||
return 0 if successful, 1 if get EOF error before read is complete
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int Comm::read_lines_from_file_universe(FILE *fp, int nlines, int maxline,
|
||||
char *buf)
|
||||
{
|
||||
int m;
|
||||
|
||||
int me_universe = universe->me;
|
||||
MPI_Comm uworld = universe->uworld;
|
||||
|
||||
if (me_universe == 0) {
|
||||
m = 0;
|
||||
for (int i = 0; i < nlines; i++) {
|
||||
if (!fgets(&buf[m],maxline,fp)) {
|
||||
m = 0;
|
||||
break;
|
||||
}
|
||||
m += strlen(&buf[m]);
|
||||
}
|
||||
if (m) {
|
||||
if (buf[m-1] != '\n') strcpy(&buf[m++],"\n");
|
||||
m++;
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Bcast(&m,1,MPI_INT,0,uworld);
|
||||
if (m == 0) return 1;
|
||||
MPI_Bcast(buf,m,MPI_CHAR,0,uworld);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
realloc the size of the send buffer as needed with BUFFACTOR and bufextra
|
||||
if flag = 1, realloc
|
||||
|
||||
Reference in New Issue
Block a user