git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@207 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2006-12-19 16:39:30 +00:00
parent 828e342394
commit 5c22269d4e
2 changed files with 32 additions and 24 deletions

View File

@ -789,13 +789,13 @@ void Input::log()
if (logfile) fclose(logfile); if (logfile) fclose(logfile);
if (strcmp(arg[0],"none") == 0) logfile = NULL; if (strcmp(arg[0],"none") == 0) logfile = NULL;
else { else {
char fname[128]; // char fname[128];
if (universe->nworlds == 1) strcpy(fname,arg[0]); // if (universe->nworlds == 1) strcpy(fname,arg[0]);
else sprintf(fname,"%s.%d",arg[0],universe->iworld); // else sprintf(fname,"%s.%d",arg[0],universe->iworld);
logfile = fopen(fname,"w"); logfile = fopen(arg[0],"w");
if (logfile == NULL) { if (logfile == NULL) {
char str[128]; char str[128];
sprintf(str,"Cannot open logfile %s",fname); sprintf(str,"Cannot open logfile %s",arg[0]);
error->one(str); error->one(str);
} }
} }

View File

@ -28,7 +28,7 @@
#define VARDELTA 4 #define VARDELTA 4
enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE}; enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE,ULOOP};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -136,19 +136,29 @@ void Variable::set(int narg, char **arg)
data[nvar] = new char*[num[nvar]]; data[nvar] = new char*[num[nvar]];
copy(num[nvar],&arg[2],data[nvar]); copy(num[nvar],&arg[2],data[nvar]);
// UNIVERSE // UNIVERSE and ULOOP
// num = listed args, index = partition this proc is in, data = copied args // for UNIVERSE: num = listed args, data = copied args
// for ULOOP: num = N, data = list of NULLS since never used
// index = partition this proc is in
// universe proc 0 creates lock file // universe proc 0 creates lock file
// error check that all other universe variables are same length // error check that all other universe/uloop variables are same length
} else if (strcmp(arg[1],"universe") == 0 || strcmp(arg[1],"uloop") == 0) {
if (strcmp(arg[1],"universe") == 0) {
style[nvar] = UNIVERSE;
num[nvar] = narg - 2;
data[nvar] = new char*[num[nvar]];
copy(num[nvar],&arg[2],data[nvar]);
} else {
style[nvar] = ULOOP;
num[nvar] = atoi(arg[2]);
data[nvar] = new char*[num[nvar]];
for (int i = 0; i < num[nvar]; i++) data[nvar][i] = NULL;
}
} else if (strcmp(arg[1],"universe") == 0) {
style[nvar] = UNIVERSE;
num[nvar] = narg - 2;
if (num[nvar] < universe->nworlds) if (num[nvar] < universe->nworlds)
error->all("Universe variable count < # of partitions"); error->all("Universe/uloop variable count < # of partitions");
index[nvar] = universe->iworld; index[nvar] = universe->iworld;
data[nvar] = new char*[num[nvar]];
copy(num[nvar],&arg[2],data[nvar]);
if (universe->me == 0) { if (universe->me == 0) {
FILE *fp = fopen("tmp.lammps.variable","w"); FILE *fp = fopen("tmp.lammps.variable","w");
@ -157,8 +167,9 @@ void Variable::set(int narg, char **arg)
} }
for (int jvar = 0; jvar < nvar; jvar++) for (int jvar = 0; jvar < nvar; jvar++)
if (num[jvar] && style[jvar] == UNIVERSE && num[nvar] != num[jvar]) if (num[jvar] && (style[jvar] == UNIVERSE || style[jvar] == ULOOP) &&
error->all("All universe variables must have same # of values"); num[nvar] != num[jvar])
error->all("All universe/uloop variables must have same # of values");
if (me == 0) { if (me == 0) {
if (universe->uscreen) if (universe->uscreen)
@ -252,7 +263,7 @@ int Variable::next(int narg, char **arg)
} }
} }
} else if (istyle == UNIVERSE) { } else if (istyle == UNIVERSE || istyle == ULOOP) {
// wait until lock file can be created and owned by proc 0 of this world // wait until lock file can be created and owned by proc 0 of this world
// read next available index and Bcast it within my world // read next available index and Bcast it within my world
@ -307,9 +318,10 @@ char *Variable::retrieve(char *name)
if (index[ivar] >= num[ivar]) return NULL; if (index[ivar] >= num[ivar]) return NULL;
char *str; char *str;
if (style[ivar] == INDEX) { if (style[ivar] == INDEX || style[ivar] == WORLD ||
style[ivar] == UNIVERSE) {
str = data[ivar][index[ivar]]; str = data[ivar][index[ivar]];
} else if (style[ivar] == LOOP) { } else if (style[ivar] == LOOP || style[ivar] == ULOOP) {
char *value = new char[16]; char *value = new char[16];
sprintf(value,"%d",index[ivar]+1); sprintf(value,"%d",index[ivar]+1);
int n = strlen(value) + 1; int n = strlen(value) + 1;
@ -326,10 +338,6 @@ char *Variable::retrieve(char *name)
strcpy(data[ivar][1],value); strcpy(data[ivar][1],value);
delete [] value; delete [] value;
str = data[ivar][1]; str = data[ivar][1];
} else if (style[ivar] == WORLD) {
str = data[ivar][index[ivar]];
} else if (style[ivar] == UNIVERSE) {
str = data[ivar][index[ivar]];
} }
return str; return str;
} }