Commit 2c38f8ce authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2160 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 39a13b3e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -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>
+23 −0
Original line number Diff line number Diff line
@@ -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:]
+22 −3
Original line number Diff line number Diff line
@@ -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,
+21 −3
Original line number Diff line number Diff line
@@ -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,
+30 −9
Original line number Diff line number Diff line
@@ -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
@@ -98,6 +100,25 @@ 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>
Loading