git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11214 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -513,12 +513,12 @@ int Variable::next(int narg, char **arg)
|
|||||||
} else if (istyle == UNIVERSE || istyle == ULOOP) {
|
} 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
|
|
||||||
// rename() is not atomic in practice, but no known simple fix
|
// rename() is not atomic in practice, but no known simple fix
|
||||||
// means multiple procs can read/write file at the same time (bad!)
|
// means multiple procs can read/write file at the same time (bad!)
|
||||||
// random delays help
|
// random delays help
|
||||||
// delay for a random fraction of 1 second before first rename() call
|
// delay for random fraction of 1 second before first rename() call
|
||||||
// delay for a random fraction of 1 second before subsequent tries
|
// delay for random fraction of 1 second before subsequent tries
|
||||||
|
// when successful, read next available index and Bcast it within my world
|
||||||
|
|
||||||
int nextindex;
|
int nextindex;
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
@ -535,11 +535,11 @@ int Variable::next(int narg, char **arg)
|
|||||||
|
|
||||||
FILE *fp = fopen("tmp.lammps.variable.lock","r");
|
FILE *fp = fopen("tmp.lammps.variable.lock","r");
|
||||||
fscanf(fp,"%d",&nextindex);
|
fscanf(fp,"%d",&nextindex);
|
||||||
printf("READ %d %d\n",universe->me,nextindex);
|
//printf("READ %d %d\n",universe->me,nextindex);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = fopen("tmp.lammps.variable.lock","w");
|
fp = fopen("tmp.lammps.variable.lock","w");
|
||||||
fprintf(fp,"%d\n",nextindex+1);
|
fprintf(fp,"%d\n",nextindex+1);
|
||||||
printf("WRITE %d %d\n",universe->me,nextindex+1);
|
//printf("WRITE %d %d\n",universe->me,nextindex+1);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
rename("tmp.lammps.variable.lock","tmp.lammps.variable");
|
rename("tmp.lammps.variable.lock","tmp.lammps.variable");
|
||||||
if (universe->uscreen)
|
if (universe->uscreen)
|
||||||
|
|||||||
Reference in New Issue
Block a user