forked from lijiext/lammps
come code cleanup and refactoring
This commit is contained in:
parent
02b800a3bb
commit
7a8bb5baaf
|
@ -81,8 +81,13 @@ void KimQuery::command(int narg, char **arg)
|
||||||
|
|
||||||
value = do_query(model, property, comm->me, world);
|
value = do_query(model, property, comm->me, world);
|
||||||
|
|
||||||
if (comm->me == 0)
|
// check for valid result
|
||||||
printf("property %s for model %s is %s\n",property,model,value);
|
|
||||||
|
int len = strlen(value) + 1;
|
||||||
|
if (len == 1) {
|
||||||
|
// TODO: store more detailed error message after \0 byte.
|
||||||
|
error->all(FLERR,"Query of OpenKIM database failed");
|
||||||
|
}
|
||||||
|
|
||||||
char **varcmd = new char*[3];
|
char **varcmd = new char*[3];
|
||||||
varcmd[0] = varname;
|
varcmd[0] = varname;
|
||||||
|
@ -98,19 +103,21 @@ void KimQuery::command(int narg, char **arg)
|
||||||
|
|
||||||
char *do_query(char *model, char *property, int rank, MPI_Comm comm)
|
char *do_query(char *model, char *property, int rank, MPI_Comm comm)
|
||||||
{
|
{
|
||||||
char val[512], *retval;
|
char value[512], *retval;
|
||||||
int len;
|
|
||||||
|
|
||||||
// only run query from rank 0
|
// only run query from rank 0
|
||||||
if (rank == 0) {
|
if (rank == 0) {
|
||||||
|
|
||||||
// fake query
|
// fake query
|
||||||
strcpy(val,(const char*)"4.25");
|
strcpy(value,(const char*)"4.25");
|
||||||
}
|
}
|
||||||
MPI_Bcast(val, 512, MPI_CHAR, 0, comm);
|
MPI_Bcast(value, 512, MPI_CHAR, 0, comm);
|
||||||
len = strlen(val) + 1;
|
|
||||||
|
// must make a proper copy of the query, as the stack allocation
|
||||||
|
// will go out of scope
|
||||||
|
|
||||||
|
int len = strlen(value) + 1;
|
||||||
retval = new char[len];
|
retval = new char[len];
|
||||||
strcpy(retval,val);
|
strcpy(retval,value);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue