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

This commit is contained in:
sjplimp
2008-10-07 15:02:40 +00:00
parent 39a13b3e59
commit 2c38f8ce07
8 changed files with 153 additions and 28 deletions

View File

@ -48,10 +48,34 @@ be treated as a single argument, as in the examples above.
<P>The if command can contain an optional "else" clause. If it does and
the result of the if test is FALSE, then command2 is executed.
</P>
<P>Note that by jumping to a label in the same input script, the if
command can be used to break out of a loop. See the <A HREF = "variable.html">variable
delete</A> for info on how to delete the associated loop
variable, so that it can be re-used later in the input script.
</P>
<P>Note that if either command1 or command2 is a bogus LAMMPS command,
such as "exit" in the first example, then executing the command will
cause LAMMPS to halt.
</P>
<P>Here is an example of a double loop which uses the if and
<A HREF = "jump.html">jump</A> commands to break out of the inner loop when a
condition is met, then continues iterating thru the outer loop.
</P>
<PRE>label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete
</PRE>
<PRE>next a
jump in.script loopa
</PRE>
<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>

View File

@ -45,10 +45,33 @@ be treated as a single argument, as in the examples above.
The if command can contain an optional "else" clause. If it does and
the result of the if test is FALSE, then command2 is executed.
Note that by jumping to a label in the same input script, the if
command can be used to break out of a loop. See the "variable
delete"_variable.html for info on how to delete the associated loop
variable, so that it can be re-used later in the input script.
Note that if either command1 or command2 is a bogus LAMMPS command,
such as "exit" in the first example, then executing the command will
cause LAMMPS to halt.
Here is an example of a double loop which uses the if and
"jump"_jump.html commands to break out of the inner loop when a
condition is met, then continues iterating thru the outer loop.
label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete :pre
next a
jump in.script loopa :pre
[Restrictions:] none
[Related commands:]

View File

@ -27,9 +27,9 @@ jump in.run2 runloop
</P>
<P>This command closes the current input script file, opens the file with
the specified name, and begins reading LAMMPS commands from that file.
The original file is not returned to, although by using multiple jump
commands it is possible to chain from file to file or back to the
original file.
Unlike the <A HREF = "include.html">include</A> command, the original file is not
returned to, although by using multiple jump commands it is possible
to chain from file to file or back to the original file.
</P>
<P>Optionally, if a 2nd argument is used, it is treated as a label and
the new file is scanned (without executing commands) until the label
@ -61,6 +61,25 @@ simulation.
<PRE>variable f world script.1 script.2 script.3 script.4
jump $f
</PRE>
<P>Here is an example of a double loop which uses the <A HREF = "if.html">if</A> and
jump commands to break out of the inner loop when a condition is met,
then continues iterating thru the outer loop.
</P>
<PRE>label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete
</PRE>
<PRE>next a
jump in.script loopa
</PRE>
<P><B>Restrictions:</B>
</P>
<P>If you jump to a file and it does not contain the specified label,

View File

@ -24,9 +24,9 @@ jump in.run2 runloop :pre
This command closes the current input script file, opens the file with
the specified name, and begins reading LAMMPS commands from that file.
The original file is not returned to, although by using multiple jump
commands it is possible to chain from file to file or back to the
original file.
Unlike the "include"_include.html command, the original file is not
returned to, although by using multiple jump commands it is possible
to chain from file to file or back to the original file.
Optionally, if a 2nd argument is used, it is treated as a label and
the new file is scanned (without executing commands) until the label
@ -58,6 +58,24 @@ mpirun -np 40 lmp_ibm -partition 4x10 -in in.file :pre
variable f world script.1 script.2 script.3 script.4
jump $f :pre
Here is an example of a double loop which uses the "if"_if.html and
jump commands to break out of the inner loop when a condition is met,
then continues iterating thru the outer loop.
label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete :pre
next a
jump in.script loopa :pre
[Restrictions:]
If you jump to a file and it does not contain the specified label,

View File

@ -48,7 +48,9 @@ value from their respective lists.
<P>When any of the variables in the next command has no more values, a
flag is set that causes the input script to skip the next
<A HREF = "jump.html">jump</A> command encountered. This enables a loop containing
a next command to exit.
a next command to exit. As explained in the <A HREF = "variable.html">variable</A>
command, the variable that has exhausted its values is also deleted.
This allows it to be used and re-defined later in the input script.
</P>
<P>When the next command is used with <I>index</I>- or <I>loop</I>-style variables,
the next value is assigned to the variable for all processors. When
@ -87,17 +89,36 @@ finished.
For example, this script will run 15 simulations in a double loop.
</P>
<PRE>variable i loop 3
variable j loop 5
clear
...
read_data data.polymer.$i$j
print Running simulation $i.$j
run 10000
next j
jump in.script
variable j loop 5
clear
...
read_data data.polymer.$i$j
print Running simulation $i.$j
run 10000
next j
jump in.script
next i
jump in.script
</PRE>
<P>Here is an example of a double loop which uses the <A HREF = "if.html">if</A> and
<A HREF = "jump.html">jump</A> commands to break out of the inner loop when a
condition is met, then continues iterating thru the outer loop.
</P>
<PRE>label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete
</PRE>
<PRE>next a
jump in.script loopa
</PRE>
<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>

View File

@ -45,7 +45,9 @@ value from their respective lists.
When any of the variables in the next command has no more values, a
flag is set that causes the input script to skip the next
"jump"_jump.html command encountered. This enables a loop containing
a next command to exit.
a next command to exit. As explained in the "variable"_variable.html
command, the variable that has exhausted its values is also deleted.
This allows it to be used and re-defined later in the input script.
When the next command is used with {index}- or {loop}-style variables,
the next value is assigned to the variable for all processors. When
@ -84,17 +86,35 @@ Jump and next commands can also be nested to enable multi-level loops.
For example, this script will run 15 simulations in a double loop.
variable i loop 3
variable j loop 5
clear
...
read_data data.polymer.$i$j
print Running simulation $i.$j
run 10000
next j
jump in.script
variable j loop 5
clear
...
read_data data.polymer.$i$j
print Running simulation $i.$j
run 10000
next j
jump in.script
next i
jump in.script :pre
Here is an example of a double loop which uses the "if"_if.html and
"jump"_jump.html commands to break out of the inner loop when a
condition is met, then continues iterating thru the outer loop.
label loopa
variable a loop 5
label loopb
variable b loop 5
print "A,B = $a,$b"
run 10000
if $b > 2 then "jump in.script break"
next b
jump in.script loopb
label break
variable b delete :pre
next a
jump in.script loopa :pre
[Restrictions:] none
[Related commands:]

View File

@ -140,9 +140,9 @@ commands before the variable would become exhausted. For example,
<PRE>label loop
variable a loop 5
print "A = $a"
if $a > 2 then "jump in.test break"
if $a > 2 then "jump in.script break"
next a
jump in.test loop
jump in.script loop
label break
variable a delete
</PRE>

View File

@ -134,9 +134,9 @@ commands before the variable would become exhausted. For example,
label loop
variable a loop 5
print "A = $a"
if $a > 2 then "jump in.test break"
if $a > 2 then "jump in.script break"
next a
jump in.test loop
jump in.script loop
label break
variable a delete :pre