add option to the print command to also print to the global universe screen and logfile

This commit is contained in:
Axel Kohlmeyer 2017-11-07 10:00:57 -05:00
parent ba43465268
commit 2e40c00995
2 changed files with 21 additions and 3 deletions

View File

@ -14,10 +14,11 @@ print string keyword value :pre
string = text string to print, which may contain variables :ulb,l
zero or more keyword/value pairs may be appended :l
keyword = {file} or {append} or {screen} :l
keyword = {file} or {append} or {screen} or {universe} :l
{file} value = filename
{append} value = filename
{screen} value = {yes} or {no} :pre
{screen} value = {yes} or {no}
{universe} value = {yes} or {no} :pre
:ule
[Examples:]
@ -26,6 +27,7 @@ print "Done with equilibration" file info.dat
print Vol=$v append info.dat screen no
print "The system volume is now $v"
print 'The system volume is now $v'
print "NEB calculation 1 complete" screen no universe yes
print """
System volume = $v
System temperature = $t
@ -49,6 +51,11 @@ it does not exist.
If the {screen} keyword is used, output to the screen and logfile can
be turned on or off as desired.
If the {universe} keyword is used, output to the global screen and
logfile can be turned on or off as desired. In multi-partition
calculations, the {screen} option and the corresponding output only
apply to the screen and logfile of the individual partition.
If you want the print command to be executed multiple times (with
changing variable values), there are 3 options. First, consider using
the "fix print"_fix_print.html command, which will print a string
@ -74,4 +81,4 @@ thermodynamic properties, global values calculated by a
[Default:]
The option defaults are no file output and screen = yes.
The option defaults are no file output, screen = yes, and universe = no.

View File

@ -1175,6 +1175,7 @@ void Input::print()
FILE *fp = NULL;
int screenflag = 1;
int universeflag = 0;
int iarg = 1;
while (iarg < narg) {
@ -1197,6 +1198,12 @@ void Input::print()
else if (strcmp(arg[iarg+1],"no") == 0) screenflag = 0;
else error->all(FLERR,"Illegal print command");
iarg += 2;
} else if (strcmp(arg[iarg],"universe") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal print command");
if (strcmp(arg[iarg+1],"yes") == 0) universeflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) universeflag = 0;
else error->all(FLERR,"Illegal print command");
iarg += 2;
} else error->all(FLERR,"Illegal print command");
}
@ -1208,6 +1215,10 @@ void Input::print()
fclose(fp);
}
}
if (universeflag && (universe->me == 0)) {
if (universe->uscreen) fprintf(universe->uscreen, "%s\n",line);
if (universe->ulogfile) fprintf(universe->ulogfile,"%s\n",line);
}
}
/* ---------------------------------------------------------------------- */