group-ID = ID of group of atoms whose velocity will be changed
diff --git a/doc/velocity.txt b/doc/velocity.txt
index 8e8615e4dc..b2f18c0dbe 100644
--- a/doc/velocity.txt
+++ b/doc/velocity.txt
@@ -10,7 +10,7 @@ velocity command :h3
[Syntax:]
-velocity group-ID style args keyword args ... :pre
+velocity group-ID style args keyword value ... :pre
group-ID = ID of group of atoms whose velocity will be changed :ulb,l
style = {create} or {set} or {scale} or {ramp} or {zero} :l
diff --git a/doc/write_dump.html b/doc/write_dump.html
new file mode 100644
index 0000000000..a375eec63b
--- /dev/null
+++ b/doc/write_dump.html
@@ -0,0 +1,101 @@
+
+ LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands
+
+
+
+
+
+
+
+
+
+write_dump command
+
+Syntax:
+
+write_dump ID group-ID style N file dump-args modify dump-modify-args
+
+- ID = user-assigned name for the dump (ignored)
+
+
- group-ID = ID of the group of atoms to be dumped
+
+
- style = any of the supported dump styles
+
+
- N = dump every this many timesteps (ignored)
+
+
- file = name of file to write dump info to
+
+
- dump-args = any additional args needed for a particular dump style
+
+
- modify = all args after this keyword are passed to dump_modify (optional)
+
+
- dump-modify-args = args for dump_modify (optional)
+
+Examples:
+
+write_dump 1 all atom 0 dump.atom
+write_dump 1 subgroup atom 0 dump.run.bin
+write_dump 1 all custom 0 dump.myforce.* id type x y vx fx
+write_dump 1 flow custom 0 dump.%.myforce id type c_myF[3] v_ke modify sort id
+write_dump 1 all xyz 0 system.xyz modify sort id elements O H
+write_dump 1 all image 0 snap*.jpg type type size 960 960 modify backcolor white
+write_dump 1 all image 0 snap*.jpg element element &
+ bond atom 0.3 shiny 0.1 ssao yes 6345 0.2 size 1600 1600 &
+ modify backcolor white element C C O H N C C C O H H S O H
+
+Description:
+
+Dump a single snapshot of atom quantities to one or more files for the
+current state of the system. This is a one-time operation, in
+contrast to the dump command which will write out multiple
+snapshots periodically during a running simulation.
+
+The syntax for this command is identical to that of the
+dump and dump_modify commands as if
+they were concatenated together, with one exception. This is so that
+the full range of dump_modify options can be
+specified for the single snapshot, just as they can be for multiple
+snapshots. The syntax exception is that if a second set of
+dump-modify-args is specified, they must be preceeded by the "modify"
+keyword, so that LAMMPS can cleanly separate the two sets of args.
+
+Note that the dump ID and frequency N arguments are ignored, since
+they are irrelevant when only a single snapshot is being written.
+
+Also note that if the specified filename uses the wildcard characters
+"*" or "%", as supported by the dump commmand, they will
+operate in the same fashion to create the new filename(s).
+
+
+
+Restrictions:
+
+All restrictions for the dump and
+dump_modify commands apply to this command as well.
+For the dump image dump style, this means the
+filename is required to contain a '*' character, which will be
+replaced by the current timestep.
+
+Since dumps are normally written during a run or energy
+minimization, the simulation has to be ready to run
+before this command can be used. Similarly, if the dump requires
+information from a compute, fix, or variable, the information needs to
+have been calculated for the current timestep (e.g. by a prior run),
+else LAMMPS will generate an error message.
+
+For example, it is not possible to dump per-atom energy with this
+command before a run has been performed, since no energies and forces
+have yet been calculated. See the variable doc page
+sectinn on Variable Accuracy for more information on this topic.
+
+Related commands:
+
+dump, dump image, dump_modify
+
+Default:
+
+The defaults are listed on the doc pages for the dump and
+dump image and dump_modify
+commands.
+
+
diff --git a/doc/write_dump.txt b/doc/write_dump.txt
new file mode 100644
index 0000000000..7ec1268cff
--- /dev/null
+++ b/doc/write_dump.txt
@@ -0,0 +1,89 @@
+ "LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
+
+:link(lws,http://lammps.sandia.gov)
+:link(ld,Manual.html)
+:link(lc,Section_commands.html#comm)
+
+:line
+
+write_dump command :h3
+
+[Syntax:]
+
+write_dump ID group-ID style N file dump-args modify dump-modify-args :pre
+
+ID = user-assigned name for the dump (ignored) :ulb,l
+group-ID = ID of the group of atoms to be dumped :l
+style = any of the supported "dump styles"_dump.html :l
+N = dump every this many timesteps (ignored) :l
+file = name of file to write dump info to :l
+dump-args = any additional args needed for a particular "dump style"_dump.html :l
+modify = all args after this keyword are passed to "dump_modify"_dump_modify.html (optional) :l
+dump-modify-args = args for "dump_modify"_dump_modify.html (optional) :l,ule
+
+[Examples:]
+
+write_dump 1 all atom 0 dump.atom
+write_dump 1 subgroup atom 0 dump.run.bin
+write_dump 1 all custom 0 dump.myforce.* id type x y vx fx
+write_dump 1 flow custom 0 dump.%.myforce id type c_myF\[3\] v_ke modify sort id
+write_dump 1 all xyz 0 system.xyz modify sort id elements O H
+write_dump 1 all image 0 snap*.jpg type type size 960 960 modify backcolor white
+write_dump 1 all image 0 snap*.jpg element element &
+ bond atom 0.3 shiny 0.1 ssao yes 6345 0.2 size 1600 1600 &
+ modify backcolor white element C C O H N C C C O H H S O H :pre
+
+[Description:]
+
+Dump a single snapshot of atom quantities to one or more files for the
+current state of the system. This is a one-time operation, in
+contrast to the "dump"_dump.html command which will write out multiple
+snapshots periodically during a running simulation.
+
+The syntax for this command is identical to that of the
+"dump"_dump.html and "dump_modify"_dump_modify.html commands as if
+they were concatenated together, with one exception. This is so that
+the full range of "dump_modify"_dump_modify.html options can be
+specified for the single snapshot, just as they can be for multiple
+snapshots. The syntax exception is that if a second set of
+dump-modify-args is specified, they must be preceeded by the "modify"
+keyword, so that LAMMPS can cleanly separate the two sets of args.
+
+Note that the dump ID and frequency {N} arguments are ignored, since
+they are irrelevant when only a single snapshot is being written.
+
+Also note that if the specified filename uses the wildcard characters
+"*" or "%", as supported by the "dump"_dump.html commmand, they will
+operate in the same fashion to create the new filename(s).
+
+:line
+
+[Restrictions:]
+
+All restrictions for the "dump"_dump.html and
+"dump_modify"_dump_modify.html commands apply to this command as well.
+For the "dump image"_dump_image.html dump style, this means the
+filename is required to contain a '*' character, which will be
+replaced by the current timestep.
+
+Since dumps are normally written during a "run"_run.html or "energy
+minimization"_minimize.html, the simulation has to be ready to run
+before this command can be used. Similarly, if the dump requires
+information from a compute, fix, or variable, the information needs to
+have been calculated for the current timestep (e.g. by a prior run),
+else LAMMPS will generate an error message.
+
+For example, it is not possible to dump per-atom energy with this
+command before a run has been performed, since no energies and forces
+have yet been calculated. See the "variable"_variable.html doc page
+sectinn on Variable Accuracy for more information on this topic.
+
+[Related commands:]
+
+"dump"_dump.html, "dump image"_dump_image.html, "dump_modify"_dump_modify.html
+
+[Default:]
+
+The defaults are listed on the doc pages for the "dump"_dump.html and
+"dump image"_dump_image.html and "dump_modify"_dump_modify.html
+commands.
From 29f515735a7d8085fc5d0a3857c0470463b093cb Mon Sep 17 00:00:00 2001
From: sjplimp
Date: Sat, 2 Nov 2013 00:02:37 +0000
Subject: [PATCH 2/4] git-svn-id:
svn://svn.icms.temple.edu/lammps-ro/trunk@10918
f3b2605a-c512-4ea7-a41b-209d697bcdaa
---
src/input.cpp | 21 ++++++++++----
src/output.cpp | 3 +-
src/variable.cpp | 37 +++++++++++++++++++++++--
src/write_dump.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++
src/write_dump.h | 55 ++++++++++++++++++++++++++++++++++++
5 files changed, 176 insertions(+), 9 deletions(-)
create mode 100644 src/write_dump.cpp
create mode 100644 src/write_dump.h
diff --git a/src/input.cpp b/src/input.cpp
index 17d32f7d7d..09cba19c59 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -978,11 +978,11 @@ void Input::shell()
if (narg < 1) error->all(FLERR,"Illegal shell command");
if (strcmp(arg[0],"cd") == 0) {
- if (narg != 2) error->all(FLERR,"Illegal shell command");
+ if (narg != 2) error->all(FLERR,"Illegal shell cd command");
chdir(arg[1]);
} else if (strcmp(arg[0],"mkdir") == 0) {
- if (narg < 2) error->all(FLERR,"Illegal shell command");
+ if (narg < 2) error->all(FLERR,"Illegal shell mkdir command");
#if !defined(WINDOWS) && !defined(__MINGW32__)
if (me == 0)
for (int i = 1; i < narg; i++)
@@ -990,19 +990,30 @@ void Input::shell()
#endif
} else if (strcmp(arg[0],"mv") == 0) {
- if (narg != 3) error->all(FLERR,"Illegal shell command");
+ if (narg != 3) error->all(FLERR,"Illegal shell mv command");
if (me == 0) rename(arg[1],arg[2]);
} else if (strcmp(arg[0],"rm") == 0) {
- if (narg < 2) error->all(FLERR,"Illegal shell command");
+ if (narg < 2) error->all(FLERR,"Illegal shell rm command");
if (me == 0)
for (int i = 1; i < narg; i++) unlink(arg[i]);
} else if (strcmp(arg[0],"rmdir") == 0) {
- if (narg < 2) error->all(FLERR,"Illegal shell command");
+ if (narg < 2) error->all(FLERR,"Illegal shell rmdir command");
if (me == 0)
for (int i = 1; i < narg; i++) rmdir(arg[i]);
+ } else if (strcmp(arg[0],"putenv") == 0) {
+ if (narg < 2) error->all(FLERR,"Illegal shell putenv command");
+ for (int i = 1; i < narg; i++) {
+ char *ptr = strdup(arg[i]);
+#ifdef _WIN32
+ if (ptr != NULL) _putenv(ptr);
+#else
+ if (ptr != NULL) putenv(ptr);
+#endif
+ }
+
// use work string to concat args back into one string separated by spaces
// invoke string in shell via system()
diff --git a/src/output.cpp b/src/output.cpp
index 86c463164e..251a66fc87 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -544,7 +544,8 @@ void Output::add_dump(int narg, char **arg)
error->all(FLERR,"Reuse of dump ID");
int igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR,"Could not find dump group ID");
- if (force->inumeric(FLERR,arg[3]) <= 0) error->all(FLERR,"Invalid dump frequency");
+ if (force->inumeric(FLERR,arg[3]) <= 0)
+ error->all(FLERR,"Invalid dump frequency");
// extend Dump list if necessary
diff --git a/src/variable.cpp b/src/variable.cpp
index 5e13e61dc1..cb7ee1d8a3 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -47,7 +47,7 @@ using namespace MathConst;
#define MYROUND(a) (( a-floor(a) ) >= .5) ? ceil(a) : floor(a)
-enum{INDEX,LOOP,WORLD,UNIVERSE,ULOOP,STRING,SCALARFILE,ATOMFILE,EQUAL,ATOM};
+enum{INDEX,LOOP,WORLD,UNIVERSE,ULOOP,STRING,GETENV,SCALARFILE,ATOMFILE,EQUAL,ATOM};
enum{ARG,OP};
// customize by adding a function
@@ -280,6 +280,27 @@ void Variable::set(int narg, char **arg)
data[nvar] = new char*[num[nvar]];
copy(1,&arg[2],data[nvar]);
+ // GETENV
+ // remove pre-existing var if also style GETENV (allows it to be reset)
+ // num = 1, which = 1st value
+ // data = 1 value, string to eval
+
+ } else if (strcmp(arg[1],"getenv") == 0) {
+ if (narg != 3) error->all(FLERR,"Illegal variable command");
+ if (find(arg[0]) >= 0) {
+ if (style[find(arg[0])] != GETENV)
+ error->all(FLERR,"Cannot redefine variable as a different style");
+ remove(find(arg[0]));
+ }
+ if (nvar == maxvar) grow();
+ style[nvar] = GETENV;
+ num[nvar] = 1;
+ which[nvar] = 0;
+ pad[nvar] = 0;
+ data[nvar] = new char*[num[nvar]];
+ copy(1,&arg[2],data[nvar]);
+ data[nvar][1] = NULL;
+
// SCALARFILE for strings or numbers
// which = 1st value
// data = 1 value, string to eval
@@ -413,10 +434,11 @@ int Variable::next(int narg, char **arg)
error->all(FLERR,"All variables in next command must be same style");
}
- // invalid styles STRING or EQUAL or WORLD or ATOM
+ // invalid styles STRING or EQUAL or WORLD or ATOM or GETENV
int istyle = style[find(arg[0])];
- if (istyle == STRING || istyle == EQUAL || istyle == WORLD || istyle == ATOM)
+ if (istyle == STRING || istyle == EQUAL || istyle == WORLD
+ || istyle == GETENV || istyle == ATOM)
error->all(FLERR,"Invalid variable style with next command");
// increment all variables in list
@@ -505,6 +527,7 @@ int Variable::next(int narg, char **arg)
return ptr to stored string
if LOOP or ULOOP var, write int to data[0] and return ptr to string
if EQUAL var, evaluate variable and put result in str
+ if GETENV var, query environment and put result in str
if ATOM or ATOMFILE var, return NULL
return NULL if no variable with name or which value is bad,
caller must respond
@@ -543,6 +566,14 @@ char *Variable::retrieve(char *name)
data[ivar][1] = new char[n];
strcpy(data[ivar][1],result);
str = data[ivar][1];
+ } else if (style[ivar] == GETENV) {
+ const char *result = getenv(data[ivar][0]);
+ if (data[ivar][1]) delete [] data[ivar][1];
+ if (result == NULL) result = (const char *)"";
+ int n = strlen(result) + 1;
+ data[ivar][1] = new char[n];
+ strcpy(data[ivar][1],result);
+ str = data[ivar][1];
} else if (style[ivar] == ATOM || style[ivar] == ATOMFILE) return NULL;
return str;
diff --git a/src/write_dump.cpp b/src/write_dump.cpp
new file mode 100644
index 0000000000..04f161a822
--- /dev/null
+++ b/src/write_dump.cpp
@@ -0,0 +1,69 @@
+/* ----------------------------------------------------------------------
+ LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
+ http://lammps.sandia.gov, Sandia National Laboratories
+ Steve Plimpton, sjplimp@sandia.gov
+
+ Copyright (2003) Sandia Corporation. Under the terms of Contract
+ DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
+ certain rights in this software. This software is distributed under
+ the GNU General Public License.
+
+ See the README file in the top-level LAMMPS directory.
+------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------
+ Contributing author: Axel Kohlmeyer (Temple U)
+------------------------------------------------------------------------- */
+
+#include "write_dump.h"
+#include "style_dump.h"
+#include "dump.h"
+#include "atom.h"
+#include "group.h"
+#include "error.h"
+
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+void WriteDump::command(int narg, char **arg)
+{
+ if (narg < 3) error->all(FLERR,"Illegal write_dump command");
+
+ if (atom->tag_enable == 0)
+ error->all(FLERR,"Must have atom IDs for write_dump command");
+
+ // modindex = index in args of "modify", narg if doesn't exist
+
+ int modindex;
+ for (modindex = 0; modindex < narg; modindex++)
+ if (strcmp(arg[modindex],"modify") == 0) break;
+
+ // create the Dump instance
+
+ Dump *dump;
+
+ if (0) return; // dummy line to enable else-if macro expansion
+
+#define DUMP_CLASS
+#define DumpStyle(key,Class) \
+ else if (strcmp(arg[2],#key) == 0) dump = new Class(lmp,modindex,arg);
+#include "style_dump.h"
+#undef DUMP_CLASS
+
+ else error->all(FLERR,"Invalid dump style");
+
+ // pass additional args to modify_params
+
+ if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
+
+ // write the current snapshot to dump file
+
+ dump->init();
+ dump->write();
+
+ // delete the Dump instance
+
+ delete dump;
+}
+
diff --git a/src/write_dump.h b/src/write_dump.h
new file mode 100644
index 0000000000..f2a02fadfe
--- /dev/null
+++ b/src/write_dump.h
@@ -0,0 +1,55 @@
+/* -*- c++ -*- ----------------------------------------------------------
+ LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
+ http://lammps.sandia.gov, Sandia National Laboratories
+ Steve Plimpton, sjplimp@sandia.gov
+
+ Copyright (2003) Sandia Corporation. Under the terms of Contract
+ DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
+ certain rights in this software. This software is distributed under
+ the GNU General Public License.
+
+ See the README file in the top-level LAMMPS directory.
+------------------------------------------------------------------------- */
+
+#ifdef COMMAND_CLASS
+
+CommandStyle(write_dump,WriteDump)
+
+#else
+
+#ifndef LMP_WRITE_DUMP_H
+#define LMP_WRITE_DUMP_H
+
+#include "pointers.h"
+
+namespace LAMMPS_NS {
+
+class WriteDump : protected Pointers {
+ public:
+ WriteDump(class LAMMPS *lmp) : Pointers(lmp) {};
+ void command(int, char **);
+};
+
+}
+
+#endif
+#endif
+
+/* ERROR/WARNING messages:
+
+E: Illegal ... command
+
+Self-explanatory. Check the input script syntax and compare to the
+documentation for the command. You can use -echo screen as a
+command-line option when running LAMMPS to see the offending line.
+
+E: Must have atom IDs for group2ndx command
+
+There are no atom IDs defined in the system, but they are required
+to identify atoms in a gromacs style index file.
+
+E: Cannot open index file for writing
+
+Self-explanatory. Check your filename, permissions, and disk space or quota.
+
+*/
From 2e55aaa195b5d24cca03de59ba9bd85aeeba8f54 Mon Sep 17 00:00:00 2001
From: sjplimp
Date: Sat, 2 Nov 2013 00:05:19 +0000
Subject: [PATCH 3/4] git-svn-id:
svn://svn.icms.temple.edu/lammps-ro/trunk@10919
f3b2605a-c512-4ea7-a41b-209d697bcdaa
---
src/version.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/version.h b/src/version.h
index 22ccfbb47b..c4bf8507de 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1 +1 @@
-#define LAMMPS_VERSION "30 Oct 2013"
+#define LAMMPS_VERSION "1 Nov 2013"
From 8d90186b1297f0e0019c61c53d0319629755e9f5 Mon Sep 17 00:00:00 2001
From: sjplimp
Date: Sat, 2 Nov 2013 00:05:21 +0000
Subject: [PATCH 4/4] git-svn-id:
svn://svn.icms.temple.edu/lammps-ro/trunk@10920
f3b2605a-c512-4ea7-a41b-209d697bcdaa
---
doc/Manual.html | 2 +-
doc/Manual.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/Manual.html b/doc/Manual.html
index 59b532681a..09dd2933f1 100644
--- a/doc/Manual.html
+++ b/doc/Manual.html
@@ -22,7 +22,7 @@
LAMMPS Documentation
-30 Oct 2013 version
+1 Nov 2013 version
Version info:
diff --git a/doc/Manual.txt b/doc/Manual.txt
index 50eb428416..597710e627 100644
--- a/doc/Manual.txt
+++ b/doc/Manual.txt
@@ -18,7 +18,7 @@
LAMMPS Documentation :c,h3
-30 Oct 2013 version :c,h4
+1 Nov 2013 version :c,h4
Version info: :h4