diff -Naur lammps-29Jan09/doc/Section_commands.html lammps-12Feb09/doc/Section_commands.html
--- lammps-29Jan09/doc/Section_commands.html	2009-01-19 10:18:42.000000000 -0700
+++ lammps-12Feb09/doc/Section_commands.html	2009-02-06 09:12:07.000000000 -0700
@@ -372,8 +372,9 @@
 <TR ALIGN="center"><TD ><A HREF = "pair_lj.html">lj/cut/coul/cut</A></TD><TD ><A HREF = "pair_lj.html">lj/cut/coul/debye</A></TD><TD ><A HREF = "pair_lj.html">lj/cut/coul/long</A></TD><TD ><A HREF = "pair_lj.html">lj/cut/coul/long/tip4p</A></TD></TR>
 <TR ALIGN="center"><TD ><A HREF = "pair_lj_expand.html">lj/expand</A></TD><TD ><A HREF = "pair_gromacs.html">lj/gromacs</A></TD><TD ><A HREF = "pair_gromacs.html">lj/gromacs/coul/gromacs</A></TD><TD ><A HREF = "pair_lj_smooth.html">lj/smooth</A></TD></TR>
 <TR ALIGN="center"><TD ><A HREF = "pair_lubricate.html">lubricate</A></TD><TD ><A HREF = "pair_meam.html">meam</A></TD><TD ><A HREF = "pair_morse.html">morse</A></TD><TD ><A HREF = "pair_morse.html">morse/opt</A></TD></TR>
-<TR ALIGN="center"><TD ><A HREF = "pair_peri_pmb.html">peri/pmb</A></TD><TD ><A HREF = "pair_resquared.html">resquared</A></TD><TD ><A HREF = "pair_soft.html">soft</A></TD><TD ><A HREF = "pair_sw.html">sw</A></TD></TR>
-<TR ALIGN="center"><TD ><A HREF = "pair_table.html">table</A></TD><TD ><A HREF = "pair_tersoff.html">tersoff</A></TD><TD ><A HREF = "pair_tersoff_zbl.html">tersoff/zbl</A></TD><TD ><A HREF = "pair_yukawa.html">yukawa</A> 
+<TR ALIGN="center"><TD ><A HREF = "pair_peri_pmb.html">peri/pmb</A></TD><TD ><A HREF = "pair_reax.html">reax</A></TD><TD ><A HREF = "pair_resquared.html">resquared</A></TD><TD ><A HREF = "pair_soft.html">soft</A></TD></TR>
+<TR ALIGN="center"><TD ><A HREF = "pair_sw.html">sw</A></TD><TD ><A HREF = "pair_table.html">table</A></TD><TD ><A HREF = "pair_tersoff.html">tersoff</A></TD><TD ><A HREF = "pair_tersoff_zbl.html">tersoff/zbl</A></TD></TR>
+<TR ALIGN="center"><TD ><A HREF = "pair_yukawa.html">yukawa</A> 
 </TD></TR></TABLE></DIV>
 
 <P>These are pair styles contributed by users, which can be used if
diff -Naur lammps-29Jan09/doc/Section_commands.txt lammps-12Feb09/doc/Section_commands.txt
--- lammps-29Jan09/doc/Section_commands.txt	2009-01-19 10:18:42.000000000 -0700
+++ lammps-12Feb09/doc/Section_commands.txt	2009-02-06 09:12:07.000000000 -0700
@@ -530,6 +530,7 @@
 "morse"_pair_morse.html,
 "morse/opt"_pair_morse.html,
 "peri/pmb"_pair_peri_pmb.html,
+"reax"_pair_reax.html,
 "resquared"_pair_resquared.html,
 "soft"_pair_soft.html,
 "sw"_pair_sw.html,
diff -Naur lammps-29Jan09/doc/Section_start.html lammps-12Feb09/doc/Section_start.html
--- lammps-29Jan09/doc/Section_start.html	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/Section_start.html	2009-02-10 11:37:23.000000000 -0700
@@ -356,38 +356,53 @@
 "make package-check" will list differences between src and package
 versions of the same files.
 </P>
-<P>To use the "meam" package you must build LAMMPS with the MEAM library
-in lib/meam, which computes the modified embedded atom method
-potential, which is a generalization of EAM potentials that can be
-used to model a wider variety of materials.  This MEAM implementation
-was written by Greg Wagner at Sandia.  To build LAMMPS with MEAM, you
-must use a low-level LAMMPS Makefile that includes the MEAM directory
-in its paths.  See Makefile.linux_meam as an example.  You must also
-build MEAM itself as a library before building LAMMPS, so that LAMMPS
-can link against it.  This requires a F90 compiler.  The library is
-built by typing "make" from within the meam directory with the
-appropriate Makefile, e.g. "make -f Makefile.icc".  If one of the
-provided Makefiles is not appropriate for your system you can edit or
-add one as needed.
-</P>
-<P>Note that linking a Fortran library to a C++ code can be problematic
-(e.g. Fortran routine names can't be found due to non-standard
-underscore rules) and typically requires additional C++ or F90
-libraries be included in the link.  You may need to read documentation
-for your compiler about how to do this correctly.
-</P>
-<P>To use the "poems" package you must build LAMMPS with the POEMS
-library in lib/poems, which computes the constrained rigid-body motion
-of articulated (jointed) multibody systems.  POEMS was written and is
-distributed by Prof Kurt Anderson's group at Rensselaer Polytechnic
-Institute (RPI).  To build LAMMPS with POEMS, you must use a low-level
-LAMMPS Makefile that includes the POEMS directory in its paths.  See
-Makefile.g++_poems as an example.  You must also build POEMS itself as
-a library before building LAMMPS, so that LAMMPS can link against it.
-The POEMS library is built by typing "make" from within the poems
-directory with the appropriate Makefile, e.g. "make -f Makefile.g++".
-If one of the provided Makefiles is not appropriate for your system
-you can edit or add one as needed.
+<P>Some packages require that additional libraries first be compiled,
+which LAMMPS will link to when it builds.  Currently, these are the
+"meam", "poems", and "reax" packages.  You should look at the README
+files in the lib directories (e.g. lib/reax/README) for instructions
+on how to build the libraries themselves.
+</P>
+<P>The "meam" library in lib/meam computes the modified embedded atom
+method potential, which is a generalization of EAM potentials that can
+be used to model a wider variety of materials.  This MEAM
+implementation was written by Greg Wagner at Sandia.  It requires a
+F90 compiler to build.
+</P>
+<P>The "reax" library in lib/reax computes the Reactive Force Field
+(ReaxFF) potential, developed by Adri van Duin in Bill Goddard's group
+at CalTech.  This implementation in LAMMPS uses many of Adri's files
+and was developed by Aidan Thompson at Sandia and Hansohl Cho at MIT.
+It requires a F77 or F90 compiler to build.
+</P>
+<P>The "poems" library in lib/poems computes the constrained rigid-body
+motion of articulated (jointed) multibody systems.  POEMS was written
+and is distributed by Prof Kurt Anderson's group at Rensselaer
+Polytechnic Institute (RPI). 
+</P>
+<P>In all cases, these libraries are built by typing
+</P>
+<PRE>make -f Makefile.foo 
+</PRE>
+<P>in the appropriate directory, e.g. in lib/reax.
+</P>
+<P>You should use the Makefile that is a match for your system.  If one
+of the provided Makefiles is not appropriate for your system you can
+edit or add one as needed.
+</P>
+<P>Once the desired library or libraries are built, you can build LAMMPS.
+You will need to create and use a lo-level LAMMPS makefile in src/MAKE
+that links with the specific libraries you want.  See a Makefile.foo
+that has the library name in it to see how this is done.
+E.g. Makefile.g++_reax or Makefile.g++_poems_meam.  Typically these
+will have additional -I, -L, and -l arguments that enable compiling
+and linking with files from the library.
+</P>
+<P>Note that linking a Fortran library (like MEAM or REAX) to a C++ code
+(like LAMMPS) can be tricky.  E.g. Fortran routine may not be found
+due to non-standard underscore rules.  It typically requires
+additional C++ or Fortran libraries be included in the link.  You may
+need to read documentation for your Fortran and C++ compilers about
+how to do this correctly.
 </P>
 <HR>
 
diff -Naur lammps-29Jan09/doc/Section_start.txt lammps-12Feb09/doc/Section_start.txt
--- lammps-29Jan09/doc/Section_start.txt	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/Section_start.txt	2009-02-10 11:37:23.000000000 -0700
@@ -349,38 +349,53 @@
 "make package-check" will list differences between src and package
 versions of the same files.
 
-To use the "meam" package you must build LAMMPS with the MEAM library
-in lib/meam, which computes the modified embedded atom method
-potential, which is a generalization of EAM potentials that can be
-used to model a wider variety of materials.  This MEAM implementation
-was written by Greg Wagner at Sandia.  To build LAMMPS with MEAM, you
-must use a low-level LAMMPS Makefile that includes the MEAM directory
-in its paths.  See Makefile.linux_meam as an example.  You must also
-build MEAM itself as a library before building LAMMPS, so that LAMMPS
-can link against it.  This requires a F90 compiler.  The library is
-built by typing "make" from within the meam directory with the
-appropriate Makefile, e.g. "make -f Makefile.icc".  If one of the
-provided Makefiles is not appropriate for your system you can edit or
-add one as needed.
-
-Note that linking a Fortran library to a C++ code can be problematic
-(e.g. Fortran routine names can't be found due to non-standard
-underscore rules) and typically requires additional C++ or F90
-libraries be included in the link.  You may need to read documentation
-for your compiler about how to do this correctly.
-
-To use the "poems" package you must build LAMMPS with the POEMS
-library in lib/poems, which computes the constrained rigid-body motion
-of articulated (jointed) multibody systems.  POEMS was written and is
-distributed by Prof Kurt Anderson's group at Rensselaer Polytechnic
-Institute (RPI).  To build LAMMPS with POEMS, you must use a low-level
-LAMMPS Makefile that includes the POEMS directory in its paths.  See
-Makefile.g++_poems as an example.  You must also build POEMS itself as
-a library before building LAMMPS, so that LAMMPS can link against it.
-The POEMS library is built by typing "make" from within the poems
-directory with the appropriate Makefile, e.g. "make -f Makefile.g++".
-If one of the provided Makefiles is not appropriate for your system
-you can edit or add one as needed.
+Some packages require that additional libraries first be compiled,
+which LAMMPS will link to when it builds.  Currently, these are the
+"meam", "poems", and "reax" packages.  You should look at the README
+files in the lib directories (e.g. lib/reax/README) for instructions
+on how to build the libraries themselves.
+
+The "meam" library in lib/meam computes the modified embedded atom
+method potential, which is a generalization of EAM potentials that can
+be used to model a wider variety of materials.  This MEAM
+implementation was written by Greg Wagner at Sandia.  It requires a
+F90 compiler to build.
+
+The "reax" library in lib/reax computes the Reactive Force Field
+(ReaxFF) potential, developed by Adri van Duin in Bill Goddard's group
+at CalTech.  This implementation in LAMMPS uses many of Adri's files
+and was developed by Aidan Thompson at Sandia and Hansohl Cho at MIT.
+It requires a F77 or F90 compiler to build.
+
+The "poems" library in lib/poems computes the constrained rigid-body
+motion of articulated (jointed) multibody systems.  POEMS was written
+and is distributed by Prof Kurt Anderson's group at Rensselaer
+Polytechnic Institute (RPI). 
+
+In all cases, these libraries are built by typing
+
+make -f Makefile.foo :pre
+
+in the appropriate directory, e.g. in lib/reax.
+
+You should use the Makefile that is a match for your system.  If one
+of the provided Makefiles is not appropriate for your system you can
+edit or add one as needed.
+
+Once the desired library or libraries are built, you can build LAMMPS.
+You will need to create and use a lo-level LAMMPS makefile in src/MAKE
+that links with the specific libraries you want.  See a Makefile.foo
+that has the library name in it to see how this is done.
+E.g. Makefile.g++_reax or Makefile.g++_poems_meam.  Typically these
+will have additional -I, -L, and -l arguments that enable compiling
+and linking with files from the library.
+
+Note that linking a Fortran library (like MEAM or REAX) to a C++ code
+(like LAMMPS) can be tricky.  E.g. Fortran routine may not be found
+due to non-standard underscore rules.  It typically requires
+additional C++ or Fortran libraries be included in the link.  You may
+need to read documentation for your Fortran and C++ compilers about
+how to do this correctly.
 
 :line
 
diff -Naur lammps-29Jan09/doc/compute_pe_atom.html lammps-12Feb09/doc/compute_pe_atom.html
--- lammps-29Jan09/doc/compute_pe_atom.html	2008-04-04 08:24:01.000000000 -0600
+++ lammps-12Feb09/doc/compute_pe_atom.html	2009-02-12 13:45:46.000000000 -0700
@@ -60,8 +60,8 @@
 in the last 2 columns of thermo output:
 </P>
 <PRE>compute		peratom all pe/atom
-compute		p all reduce sum c_peratom
-thermo_style	custom step temp etotal press pe c_p 
+compute		pe all reduce sum c_peratom
+thermo_style	custom step temp etotal press pe c_pe 
 </PRE>
 <P>IMPORTANT NOTE: The per-atom energy does NOT include contributions due
 to long-range Coulombic interactions (via the
diff -Naur lammps-29Jan09/doc/compute_pe_atom.txt lammps-12Feb09/doc/compute_pe_atom.txt
--- lammps-29Jan09/doc/compute_pe_atom.txt	2008-04-04 08:24:01.000000000 -0600
+++ lammps-12Feb09/doc/compute_pe_atom.txt	2009-02-12 13:45:46.000000000 -0700
@@ -57,8 +57,8 @@
 in the last 2 columns of thermo output:
 
 compute		peratom all pe/atom
-compute		p all reduce sum c_peratom
-thermo_style	custom step temp etotal press pe c_p :pre
+compute		pe all reduce sum c_peratom
+thermo_style	custom step temp etotal press pe c_pe :pre
 
 IMPORTANT NOTE: The per-atom energy does NOT include contributions due
 to long-range Coulombic interactions (via the
diff -Naur lammps-29Jan09/doc/pair_coeff.html lammps-12Feb09/doc/pair_coeff.html
--- lammps-29Jan09/doc/pair_coeff.html	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/pair_coeff.html	2009-02-06 09:12:07.000000000 -0700
@@ -130,6 +130,7 @@
 <LI><A HREF = "pair_morse.html">pair_style morse</A> - Morse potential
 <LI><A HREF = "pair_morse.html">pair_style morse/opt</A> - optimized version of Morse potential
 <LI><A HREF = "pair_peri_pmb.html">pair_style peri/pmb</A> - peridynamic PMB potential
+<LI><A HREF = "pair_reax.html">pair_style reax</A> - ReaxFF potential
 <LI><A HREF = "pair_resquared.html">pair_style resquared</A> - Everaers RE-Squared ellipsoidal potential
 <LI><A HREF = "pair_soft.html">pair_style soft</A> - Soft (cosine) potential
 <LI><A HREF = "pair_sw.html">pair_style sw</A> - Stillinger-Weber 3-body potential
diff -Naur lammps-29Jan09/doc/pair_coeff.txt lammps-12Feb09/doc/pair_coeff.txt
--- lammps-29Jan09/doc/pair_coeff.txt	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/pair_coeff.txt	2009-02-06 09:12:07.000000000 -0700
@@ -126,6 +126,7 @@
 "pair_style morse"_pair_morse.html - Morse potential
 "pair_style morse/opt"_pair_morse.html - optimized version of Morse potential
 "pair_style peri/pmb"_pair_peri_pmb.html - peridynamic PMB potential
+"pair_style reax"_pair_reax.html - ReaxFF potential
 "pair_style resquared"_pair_resquared.html - Everaers RE-Squared ellipsoidal potential
 "pair_style soft"_pair_soft.html - Soft (cosine) potential
 "pair_style sw"_pair_sw.html - Stillinger-Weber 3-body potential
diff -Naur lammps-29Jan09/doc/pair_reax.html lammps-12Feb09/doc/pair_reax.html
--- lammps-29Jan09/doc/pair_reax.html	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/doc/pair_reax.html	2009-02-12 13:45:46.000000000 -0700
@@ -0,0 +1,144 @@
+<HTML>
+<CENTER><A HREF = "http://lammps.sandia.gov">LAMMPS WWW Site</A> - <A HREF = "Manual.html">LAMMPS Documentation</A> - <A HREF = "Section_commands.html#comm">LAMMPS Commands</A> 
+</CENTER>
+
+
+
+
+
+
+<HR>
+
+<H3>pair_style reax command 
+</H3>
+<P><B>Syntax:</B>
+</P>
+<PRE>pair_style reax hbcut precision 
+</PRE>
+<UL><LI>hbcut = hydrogen-bond cutoff (distance units)
+<LI>precision = precision for charge equilibration 
+</UL>
+<P><B>Examples:</B>
+</P>
+<PRE>pair_style reax
+pair_style reax 10.0 1.0e-5
+pair_coeff * * ffield.reax C H O N 
+</PRE>
+<P><B>Description:</B>
+</P>
+<P>The pair style computes the ReaxFF potential of van Duin, Goddard and
+co-workers.  ReaxFF uses distance-dependent bond-order functions to
+represent the contributions of chemical bonding to the potential
+energy.  Details of the ReaxFF and its interatomic potential energy
+calculation are given in the following publications: <A HREF = "#van_Duin_2001">(van Duin
+2001)</A> and <A HREF = "#van_Duin_2003">(van Duin 2003)</A>.
+</P>
+<P>LAMMPS provides a ReaxFF potential file in its potentials dir, namely
+potentials/ffield.reax.  Its format is identical to that used by van
+Duin and co-workers.  It contains parameterizations for the following
+elements: C, H, O, N, S, and Si.  You can use your another file in
+place of it, and ReaxFF files with parameterizations for other
+elements or for specific chemical systems may be available elsewhere.
+</P>
+<P>The <I>hbcut</I> and <I>precision</I> settings are optional arguments.  If
+neither is provided, default settings are used: <I>hbcut</I> = 10 (which is
+Angstroms in real units) and <I>precision</I> = 1.0e-6 (one part in 10^6).
+If you wish to override either of these defaults, then both settings
+must be specified.
+</P>
+<P>Use of this pair style requires that a charge be defined for every
+atom since the potential performs charge equilibration.  See the
+<A HREF = "atom_style.html">atom_style</A> and <A HREF = "read_data.html">read_data</A> commands
+for details on how to specify charges.
+</P>
+<P>The thermo variable <I>evdwl</I> stores the sum of all the ReaxFF potential
+energy contributions, with the exception of the Coulombic and charge
+equilibration contributions which are stored in the thermo variable
+<I>ecoul</I>.  The output of these quantities is controlled by the
+<A HREF = "thermo.html">thermo</A> command.
+</P>
+<P>Only a single pair_coeff command is used with the <I>reax</I> style which
+specifies a ReaxFF potential file with parameters for all needed
+elements.  These are mapped to LAMMPS atom types by specifying N
+additional arguments after the filename in the pair_coeff command,
+where N is the number of LAMMPS atom types:
+</P>
+<UL><LI>filename
+<LI>N indices = mapping of ReaxFF elements to atom types 
+</UL>
+<P>The specification of the filename and the mapping of LAMMPS atom types
+recognized by the ReaxFF is done differently than for other LAMMPS
+potentials, due to the non-portable difficulty of passing character
+strings (e.g. filename, element names) between C++ and Fortran.
+</P>
+<P>The filename has to be "ffield.reax" and it has to exist in the
+directory you are running LAMMPS in.  This means you cannot prepend a
+path to the file in the potentials dir.  Rather, you should copy that
+file into the directory you are running from.  If you wish to use
+another ReaxFF potential file, then name it "ffield.reax" and put in
+your running dir.
+</P>
+<P>In the ReaxFF potential file, near the top, is a section that contains
+element names, each with a couple dozen numeric parameters.  The
+ffield.reax provided with LAMMPS lists 6 elements: C, H, O, N, S, Si.
+Think of these as numbered 1 to 6.  Each of the N indices you specify
+for the N atom types of LAMMPS atoms must be an integer from 1 to 6.
+Atoms with LAMMPS type 1 will be mapped to whatever element you
+specify as the first index value, etc.
+</P>
+<P>As an example, if your LAMMPS simulation has 4 atoms types and you
+want the 1st two to be C, the 3rd to be N, and the 4th to be H, you
+would use the following pair_coeff command:
+</P>
+<PRE>pair_coeff * * ffield.reax 1 1 4 2 
+</PRE>
+<HR>
+
+<P><B>Mixing, shift, table, tail correction, restart, rRESPA info</B>:
+</P>
+<P>This pair style does not support the <A HREF = "pair_modify.html">pair_modify</A>
+mix, shift, table, and tail options.
+</P>
+<P>This pair style does not write its information to <A HREF = "restart.html">binary restart
+files</A>, since it is stored in potential files.  Thus, you
+need to re-specify the pair_style and pair_coeff commands in an input
+script that reads a restart file.
+</P>
+<P>This pair style can only be used via the <I>pair</I> keyword of the
+<A HREF = "run_style.html">run_style respa</A> command.  It does not support the
+<I>inner</I>, <I>middle</I>, <I>outer</I> keywords.
+</P>
+<P><B>Restrictions:</B>
+</P>
+<P>This pair style is part of the "reax" package.  It is only enabled if
+LAMMPS was built with that package, which also requires the REAX
+library be built and linked with LAMMPS.  See the <A HREF = "Section_start.html#2_3">Making
+LAMMPS</A> section for more info.
+</P>
+<P>The ffield.reax potential file provided with LAMMPS in the potentials
+directory is parameterized for real <A HREF = "units.html">units</A>.  You can use
+the ReaxFF potential with any LAMMPS units, but you would need to
+create your own potential file with coefficients listed in the
+appropriate units if your simulation doesn't use "real" units.  This
+would be somewhat tricky, so contact the LAMMPS authors if you wish to
+do this.
+</P>
+<P><B>Related commands:</B>
+</P>
+<P><A HREF = "pair_coeff.html">pair_coeff</A>
+</P>
+<P><B>Default:</B> none
+</P>
+<HR>
+
+<A NAME = "van_Duin_2001"></A>
+
+<P><B>(van Duin 2001)</B> van Duin, Dasgupta, Lorant, Goddard
+Journal of Physical Chemistry A, 105, 9396-9409 (2001).
+</P>
+<A NAME = "van_Duin_2003"></A>
+
+<P><B>(van Duin 2003)</B> van Duin, Strachan, Stewman, Zhang, Xu, Goddard,
+Journal of Physical Chemistry A, 107, 3803-3811 (2003).
+</P>
+</HTML>
diff -Naur lammps-29Jan09/doc/pair_reax.txt lammps-12Feb09/doc/pair_reax.txt
--- lammps-29Jan09/doc/pair_reax.txt	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/doc/pair_reax.txt	2009-02-12 13:45:46.000000000 -0700
@@ -0,0 +1,137 @@
+"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
+
+pair_style reax command :h3
+
+[Syntax:]
+
+pair_style reax hbcut precision :pre
+
+hbcut = hydrogen-bond cutoff (distance units)
+precision = precision for charge equilibration :ul
+
+[Examples:]
+
+pair_style reax
+pair_style reax 10.0 1.0e-5
+pair_coeff * * ffield.reax C H O N :pre
+
+[Description:]
+
+The pair style computes the ReaxFF potential of van Duin, Goddard and
+co-workers.  ReaxFF uses distance-dependent bond-order functions to
+represent the contributions of chemical bonding to the potential
+energy.  Details of the ReaxFF and its interatomic potential energy
+calculation are given in the following publications: "(van Duin
+2001)"_#van_Duin_2001 and "(van Duin 2003)"_#van_Duin_2003.
+
+LAMMPS provides a ReaxFF potential file in its potentials dir, namely
+potentials/ffield.reax.  Its format is identical to that used by van
+Duin and co-workers.  It contains parameterizations for the following
+elements: C, H, O, N, S, and Si.  You can use your another file in
+place of it, and ReaxFF files with parameterizations for other
+elements or for specific chemical systems may be available elsewhere.
+
+The {hbcut} and {precision} settings are optional arguments.  If
+neither is provided, default settings are used: {hbcut} = 10 (which is
+Angstroms in real units) and {precision} = 1.0e-6 (one part in 10^6).
+If you wish to override either of these defaults, then both settings
+must be specified.
+
+Use of this pair style requires that a charge be defined for every
+atom since the potential performs charge equilibration.  See the
+"atom_style"_atom_style.html and "read_data"_read_data.html commands
+for details on how to specify charges.
+
+The thermo variable {evdwl} stores the sum of all the ReaxFF potential
+energy contributions, with the exception of the Coulombic and charge
+equilibration contributions which are stored in the thermo variable
+{ecoul}.  The output of these quantities is controlled by the
+"thermo"_thermo.html command.
+
+Only a single pair_coeff command is used with the {reax} style which
+specifies a ReaxFF potential file with parameters for all needed
+elements.  These are mapped to LAMMPS atom types by specifying N
+additional arguments after the filename in the pair_coeff command,
+where N is the number of LAMMPS atom types:
+
+filename
+N indices = mapping of ReaxFF elements to atom types :ul
+
+The specification of the filename and the mapping of LAMMPS atom types
+recognized by the ReaxFF is done differently than for other LAMMPS
+potentials, due to the non-portable difficulty of passing character
+strings (e.g. filename, element names) between C++ and Fortran.
+
+The filename has to be "ffield.reax" and it has to exist in the
+directory you are running LAMMPS in.  This means you cannot prepend a
+path to the file in the potentials dir.  Rather, you should copy that
+file into the directory you are running from.  If you wish to use
+another ReaxFF potential file, then name it "ffield.reax" and put in
+your running dir.
+
+In the ReaxFF potential file, near the top, is a section that contains
+element names, each with a couple dozen numeric parameters.  The
+ffield.reax provided with LAMMPS lists 6 elements: C, H, O, N, S, Si.
+Think of these as numbered 1 to 6.  Each of the N indices you specify
+for the N atom types of LAMMPS atoms must be an integer from 1 to 6.
+Atoms with LAMMPS type 1 will be mapped to whatever element you
+specify as the first index value, etc.
+
+As an example, if your LAMMPS simulation has 4 atoms types and you
+want the 1st two to be C, the 3rd to be N, and the 4th to be H, you
+would use the following pair_coeff command:
+
+pair_coeff * * ffield.reax 1 1 4 2 :pre
+
+:line
+
+[Mixing, shift, table, tail correction, restart, rRESPA info]:
+
+This pair style does not support the "pair_modify"_pair_modify.html
+mix, shift, table, and tail options.
+
+This pair style does not write its information to "binary restart
+files"_restart.html, since it is stored in potential files.  Thus, you
+need to re-specify the pair_style and pair_coeff commands in an input
+script that reads a restart file.
+
+This pair style can only be used via the {pair} keyword of the
+"run_style respa"_run_style.html command.  It does not support the
+{inner}, {middle}, {outer} keywords.
+
+[Restrictions:]
+
+This pair style is part of the "reax" package.  It is only enabled if
+LAMMPS was built with that package, which also requires the REAX
+library be built and linked with LAMMPS.  See the "Making
+LAMMPS"_Section_start.html#2_3 section for more info.
+
+The ffield.reax potential file provided with LAMMPS in the potentials
+directory is parameterized for real "units"_units.html.  You can use
+the ReaxFF potential with any LAMMPS units, but you would need to
+create your own potential file with coefficients listed in the
+appropriate units if your simulation doesn't use "real" units.  This
+would be somewhat tricky, so contact the LAMMPS authors if you wish to
+do this.
+
+[Related commands:]
+
+"pair_coeff"_pair_coeff.html
+
+[Default:] none
+
+:line
+
+:link(van_Duin_2001)
+[(van Duin 2001)] van Duin, Dasgupta, Lorant, Goddard
+Journal of Physical Chemistry A, 105, 9396-9409 (2001).
+
+:link(van_Duin_2003)
+[(van Duin 2003)] van Duin, Strachan, Stewman, Zhang, Xu, Goddard,
+Journal of Physical Chemistry A, 107, 3803-3811 (2003).
diff -Naur lammps-29Jan09/doc/pair_style.html lammps-12Feb09/doc/pair_style.html
--- lammps-29Jan09/doc/pair_style.html	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/pair_style.html	2009-02-06 09:12:07.000000000 -0700
@@ -132,6 +132,7 @@
 <LI><A HREF = "pair_morse.html">pair_style morse</A> - Morse potential
 <LI><A HREF = "pair_morse.html">pair_style morse/opt</A> - optimized version of Morse potential
 <LI><A HREF = "pair_peri_pmb.html">pair_style peri/pmb</A> - peridynamic PMB potential
+<LI><A HREF = "pair_reax.html">pair_style reax</A> - ReaxFF potential
 <LI><A HREF = "pair_resquared.html">pair_style resquared</A> - Everaers RE-Squared ellipsoidal potential
 <LI><A HREF = "pair_soft.html">pair_style soft</A> - Soft (cosine) potential
 <LI><A HREF = "pair_sw.html">pair_style sw</A> - Stillinger-Weber 3-body potential
diff -Naur lammps-29Jan09/doc/pair_style.txt lammps-12Feb09/doc/pair_style.txt
--- lammps-29Jan09/doc/pair_style.txt	2009-01-08 17:14:52.000000000 -0700
+++ lammps-12Feb09/doc/pair_style.txt	2009-02-06 09:12:07.000000000 -0700
@@ -128,6 +128,7 @@
 "pair_style morse"_pair_morse.html - Morse potential
 "pair_style morse/opt"_pair_morse.html - optimized version of Morse potential
 "pair_style peri/pmb"_pair_peri_pmb.html - peridynamic PMB potential
+"pair_style reax"_pair_reax.html - ReaxFF potential
 "pair_style resquared"_pair_resquared.html - Everaers RE-Squared ellipsoidal potential
 "pair_style soft"_pair_soft.html - Soft (cosine) potential
 "pair_style sw"_pair_sw.html - Stillinger-Weber 3-body potential
diff -Naur lammps-29Jan09/examples/README lammps-12Feb09/examples/README
--- lammps-29Jan09/examples/README	2008-07-25 08:47:38.000000000 -0600
+++ lammps-12Feb09/examples/README	2009-02-12 14:03:10.000000000 -0700
@@ -42,6 +42,7 @@
 peptide:  dynamics of a small solvated peptide chain (5-mer)
 peri:	  Peridynamic model of cylinder impacted by indenter
 pour:     pouring of granular particles into a 3d box, then chute flow
+reax:     RDX and TATB models using the ReaxFF
 rigid:    rigid bodies modeled as independent or coupled
 shear:    sideways shear applied to 2d solid, with and without a void
 
diff -Naur lammps-29Jan09/examples/reax/data.rdx lammps-12Feb09/examples/reax/data.rdx
--- lammps-29Jan09/examples/reax/data.rdx	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/data.rdx	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,43 @@
+# Position data for C H O N system				
+
+21 atoms
+4 atom types	
+
+35 48 xlo xhi
+35 48 ylo yhi
+35 48 zlo zhi
+
+Masses
+
+1 12.0000
+2 1.0080
+3 15.9990
+4 14.0000
+
+Atoms				
+
+1 1 0 39.24155  41.46863  38.92277    
+2 4 0 39.27964  41.53820  40.44084 
+3 1 0 40.64521  41.50620  41.10779    
+4 4 0 41.60957  40.51708  40.47343    
+5 1 0 41.62276  40.43167  38.95576    
+6 4 0 40.23819  40.48531  38.33063   
+7 4 0 38.24418  40.70058  41.12136   
+8 4 0 41.66978  39.19116  41.16286   
+9 4 0 39.66004  39.14553  38.00265    
+10 3 0 37.19348  40.43753  40.52718   
+11 3 0 38.34902  40.47543  42.33157    
+12 3 0 41.39553  39.12212  42.36547  
+13 3 0 42.20174  38.23511  40.58913 
+14 3 0 40.42044  38.20021  37.76930
+15 3 0 38.45458  39.05315  37.74847
+16 2 0 38.20622  41.30517  38.53402
+17 2 0 39.53639  42.48383  38.55015
+18 2 0 41.09313  42.52384  40.96591 
+19 2 0 40.57077  41.37146  42.21506   
+20 2 0 42.17264  41.33745  38.59030  
+21 2 0 42.21828  39.56012  38.58766    
+
+
+
+
diff -Naur lammps-29Jan09/examples/reax/data.tatb lammps-12Feb09/examples/reax/data.tatb
--- lammps-29Jan09/examples/reax/data.tatb	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/data.tatb	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,406 @@
+# Position data for TATB, C6H6N6O6, 16 molecules			
+
+384 atoms
+4 atom types	
+
+0.0 0.136240000000E+02 xlo xhi
+0.0  0.171149153805E+02 ylo yhi
+0.0 0.151826391451E+02 zlo zhi 
+
+-0.575315630927E+01 -6.325466 7.4257288  xy xz yz
+
+Masses
+
+1 12.0000
+2 1.0080
+3 15.9990
+4 14.0000
+
+Atoms				
+
+         1   1    0      -1.54861   11.25031  5.49299
+         2   1    0      -1.07764   10.65860  4.23736
+         3   1    0      -1.00861   11.47314  3.03061
+         4   1    0      -1.46778   12.85997  3.04000
+         5   1    0      -2.01189   13.43735  4.28107
+         6   1    0      -2.02233   12.63421  5.51085
+         7   2    0      -0.73103    8.77550  5.26339
+         8   2    0      -0.19413    8.98399  3.21664
+         9   2    0      -0.98832   13.09964  0.98046
+         10  2     0     -1.85010   14.78207  2.00945
+         11  2     0     -2.92995   14.29644  6.58777
+         12  2     0     -2.59566   12.42307  7.59092
+         13  4     0     -1.49808   10.48244  6.73385
+         14  4     0     -0.69448    9.36219  4.20529
+         15  4     0     -0.51800   10.87564  1.77786
+         16  4     0     -1.41310   13.60495  1.92669
+         17  4     0     -2.54205   14.78207  4.28105
+         18  4     0     -2.48495   13.16402  6.65589
+         20  3     0     -1.91867   11.02530  7.85252
+         21  3     0     -1.06280    9.24479  6.72301
+         22  3     0     -0.12257    9.63028  1.76565
+         23  3     0     -0.48743   11.60954  0.69872
+         24  3     0     -2.53256   15.51411  3.17907
+         25  3     0     -3.02427   15.29626  5.39167
+         26  1     0     -0.08296   17.35525  4.93569
+         27  1     0      5.19923    0.83205  6.19132
+         28  1     0      5.13019    0.01751  7.39807
+         29  1     0     -0.16379   15.74559  7.38868
+         30  1     0      0.38033   15.16821  6.14761
+         31  1     0      0.39076   15.97134  4.91783
+         32  2     0      4.85261    2.71515  5.16529
+         35  2     0      4.31571    2.50664  7.21204
+         36  2     0      5.10990   -1.60900  9.44822
+         37  2     0      0.21854   13.82349  8.41923
+         38  2     0      1.29838   14.30912  3.84092
+         41  2     0      0.96410   16.18249  2.83776
+         42  4     0     -0.13348   18.12312  3.69483
+         43  4     0      4.81607    2.12845  6.22339
+         44  4     0      4.63959    0.61500  8.65082
+         47  4     0     -0.21847   15.00060  8.50199
+         48  4     0      0.91048   13.82348  6.14763
+         49  4     0      0.85339   15.44153  3.77279
+         50  3     0      0.28711   17.58026  2.57616
+         51  3     0      5.18440    2.24586  3.70568
+         52  3     0      4.24415    1.86036  8.66303
+         53  3     0      4.60901   -0.11890  9.72995
+         54  3     0      0.90099   13.09144  7.24960
+         55  3     0      1.39270   13.30929  5.03702
+         56  1     0      5.26339   11.25031  5.49299
+         57  1     0      5.73436   10.65860  4.23736
+         58  1     0      5.80339   11.47314  3.03061
+         59  1     0      5.34422   12.85997  3.04000
+         60  1     0      4.80011   13.43735  4.28107
+         61  1     0      4.78967   12.63421  5.51085
+         62  2     0      6.08097    8.77550  5.26339
+         63  2     0      6.61787    8.98399  3.21664
+         64  2     0      5.82368   13.09964  0.98046
+         65  2     0      4.96190   14.78207  2.00945
+         66  2     0      3.88205   14.29644  6.58777
+         68  2     0      4.21634   12.42307  7.59092
+         69  4     0      5.31392   10.48244  6.73385
+         70  4     0      6.11752    9.36219  4.20529
+         71  4     0      6.29400   10.87564  1.77786
+         72  4     0      5.39890   13.60495  1.92669
+         73  4     0      4.26995   14.78207  4.28105
+         74  4     0      4.32705   13.16402  6.65589
+         75  3     0      4.89333   11.02530  7.85252
+         76  3     0      5.74920    9.24479  6.72301
+         77  3     0      6.68943    9.63028  1.76565
+         78  3     0      6.32457   11.60954  0.69872
+         79  3     0      4.27944   15.51411  3.17907
+         80  3     0      3.78773   15.29626  5.39167
+         83  1     0      6.72904   17.35525  4.93569
+         84  1     0     12.01123    0.83205  6.19132
+         85  1     0     11.94219    0.01751  7.39807
+         86  1     0      6.64821   15.74559  7.38868
+         89  1     0      7.19233   15.16821  6.14761
+         90  1     0      7.20276   15.97135  4.91783
+         91  2     0     11.66461    2.71515  5.16529
+         92  2     0     11.12771    2.50664  7.21204
+         95  2     0     11.92190   -1.60900  9.44822
+         96  2     0      7.03054   13.82349  8.41923
+         97  2     0      8.11038   14.30912  3.84092
+         98  2     0      7.77610   16.18249  2.83776
+         99  4     0      6.67852   18.12312  3.69483
+         100 4      0    11.62807    2.12845  6.22339
+         101 4      0    11.45159    0.61500  8.65082
+         102 4      0     6.59353   15.00060  8.50199
+         103 4      0     7.72248   13.82348  6.14763
+         104 4      0     7.66539   15.44154  3.77279
+         105 3      0     7.09911   17.58026  2.57616
+         106 3      0    11.99640    2.24586  3.70568
+         107 3      0    11.05615    1.86036  8.66303
+         108 3      0    11.42101   -0.11890  9.72995
+         109 3      0     7.71299   13.09144  7.24960
+         110 3      0     8.20470   13.30929  5.03701
+         111 1      0     1.32797    2.69285  5.49299
+         112 1      0     1.79894    2.10114  4.23735
+         113 1      0     1.86797    2.91569  3.03061
+         114 1      0     1.40880    4.30251  3.04000
+         116 1      0     0.86468    4.87989  4.28107
+         117 1      0     0.85425    4.07676  5.51085
+         118 2      0    -3.60760   17.33296  5.26338
+         119 2      0    -3.07071   17.54145  3.21664
+         120 2      0     1.88826    4.54219  0.98046
+         121 2      0     1.02647    6.22461  2.00945
+         122 2      0    -0.05338    5.73898  6.58776
+         123 2      0     0.28092    3.86561  7.59092
+         124 4      0     1.37850    1.92498  6.73385
+         125 4      0    -3.57105   17.91965  4.20529
+         126 4      0    -3.39458   19.43310  1.77786
+         127 4      0     1.46348    5.04750  1.92669
+         128 4      0     0.33453    6.22462  4.28105
+         131 4      0     0.39163    4.60657  6.65589
+         132 3      0     0.95791    2.46784  7.85252
+         133 3      0     1.81378    0.68733  6.72300
+         134 3      0    -2.99915   18.18775  1.76565
+         137 3      0    -3.36401   20.16700  0.69873
+         138 3      0     0.34402    6.95666  3.17908
+         139 3      0    -0.14770    6.73881  5.39166
+         140 1      0     2.79361    8.79780  4.93569
+         143 1      0     2.32264    9.38950  6.19133
+         144 1      0     2.25361    8.57496  7.39807
+         145 1      0     2.71279    7.18814  7.38868
+         146 1      0     3.25691    6.61076  6.14761
+         147 1      0     3.26733    7.41389  4.91783
+         148 2      0     1.97603   11.27260  5.16529
+         149 2      0     1.43914   11.06410  7.21204
+         150 2      0     2.23333    6.94846  9.44822
+         151 2      0     3.09512    5.26603  8.41923
+         152 2      0     4.17495    5.75167  3.84092
+         153 2      0     3.84068    7.62504  2.83776
+         154 4      0     2.74309    9.56567  3.69483
+         155 4      0     1.93948   10.68591  6.22339
+         156 4      0     1.76301    9.17246  8.65082
+         157 4      0     2.65811    6.44315  8.50199
+         158 4      0     3.78706    5.26603  6.14763
+         159 4      0     3.72996    6.88408  3.77279
+         160 3      0     3.16369    9.02281  2.57616
+         161 3      0     2.30781   10.80332  3.70567
+         162 3      0     1.36757   10.41782  8.66304
+         164 3      0     1.73243    8.43856  9.72995
+         165 3      0     3.77757    4.53399  7.24961
+         166 3      0     4.26928    4.75184  5.03701
+         167 1      0     8.13997    2.69285  5.49299
+         168 1      0     8.61094    2.10114  4.23735
+         169 1      0     8.67997    2.91569  3.03061
+         170 1      0     8.22080    4.30251  3.04000
+         171 1      0     7.67668    4.87989  4.28107
+         172 1      0     7.66625    4.07676  5.51085
+         173 2      0     3.20440   17.33296  5.26338
+         174 2      0     3.74129   17.54145  3.21664
+         175 2      0     8.70026    4.54219  0.98046
+         176 2      0     7.83847    6.22461  2.00945
+         179 2      0     6.75862    5.73898  6.58776
+         180 2      0     7.09292    3.86561  7.59092
+         181 4      0     8.19050    1.92498  6.73385
+         182 4      0     3.24095   17.91965  4.20529
+         185 4      0     3.41742   19.43310  1.77786
+         186 4      0     8.27548    5.04750  1.92669
+         187 4      0     7.14653    6.22462  4.28105
+         188 4      0     7.20363    4.60657  6.65589
+         191 3      0     7.76991    2.46784  7.85252
+         192 3      0     8.62578    0.68733  6.72300
+         211 3      0     3.81285   18.18774  1.76565
+         225 3      0     3.44799   20.16700  0.69872
+         226 3      0     7.15602    6.95666  3.17908
+         231 3      0     6.66430    6.73881  5.39166
+         232 1      0     9.60561    8.79780  4.93569
+         237 1      0     9.13464    9.38950  6.19133
+         238 1      0     9.06561    8.57496  7.39807
+         259 1      0     9.52479    7.18814  7.38868
+         273 1      0    10.06891    6.61076  6.14761
+         274 1      0    10.07933    7.41389  4.91783
+         279 2      0     8.78803   11.27260  5.16529
+         280 2      0     8.25114   11.06410  7.21204
+         285 2      0     9.04533    6.94846  9.44822
+         286 2      0     9.90712    5.26603  8.41923
+         307 2      0    10.98695    5.75167  3.84092
+         321 2      0    10.65268    7.62504  2.83776
+         322 4      0     9.55509    9.56567  3.69483
+         327 4      0     8.75148   10.68591  6.22339
+         328 4      0     8.57501    9.17246  8.65082
+         333 4      0     9.47011    6.44315  8.50199
+         334 4      0    10.59906    5.26603  6.14763
+         355 4      0    10.54196    6.88408  3.77279
+         369 3      0     9.97569    9.02281  2.57616
+         370 3      0     9.11981   10.80332  3.70567
+         375 3      0     8.17957   10.41782  8.66304
+         376 3      0     8.54443    8.43856  9.72995
+         381 3      0    10.58957    4.53399  7.24961
+         382 3      0    11.08128    4.75184  5.03701
+         19  1     0     -1.83476    6.40572 13.08431
+         33  1     0     -1.36379    5.81401 11.82868
+         34  1     0     -1.29476    6.62855 10.62193
+         39  1     0     -1.75393    8.01538 10.63132
+         40  1     0     -2.29804    8.59276 11.87239
+         45  1     0     -2.30848    7.78962 13.10217
+         46  2     0     -1.01718    3.93091 12.85471
+         67  2     0     -0.48028    4.13940 10.80796
+         81  2     0     -1.27447    8.25505  8.57178
+         82  2     0     -2.13625    9.93748  9.60077
+         87  2     0     -3.21610    9.45185 14.17909
+         88  2     0     -2.88181    7.57848 15.18224
+         93  4     0     -1.78423    5.63785 14.32517
+         94  4     0     -0.98063    4.51760 11.79661
+         115 4      0    -0.80415    6.03105  9.36918
+         129 4      0    -1.69925    8.76036  9.51801
+         130 4      0    -2.82820    9.93748 11.87237
+         135 4      0    -2.77110    8.31943 14.24721
+         136 3      0    -2.20482    6.18071 15.44384
+         141 3      0    -1.34895    4.40020 14.31433
+         142 3      0    -0.40872    4.78569  9.35697
+         163 3      0    -0.77358    6.76495  8.29004
+         177 3      0    -2.81871   10.66952 10.77039
+         178 3      0    -3.31042   10.45167 12.98299
+         183 1      0    -0.36911   12.51066 12.52701
+         184 1      0     4.91308   -4.01254 13.78265
+         189 1      0     4.84404   -4.82709 14.98939
+         190 1      0    -0.44994   10.90100 14.98000
+         193 1      0     0.09418   10.32362 13.73893
+         194 1      0     0.10461   11.12675 12.50915
+         195 2      0     4.56646   -2.12944 12.75661
+         196 2      0     4.02956   -2.33795 14.80336
+         197 2      0     4.82375   -6.45359 17.03954
+         198 2      0    -0.06761    8.97890 16.01055
+         199 2      0     1.01223    9.46454 11.43224
+         200 2      0     0.67795   11.33790 10.42908
+         201 4      0    -0.41963   13.27853 11.28615
+         202 4      0     4.52992   -2.71614 13.81471
+         203 4      0     4.35344   -4.22959 16.24214
+         204 4      0    -0.50462   10.15601 16.09331
+         205 4      0     0.62433    8.97889 13.73895
+         206 4      0     0.56724   10.59694 11.36411
+         207 3      0     0.00096   12.73567 10.16748
+         208 3      0     4.89825   -2.59873 11.29700
+         209 3      0     3.95800   -2.98423 16.25435
+         210 3      0     4.32286   -4.96349 17.32127
+         212 3      0     0.61484    8.24685 14.84092
+         213 3      0     1.10655    8.46470 12.62834
+         214 1      0     4.97724    6.40572 13.08431
+         215 1      0     5.44821    5.81401 11.82868
+         216 1      0     5.51724    6.62855 10.62193
+         217 1      0     5.05807    8.01538 10.63132
+         218 1      0     4.51396    8.59276 11.87239
+         219 1      0     4.50352    7.78962 13.10217
+         220 2      0     5.79482    3.93091 12.85471
+         221 2      0     6.33172    4.13940 10.80796
+         222 2      0     5.53753    8.25505  8.57178
+         223 2      0     4.67575    9.93748  9.60077
+         224 2      0     3.59590    9.45185 14.17909
+         227 2      0     3.93019    7.57848 15.18224
+         228 4      0     5.02777    5.63785 14.32517
+         229 4      0     5.83137    4.51760 11.79661
+         230 4      0     6.00785    6.03105  9.36918
+         233 4      0     5.11275    8.76036  9.51801
+         234 4      0     3.98380    9.93748 11.87237
+         235 4      0     4.04090    8.31943 14.24721
+         236 3      0     4.60718    6.18071 15.44384
+         239 3      0     5.46305    4.40020 14.31433
+         240 3      0     6.40328    4.78569  9.35697
+         241 3      0     6.03842    6.76495  8.29004
+         242 3      0     3.99329   10.66952 10.77039
+         243 3      0     3.50158   10.45167 12.98299
+         244 1      0     6.44289   12.51066 12.52701
+         245 1      0    11.72508   -4.01254 13.78265
+         246 1      0    11.65604   -4.82709 14.98939
+         247 1      0     6.36206   10.90100 14.98000
+         248 1      0     6.90618   10.32362 13.73893
+         249 1      0     6.91661   11.12675 12.50915
+         250 2      0    11.37846   -2.12944 12.75661
+         251 2      0    10.84156   -2.33795 14.80336
+         252 2      0    11.63575   -6.45360 17.03954
+         253 2      0     6.74439    8.97890 16.01055
+         254 2      0     7.82423    9.46454 11.43224
+         255 2      0     7.48995   11.33790 10.42908
+         256 4      0     6.39237   13.27853 11.28615
+         257 4      0    11.34192   -2.71614 13.81471
+         258 4      0    11.16544   -4.22959 16.24214
+         260 4      0     6.30738   10.15601 16.09331
+         261 4      0     7.43633    8.97889 13.73895
+         262 4      0     7.37924   10.59694 11.36411
+         263 3      0     6.81296   12.73567 10.16748
+         264 3      0    11.71025   -2.59873 11.29700
+         265 3      0    10.77000   -2.98423 16.25435
+         266 3      0    11.13486   -4.96350 17.32127
+         267 3      0     7.42684    8.24685 14.84092
+         268 3      0     7.91855    8.46470 12.62834
+         269 1      0     1.04182   -2.15174 13.08431
+         270 1      0     1.51279   -2.74345 11.82867
+         271 1      0     1.58182   -1.92890 10.62193
+         272 1      0     1.12265   -0.54208 10.63132
+         275 1      0     0.57853    0.03530 11.87239
+         276 1      0     0.56810   -0.76783 13.10217
+         277 2      0    -3.89375   12.48837 12.85470
+         278 2      0    -3.35686   12.69686 10.80796
+         281 2      0     1.60211   -0.30240  8.57178
+         282 2      0     0.74032    1.38002  9.60077
+         283 2      0    -0.33952    0.89439 14.17908
+         284 2      0    -0.00523   -0.97898 15.18224
+         287 4      0     1.09235   -2.91961 14.32517
+         288 4      0    -3.85720   13.07506 11.79661
+         289 4      0    -3.68073   14.58851  9.36918
+         290 4      0     1.17733    0.20291  9.51801
+         291 4      0     0.04838    1.38003 11.87237
+         292 4      0     0.10548   -0.23802 14.24721
+         293 3      0     0.67176   -2.37675 15.44384
+         294 3      0     1.52763   -4.15726 14.31432
+         295 3      0    -3.28530   13.34315  9.35697
+         296 3      0    -3.65016   15.32241  8.29004
+         297 3      0     0.05787    2.11207 10.77040
+         298 3      0    -0.43385    1.89422 12.98299
+         299 1      0     2.50746    3.95321 12.52701
+         300 1      0     2.03649    4.54491 13.782650
+         301 1      0     1.96746    3.73037 14.98939
+         302 1      0     2.42664    2.34355 14.98000
+         303 1      0     2.97076    1.76617 13.73893
+         304 1      0     2.98118    2.56930 12.50915
+         305 2      0     1.68988    6.42801 12.75661
+         306 2      0     1.15299    6.21951 14.80336
+         308 2      0     1.94718    2.10387 17.03954
+         309 2      0     2.80897    0.42144 16.01055
+         310 2      0     3.88880    0.90708 11.43224
+         311 2      0     3.55453    2.78045 10.42908
+         312 4      0     2.45694    4.72108 11.28615
+         313 4      0     1.65333    5.84132 13.81471
+         314 4      0     1.47686    4.32787 16.24214
+         315 4      0     2.37196    1.59856 16.09331
+         316 4      0     3.50091    0.42144 13.73895
+         317 4      0     3.44381    2.03949 11.36411
+         318 3      0     2.87754    4.17822 10.16748
+         319 3      0     2.02166    5.95873 11.29699
+         320 3      0     1.08142    5.57323 16.25436
+         323 3      0     1.44628    3.59397 17.32127
+         324 3      0     3.49142   -0.31060 14.84093
+         325 3      0     3.98313   -0.09275 12.62833
+         326 1      0     7.85382   -2.15174 13.08431
+         329 1      0     8.32479   -2.74345 11.82867
+         330 1      0     8.39382   -1.92890 10.62193
+         331 1      0     7.93465   -0.54208 10.63132
+         332 1      0     7.39053    0.03530 11.87239
+         335 1      0     7.38010   -0.76783 13.10217
+         336 2      0     2.91825   12.48837 12.85470
+         337 2      0     3.45514   12.69686 10.80796
+         338 2      0     8.41411   -0.30240  8.57178
+         339 2      0     7.55232    1.38002  9.60077
+         340 2      0     6.47247    0.89439 14.17908
+         341 2      0     6.80677   -0.97898 15.18224
+         342 4      0     7.90435   -2.91961 14.32517
+         343 4      0     2.95479   13.07506 11.79661
+         344 4      0     3.13127   14.58851  9.36918
+         345 4      0     7.98933    0.20291  9.51801
+         346 4      0     6.86038    1.38003 11.87237
+         347 4      0     6.91748   -0.23802 14.24721
+         348 3      0     7.48376   -2.37675 15.44384
+         349 3      0     8.33963   -4.15726 14.31432
+         350 3      0     3.52670   13.34315  9.35697
+         351 3      0     3.16184   15.32241  8.29004
+         352 3      0     6.86987    2.11207 10.77040
+         353 3      0     6.37815    1.89422 12.98298
+         354 1      0     9.31946    3.95321 12.52701
+         356 1      0     8.84849    4.54491 13.78265
+         357 1      0     8.77946    3.73037 14.98939
+         358 1      0     9.23864    2.34355 14.98000
+         359 1      0     9.78276    1.76617 13.73893
+         360 1      0     9.79318    2.56930 12.50915
+         361 2      0     8.50188    6.42801 12.75661
+         362 2      0     7.96499    6.21951 14.80336
+         363 2      0     8.75918    2.10387 17.03954
+         364 2      0     9.62097    0.42144 16.01055
+         365 2      0    10.70080    0.90708 11.43224
+         366 2      0    10.36653    2.78045 10.42908
+         367 4      0     9.26894    4.72108 11.28615
+         368 4      0     8.46533    5.84132 13.81471
+         371 4      0     8.28886    4.32787 16.24214
+         372 4      0     9.18396    1.59856 16.09331
+         373 4      0    10.31291    0.42144 13.73895
+         374 4      0    10.25581    2.03949 11.36411
+         377 3      0     9.68954    4.17822 10.16748
+         378 3      0     8.83366    5.95873 11.29699
+         379 3      0     7.89342    5.57323 16.25436
+         380 3      0     8.25828    3.59397 17.32127
+         383 3      0    10.30342   -0.31060 14.84093
+         384 3      0    10.79513   -0.09275 12.62833
+
+
diff -Naur lammps-29Jan09/examples/reax/dump.reax.rdx lammps-12Feb09/examples/reax/dump.reax.rdx
--- lammps-29Jan09/examples/reax/dump.reax.rdx	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/dump.reax.rdx	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,330 @@
+ITEM: TIMESTEP
+0
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.326273 0.497587 0.301752
+4 4 0.508428 0.424391 0.421033
+5 1 0.509443 0.417821 0.304289
+6 4 0.402938 0.421947 0.256202
+7 4 0.249552 0.438506 0.470874
+8 4 0.51306 0.322397 0.474066
+9 4 0.358465 0.318887 0.230973
+10 3 0.168729 0.418272 0.425168
+13 3 0.55398 0.248855 0.429933
+14 3 0.416957 0.24617 0.213023
+15 3 0.265737 0.311781 0.211421
+16 2 0.246632 0.485013 0.271848
+20 2 0.551742 0.487496 0.276177
+21 2 0.555252 0.350778 0.275974
+11 3 0.257617 0.421187 0.563967
+12 3 0.491964 0.317086 0.566575
+19 2 0.428521 0.490112 0.555005
+2 4 0.329203 0.502938 0.418526
+3 1 0.434247 0.500477 0.46983
+17 2 0.348953 0.575679 0.273088
+18 2 0.468702 0.578757 0.458916
+ITEM: TIMESTEP
+10
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.326608 0.497799 0.301796
+4 4 0.509047 0.424706 0.421159
+5 1 0.509378 0.418195 0.30433
+6 4 0.403081 0.422251 0.255579
+7 4 0.249271 0.43843 0.47105
+8 4 0.513202 0.322148 0.474253
+9 4 0.358356 0.318629 0.230768
+10 3 0.168648 0.41811 0.425345
+13 3 0.553897 0.248682 0.430113
+14 3 0.416761 0.245994 0.213026
+15 3 0.265742 0.311523 0.211429
+16 2 0.246958 0.484537 0.272224
+20 2 0.551782 0.487771 0.276191
+21 2 0.554731 0.350696 0.276375
+11 3 0.257418 0.421022 0.563961
+12 3 0.491975 0.316833 0.566569
+19 2 0.428303 0.489601 0.554577
+2 4 0.329007 0.503612 0.41864
+3 1 0.434338 0.500675 0.469516
+17 2 0.349179 0.57589 0.2731
+18 2 0.468779 0.578958 0.458727
+ITEM: TIMESTEP
+20
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327232 0.497802 0.302068
+4 4 0.509935 0.425027 0.421406
+5 1 0.508975 0.418625 0.30459
+6 4 0.403251 0.422559 0.254659
+7 4 0.249268 0.438894 0.471023
+8 4 0.51358 0.322478 0.47425
+9 4 0.358506 0.318959 0.230424
+10 3 0.16851 0.417708 0.425778
+13 3 0.553644 0.248298 0.430546
+14 3 0.416258 0.245601 0.213081
+15 3 0.265797 0.310905 0.2115
+16 2 0.247627 0.485471 0.272048
+20 2 0.551392 0.488204 0.276441
+21 2 0.554913 0.351713 0.2762
+11 3 0.256954 0.420606 0.56389
+12 3 0.491979 0.316226 0.566508
+19 2 0.428654 0.490491 0.554061
+2 4 0.32863 0.504499 0.418865
+3 1 0.434319 0.500648 0.46888
+17 2 0.349815 0.575901 0.273369
+18 2 0.468778 0.57894 0.458118
+ITEM: TIMESTEP
+30
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327152 0.498104 0.301881
+4 4 0.510181 0.425474 0.421312
+5 1 0.509279 0.418722 0.304416
+6 4 0.403465 0.423007 0.254455
+7 4 0.248819 0.439412 0.471254
+8 4 0.514291 0.322525 0.474545
+9 4 0.358537 0.319 0.229662
+10 3 0.16852 0.417275 0.426034
+13 3 0.553247 0.24802 0.430812
+14 3 0.415835 0.245307 0.213333
+15 3 0.265872 0.310432 0.211776
+16 2 0.247602 0.485874 0.27181
+20 2 0.550881 0.489024 0.276768
+21 2 0.555297 0.351903 0.275991
+11 3 0.256714 0.420178 0.563717
+12 3 0.491831 0.315759 0.566356
+19 2 0.428862 0.490762 0.554233
+2 4 0.32878 0.504988 0.418759
+3 1 0.434436 0.500921 0.469066
+17 2 0.350905 0.5761 0.273765
+18 2 0.468845 0.579092 0.457104
+ITEM: TIMESTEP
+40
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327429 0.498468 0.3018
+4 4 0.509509 0.425182 0.421141
+5 1 0.509381 0.419121 0.304355
+6 4 0.40336 0.422734 0.255143
+7 4 0.248614 0.440186 0.471334
+8 4 0.515014 0.322904 0.474686
+9 4 0.358717 0.319379 0.22896
+10 3 0.168609 0.416969 0.425823
+13 3 0.552903 0.247872 0.430601
+14 3 0.415866 0.245146 0.213734
+15 3 0.26573 0.31039 0.212199
+16 2 0.247793 0.485681 0.271957
+20 2 0.552301 0.488274 0.27594
+21 2 0.554988 0.351771 0.276209
+11 3 0.256885 0.41986 0.563678
+12 3 0.491482 0.315709 0.566353
+19 2 0.428594 0.490502 0.554034
+2 4 0.329053 0.504291 0.418582
+3 1 0.43457 0.501235 0.468873
+17 2 0.349474 0.576628 0.272865
+18 2 0.469067 0.579609 0.458902
+ITEM: TIMESTEP
+50
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.326925 0.498436 0.301528
+4 4 0.509 0.425035 0.420987
+5 1 0.509724 0.41867 0.304158
+6 4 0.403321 0.422594 0.255677
+7 4 0.248321 0.440383 0.471478
+8 4 0.515334 0.322818 0.474887
+9 4 0.358684 0.319294 0.22862
+10 3 0.168879 0.416955 0.425261
+13 3 0.55266 0.248025 0.430059
+14 3 0.416244 0.245305 0.21418
+15 3 0.265578 0.310821 0.212667
+16 2 0.247483 0.485768 0.271684
+20 2 0.551538 0.488768 0.276386
+21 2 0.555312 0.351574 0.275962
+11 3 0.2574 0.41981 0.563631
+12 3 0.491115 0.316112 0.566341
+19 2 0.428647 0.490502 0.554443
+2 4 0.329301 0.503794 0.418392
+3 1 0.434537 0.501162 0.469467
+17 2 0.350474 0.576427 0.273298
+18 2 0.468964 0.579358 0.457882
+ITEM: TIMESTEP
+60
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327058 0.497995 0.301769
+4 4 0.509231 0.424815 0.421196
+5 1 0.509351 0.418429 0.304417
+6 4 0.403254 0.422371 0.255384
+7 4 0.248666 0.440173 0.471222
+8 4 0.514913 0.322916 0.474652
+9 4 0.358727 0.319414 0.229155
+10 3 0.169105 0.417076 0.424867
+13 3 0.552527 0.248218 0.42973
+14 3 0.416483 0.245515 0.214438
+15 3 0.265546 0.311176 0.212951
+16 2 0.247647 0.486179 0.271548
+20 2 0.551221 0.488554 0.276654
+21 2 0.555529 0.351854 0.275991
+11 3 0.257718 0.419883 0.563518
+12 3 0.490989 0.316436 0.566299
+19 2 0.428739 0.490808 0.554335
+2 4 0.329 0.503768 0.418553
+3 1 0.434315 0.500681 0.469259
+17 2 0.350589 0.576047 0.273553
+18 2 0.468756 0.578935 0.457764
+ITEM: TIMESTEP
+70
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327228 0.49794 0.30183
+4 4 0.510027 0.425014 0.421459
+5 1 0.509236 0.418488 0.304544
+6 4 0.403405 0.422581 0.254543
+7 4 0.248993 0.439189 0.470947
+8 4 0.513911 0.322519 0.474402
+9 4 0.358544 0.319031 0.230246
+10 3 0.169142 0.417237 0.424633
+13 3 0.552527 0.2483 0.429598
+14 3 0.416596 0.245628 0.214497
+15 3 0.265529 0.311369 0.213038
+16 2 0.247687 0.485106 0.272032
+20 2 0.551801 0.48801 0.276345
+21 2 0.554684 0.351123 0.276457
+11 3 0.257807 0.420002 0.563474
+12 3 0.491064 0.316618 0.566325
+19 2 0.428259 0.489637 0.554111
+2 4 0.328619 0.504475 0.418762
+3 1 0.434313 0.500596 0.469083
+17 2 0.349964 0.576075 0.273226
+18 2 0.468794 0.578958 0.458543
+ITEM: TIMESTEP
+80
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.32711 0.497758 0.301843
+4 4 0.510092 0.425389 0.421302
+5 1 0.509238 0.418223 0.304546
+6 4 0.40362 0.422989 0.254558
+7 4 0.249837 0.438431 0.470332
+8 4 0.512756 0.32259 0.47384
+9 4 0.358586 0.319167 0.231624
+10 3 0.169227 0.417323 0.42484
+13 3 0.552411 0.248378 0.429892
+14 3 0.416262 0.245739 0.214485
+15 3 0.265825 0.311236 0.213065
+16 2 0.247545 0.485205 0.271944
+20 2 0.55209 0.487535 0.276227
+21 2 0.554866 0.351083 0.276411
+11 3 0.257514 0.420042 0.563142
+12 3 0.491334 0.316488 0.566117
+19 2 0.428333 0.489771 0.554295
+2 4 0.328904 0.504773 0.418568
+3 1 0.434217 0.500401 0.469239
+17 2 0.349481 0.575935 0.27303
+18 2 0.468715 0.578816 0.459064
+ITEM: TIMESTEP
+90
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.326935 0.498273 0.301488
+4 4 0.509614 0.425531 0.421036
+5 1 0.509829 0.418404 0.304244
+6 4 0.403738 0.423173 0.2551
+7 4 0.250263 0.437831 0.469933
+8 4 0.512022 0.322505 0.47352
+9 4 0.35854 0.319109 0.232513
+10 3 0.169213 0.417294 0.424819
+13 3 0.552245 0.248284 0.430023
+14 3 0.416083 0.245763 0.214608
+15 3 0.265905 0.311107 0.213212
+16 2 0.247407 0.484796 0.27188
+20 2 0.552743 0.48764 0.275884
+21 2 0.554738 0.350576 0.276519
+11 3 0.257415 0.420002 0.562942
+12 3 0.491432 0.316414 0.565997
+19 2 0.428058 0.489335 0.55451
+2 4 0.329371 0.504557 0.418306
+3 1 0.43446 0.500917 0.469602
+17 2 0.34919 0.576466 0.272688
+18 2 0.46896 0.579319 0.459469
+ITEM: TIMESTEP
+100
+ITEM: NUMBER OF ATOMS
+21
+ITEM: BOX BOUNDS
+35 48
+35 48
+35 48
+ITEM: ATOMS
+1 1 0.327483 0.498915 0.301434
+4 4 0.509137 0.425356 0.420887
+5 1 0.509945 0.419177 0.304176
+6 4 0.4037 0.423015 0.255628
+7 4 0.250144 0.437683 0.469852
+8 4 0.511984 0.322312 0.473586
+9 4 0.358472 0.318975 0.232614
+10 3 0.169236 0.417105 0.424553
+13 3 0.551932 0.248123 0.429875
+14 3 0.416118 0.245651 0.214965
+15 3 0.265804 0.311083 0.213608
+16 2 0.24777 0.485768 0.271724
+20 2 0.553332 0.488017 0.275592
+21 2 0.555154 0.351523 0.2762
+11 3 0.257596 0.419852 0.562724
+12 3 0.491237 0.316397 0.566006
+19 2 0.428507 0.490218 0.55427
+2 4 0.329585 0.504077 0.41824
+3 1 0.434712 0.501501 0.469167
+17 2 0.349329 0.577108 0.272362
+18 2 0.469281 0.579959 0.459824
diff -Naur lammps-29Jan09/examples/reax/dump.reax.tatb lammps-12Feb09/examples/reax/dump.reax.tatb
--- lammps-29Jan09/examples/reax/dump.reax.tatb	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/dump.reax.tatb	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,786 @@
+ITEM: TIMESTEP
+0
+ITEM: NUMBER OF ATOMS
+384
+ITEM: BOX BOUNDS
+-12.0786 13.624
+0 24.5406
+0 15.1826
+ITEM: ATOMS
+7 2 -0.73103 8.7755 5.26339
+8 2 -0.19413 8.98399 3.21664
+13 4 -1.49808 10.4824 6.73385
+14 4 -0.69448 9.36219 4.20529
+21 3 -1.0628 9.24479 6.72301
+32 2 4.85261 2.71515 5.16529
+51 3 5.1844 2.24586 3.70568
+62 2 6.08097 8.7755 5.26339
+63 2 6.61787 8.98399 3.21664
+69 4 5.31392 10.4824 6.73385
+70 4 6.11752 9.36219 4.20529
+76 3 5.7492 9.24479 6.72301
+91 2 -1.95939 2.71515 5.16529
+106 3 -1.6276 2.24586 3.70568
+111 1 1.32797 2.69285 5.49299
+112 1 1.79894 2.10114 4.23735
+113 1 1.86797 2.91569 3.03061
+114 1 1.4088 4.30251 3.04
+116 1 0.86468 4.87989 4.28107
+117 1 0.85425 4.07676 5.51085
+120 2 1.88826 4.54219 0.98046
+121 2 1.02647 6.22461 2.00945
+122 2 -0.05338 5.73898 6.58776
+123 2 0.28092 3.86561 7.59092
+126 4 2.35858 2.31818 1.77786
+127 4 1.46348 5.0475 1.92669
+128 4 0.33453 6.22462 4.28105
+131 4 0.39163 4.60657 6.65589
+134 3 2.75401 1.07283 1.76565
+137 3 2.38915 3.05208 0.69873
+138 3 0.34402 6.95666 3.17908
+139 3 -0.1477 6.73881 5.39166
+140 1 2.79361 8.7978 4.93569
+143 1 2.32264 9.3895 6.19133
+144 1 2.25361 8.57496 7.39807
+145 1 2.71279 7.18814 7.38868
+146 1 3.25691 6.61076 6.14761
+147 1 3.26733 7.41389 4.91783
+149 2 1.43914 11.0641 7.21204
+152 2 4.17495 5.75167 3.84092
+153 2 3.84068 7.62504 2.83776
+154 4 2.74309 9.56567 3.69483
+155 4 1.93948 10.6859 6.22339
+158 4 3.78706 5.26603 6.14763
+159 4 3.72996 6.88408 3.77279
+160 3 3.16369 9.02281 2.57616
+165 3 3.77757 4.53399 7.24961
+166 3 4.26928 4.75184 5.03701
+167 1 8.13997 2.69285 5.49299
+168 1 8.61094 2.10114 4.23735
+169 1 8.67997 2.91569 3.03061
+170 1 8.2208 4.30251 3.04
+171 1 7.67668 4.87989 4.28107
+172 1 7.66625 4.07676 5.51085
+175 2 8.70026 4.54219 0.98046
+176 2 7.83847 6.22461 2.00945
+179 2 6.75862 5.73898 6.58776
+180 2 7.09292 3.86561 7.59092
+185 4 9.17058 2.31818 1.77786
+186 4 8.27548 5.0475 1.92669
+187 4 7.14653 6.22462 4.28105
+188 4 7.20363 4.60657 6.65589
+211 3 9.56601 1.07282 1.76565
+225 3 9.20115 3.05208 0.69872
+226 3 7.15602 6.95666 3.17908
+231 3 6.6643 6.73881 5.39166
+232 1 -4.01839 8.7978 4.93569
+237 1 -4.48936 9.3895 6.19133
+238 1 -4.55839 8.57496 7.39807
+259 1 -4.09921 7.18814 7.38868
+273 1 -3.55509 6.61076 6.14761
+274 1 -3.54467 7.41389 4.91783
+280 2 -5.37286 11.0641 7.21204
+307 2 -2.63705 5.75167 3.84092
+321 2 -2.97132 7.62504 2.83776
+322 4 -4.06891 9.56567 3.69483
+327 4 -4.87252 10.6859 6.22339
+334 4 -3.02494 5.26603 6.14763
+355 4 -3.08204 6.88408 3.77279
+369 3 -3.64831 9.02281 2.57616
+381 3 -3.03443 4.53399 7.24961
+382 3 -2.54272 4.75184 5.03701
+197 2 5.39606 3.2356 1.8569
+198 2 6.25786 1.55317 0.827911
+203 4 4.92575 5.4596 1.0595
+204 4 5.82085 2.73028 0.910671
+209 3 4.53031 6.70496 1.07171
+210 3 4.89517 4.7257 2.13863
+252 2 -1.41594 3.23559 1.8569
+253 2 -0.554144 1.55317 0.827911
+258 4 -1.88625 5.4596 1.0595
+260 4 -0.991154 2.73028 0.910671
+265 3 -2.28169 6.70496 1.07171
+266 3 -1.91683 4.72569 2.13863
+293 3 1.24407 7.31244 0.261201
+348 3 8.05607 7.31244 0.261201
+20 3 -1.91867 11.0253 7.85252
+75 3 4.89333 11.0253 7.85252
+150 2 2.23333 6.94846 9.44822
+151 2 3.09512 5.26603 8.41923
+156 4 1.76301 9.17246 8.65082
+157 4 2.65811 6.44315 8.50199
+162 3 1.36757 10.4178 8.66304
+164 3 1.73243 8.43856 9.72995
+285 2 -4.57867 6.94846 9.44822
+286 2 -3.71688 5.26603 8.41923
+328 4 -5.04899 9.17246 8.65082
+333 4 -4.15389 6.44315 8.50199
+375 3 -5.44443 10.4178 8.66304
+376 3 -5.07957 8.43856 9.72995
+19 1 -1.83476 6.40572 13.0843
+33 1 -1.36379 5.81401 11.8287
+34 1 -1.29476 6.62855 10.6219
+39 1 -1.75393 8.01538 10.6313
+40 1 -2.29804 8.59276 11.8724
+45 1 -2.30848 7.78962 13.1022
+81 2 -1.27447 8.25505 8.57178
+82 2 -2.13625 9.93748 9.60077
+87 2 -3.2161 9.45185 14.1791
+88 2 -2.88181 7.57848 15.1822
+115 4 -0.80415 6.03105 9.36918
+129 4 -1.69925 8.76036 9.51801
+130 4 -2.8282 9.93748 11.8724
+135 4 -2.7711 8.31943 14.2472
+142 3 -0.40872 4.78569 9.35697
+163 3 -0.77358 6.76495 8.29004
+177 3 -2.81871 10.6695 10.7704
+178 3 -3.31042 10.4517 12.983
+183 1 -0.36911 12.5107 12.527
+184 1 -0.840076 13.1024 13.7827
+189 1 -0.909116 12.2878 14.9894
+190 1 -0.44994 10.901 14.98
+193 1 0.09418 10.3236 13.7389
+194 1 0.10461 11.1267 12.5091
+196 2 -1.7236 14.777 14.8034
+199 2 1.01223 9.46454 11.4322
+200 2 0.67795 11.3379 10.4291
+201 4 -0.41963 13.2785 11.2861
+202 4 -1.22324 14.3988 13.8147
+205 4 0.62433 8.97889 13.739
+206 4 0.56724 10.5969 11.3641
+207 3 0.00096 12.7357 10.1675
+212 3 0.61484 8.24685 14.8409
+213 3 1.10655 8.4647 12.6283
+214 1 4.97724 6.40572 13.0843
+215 1 5.44821 5.81401 11.8287
+216 1 5.51724 6.62855 10.6219
+217 1 5.05807 8.01538 10.6313
+218 1 4.51396 8.59276 11.8724
+219 1 4.50352 7.78962 13.1022
+222 2 5.53753 8.25505 8.57178
+223 2 4.67575 9.93748 9.60077
+224 2 3.5959 9.45185 14.1791
+227 2 3.93019 7.57848 15.1822
+230 4 6.00785 6.03105 9.36918
+233 4 5.11275 8.76036 9.51801
+234 4 3.9838 9.93748 11.8724
+235 4 4.0409 8.31943 14.2472
+240 3 6.40328 4.78569 9.35697
+241 3 6.03842 6.76495 8.29004
+242 3 3.99329 10.6695 10.7704
+243 3 3.50158 10.4517 12.983
+244 1 -7.18111 12.5107 12.527
+245 1 -7.65208 13.1024 13.7827
+246 1 -7.72112 12.2878 14.9894
+247 1 -7.26194 10.901 14.98
+248 1 -6.71782 10.3236 13.7389
+249 1 -6.70739 11.1267 12.5091
+251 2 -8.5356 14.777 14.8034
+254 2 -5.79977 9.46454 11.4322
+255 2 -6.13405 11.3379 10.4291
+256 4 -7.23163 13.2785 11.2861
+257 4 -8.03524 14.3988 13.8147
+261 4 -6.18767 8.97889 13.739
+262 4 -6.24476 10.5969 11.3641
+263 3 -6.81104 12.7357 10.1675
+267 3 -6.19716 8.24685 14.8409
+268 3 -5.70545 8.4647 12.6283
+277 2 -3.89375 12.4884 12.8547
+278 2 -3.35686 12.6969 10.808
+287 4 -4.66081 14.1953 14.3252
+288 4 -3.8572 13.0751 11.7966
+294 3 -4.22553 12.9577 14.3143
+305 2 1.68988 6.42801 12.7566
+319 3 2.02166 5.95873 11.297
+336 2 2.91825 12.4884 12.8547
+337 2 3.45514 12.6969 10.808
+342 4 2.15119 14.1953 14.3252
+343 4 2.95479 13.0751 11.7966
+349 3 2.58647 12.9577 14.3143
+361 2 -5.12212 6.42801 12.7566
+378 3 -4.79034 5.95873 11.297
+1 1 -1.54861 11.2503 5.49299
+2 1 -1.07764 10.6586 4.23736
+3 1 -1.00861 11.4731 3.03061
+4 1 -1.46778 12.86 3.04
+5 1 -2.01189 13.4374 4.28107
+6 1 -2.02233 12.6342 5.51085
+9 2 -0.98832 13.0996 0.98046
+10 2 -1.8501 14.7821 2.00945
+11 2 -2.92995 14.2964 6.58777
+12 2 -2.59566 12.4231 7.59092
+15 4 -0.518 10.8756 1.77786
+16 4 -1.4131 13.605 1.92669
+17 4 -2.54205 14.7821 4.28105
+18 4 -2.48495 13.164 6.65589
+22 3 -0.12257 9.63028 1.76565
+23 3 -0.48743 11.6095 0.69872
+24 3 -2.53256 15.5141 3.17907
+25 3 -3.02427 15.2963 5.39167
+26 1 -0.08296 17.3553 4.93569
+27 1 -0.553926 17.947 6.19132
+28 1 -0.622966 17.1324 7.39807
+29 1 -0.16379 15.7456 7.38868
+30 1 0.38033 15.1682 6.14761
+31 1 0.39076 15.9713 4.91783
+35 2 -1.43745 19.6216 7.21204
+38 2 1.29838 14.3091 3.84092
+41 2 0.9641 16.1825 2.83776
+42 4 -0.13348 18.1231 3.69483
+43 4 -0.937086 19.2434 6.22339
+48 4 0.91048 13.8235 6.14763
+49 4 0.85339 15.4415 3.77279
+50 3 0.28711 17.5803 2.57616
+54 3 0.90099 13.0914 7.2496
+55 3 1.3927 13.3093 5.03702
+56 1 5.26339 11.2503 5.49299
+57 1 5.73436 10.6586 4.23736
+58 1 5.80339 11.4731 3.03061
+59 1 5.34422 12.86 3.04
+60 1 4.80011 13.4374 4.28107
+61 1 4.78967 12.6342 5.51085
+64 2 5.82368 13.0996 0.98046
+65 2 4.9619 14.7821 2.00945
+66 2 3.88205 14.2964 6.58777
+68 2 4.21634 12.4231 7.59092
+71 4 6.294 10.8756 1.77786
+72 4 5.3989 13.605 1.92669
+73 4 4.26995 14.7821 4.28105
+74 4 4.32705 13.164 6.65589
+77 3 6.68943 9.63028 1.76565
+78 3 6.32457 11.6095 0.69872
+79 3 4.27944 15.5141 3.17907
+80 3 3.78773 15.2963 5.39167
+83 1 -6.89496 17.3553 4.93569
+84 1 -7.36593 17.947 6.19132
+85 1 -7.43497 17.1324 7.39807
+86 1 -6.97579 15.7456 7.38868
+89 1 -6.43167 15.1682 6.14761
+90 1 -6.42124 15.9713 4.91783
+92 2 -8.24945 19.6216 7.21204
+97 2 -5.51362 14.3091 3.84092
+98 2 -5.8479 16.1825 2.83776
+99 4 -6.94548 18.1231 3.69483
+100 4 -7.74909 19.2434 6.22339
+103 4 -5.90152 13.8235 6.14763
+104 4 -5.95861 15.4415 3.77279
+105 3 -6.52489 17.5803 2.57616
+109 3 -5.91101 13.0914 7.2496
+110 3 -5.4193 13.3093 5.03701
+118 2 -3.6076 17.333 5.26338
+119 2 -3.07071 17.5415 3.21664
+124 4 -4.37466 19.0399 6.73385
+125 4 -3.57105 17.9197 4.20529
+133 3 -3.93938 17.8022 6.723
+148 2 1.97603 11.2726 5.16529
+161 3 2.30781 10.8033 3.70567
+173 2 3.2044 17.333 5.26338
+174 2 3.74129 17.5415 3.21664
+181 4 2.43734 19.0399 6.73385
+182 4 3.24095 17.9197 4.20529
+192 3 2.87262 17.8022 6.723
+279 2 -4.83597 11.2726 5.16529
+370 3 -4.50419 10.8033 3.70567
+136 3 -1.63251 15.8699 0.261201
+236 3 5.17949 15.8699 0.261201
+308 2 2.51949 11.7931 1.8569
+309 2 3.38128 10.1106 0.827911
+314 4 2.04917 14.0171 1.0595
+315 4 2.94427 11.2877 0.910671
+320 3 1.65373 15.2624 1.07172
+323 3 2.01859 13.2832 2.13863
+363 2 -4.29251 11.7931 1.8569
+364 2 -3.43072 10.1106 0.827911
+371 4 -4.76283 14.0171 1.0595
+372 4 -3.86773 11.2877 0.910671
+379 3 -5.15827 15.2624 1.07172
+380 3 -4.79341 13.2832 2.13863
+36 2 -0.643256 15.5059 9.44822
+37 2 0.21854 13.8235 8.41923
+44 4 -1.11357 17.7299 8.65082
+47 4 -0.21847 15.0006 8.50199
+52 3 -1.50901 18.9753 8.66303
+53 3 -1.14415 16.996 9.72995
+95 2 -7.45526 15.5059 9.44822
+96 2 -6.59346 13.8235 8.41923
+101 4 -7.92557 17.7299 8.65082
+102 4 -7.03047 15.0006 8.50199
+107 3 -8.32101 18.9753 8.66303
+108 3 -7.95615 16.996 9.72995
+132 3 -4.79525 19.5828 7.85252
+191 3 2.01675 19.5828 7.85252
+46 2 -6.77034 21.0458 12.8547
+67 2 -6.23344 21.2543 10.808
+93 4 -7.53739 22.7528 14.3252
+94 4 -6.73379 21.6325 11.7966
+141 3 -7.10211 21.5151 14.3143
+195 2 -1.1867 14.9855 12.7566
+208 3 -0.854906 14.5162 11.297
+220 2 0.0416637 21.0458 12.8547
+221 2 0.578564 21.2543 10.808
+228 4 -0.725386 22.7528 14.3252
+229 4 0.0782137 21.6325 11.7966
+239 3 -0.290106 21.5151 14.3143
+250 2 -7.9987 14.9855 12.7566
+264 3 -7.66691 14.5162 11.297
+269 1 -4.71134 14.9632 13.0843
+270 1 -4.24037 14.3715 11.8287
+271 1 -4.17134 15.186 10.6219
+272 1 -4.63051 16.5728 10.6313
+275 1 -5.17463 17.1502 11.8724
+276 1 -5.18506 16.3471 13.1022
+281 2 -4.15105 16.8125 8.57178
+282 2 -5.01284 18.4949 9.60077
+283 2 -6.09268 18.0093 14.1791
+284 2 -5.75839 16.1359 15.1822
+289 4 -3.68073 14.5885 9.36918
+290 4 -4.57583 17.3178 9.51801
+291 4 -5.70478 18.4949 11.8724
+292 4 -5.64768 16.8769 14.2472
+295 3 -3.2853 13.3432 9.35697
+296 3 -3.65016 15.3224 8.29004
+297 3 -5.69529 19.227 10.7704
+298 3 -6.18701 19.0091 12.983
+299 1 -3.2457 21.0681 12.527
+300 1 -3.71667 21.6598 13.7827
+301 1 -3.7857 20.8453 14.9894
+302 1 -3.32652 19.4585 14.98
+303 1 -2.7824 18.8811 13.7389
+304 1 -2.77198 19.6842 12.5091
+306 2 -4.60017 23.3344 14.8034
+310 2 -1.86436 18.022 11.4322
+311 2 -2.19863 19.8954 10.4291
+312 4 -3.29622 21.836 11.2861
+313 4 -4.09983 22.9562 13.8147
+316 4 -2.25225 17.5364 13.739
+317 4 -2.30935 19.1544 11.3641
+318 3 -2.87562 21.2931 10.1675
+324 3 -2.26174 16.8043 14.8409
+325 3 -1.77003 17.0222 12.6283
+326 1 2.10066 14.9632 13.0843
+329 1 2.57163 14.3715 11.8287
+330 1 2.64066 15.186 10.6219
+331 1 2.18149 16.5728 10.6313
+332 1 1.63737 17.1502 11.8724
+335 1 1.62694 16.3471 13.1022
+338 2 2.66095 16.8125 8.57178
+339 2 1.79916 18.4949 9.60077
+340 2 0.719314 18.0093 14.1791
+341 2 1.05361 16.1359 15.1822
+344 4 3.13127 14.5885 9.36918
+345 4 2.23617 17.3178 9.51801
+346 4 1.10722 18.4949 11.8724
+347 4 1.16432 16.8769 14.2472
+350 3 3.5267 13.3432 9.35697
+351 3 3.16184 15.3224 8.29004
+352 3 1.11671 19.227 10.7704
+353 3 0.624994 19.0091 12.983
+354 1 -10.0577 21.0681 12.527
+356 1 -10.5287 21.6598 13.7827
+357 1 -10.5977 20.8453 14.9894
+358 1 -10.1385 19.4585 14.98
+359 1 -9.5944 18.8811 13.7389
+360 1 -9.58398 19.6842 12.5091
+362 2 -11.4122 23.3344 14.8034
+365 2 -8.67636 18.022 11.4322
+366 2 -9.01063 19.8954 10.4291
+367 4 -10.1082 21.836 11.2861
+368 4 -10.9118 22.9562 13.8147
+373 4 -9.06425 17.5364 13.739
+374 4 -9.12135 19.1544 11.3641
+377 3 -9.68762 21.2931 10.1675
+383 3 -9.07374 16.8043 14.8409
+384 3 -8.58203 17.0222 12.6283
+ITEM: TIMESTEP
+25
+ITEM: NUMBER OF ATOMS
+384
+ITEM: BOX BOUNDS
+-12.0786 13.624
+0 24.5406
+0 15.1826
+ITEM: ATOMS
+7 2 -0.736195 8.77832 5.29684
+8 2 -0.190919 8.99287 3.17605
+13 4 -1.49785 10.4746 6.74655
+14 4 -0.692656 9.35602 4.20509
+21 3 -1.06488 9.25084 6.72231
+32 2 4.85777 2.71233 5.13185
+51 3 5.18648 2.23981 3.70638
+62 2 6.0758 8.77832 5.29684
+63 2 6.62108 8.99287 3.17605
+69 4 5.31415 10.4746 6.74655
+70 4 6.11934 9.35602 4.20509
+76 3 5.74712 9.25084 6.72231
+91 2 -1.95423 2.71233 5.13185
+106 3 -1.62552 2.23981 3.70638
+227 2 10.2696 0.120702 0.0137087
+112 1 1.80159 2.09155 4.23712
+113 1 1.87248 2.91095 3.02055
+114 1 1.4094 4.30795 3.03197
+116 1 0.860846 4.89034 4.28111
+117 1 0.851031 4.08058 5.51937
+120 2 1.90516 4.50173 0.962498
+121 2 1.02131 6.23943 2.01549
+122 2 -0.0581547 5.76197 6.57081
+348 3 8.05782 7.31058 0.255275
+126 4 2.36349 2.31238 1.7655
+127 4 1.46404 5.05077 1.92095
+128 4 0.328952 6.23892 4.28118
+131 4 0.389167 4.60919 6.66168
+134 3 2.75185 1.07894 1.76683
+137 3 2.38854 3.04961 0.704654
+138 3 0.343596 6.95351 3.18484
+139 3 -0.145357 6.73609 5.38672
+140 1 2.79372 8.80429 4.926
+143 1 2.31999 9.39909 6.19156
+144 1 2.2491 8.5797 7.40813
+145 1 2.71219 7.18271 7.39671
+146 1 3.26074 6.60031 6.14757
+147 1 3.27055 7.41007 4.90931
+149 2 1.43593 11.0552 7.25263
+152 2 4.17973 5.72869 3.85787
+153 2 3.82675 7.65709 2.82365
+154 4 2.74286 9.57355 3.68212
+155 4 1.93766 10.6921 6.22359
+158 4 3.79264 5.25173 6.1475
+159 4 3.73242 6.88146 3.767
+160 3 3.16194 9.02467 2.58209
+165 3 3.77799 4.53714 7.24385
+166 3 4.26694 4.75456 5.04195
+88 2 3.45758 0.120702 0.0137087
+168 1 8.61359 2.09155 4.23712
+169 1 8.68448 2.91095 3.02055
+170 1 8.2214 4.30795 3.03197
+171 1 7.67285 4.89034 4.28111
+172 1 7.66303 4.08058 5.51937
+175 2 8.71716 4.50173 0.962497
+176 2 7.83331 6.23943 2.01549
+179 2 6.75385 5.76197 6.57081
+293 3 1.24582 7.31058 0.255275
+185 4 9.1755 2.31238 1.7655
+186 4 8.27604 5.05077 1.92095
+187 4 7.14095 6.23892 4.28118
+188 4 7.20117 4.60919 6.66168
+211 3 9.56385 1.07893 1.76683
+225 3 9.20054 3.04961 0.704646
+226 3 7.1556 6.95351 3.18484
+231 3 6.66664 6.73609 5.38672
+232 1 -4.01828 8.80429 4.926
+237 1 -4.49201 9.39909 6.19156
+238 1 -4.5629 8.5797 7.40813
+259 1 -4.09981 7.18271 7.39671
+273 1 -3.55126 6.60031 6.14757
+274 1 -3.54145 7.41007 4.90931
+280 2 -5.37607 11.0552 7.25263
+307 2 -2.63227 5.72869 3.85787
+321 2 -2.98525 7.65709 2.82365
+322 4 -4.06914 9.57355 3.68212
+327 4 -4.87434 10.6921 6.22359
+334 4 -3.01936 5.25173 6.1475
+355 4 -3.07958 6.88146 3.767
+369 3 -3.65006 9.02467 2.58209
+381 3 -3.03401 4.53714 7.24385
+382 3 -2.54506 4.75456 5.04195
+197 2 5.37916 3.27605 1.87486
+198 2 6.26302 1.53835 0.821868
+203 4 4.92083 5.4654 1.07186
+204 4 5.82029 2.72701 0.91641
+209 3 4.53247 6.69885 1.07053
+210 3 4.89577 4.72817 2.13271
+252 2 -1.43284 3.27604 1.87486
+253 2 -0.548982 1.53835 0.821868
+258 4 -1.89117 5.4654 1.07186
+260 4 -0.991711 2.72701 0.91641
+265 3 -2.27953 6.69885 1.07053
+266 3 -1.91623 4.72816 2.13271
+1 1 -1.54872 11.2438 5.50269
+56 1 5.26328 11.2438 5.50269
+20 3 -1.91692 11.0234 7.84659
+75 3 4.89508 11.0234 7.84659
+150 2 2.21643 6.98892 9.46618
+151 2 3.10028 5.25121 8.41319
+156 4 1.75809 9.17826 8.66318
+157 4 2.65755 6.43988 8.50773
+162 3 1.36973 10.4117 8.66185
+164 3 1.73303 8.44104 9.72402
+285 2 -4.59557 6.98892 9.46618
+286 2 -3.71172 5.25121 8.41319
+328 4 -5.05391 9.17826 8.66318
+333 4 -4.15445 6.43988 8.50773
+375 3 -5.44227 10.4117 8.66185
+376 3 -5.07897 8.44104 9.72402
+180 2 7.10685 3.83356 7.60503
+33 1 -1.36114 5.80442 11.8285
+34 1 -1.29025 6.62381 10.6119
+39 1 -1.75333 8.02082 10.6233
+40 1 -2.30187 8.60321 11.8724
+45 1 -2.3117 7.79343 13.1107
+81 2 -1.25757 8.21459 8.55382
+82 2 -2.14141 9.9523 9.60681
+87 2 -3.22087 9.47483 14.1621
+378 3 -4.78826 5.95268 11.2977
+115 4 -0.799231 6.02525 9.35682
+129 4 -1.69869 8.76363 9.51227
+130 4 -2.83378 9.95178 11.8725
+135 4 -2.77356 8.32205 14.253
+142 3 -0.410876 4.7918 9.35815
+163 3 -0.774183 6.76247 8.29597
+177 3 -2.81913 10.6664 10.7762
+178 3 -3.30808 10.4489 12.978
+183 1 -0.369003 12.5172 12.5173
+184 1 -0.842727 13.112 13.7829
+189 1 -0.913624 12.2926 14.9995
+190 1 -0.450541 10.8956 14.988
+193 1 0.0980141 10.3132 13.7389
+194 1 0.107829 11.1229 12.5006
+196 2 -1.72681 14.7681 14.8439
+199 2 1.01701 9.44155 11.4492
+200 2 0.664023 11.3699 10.415
+201 4 -0.419862 13.2864 11.2734
+202 4 -1.22506 14.4049 13.8149
+205 4 0.629908 8.96459 13.7388
+206 4 0.569703 10.5943 11.3583
+207 3 -0.000792083 12.7375 10.1734
+212 3 0.615264 8.25 14.8352
+213 3 1.10421 8.46742 12.6333
+123 2 0.294847 3.83356 7.60503
+215 1 5.45086 5.80442 11.8285
+216 1 5.52175 6.62381 10.6119
+217 1 5.05867 8.02082 10.6233
+218 1 4.51013 8.60321 11.8724
+219 1 4.5003 7.79343 13.1107
+222 2 5.55443 8.21459 8.55382
+223 2 4.67059 9.9523 9.60681
+224 2 3.59113 9.47483 14.1621
+361 2 -5.11695 6.42519 12.7232
+230 4 6.01277 6.02525 9.35682
+233 4 5.11331 8.76363 9.51227
+234 4 3.97822 9.95178 11.8725
+235 4 4.03844 8.32205 14.253
+240 3 6.40112 4.7918 9.35815
+241 3 6.03782 6.76247 8.29597
+242 3 3.99287 10.6664 10.7762
+243 3 3.50392 10.4489 12.978
+244 1 -7.181 12.5172 12.5173
+245 1 -7.65473 13.112 13.7829
+246 1 -7.72562 12.2926 14.9995
+247 1 -7.26254 10.8956 14.988
+248 1 -6.71399 10.3132 13.7389
+249 1 -6.70417 11.1229 12.5006
+251 2 -8.53881 14.7681 14.8439
+254 2 -5.79499 9.44155 11.4492
+255 2 -6.14798 11.3699 10.415
+256 4 -7.23186 13.2864 11.2734
+257 4 -8.03706 14.4049 13.8149
+261 4 -6.18209 8.96459 13.7388
+262 4 -6.2423 10.5943 11.3583
+263 3 -6.81279 12.7375 10.1734
+267 3 -6.19674 8.25 14.8352
+268 3 -5.70779 8.46742 12.6333
+277 2 -3.89891 12.4912 12.8881
+278 2 -3.35365 12.7057 10.7674
+287 4 -4.66057 14.1874 14.3379
+288 4 -3.85538 13.0689 11.7964
+294 3 -4.2276 12.9637 14.3136
+305 2 1.69505 6.42519 12.7232
+319 3 2.02374 5.95268 11.2977
+336 2 2.91308 12.4912 12.8881
+337 2 3.45835 12.7057 10.7674
+342 4 2.15143 14.1874 14.3379
+343 4 2.95661 13.0689 11.7964
+349 3 2.5844 12.9637 14.3136
+269 1 -4.71144 14.9567 13.094
+326 1 2.10056 14.9567 13.094
+341 2 7.39301 8.67816 0.0137082
+2 1 -1.07499 10.649 4.23714
+3 1 -1.0041 11.4684 3.02055
+4 1 -1.46718 12.8654 3.03197
+5 1 -2.01572 13.4478 4.28111
+6 1 -2.02555 12.638 5.51937
+9 2 -0.971422 13.0592 0.962498
+10 2 -1.85526 14.7969 2.01549
+11 2 -2.93472 14.3194 6.57082
+380 3 -4.79281 13.2856 2.13271
+15 4 -0.513081 10.8698 1.7655
+16 4 -1.41254 13.6082 1.92095
+17 4 -2.54763 14.7964 4.28118
+18 4 -2.48741 13.1666 6.66168
+22 3 -0.124726 9.63639 1.76683
+23 3 -0.488033 11.6071 0.704645
+24 3 -2.53298 15.511 3.18483
+25 3 -3.02193 15.2935 5.38673
+26 1 -0.0828531 17.3617 4.92599
+27 1 -0.556576 17.9566 6.19154
+28 1 -0.627474 17.1372 7.40813
+29 1 -0.16439 15.7402 7.39671
+30 1 0.384164 15.1578 6.14757
+31 1 0.393979 15.9675 4.90931
+35 2 -1.44066 19.6127 7.25263
+38 2 1.30316 14.2861 3.85787
+41 2 0.950173 16.2145 2.82365
+42 4 -0.133712 18.131 3.68212
+43 4 -0.938911 19.2495 6.22359
+48 4 0.916058 13.8092 6.1475
+49 4 0.855853 15.4389 3.767
+50 3 0.285358 17.5821 2.58209
+54 3 0.901414 13.0946 7.24384
+55 3 1.39036 13.312 5.04196
+284 2 0.581007 8.67816 0.0137082
+57 1 5.73701 10.649 4.23714
+58 1 5.8079 11.4684 3.02055
+59 1 5.34482 12.8654 3.03197
+60 1 4.79628 13.4478 4.28111
+61 1 4.78645 12.638 5.51937
+64 2 5.84058 13.0592 0.962498
+65 2 4.95674 14.7969 2.01549
+66 2 3.87728 14.3194 6.57082
+379 3 -5.15611 15.2563 1.07054
+71 4 6.29892 10.8698 1.7655
+72 4 5.39946 13.6082 1.92095
+73 4 4.26437 14.7964 4.28118
+74 4 4.32459 13.1666 6.66168
+77 3 6.68727 9.63639 1.76683
+78 3 6.32397 11.6071 0.704645
+79 3 4.27902 15.511 3.18483
+80 3 3.79007 15.2935 5.38673
+83 1 -6.89485 17.3617 4.92599
+84 1 -7.36858 17.9566 6.19154
+85 1 -7.43947 17.1372 7.40813
+86 1 -6.97639 15.7402 7.39671
+89 1 -6.42784 15.1578 6.14757
+90 1 -6.41802 15.9675 4.90931
+92 2 -8.25266 19.6127 7.25263
+97 2 -5.50884 14.2861 3.85787
+98 2 -5.86183 16.2145 2.82365
+99 4 -6.94571 18.131 3.68213
+100 4 -7.75091 19.2495 6.22359
+103 4 -5.89594 13.8092 6.1475
+104 4 -5.95615 15.4389 3.767
+105 3 -6.52664 17.5821 2.58209
+109 3 -5.91059 13.0946 7.24384
+110 3 -5.42164 13.312 5.04195
+118 2 -3.61276 17.3358 5.29682
+119 2 -3.0675 17.5503 3.17605
+124 4 -4.37442 19.032 6.74656
+125 4 -3.56923 17.9135 4.20509
+133 3 -3.94145 17.8083 6.7223
+148 2 1.9812 11.2698 5.13184
+161 3 2.30989 10.7973 3.70637
+173 2 3.19924 17.3358 5.29682
+174 2 3.7445 17.5503 3.17605
+181 4 2.43758 19.032 6.74656
+182 4 3.24277 17.9135 4.20509
+192 3 2.87055 17.8083 6.7223
+279 2 -4.8308 11.2698 5.13184
+370 3 -4.50211 10.7973 3.70637
+136 3 -1.63076 15.868 0.255274
+236 3 5.18124 15.868 0.255274
+308 2 2.50259 11.8335 1.87486
+309 2 3.38644 10.0958 0.821874
+314 4 2.04425 14.0229 1.07186
+315 4 2.94371 11.2845 0.91641
+320 3 1.65589 15.2563 1.07054
+323 3 2.01919 13.2856 2.13271
+363 2 -4.30941 11.8335 1.87486
+364 2 -3.42556 10.0958 0.821874
+371 4 -4.76775 14.0229 1.07186
+372 4 -3.86829 11.2845 0.91641
+111 1 -4.42529 19.8013 5.50268
+167 1 2.38671 19.8013 5.50268
+36 2 -0.660154 15.5464 9.46618
+37 2 0.223702 13.8087 8.41319
+44 4 -1.11849 17.7357 8.66318
+47 4 -0.219027 14.9973 8.50773
+52 3 -1.50685 18.9692 8.66185
+53 3 -1.14354 16.9985 9.72403
+95 2 -7.47215 15.5464 9.46618
+96 2 -6.5883 13.8087 8.41319
+101 4 -7.93049 17.7357 8.66318
+102 4 -7.03103 14.9973 8.50773
+107 3 -8.31885 18.9692 8.66185
+108 3 -7.95554 16.9985 9.72403
+132 3 -4.79349 19.5809 7.84659
+191 3 2.01851 19.5809 7.84659
+46 2 -6.7755 21.0486 12.8882
+67 2 -6.23023 21.2632 10.7674
+93 4 -7.53715 22.7449 14.3379
+94 4 -6.73196 21.6263 11.7964
+141 3 -7.10418 21.5212 14.3136
+195 2 -1.18153 14.9827 12.7232
+208 3 -0.85283 14.5101 11.2977
+220 2 0.0364986 21.0486 12.8882
+221 2 0.581775 21.2632 10.7674
+228 4 -0.725154 22.7449 14.3379
+229 4 0.0800379 21.6263 11.7964
+239 3 -0.292183 21.5212 14.3136
+250 2 -7.99353 14.9827 12.7232
+264 3 -7.66483 14.5101 11.2977
+68 2 4.23027 12.391 7.60503
+270 1 -4.23772 14.3619 11.8284
+271 1 -4.16683 15.1813 10.6119
+272 1 -4.62991 16.5783 10.6233
+275 1 -5.17846 17.1607 11.8724
+276 1 -5.18828 16.3509 13.1107
+281 2 -4.13415 16.7721 8.55382
+282 2 -5.018 18.5098 9.60681
+283 2 -6.09745 18.0323 14.1621
+384 3 -8.58437 17.0249 12.6333
+289 4 -3.67581 14.5827 9.35682
+290 4 -4.57527 17.3211 9.51227
+291 4 -5.71035 18.5092 11.8725
+292 4 -5.65014 16.8795 14.253
+295 3 -3.28746 13.3493 9.35815
+296 3 -3.65076 15.3199 8.29597
+297 3 -5.69571 19.2238 10.7762
+298 3 -6.18466 19.0064 12.978
+299 1 -3.24559 21.0746 12.5173
+300 1 -3.71932 21.6694 13.7829
+301 1 -3.7902 20.85 14.9995
+302 1 -3.32712 19.453 14.988
+303 1 -2.77856 18.8706 13.7389
+304 1 -2.76876 19.6804 12.5006
+306 2 -4.60338 23.3255 14.844
+310 2 -1.85958 17.999 11.4492
+311 2 -2.21255 19.9274 10.415
+312 4 -3.29645 21.8439 11.2734
+313 4 -4.10165 22.9624 13.8149
+316 4 -2.24667 17.5221 13.7388
+317 4 -2.30688 19.1518 11.3583
+318 3 -2.87737 21.295 10.1734
+324 3 -2.26131 16.8075 14.8352
+325 3 -1.77237 17.0249 12.6333
+12 2 -2.58173 12.391 7.60503
+329 1 2.57428 14.3619 11.8284
+330 1 2.64517 15.1813 10.6119
+331 1 2.18209 16.5783 10.6233
+332 1 1.63354 17.1607 11.8724
+335 1 1.62372 16.3509 13.1107
+338 2 2.67785 16.7721 8.55382
+339 2 1.794 18.5098 9.60681
+340 2 0.714539 18.0323 14.1621
+383 3 -9.07331 16.8075 14.8352
+344 4 3.13619 14.5827 9.35682
+345 4 2.23673 17.3211 9.51227
+346 4 1.10165 18.5092 11.8725
+347 4 1.16186 16.8795 14.253
+350 3 3.52454 13.3493 9.35815
+351 3 3.16124 15.3199 8.29597
+352 3 1.11629 19.2238 10.7762
+353 3 0.627336 19.0064 12.978
+354 1 -10.0576 21.0746 12.5173
+356 1 -10.5313 21.6694 13.7829
+357 1 -10.6022 20.85 14.9995
+358 1 -10.1391 19.453 14.988
+359 1 -9.59056 18.8706 13.7389
+360 1 -9.58076 19.6804 12.5006
+362 2 -11.4154 23.3255 14.844
+365 2 -8.67158 17.999 11.4492
+366 2 -9.02455 19.9274 10.415
+367 4 -10.1084 21.8439 11.2734
+368 4 -10.9137 22.9624 13.8149
+373 4 -9.05867 17.5221 13.7388
+374 4 -9.11888 19.1518 11.3583
+377 3 -9.68937 21.295 10.1734
+19 1 -7.58802 23.5141 13.094
+214 1 -0.776023 23.5141 13.094
diff -Naur lammps-29Jan09/examples/reax/ffield.reax lammps-12Feb09/examples/reax/ffield.reax
--- lammps-29Jan09/examples/reax/ffield.reax	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/ffield.reax	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,210 @@
+Reactive MD-force field                                                         
+ 39       ! Number of general parameters                                        
+   50.0000 !Overcoordination parameter                                          
+    9.5469 !Overcoordination parameter                                          
+  127.8302 !Valency angle conjugation parameter                                 
+    3.0000 !Triple bond stabilisation parameter                                 
+    6.5000 !Triple bond stabilisation parameter                                 
+    0.0000 !C2-correction                                                       
+    1.0496 !Undercoordination parameter                                         
+    9.0000 !Triple bond stabilisation parameter                                 
+   11.5054 !Undercoordination parameter                                         
+   13.4059 !Undercoordination parameter                                         
+    0.0000 !Triple bond stabilization energy                                    
+    0.0000 !Lower Taper-radius                                                  
+   10.0000 !Upper Taper-radius                                                  
+    2.8793 !Not used                                                            
+   33.8667 !Valency undercoordination                                           
+    7.0994 !Valency angle/lone pair parameter                                   
+    1.0563 !Valency angle                                                       
+    2.0384 !Valency angle parameter                                             
+    6.1431 !Not used                                                            
+    6.9290 !Double bond/angle parameter                                         
+    0.3989 !Double bond/angle parameter: overcoord                              
+    3.9954 !Double bond/angle parameter: overcoord                              
+   -2.4837 !Not used                                                            
+    5.7796 !Torsion/BO parameter                                                
+   10.0000 !Torsion overcoordination                                            
+    1.9487 !Torsion overcoordination                                            
+   -1.2327 !Conjugation 0 (not used)                                            
+    2.1645 !Conjugation                                                         
+    1.5591 !vdWaals shielding                                                   
+    0.1000 !Cutoff for bond order (*100)                                        
+    2.0038 !Valency angle conjugation parameter                                 
+    0.6121 !Overcoordination parameter                                          
+    1.2172 !Overcoordination parameter                                          
+    1.8512 !Valency/lone pair parameter                                         
+    0.5000 !Not used                                                            
+   20.0000 !Not used                                                            
+    5.0000 !Molecular energy (not used)                                         
+    0.0000 !Molecular energy (not used)                                         
+    3.6942 !Valency angle conjugation parameter                                 
+  6    ! Nr of atoms; cov.r; valency;a.m;Rvdw;Evdw;gammaEEM;cov.r2;#            
+            alfa;gammavdW;valency;Eunder;Eover;chiEEM;etaEEM;n.u.               
+            cov r3;Elp;Heat inc.;n.u.;n.u.;n.u.;n.u.                            
+            ov/un;val1;n.u.;val3,vval4                                          
+ C    1.3763   4.0000  12.0000   1.8857   0.1818   0.8712   1.2596   4.0000     
+      9.5928   2.0784   4.0000  22.6732  79.5548   5.7254   6.9235   0.0000     
+      1.2065   0.0000  -0.8579   4.9417  28.3475  11.9957   0.8563   0.0000     
+     -2.8846   4.1590   1.0564   4.0000   2.9663   0.0000   0.0000   0.0000     
+ H    0.6646   1.0000   1.0080   1.6030   0.0600   0.7625  -0.1000   1.0000     
+      9.3951   4.4187   1.0000   0.0000 121.1250   3.8196   9.8832   1.0000     
+     -0.1000   0.0000  -0.1339   3.5803   2.8733   1.0000   1.0698   0.0000     
+    -13.0615   3.0626   1.0338   1.0000   2.8793   0.0000   0.0000   0.0000     
+ O    1.2699   2.0000  15.9990   1.9741   0.0880   1.0804   1.0624   6.0000     
+     10.2186   7.7719   4.0000  27.3264 116.0768   8.5000   7.8386   2.0000     
+      0.9446   8.6170  -1.2371  17.0845   3.7082   0.5350   0.9745   0.0000     
+     -3.1456   2.6656   1.0493   4.0000   2.9225   0.0000   0.0000   0.0000     
+ N    1.2226   3.0000  14.0000   1.9324   0.1376   0.8596   1.1839   5.0000     
+     10.0667   7.8431   4.0000  32.5000 100.0000   6.8418   6.3404   2.0000     
+      1.0497  14.5853  -1.1222   2.0637   3.2584   3.1136   0.9745   0.0000     
+     -4.2059   2.6491   1.0183   4.0000   2.8793   0.0000   0.0000   0.0000     
+ S    1.9405   2.0000  32.0600   2.0677   0.2099   1.0336   1.5479   6.0000     
+      9.9575   4.9055   4.0000  52.9998 112.1416   6.5000   8.2545   2.0000     
+      1.4601   9.7177  -2.3700   5.7487  23.2859  12.7147   0.9745   0.0000     
+    -11.0000   2.7466   1.0338   4.0000   2.8793   0.0000   0.0000   0.0000     
+ Si   2.0276   4.0000  28.0600   2.2042   0.1322   0.8218   1.5758   4.0000     
+     11.9413   2.0618   4.0000  11.8211 136.4845   1.8038   7.3852   0.0000     
+     -1.0000   0.0000  -2.3700   6.4918   8.5961   0.2368   0.8563   0.0000     
+     -3.8112   3.1873   1.0338   4.0000   2.5791   0.0000   0.0000   0.0000     
+ 18      ! Nr of bonds; Edis1;LPpen;n.u.;pbe1;pbo5;13corr;pbo6                  
+                         pbe2;pbo3;pbo4;n.u.;pbo1;pbo2;ovcorr                   
+  1  1 145.4070 103.0681  73.7841   0.2176  -0.7816   1.0000  28.4167   0.3217  
+         0.1111  -0.1940   8.6733   1.0000  -0.0994   5.9724   1.0000   0.0000  
+  1  2 167.1752   0.0000   0.0000  -0.4421   0.0000   1.0000   6.0000   0.5969  
+        17.4194   1.0000   0.0000   1.0000  -0.0099   8.5445   0.0000   0.0000  
+  2  2 188.1606   0.0000   0.0000  -0.3140   0.0000   1.0000   6.0000   0.6816  
+         8.6247   1.0000   0.0000   1.0000  -0.0183   5.7082   0.0000   0.0000  
+  1  3 171.0470  67.2480 130.3792   0.3600  -0.1696   1.0000  12.0338   0.3796  
+         0.3647  -0.2660   7.4396   1.0000  -0.1661   5.0637   0.0000   0.0000  
+  3  3  90.2465 160.9645  40.0000   0.9950  -0.2435   1.0000  28.1614   0.9704  
+         0.8145  -0.1850   7.5281   1.0000  -0.1283   6.2396   1.0000   0.0000  
+  1  4 134.9992 139.6314  78.5681   0.0420  -0.1370   1.0000  23.6247   0.2415  
+         0.1522  -0.3161   7.0000   1.0000  -0.1301   5.4980   1.0000   0.0000  
+  3  4 127.7074 177.1058  40.0000   0.4561  -0.1481   1.0000  31.4801   0.2000  
+         0.8968  -0.3555   7.0000   1.0000  -0.1219   7.0000   1.0000   0.0000  
+  4  4 151.9142  87.1928 151.4761   0.4280  -0.1001   1.0000  12.3631   0.6229  
+         0.1721  -0.1614  12.1345   1.0000  -0.0882   5.3056   1.0000   0.0000  
+  2  3 216.6018   0.0000   0.0000  -0.4201   0.0000   1.0000   6.0000   0.9143  
+         4.7737   1.0000   0.0000   1.0000  -0.0591   5.9451   0.0000   0.0000  
+  2  4 223.1853   0.0000   0.0000  -0.4661   0.0000   1.0000   6.0000   0.5178  
+         7.8731   1.0000   0.0000   1.0000  -0.0306   6.1506   0.0000   0.0000  
+  1  5 128.9942  74.5848  55.2528   0.1035  -0.5211   1.0000  18.9617   0.6000  
+         0.2949  -0.2398   8.1175   1.0000  -0.1029   5.6731   1.0000   0.0000  
+  2  5 151.5159   0.0000   0.0000  -0.4721   0.0000   1.0000   6.0000   0.6000  
+         9.4366   1.0000   0.0000   1.0000  -0.0290   7.0050   1.0000   0.0000  
+  3  5   0.0000   0.0000   0.0000   0.5563  -0.4038   1.0000  49.5611   0.6000  
+         0.4259  -0.4577  12.7569   1.0000  -0.1100   7.1145   1.0000   0.0000  
+  4  5   0.0000   0.0000   0.0000   0.4438  -0.2034   1.0000  40.3399   0.6000  
+         0.3296  -0.3153   9.1227   1.0000  -0.1805   5.6864   1.0000   0.0000  
+  5  5  96.1871  93.7006  68.6860   0.0955  -0.4781   1.0000  17.8574   0.6000  
+         0.2723  -0.2373   9.7875   1.0000  -0.0950   6.4757   1.0000   0.0000  
+  6  6 109.1904  70.8314  30.0000   0.2765  -0.3000   1.0000  16.0000   0.1583  
+         0.2804  -0.1994   8.1117   1.0000  -0.0675   8.2993   0.0000   0.0000  
+  2  6 137.1002   0.0000   0.0000  -0.1902   0.0000   1.0000   6.0000   0.4256  
+        17.7186   1.0000   0.0000   1.0000  -0.0377   6.4281   0.0000   0.0000  
+  3  6 191.1743  52.0733  43.3991  -0.2584  -0.3000   1.0000  36.0000   0.8764  
+         1.0248  -0.3658   4.2151   1.0000  -0.5004   4.2605   1.0000   0.0000  
+  8    ! Nr of off-diagonal terms; Ediss;Ro;gamma;rsigma;rpi;rpi2               
+  1  2   0.0455   1.7218  10.4236   1.0379  -1.0000  -1.0000                    
+  2  3   0.0469   1.9185  10.3707   0.9406  -1.0000  -1.0000                    
+  2  4   0.0999   1.8372   9.6539   0.9692  -1.0000  -1.0000                    
+  1  3   0.1186   1.9820   9.5927   1.2936   1.1203   1.0805                    
+  1  4   0.1486   1.8922   9.7989   1.3746   1.2091   1.1427                    
+  3  4   0.1051   2.0060  10.0691   1.3307   1.1034   1.0060                    
+  2  6   0.0470   1.6738  11.6877   1.1931  -1.0000  -1.0000                    
+  3  6   0.1263   1.8163  10.6833   1.6266   1.2052  -1.0000                    
+ 62    ! Nr of angles;at1;at2;at3;Thetao,o;ka;kb;pv1;pv2                        
+  1  1  1  70.0265  13.6338   2.1884   0.0000   0.1676  26.3587   1.0400        
+  1  1  2  69.7786  10.3544   8.4326   0.0000   0.1153   0.0000   1.0400        
+  2  1  2  74.6020  11.8629   2.9294   0.0000   0.1367   0.0000   1.0400        
+  1  2  2   0.0000   0.0000   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  1   0.0000   3.4110   7.7350   0.0000   0.0000   0.0000   1.0400        
+  2  2  2   0.0000  27.9213   5.8635   0.0000   0.0000   0.0000   1.0400        
+  1  1  3  72.9588  16.7105   3.5244   0.0000   1.1127   0.0000   1.1880        
+  3  1  3  80.0708  45.0000   2.1487   0.0000   1.1127 -35.0000   1.1880        
+  1  1  4  61.5055  45.0000   1.2242   0.0000   1.1127   0.0000   1.1880        
+  3  1  4  71.9345  45.0000   1.5052   0.0000   1.1127   0.0000   1.1880        
+  4  1  4  51.3604  45.0000   0.6846   0.0000   1.1127   0.0000   1.1880        
+  2  1  3  66.6150  13.6403   3.8212   0.0000   0.0755   0.0000   1.0500        
+  2  1  4  68.9632  16.3575   3.1449   0.0000   0.0755   0.0000   1.0500        
+  1  2  4   0.0000   0.0019   6.3000   0.0000   0.0000   0.0000   1.0400        
+  1  3  1  79.1091  45.0000   0.7067   0.0000   0.6142   0.0000   1.0783        
+  1  3  3  83.7151  42.6867   0.9699   0.0000   0.6142   0.0000   1.0783        
+  1  3  4  79.5876  45.0000   1.1761   0.0000   0.6142   0.0000   1.0783        
+  3  3  3  80.0108  38.3716   1.1572 -38.4200   0.6142   0.0000   1.0783        
+  3  3  4  81.5614  19.8012   3.9968   0.0000   0.6142   0.0000   1.0783        
+  4  3  4  85.3564  36.5858   1.7504   0.0000   0.6142   0.0000   1.0783        
+  1  3  2  78.1533  44.7226   1.3136   0.0000   0.1218   0.0000   1.0500        
+  2  3  3  84.1057   9.6413   7.5000   0.0000   0.1218   0.0000   1.0500        
+  2  3  4  79.4629  44.0409   2.2959   0.0000   0.1218   0.0000   1.0500        
+  2  3  2  79.2954  26.3838   2.2044   0.0000   0.1218   0.0000   1.0500        
+  1  4  1  66.1477  22.9891   1.5923   0.0000   1.6777   0.0000   1.0500        
+  1  4  3  91.9273  38.0207   0.5387   0.0000   1.6777   0.0000   1.0500        
+  1  4  4  92.6933   9.9708   1.6094   0.0000   1.6777   0.0000   1.0500        
+  3  4  3  73.4749  42.7640   1.7325 -17.5007   1.6777   0.0000   1.0500        
+  3  4  4  73.9183  44.8857   1.1980  -0.9193   1.6777   0.0000   1.0500        
+  4  4  4  74.0572  15.4709   5.4220   0.0000   1.6777   0.0000   1.0500        
+  1  4  2  72.7016  33.4153   1.0224   0.0000   0.0222   0.0000   1.0500        
+  2  4  3  82.4368  44.1900   1.9273   0.0000   0.0222   0.0000   1.0500        
+  2  4  4  82.6883  39.9831   1.1916   0.0000   0.0222   0.0000   1.0500        
+  2  4  2  71.2183  14.4528   3.6870   0.0000   0.0222   0.0000   1.0500        
+  1  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  5   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  3  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  3  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  4  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  2  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  2  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  1  5  74.9397  25.0560   1.8787   0.1463   0.0559   0.0000   1.0400        
+  1  5  1  86.9521  36.9951   2.0903   0.1463   0.0559   0.0000   1.0400        
+  2  1  5  74.9397  25.0560   1.8787   0.0000   0.0000   0.0000   1.0400        
+  1  5  2  86.1791  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  1  5  5  85.3644  36.9951   2.0903   0.1463   0.0559   0.0000   1.0400        
+  2  5  2  93.1959  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  2  5  5  84.3331  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  6  6  6  69.3456  21.7361   1.4283   0.0000  -0.2101   0.0000   1.3241        
+  2  6  6  75.6168  21.5317   1.0435   0.0000   2.5179   0.0000   1.0400        
+  2  6  2  78.3939  20.9772   0.8630   0.0000   2.8421   0.0000   1.0400        
+  3  6  6  70.3016  15.4081   1.3267   0.0000   2.1459   0.0000   1.0400        
+  2  6  3  73.8232  16.6592   3.7425   0.0000   0.8613   0.0000   1.0400        
+  3  6  3  90.0344   7.7656   1.7264   0.0000   0.7689   0.0000   1.0400        
+  6  3  6  22.1715   3.6615   0.3160   0.0000   4.1125   0.0000   1.0400        
+  2  3  6  83.7634   5.6693   2.7780   0.0000   1.6982   0.0000   1.0400        
+  3  3  6  73.4663  25.0761   0.9143   0.0000   2.2466   0.0000   1.0400        
+  2  2  6   0.0000  47.1300   6.0000   0.0000   1.6371   0.0000   1.0400        
+  6  2  6   0.0000  31.5209   6.0000   0.0000   1.6371   0.0000   1.0400        
+  3  2  6   0.0000  31.0427   4.5625   0.0000   1.6371   0.0000   1.0400        
+  2  2  5   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+ 20    ! Nr of torsions;at1;at2;at3;at4;;V1;V2;V3;V2(BO);vconj;n.u;n            
+  1  1  1  1   0.0000  23.2168   0.1811  -4.6220  -1.9387   0.0000   0.0000     
+  1  1  1  2   0.0000  45.7984   0.3590  -5.7106  -2.9459   0.0000   0.0000     
+  2  1  1  2   0.0000  44.6445   0.3486  -5.1725  -0.8717   0.0000   0.0000     
+  0  1  2  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  2  2  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  1  3  0   5.0520  16.7344   0.5590  -3.0181  -2.0000   0.0000   0.0000     
+  0  2  3  0   0.0000   0.1000   0.0200  -2.5415   0.0000   0.0000   0.0000     
+  0  3  3  0   0.0115  68.9706   0.8253 -28.4693   0.0000   0.0000   0.0000     
+  0  1  4  0  -4.0616  66.2036   0.3855  -4.4414  -2.0000   0.0000   0.0000     
+  0  2  4  0   0.0000   0.1000   0.0200  -2.5415   0.0000   0.0000   0.0000     
+  0  3  4  0   1.1130  14.8049   0.0231 -10.7175  -2.0000   0.0000   0.0000     
+  0  4  4  0  -0.0851  37.4200   0.0107  -3.5209  -2.0000   0.0000   0.0000     
+  0  1  1  0   0.0000   0.9305   0.0000 -24.2568   0.0000   0.0000   0.0000     
+  4  1  4  4  -3.6064  43.6430   0.0004 -11.5507  -2.0000   0.0000   0.0000     
+  0  1  5  0   3.3423  30.3435   0.0365  -2.7171   0.0000   0.0000   0.0000     
+  0  5  5  0  -0.0555 -42.7738   0.1515  -2.2056   0.0000   0.0000   0.0000     
+  0  2  5  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  6  6  0   0.0000   0.0000   0.1200  -2.4426   0.0000   0.0000   0.0000     
+  0  2  6  0   0.0000   0.0000   0.1200  -2.4847   0.0000   0.0000   0.0000     
+  0  3  6  0   0.0000   0.0000   0.1200  -2.4703   0.0000   0.0000   0.0000     
+  9    ! Nr of hydrogen bonds;at1;at2;at3;Rhb;Dehb;vhb1                         
+  3  2  3   2.0431  -6.6813   3.5000   1.7295                                   
+  3  2  4   1.6740 -10.9581   3.5000   1.7295                                   
+  4  2  3   1.4889  -9.6465   3.5000   1.7295                                   
+  4  2  4   1.8324  -8.0074   3.5000   1.7295                                   
+  3  2  5   2.6644  -3.9547   3.5000   1.7295                                   
+  4  2  5   4.0476  -5.7038   3.5000   1.7295                                   
+  5  2  3   2.1126  -4.5790   3.5000   1.7295                                   
+  5  2  4   2.2066  -5.7038   3.5000   1.7295                                   
+  5  2  5   1.9461  -4.0000   3.5000   1.7295                                   
diff -Naur lammps-29Jan09/examples/reax/in.reax.rdx lammps-12Feb09/examples/reax/in.reax.rdx
--- lammps-29Jan09/examples/reax/in.reax.rdx	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/in.reax.rdx	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,24 @@
+# REAX potential for RDX system
+# this run is equivalent to GRASP testreax
+
+units		real
+
+atom_style	charge
+read_data	data.rdx
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	every 10 delay 0 check no
+
+fix		1 all nve
+
+thermo		10
+thermo_modify	format float %15.14g
+
+timestep	1.0
+
+dump		1 all atom 10 dump.reax.rdx
+
+run		100
diff -Naur lammps-29Jan09/examples/reax/in.reax.tatb lammps-12Feb09/examples/reax/in.reax.tatb
--- lammps-29Jan09/examples/reax/in.reax.tatb	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/in.reax.tatb	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,25 @@
+# REAX potential for TATB system
+# this run is equivalent to GRASP testtatb
+
+units		real
+
+atom_style	charge
+read_data	data.tatb
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	delay 0 every 5 check no
+
+fix		1 all nve
+
+thermo		1
+thermo_style	custom step temp evdwl ecoul pe ke etotal press
+
+timestep	0.0625
+
+dump		1 all atom 25 dump.reax.tatb
+dump_modify	1 scale no
+
+run		25
diff -Naur lammps-29Jan09/examples/reax/log.reax.rdx.9Jan09.linux.1 lammps-12Feb09/examples/reax/log.reax.rdx.9Jan09.linux.1
--- lammps-29Jan09/examples/reax/log.reax.rdx.9Jan09.linux.1	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/log.reax.rdx.9Jan09.linux.1	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,60 @@
+LAMMPS (9 Jan 2009)
+# REAX potential for RDX system
+# this run is equivalent to GRASP testreax
+
+units		real
+
+atom_style	charge
+read_data	data.rdx
+  orthogonal box = (35 35 35) to (48 48 48)
+  1 by 1 by 1 processor grid
+  21 atoms
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	every 10 delay 0 check no
+
+fix		1 all nve
+
+thermo		10
+thermo_modify	format float %15.14g
+
+timestep	1.0
+
+dump		1 all atom 10 dump.reax.rdx
+
+run		100
+Memory usage per processor = 1.9804 Mbytes
+Step Temp E_pair E_mol TotEng Press 
+       0               0 -2047.6192801334               0 -2047.6192801334 1411.6115263466 
+      10 3.6258171813679 -2047.9367433642               0 -2047.7205859183 -299.36769970561 
+      20 3.4854376925069 -2048.0660279873               0 -2047.8582394332 475.16845315344 
+      30 2.5137625579087 -2047.6831945786               0 -2047.5333336047 -338.78447400608 
+      40  3.028268506362 -2047.8909509029               0 -2047.7104170389 30.336593968351 
+      50 1.9909740924203 -2047.6767143308               0 -2047.5580200191 -711.00589942496 
+      60 3.0218387059402 -2047.8022916718               0 -2047.6221411281 885.14836573571 
+      70 3.7978262058847 -2048.0109710832               0 -2047.7845591128 -398.03834475587 
+      80 3.7467426883643 -2047.9462376339               0 -2047.7228710687 225.47962761808 
+      90 2.6678278539028 -2047.7300185675               0 -2047.5709728059 -443.01207186006 
+     100 2.7677479999004 -2047.863150798               0 -2047.698148177 -203.18419576651 
+Loop time of 0.624502 on 1 procs for 100 steps with 21 atoms
+
+Pair  time (%) = 0.621737 (99.5573)
+Neigh time (%) = 0.00102305 (0.163819)
+Comm  time (%) = 0.000733376 (0.117434)
+Outpt time (%) = 0.000679255 (0.108767)
+Other time (%) = 0.000328779 (0.0526466)
+
+Nlocal:    21 ave 21 max 21 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+Nghost:    546 ave 546 max 546 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+Neighs:    1110 ave 1110 max 1110 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+
+Total # of neighbors = 1110
+Ave neighs/atom = 52.8571
+Neighbor list builds = 10
+Dangerous builds = 0
diff -Naur lammps-29Jan09/examples/reax/log.reax.rdx.9Jan09.linux.4 lammps-12Feb09/examples/reax/log.reax.rdx.9Jan09.linux.4
--- lammps-29Jan09/examples/reax/log.reax.rdx.9Jan09.linux.4	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/log.reax.rdx.9Jan09.linux.4	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,60 @@
+LAMMPS (9 Jan 2009)
+# REAX potential for RDX system
+# this run is equivalent to GRASP testreax
+
+units		real
+
+atom_style	charge
+read_data	data.rdx
+  orthogonal box = (35 35 35) to (48 48 48)
+  1 by 2 by 2 processor grid
+  21 atoms
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	every 10 delay 0 check no
+
+fix		1 all nve
+
+thermo		10
+thermo_modify	format float %15.14g
+
+timestep	1.0
+
+dump		1 all atom 10 dump.reax.rdx
+
+run		100
+Memory usage per processor = 2.12595 Mbytes
+Step Temp E_pair E_mol TotEng Press 
+       0               0 -2047.619198364               0 -2047.619198364 1411.6115014455 
+      10 3.6258172064233 -2047.9367430834               0 -2047.720585636 -299.36773853231 
+      20 3.4854376755222 -2048.0660277267               0 -2047.8582391737 475.16836372124 
+      30 2.5137625613646 -2047.6831945262               0 -2047.5333335521 -338.78451555999 
+      40 3.0282685107275 -2047.8909508952               0 -2047.7104170309 30.336594625277 
+      50 1.9909741168896 -2047.6767142995               0 -2047.5580199864 -711.00591844289 
+      60 3.0218388134802 -2047.802290215               0 -2047.6221396649 885.14839263854 
+      70 3.7978262741497 -2048.0109705523               0 -2047.7845585778 -398.03839906035 
+      80 3.7467427256751 -2047.9462376146               0 -2047.7228710472 225.47957554937 
+      90 2.6678279363425 -2047.7300185521               0 -2047.5709727857 -443.01208904133 
+     100 2.7677479912881 -2047.8631507982               0 -2047.6981481776 -203.18423218689 
+Loop time of 0.975732 on 4 procs for 100 steps with 21 atoms
+
+Pair  time (%) = 0.751038 (76.9718)
+Neigh time (%) = 0.000374079 (0.0383383)
+Comm  time (%) = 0.217836 (22.3254)
+Outpt time (%) = 0.00597531 (0.612392)
+Other time (%) = 0.000507712 (0.052034)
+
+Nlocal:    5.25 ave 14 max 0 min
+Histogram: 1 0 2 0 0 0 0 0 0 1
+Nghost:    355.5 ave 433 max 282 min
+Histogram: 1 0 0 0 2 0 0 0 0 1
+Neighs:    305 ave 784 max 0 min
+Histogram: 1 0 1 1 0 0 0 0 0 1
+
+Total # of neighbors = 1220
+Ave neighs/atom = 58.0952
+Neighbor list builds = 10
+Dangerous builds = 0
diff -Naur lammps-29Jan09/examples/reax/log.reax.tatb.9Jan09.linux.1 lammps-12Feb09/examples/reax/log.reax.tatb.9Jan09.linux.1
--- lammps-29Jan09/examples/reax/log.reax.tatb.9Jan09.linux.1	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/log.reax.tatb.9Jan09.linux.1	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,76 @@
+LAMMPS (9 Jan 2009)
+# REAX potential for TATB system
+# this run is equivalent to GRASP testtatb
+
+units		real
+
+atom_style	charge
+read_data	data.tatb
+  triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573)
+  1 by 1 by 1 processor grid
+  384 atoms
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	delay 0 every 5 check no
+
+fix		1 all nve
+
+thermo		1
+thermo_style	custom step temp evdwl ecoul pe ke etotal press
+
+timestep	0.0625
+
+dump		1 all atom 25 dump.reax.tatb
+dump_modify	1 scale no
+
+run		25
+Memory usage per processor = 6.47708 Mbytes
+Step Temp E_vdwl E_coul PotEng KinEng TotEng Press 
+       0            0   -42896.832   -2080.6298   -44977.462            0   -44977.462    350844.92 
+       1    1.5362501   -42898.549   -2080.6611    -44979.21    1.7538604   -44977.456    351524.29 
+       2    6.1403173   -42903.695    -2080.736   -44984.431    7.0100948   -44977.421    353564.02 
+       3    13.798172   -42912.254   -2080.9718   -44993.226    15.752687   -44977.473    356972.83 
+       4    24.486472   -42924.199   -2081.2329   -45005.432    27.954986   -44977.477    361762.22 
+       5     38.17262   -42939.494   -2081.5712   -45021.065    43.579781   -44977.485     367944.3 
+       6    54.814793    -42958.09   -2081.9848   -45040.075    62.579322   -44977.496    375525.26 
+       7    74.361855   -42980.094   -2082.4701   -45062.564     84.89523   -44977.669    384488.13 
+       8    96.753115   -43005.107   -2083.0273   -45088.135    110.45822   -44977.676    394820.42 
+       9    121.91206   -43032.705   -2083.6635   -45116.368    139.18094   -44977.188    406680.23 
+      10    149.75446   -43063.797   -2084.3724   -45148.169    170.96721   -44977.202    419448.39 
+      11    180.18901   -43097.773   -2085.1575    -45182.93    205.71283   -44977.218    433126.49 
+      12    213.10176   -43134.679   -2086.0149   -45220.694    243.28768   -44977.407    447323.77 
+      13    248.35364   -43173.885   -2086.9468   -45260.832      283.533   -44977.299    461500.69 
+      14    285.77131   -43215.627   -2087.9521   -45303.579    326.25089   -44977.329    474776.65 
+      15    325.13312   -43259.523   -2089.0299   -45348.553    371.18831   -44977.365    485994.64 
+      16    366.14805   -43305.244   -2090.1788   -45395.422    418.01302   -44977.409    493592.79 
+      17    408.43184   -43352.353   -2091.3994   -45443.752    466.28631   -44977.466    495609.06 
+      18    451.48082   -43400.279   -2092.6891   -45492.968    515.43319   -44977.535    489764.64 
+      19    494.65084    -43448.29   -2094.0464   -45542.336    564.71825   -44977.618    473698.76 
+      20    537.15237   -43495.483   -2095.4689   -45590.952    613.24013   -44977.712    445393.41 
+      21    578.07545   -43540.818   -2096.9532   -45637.772    659.95998   -44977.812    403758.92 
+      22    616.45506   -43583.188   -2098.4958   -45681.684    703.77607   -44977.908    349235.78 
+      23     651.3754    -43621.54   -2100.0897   -45721.629    743.64289   -44977.987    284158.54 
+      24    682.06338   -43654.313   -2101.7345   -45756.048    778.67782    -44977.37    211816.13 
+      25    708.05182   -43682.322    -2103.422   -45785.744    808.34754   -44977.396    138937.27 
+Loop time of 8.67501 on 1 procs for 25 steps with 384 atoms
+
+Pair  time (%) = 8.59189 (99.0418)
+Neigh time (%) = 0.0744822 (0.858583)
+Comm  time (%) = 0.00496221 (0.0572011)
+Outpt time (%) = 0.0024147 (0.0278352)
+Other time (%) = 0.00126433 (0.0145744)
+
+Nlocal:    384 ave 384 max 384 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+Nghost:    7559 ave 7559 max 7559 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+Neighs:    286819 ave 286819 max 286819 min
+Histogram: 1 0 0 0 0 0 0 0 0 0
+
+Total # of neighbors = 286819
+Ave neighs/atom = 746.924
+Neighbor list builds = 5
+Dangerous builds = 0
diff -Naur lammps-29Jan09/examples/reax/log.reax.tatb.9Jan09.linux.4 lammps-12Feb09/examples/reax/log.reax.tatb.9Jan09.linux.4
--- lammps-29Jan09/examples/reax/log.reax.tatb.9Jan09.linux.4	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/examples/reax/log.reax.tatb.9Jan09.linux.4	2009-02-12 14:03:10.000000000 -0700
@@ -0,0 +1,76 @@
+LAMMPS (9 Jan 2009)
+# REAX potential for TATB system
+# this run is equivalent to GRASP testtatb
+
+units		real
+
+atom_style	charge
+read_data	data.tatb
+  triclinic box = (0 0 0) to (13.624 17.1149 15.1826) with tilt (-5.75316 -6.32547 7.42573)
+  1 by 2 by 2 processor grid
+  384 atoms
+
+pair_style	reax 10.0 1.0e-6
+pair_coeff	* * ffield.reax 1 2 3 4
+
+neighbor	2.5 bin
+neigh_modify	delay 0 every 5 check no
+
+fix		1 all nve
+
+thermo		1
+thermo_style	custom step temp evdwl ecoul pe ke etotal press
+
+timestep	0.0625
+
+dump		1 all atom 25 dump.reax.tatb
+dump_modify	1 scale no
+
+run		25
+Memory usage per processor = 3.08409 Mbytes
+Step Temp E_vdwl E_coul PotEng KinEng TotEng Press 
+       0            0   -42896.832   -2080.6306   -44977.462            0   -44977.462    350844.92 
+       1    1.5362501   -42898.549   -2080.6611    -44979.21    1.7538604   -44977.456    351524.29 
+       2    6.1403173   -42903.695    -2080.736   -44984.431    7.0100948   -44977.421    353564.02 
+       3    13.798172   -42912.254   -2080.9729   -44993.227    15.752687   -44977.474    356972.84 
+       4    24.486472   -42924.199   -2081.2309    -45005.43    27.954986   -44977.475    361762.21 
+       5     38.17262   -42939.494   -2081.5707   -45021.065    43.579781   -44977.485    367944.29 
+       6    54.814793    -42958.09   -2081.9854   -45040.075    62.579322   -44977.496    375525.33 
+       7    74.361855   -42980.094   -2082.4699   -45062.564     84.89523   -44977.669    384488.09 
+       8    96.753115   -43005.107   -2083.0269   -45088.134    110.45822   -44977.676    394820.42 
+       9    121.91207   -43032.705   -2083.6626   -45116.368    139.18094   -44977.187    406680.22 
+      10    149.75446   -43063.797   -2084.3728   -45148.169    170.96721   -44977.202    419448.39 
+      11    180.18901   -43097.773   -2085.1572    -45182.93    205.71283   -44977.217    433126.49 
+      12    213.10176   -43134.679   -2086.0148   -45220.694    243.28768   -44977.406    447323.77 
+      13    248.35364   -43173.885   -2086.9469   -45260.832      283.533   -44977.299    461500.69 
+      14    285.77131   -43215.627   -2087.9531    -45303.58    326.25089    -44977.33    474776.65 
+      15    325.13312   -43259.523   -2089.0299   -45348.553    371.18831   -44977.365    485994.64 
+      16    366.14805   -43305.244   -2090.1788   -45395.422    418.01302   -44977.409    493592.79 
+      17    408.43184   -43352.353   -2091.3994   -45443.752    466.28631   -44977.466    495609.06 
+      18    451.48082   -43400.279   -2092.6894   -45492.968    515.43319   -44977.535    489764.64 
+      19    494.65084    -43448.29    -2094.046   -45542.335    564.71825   -44977.617    473698.77 
+      20    537.15237   -43495.483   -2095.4689   -45590.952    613.24013   -44977.712    445393.41 
+      21    578.07545   -43540.818   -2096.9535   -45637.772    659.95998   -44977.812    403758.91 
+      22    616.45506   -43583.188   -2098.4937   -45681.682    703.77607   -44977.906     349235.9 
+      23     651.3754    -43621.54   -2100.0898    -45721.63    743.64289   -44977.987    284158.53 
+      24    682.06338   -43654.313   -2101.7343   -45756.047    778.67782    -44977.37    211816.14 
+      25    708.05182   -43682.322   -2103.4222   -45785.744    808.34754   -44977.397    138937.26 
+Loop time of 4.36095 on 4 procs for 25 steps with 384 atoms
+
+Pair  time (%) = 4.20042 (96.3188)
+Neigh time (%) = 0.0155269 (0.356043)
+Comm  time (%) = 0.128759 (2.95254)
+Outpt time (%) = 0.0149072 (0.341834)
+Other time (%) = 0.00134313 (0.030799)
+
+Nlocal:    96 ave 96 max 96 min
+Histogram: 4 0 0 0 0 0 0 0 0 0
+Nghost:    5118 ave 5118 max 5118 min
+Histogram: 4 0 0 0 0 0 0 0 0 0
+Neighs:    79731 ave 79731 max 79731 min
+Histogram: 4 0 0 0 0 0 0 0 0 0
+
+Total # of neighbors = 318924
+Ave neighs/atom = 830.531
+Neighbor list builds = 5
+Dangerous builds = 0
diff -Naur lammps-29Jan09/lib/README lammps-12Feb09/lib/README
--- lammps-29Jan09/lib/README	2007-01-30 14:52:55.000000000 -0700
+++ lammps-12Feb09/lib/README	2009-02-06 09:39:43.000000000 -0700
@@ -11,3 +11,4 @@
 
 poems	      POEMS rigid-body integration package from RPI
 meam	      modified embedded atom method (MEAM) potential from Greg Wagner
+reax          ReaxFF potential, from Adri van Duin via Aidan Thompson
diff -Naur lammps-29Jan09/lib/meam/Makefile lammps-12Feb09/lib/meam/Makefile
--- lammps-29Jan09/lib/meam/Makefile	2008-03-18 14:20:01.000000000 -0600
+++ lammps-12Feb09/lib/meam/Makefile	1969-12-31 17:00:00.000000000 -0700
@@ -1,48 +0,0 @@
-# *
-# *_________________________________________________________________________*
-# *      MEAM: MODEFIED EMBEDDED ATOM METHOD                                *
-# *      DESCRIPTION: SEE READ-ME                                           *
-# *      FILE NAME: Makefile                                                *
-# *      AUTHORS: Greg Wagner, Sandia National Laboratories                 * 
-# *      CONTACT: gjwagne@sandia.gov                                        *
-# *_________________________________________________________________________*/
-
-SHELL = /bin/sh
-
-# ------ FILES ------
-
-SRC = meam_data.F meam_setup_done.F meam_setup_global.F meam_setup_param.F meam_dens_init.F meam_dens_final.F meam_force.F meam_cleanup.F
-
-FILES = $(SRC) Makefile 
-
-# ------ DEFINITIONS ------
-
-LIB = libmeam.a
-OBJ =   $(SRC:.F=.o)
-
-# ------ SETTINGS ------
-
-F90 =           ifort
-F90FLAGS =      -O
-ARCHIVE =	ar
-ARCHFLAG =	-rc
-USRLIB =
-SYSLIB =
-
-# ------ MAKE PROCEDURE ------
-
-lib: 	$(OBJ)
-	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
-
-# ------ COMPILE RULES ------
-
-%.o:%.F
-	$(F90) $(F90FLAGS) -c $<
-
-# ------ CLEAN ------
-
-clean:
-	-rm *.o *.mod *~ $(LIB)
-
-tar:
-	-tar -cvf ../MEAM.tar $(FILES)
diff -Naur lammps-29Jan09/lib/reax/Makefile.g77 lammps-12Feb09/lib/reax/Makefile.g77
--- lammps-29Jan09/lib/reax/Makefile.g77	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/Makefile.g77	2009-02-12 08:41:49.000000000 -0700
@@ -0,0 +1,50 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+FILES = $(SRC) Makefile 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           g77
+F90FLAGS =      -O -g
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -cvf ../REAX.tar $(FILES)
+
diff -Naur lammps-29Jan09/lib/reax/Makefile.g95 lammps-12Feb09/lib/reax/Makefile.g95
--- lammps-29Jan09/lib/reax/Makefile.g95	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/Makefile.g95	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,50 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+FILES = $(SRC) Makefile 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           g95
+F90FLAGS =      -O 
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -cvf ../REAX.tar $(FILES)
+
diff -Naur lammps-29Jan09/lib/reax/Makefile.gfortran lammps-12Feb09/lib/reax/Makefile.gfortran
--- lammps-29Jan09/lib/reax/Makefile.gfortran	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/Makefile.gfortran	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,50 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+FILES = $(SRC) Makefile 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           gfortran
+F90FLAGS =      -O -fno-second-underscore
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -cvf ../REAX.tar $(FILES)
+
diff -Naur lammps-29Jan09/lib/reax/Makefile.ifort lammps-12Feb09/lib/reax/Makefile.ifort
--- lammps-29Jan09/lib/reax/Makefile.ifort	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/Makefile.ifort	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,50 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+FILES = $(SRC) Makefile 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           ifort
+F90FLAGS =      -O 
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -cvf ../REAX.tar $(FILES)
+
diff -Naur lammps-29Jan09/lib/reax/Makefile.pgf90 lammps-12Feb09/lib/reax/Makefile.pgf90
--- lammps-29Jan09/lib/reax/Makefile.pgf90	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/Makefile.pgf90	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,50 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+FILES = $(SRC) Makefile 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           pgf90
+F90FLAGS =      -O 
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -cvf ../REAX.tar $(FILES)
+
diff -Naur lammps-29Jan09/lib/reax/README lammps-12Feb09/lib/reax/README
--- lammps-29Jan09/lib/reax/README	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/README	2009-02-12 09:09:50.000000000 -0700
@@ -0,0 +1,34 @@
+ReaxFF library
+
+Aidan Thompson, Sandia National Labs
+athomps at sandia.gov
+Jan 2008
+
+--------------
+
+This library is an implementation of the ReaxFF potential,
+specifically designed to work with LAMMPS. It is derived from Adri van
+Duin's original serial code, with intervening incarnations in CMDF and
+GRASP.
+
+This library can be built with any decent Fortran compiler, before
+LAMMPS is built, so LAMMPS can link against it. The compiler must
+produce object files compatible with the LAMMPS C++ compiler. If not,
+the LAMMPS build will fail during linking.
+
+Build the library using one of the provided Makefiles or create your
+own, specific to your compiler and system.  For example:
+
+make -f Makefile.g95
+
+If the build is successful, you should end up with a libreax.a file.
+
+Note that the include file reax_defs.h is used by both the ReaxFF
+library source files and the LAMMPS pair_reax.cpp source file (from
+module REAX).  It contains dimensions of statically-allocated arrays
+created by the ReaxFF library. The size of these arrays must be set
+small enough to avoid exceeding the available machine memory, and
+large enough to fit the actual data generated by ReaxFF. If you change
+the values in reax_defs.h, you must first rebuild the library and then
+rebuild LAMMPS.
+
diff -Naur lammps-29Jan09/lib/reax/cbka.blk lammps-12Feb09/lib/reax/cbka.blk
--- lammps-29Jan09/lib/reax/cbka.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbka.blk	2009-02-12 09:09:50.000000000 -0700
@@ -0,0 +1,116 @@
+#include "reax_defs.h"
+      implicit real*8 (a-h,o-z),integer(i-n) 
+      parameter (nneighmax=NNEIGHMAXDEF)
+      parameter (nat=NATDEF)     !Max number of atoms
+      parameter (nattot=NATTOTDEF)     !Max number of global atoms
+      parameter (nsort=NSORTDEF)    !Max number of atom types
+      parameter (mbond=MBONDDEF)     !Max number of bonds connected to one atom
+      parameter (na1mx3=3*nat) !3*max number of atoms
+      parameter (navib=NAVIBDEF)     !for 2nd derivatives
+      parameter (nbotym=NBOTYMDEF)   !Max number of bond types
+      parameter (nvatym=NVATYMDEF)   !Max number of valency angle types
+      parameter (ntotym=NTOTYMDEF)   !Max number of torsion angle types
+      parameter (nhbtym=NHBTYMDEF)   !Max number of hydrogen bond types
+      parameter (nodmtym=NODMTYMDEF)   !Max number of off-diagonal Morse types
+      parameter (nboallmax=NBOALLMAXDEF)  !Max number of all bonds
+      parameter (nbomax=NBOMAXDEF)  !Max number of bonds
+      parameter (nhbmax=NHBMAXDEF)  !Max number of  hydrogen bonds
+      parameter (nvamax=NVAMAXDEF)  !Max number of valency angles
+      parameter (nopmax=NOPMAXDEF)  !Max number of out of plane angles
+      parameter (ntomax=NTOMAXDEF)  !Max number of torsion angles
+      parameter (npamax=NPAMAXDEF)  !Max number of general parameters in force field
+      parameter (nmolmax=NMOLMAXDEF)  !Max number of molecules in system
+      parameter (nmolset=NMOLSETDEF)  !Max number of molecules in training set
+      parameter (mrestra=MRESTRADEF)     !Max number of restraints
+      parameter (mtreg=MTREGDEF)     !Max number of temperature regimes
+      parameter (mtzone=MTZONEDEF)     !Max number of temperature zones
+      parameter (mvreg=MVREGDEF)     !Max number of volume regimes
+      parameter (mvzone=MVZONEDEF)     !Max number of volume zones
+      parameter (mereg=MEREGDEF)     !Max number of electric field regimes
+      parameter (mezone=MEZONEDEF)     !Max number of electric field zones
+      character*1 qr,qrset,qresi2
+      character*2 qaset,qadd
+      character*3 qresi1
+      character*5 qlabel,qffty,qbgfaxes,qbgfsgn,qresi3
+      character*20 qkeyw
+      character*25 qfile
+      character*40 qffield,qformat,qstrana2
+      character*60 qremark,qremset,qmolset
+      character*200 qstrana1
+      common
+     $/cbka/ dhbdc(nhbmax,3,3),cp(nat,3),
+     $       cadd(nat,3),d2(3*navib,3*navib),
+     $       veladd(3,nat),
+     $       aold(3,nat),dic(3,nat),pvdw1(nsort,nsort),
+     $       pvdw2(nsort,nsort),angimp(nat,6),
+     $       yt(na1mx3),pt(na1mx3),gi(na1mx3),enmolset(nmolset),
+     $       ai(na1mx3),bi(na1mx3),yi(na1mx3),pn(na1mx3),tbo(nat),
+     $       chgbgf(nattot),
+     $       abo2(nat),bor4(nat),bos(nbomax),
+     $       eldef(nat),vradic(nat),
+     $       vmo2(nat),
+     $       ro(nbomax),dbondr(nbomax),
+     $       dbosidr(nbomax),thgo(nopmax),
+     $       elmol(nmolmax),
+     $       elaf(nsort),vpq(nsort),
+     $       rvdw(nsort),alf(nsort),eps(nsort),chat(nsort),
+     $       rcore(nsort,nsort),ecore(nsort,nsort),acore(nsort,nsort),
+     $       vlp2(nsort),
+     $       valp2(nsort),vincr(nsort),
+     $       vval3(nsort),
+     $       vuncor(nbotym),
+     $       vop(nsort),
+     $       sigqeq(nsort),      
+     $       rrcha(mrestra),
+     $       rmstra3(mrestra),      
+     $       rmcha(mrestra),
+     $       rtcha(mrestra),rvcha(mrestra),
+     $       v2bo(ntotym),v3bo(ntotym),
+     $       eel,fctor,elr,
+     $       presx2,presy2,presz2,
+     $       tset2,
+     $       enmol,formol,vvol,tpnrad,
+     $       delvib,
+     $       taut2,tincr,xmasmd,
+     $       gdicmax,parc1,parc2,sumelec,
+     $       xinh,fsnh,vqnh,snh,ham,errnh,sumhe,
+     $       swa,swb2,swc0,swc1,swc2,swc3,swc4,swc5,swc6,
+     $       swc7,plr,endpo2,ccpar,
+     $       c4,estrmin,endpo,accincr,
+     $       endpoold,xadd,yadd,zadd,addist,taddmol,
+     $       Hug_E0, Hug_P0, Hug_V0, xImpVcm, shock_vel,
+     $       shock_z_sep
+      common
+     $/cbka/ 
+     $       ioop(nopmax,9),ifreqset(nmolset),
+     $       ijk(nat,4),icgeopt(nmolset),
+     $       irap(50),irdo(50,2),
+     $       ityadd(nat),
+     $       nmoloo(nat),iradic(nat),idef(nsort),nasort(nsort),
+     $       ibgr1(nattot),ibgr2(nattot),idupc(6),
+     $       imolsta(nat),
+     $       ncent2(nbomax),irads,nrdd,nrddf,nbiolab,nuge,
+     $       nbon2,npar,nodmty,ngnh,irac,nincrop,
+     $       nboty,mdstep,
+     $       nreac,
+     $       nbonop,icelo2,
+     $       iaddfreq,iveladd,invt,
+     $       noop,ndtau,
+     $       nelc3,nfc,nsav2,nmmax,ibh2,
+     $       nmmaxold,nfcold,icellold,imodfile,
+     $       icelo2old,inmov1,inmov2,nchaold,naa,nadattempt,
+     $       nequi,iadj,
+     $       ntest,nmm,
+     $       nmolo5o,nradcount,nmollset,iflga,
+     $       iperiod,ibgfversion,iremark,iconne,
+     $       kx,ky,kz,iexco,iruid,ibity,nvlist,
+     $       ityrad,iredo,iexx,iexy,iexz,ncellopt,
+     $       ndata2,nprob,nit,i5758,ingeo,nmoloold,itemp,
+     $       icgeo,ishock_type,isymm,
+     $       qadd(nat),qlabel(nattot),qffty(nattot),qresi1(nattot),
+     $       qresi2(nattot),qresi3(nattot),
+     $       qremark(20),qformat(20),qr,qffield,
+     $       qstrana1,qstrana2,qmolset(nmolset)
+***********************************************************************
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkabo.blk lammps-12Feb09/lib/reax/cbkabo.blk
--- lammps-29Jan09/lib/reax/cbkabo.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkabo.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkabo/ abo(nat)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkatomcoord.blk lammps-12Feb09/lib/reax/cbkatomcoord.blk
--- lammps-29Jan09/lib/reax/cbkatomcoord.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkatomcoord.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common
+     $/cbkatomcoord/ id(nat,3),xmasat(nat),vel(3,nat),accel(3,nat)
+
diff -Naur lammps-29Jan09/lib/reax/cbkbo.blk lammps-12Feb09/lib/reax/cbkbo.blk
--- lammps-29Jan09/lib/reax/cbkbo.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkbo.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common
+     $/cbkbo/ bo(nbomax)
+
diff -Naur lammps-29Jan09/lib/reax/cbkboncor.blk lammps-12Feb09/lib/reax/cbkboncor.blk
--- lammps-29Jan09/lib/reax/cbkboncor.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkboncor.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+      common
+     $/cbkboncor/ dbosindc(nbomax,3,2*mbond+2),dbosidc(nbomax,3,2),
+     $            bo131(nsort),bo132(nsort),bo133(nsort),
+     $            ovc(nbotym),v13cor(nbotym)
+
diff -Naur lammps-29Jan09/lib/reax/cbkbopi.blk lammps-12Feb09/lib/reax/cbkbopi.blk
--- lammps-29Jan09/lib/reax/cbkbopi.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkbopi.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common
+     $/cbkbopi/ bopi(nbomax) 
+
diff -Naur lammps-29Jan09/lib/reax/cbkbopi2.blk lammps-12Feb09/lib/reax/cbkbopi2.blk
--- lammps-29Jan09/lib/reax/cbkbopi2.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkbopi2.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common
+     $/cbkbopi2/ bopi2(nbomax) 
+
diff -Naur lammps-29Jan09/lib/reax/cbkbosi.blk lammps-12Feb09/lib/reax/cbkbosi.blk
--- lammps-29Jan09/lib/reax/cbkbosi.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkbosi.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkbosi/ bosi(nbomax) 
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkc.blk lammps-12Feb09/lib/reax/cbkc.blk
--- lammps-29Jan09/lib/reax/cbkc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkc.blk	2009-02-12 09:09:50.000000000 -0700
@@ -0,0 +1,5 @@
+      common
+     $/cbkc/ c(nat,3),cglobal(nattot,3),itag(nat),
+     $chgglobal(nattot)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkch.blk lammps-12Feb09/lib/reax/cbkch.blk
--- lammps-29Jan09/lib/reax/cbkch.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkch.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkch/ ch(nat)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkcha.blk lammps-12Feb09/lib/reax/cbkcha.blk
--- lammps-29Jan09/lib/reax/cbkcha.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkcha.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+      common
+     $/cbkcha/ ech,syscha,chisys
+     $         vfieldx,vfieldy,vfieldz,nmcharge,ioldchg
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkcharmol.blk lammps-12Feb09/lib/reax/cbkcharmol.blk
--- lammps-29Jan09/lib/reax/cbkcharmol.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkcharmol.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkcharmol/ vmcha(nmolmax),
+     $             iat1mc(nmolmax),iat2mc(nmolmax)
+
diff -Naur lammps-29Jan09/lib/reax/cbkchb.blk lammps-12Feb09/lib/reax/cbkchb.blk
--- lammps-29Jan09/lib/reax/cbkchb.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkchb.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common   
+     $/cbkchb/ chi(nsort),eta(nsort),gam(nsort)
+
diff -Naur lammps-29Jan09/lib/reax/cbkconst.blk lammps-12Feb09/lib/reax/cbkconst.blk
--- lammps-29Jan09/lib/reax/cbkconst.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkconst.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+      common
+     $/cbkconst/ dgrrdn,one,half,three,zero,caljou,rgasc,xjouca
+     $           convmd
+
diff -Naur lammps-29Jan09/lib/reax/cbkcovbon.blk lammps-12Feb09/lib/reax/cbkcovbon.blk
--- lammps-29Jan09/lib/reax/cbkcovbon.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkcovbon.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+      common
+     $/cbkcovbon/ de2(nbotym),de3(nbotym),psi(nbotym),
+     $            psp(nbotym)         
+
diff -Naur lammps-29Jan09/lib/reax/cbkd.blk lammps-12Feb09/lib/reax/cbkd.blk
--- lammps-29Jan09/lib/reax/cbkd.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkd.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,7 @@
+      integer Lvirial,Latomvirial
+
+      common
+     $/cbkd/ d(3,nat),estrain(nat)
+
+      common
+     $/cbkvirial/ atomvirial(6,nat),virial(6),Lvirial,Latomvirial
diff -Naur lammps-29Jan09/lib/reax/cbkdbodc.blk lammps-12Feb09/lib/reax/cbkdbodc.blk
--- lammps-29Jan09/lib/reax/cbkdbodc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdbodc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,3 @@
+      common
+     $/cbkdbodc/ dbodc(nbomax,3,2)
+
diff -Naur lammps-29Jan09/lib/reax/cbkdbopi2ndc.blk lammps-12Feb09/lib/reax/cbkdbopi2ndc.blk
--- lammps-29Jan09/lib/reax/cbkdbopi2ndc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdbopi2ndc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+       
+      common
+     $/cbkdbopi2ndc/ dbopi2ndc(nbomax,3,2*mbond+2)
+
diff -Naur lammps-29Jan09/lib/reax/cbkdbopidc.blk lammps-12Feb09/lib/reax/cbkdbopidc.blk
--- lammps-29Jan09/lib/reax/cbkdbopidc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdbopidc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/dbopidc/ dbopi2dc(nbomax,3,2),dbopidc(nbomax,3,2)
+
diff -Naur lammps-29Jan09/lib/reax/cbkdbopindc.blk lammps-12Feb09/lib/reax/cbkdbopindc.blk
--- lammps-29Jan09/lib/reax/cbkdbopindc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdbopindc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+       
+      common
+     $/dbopindc/ dbopindc(nbomax,3,2*mbond+2)
+
diff -Naur lammps-29Jan09/lib/reax/cbkdcell.blk lammps-12Feb09/lib/reax/cbkdcell.blk
--- lammps-29Jan09/lib/reax/cbkdcell.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdcell.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+             
+      common
+     $/cbkdcell/ dcell(3,nat,27)
+
diff -Naur lammps-29Jan09/lib/reax/cbkdhdc.blk lammps-12Feb09/lib/reax/cbkdhdc.blk
--- lammps-29Jan09/lib/reax/cbkdhdc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdhdc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/cbkdhdc/ dhdc(nvamax,3,3)      
+
diff -Naur lammps-29Jan09/lib/reax/cbkdistan.blk lammps-12Feb09/lib/reax/cbkdistan.blk
--- lammps-29Jan09/lib/reax/cbkdistan.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdistan.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkdistan/ axis(3),aaxh,baxh,caxh,iortho
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkdrdc.blk lammps-12Feb09/lib/reax/cbkdrdc.blk
--- lammps-29Jan09/lib/reax/cbkdrdc.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkdrdc.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/cbkdrdc/ drdc(nbomax,3,2)
+
diff -Naur lammps-29Jan09/lib/reax/cbkefield.blk lammps-12Feb09/lib/reax/cbkefield.blk
--- lammps-29Jan09/lib/reax/cbkefield.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkefield.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+ 
+      common
+     $/cbkefield/ efix,efiy,efiz,c1
+
diff -Naur lammps-29Jan09/lib/reax/cbkenergies.blk lammps-12Feb09/lib/reax/cbkenergies.blk
--- lammps-29Jan09/lib/reax/cbkenergies.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkenergies.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,7 @@
+ 
+      common
+     $/cbkenergies/ eb,eoop,epen,estrc,deda(3),pressu,
+     $              efi,elp,emol,ea,eres,et,eradbo,
+     $              ev,eco,ecoa,ehb,sw,ew,ep,ekin  
+     
+
diff -Naur lammps-29Jan09/lib/reax/cbkeregime.blk lammps-12Feb09/lib/reax/cbkeregime.blk
--- lammps-29Jan09/lib/reax/cbkeregime.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkeregime.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+      character*5 qetype
+      common
+     $/cbkeregime/ qetype(mereg,mezone),nnereg(mereg),nerc,
+     $             ereg(mereg,mezone),nitec(mereg) 
+
diff -Naur lammps-29Jan09/lib/reax/cbkff.blk lammps-12Feb09/lib/reax/cbkff.blk
--- lammps-29Jan09/lib/reax/cbkff.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkff.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,9 @@
+      character*2 qas
+      common
+     $/cbkff/ gamcco(nsort,nsort),vpar(npamax),vovun(nsort),
+     $        stlp(nsort),aval(nsort),vlp1(nsort),
+     $        vover(nbotym),valp1(nsort),
+     $        vka(nvatym),qas(nsort),amas(nsort),e1(nbotym),
+     $        valf(nsort),de1(nbotym),swb,nvs(nvatym,3),nso,nvaty
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkfftorang.blk lammps-12Feb09/lib/reax/cbkfftorang.blk
--- lammps-29Jan09/lib/reax/cbkfftorang.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkfftorang.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,8 @@
+ 
+       
+       
+       
+      common 
+     $/cbkfftorang/ v4(ntotym),vconj(ntotym),
+     $              v1(ntotym),v2(ntotym),v3(ntotym)     
+
diff -Naur lammps-29Jan09/lib/reax/cbkh.blk lammps-12Feb09/lib/reax/cbkh.blk
--- lammps-29Jan09/lib/reax/cbkh.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkh.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/cbkh/ h(nvamax)     
+
diff -Naur lammps-29Jan09/lib/reax/cbkhbond.blk lammps-12Feb09/lib/reax/cbkhbond.blk
--- lammps-29Jan09/lib/reax/cbkhbond.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkhbond.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+      common
+       
+     $/cbkhbond/ hhb(nhbmax)
+
diff -Naur lammps-29Jan09/lib/reax/cbkia.blk lammps-12Feb09/lib/reax/cbkia.blk
--- lammps-29Jan09/lib/reax/cbkia.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkia.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+       
+      common
+     $/cbkia/ ia(nat,mbond+3),iag(nat,mbond+3)     
+
diff -Naur lammps-29Jan09/lib/reax/cbkidbo.blk lammps-12Feb09/lib/reax/cbkidbo.blk
--- lammps-29Jan09/lib/reax/cbkidbo.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkidbo.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,7 @@
+ 
+       
+                   
+      common
+     $/cbkidbo/ idbo(nbomax,2*mbond+2),dbondc(nbomax,3,2*mbond+2),
+     $          idbo1(nbomax)
+
diff -Naur lammps-29Jan09/lib/reax/cbkimove.blk lammps-12Feb09/lib/reax/cbkimove.blk
--- lammps-29Jan09/lib/reax/cbkimove.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkimove.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+      common
+     $/cbkimove/ imove(nattot)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkinit.blk lammps-12Feb09/lib/reax/cbkinit.blk
--- lammps-29Jan09/lib/reax/cbkinit.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkinit.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+      character*40 qruid
+      common
+     $/cbkinit/ tsetor,nzero,none,ntwo,nthree,qruid,systime,
+     $          ustime,two,pi,avognr,axiss(3),pset,rdndgr
+
diff -Naur lammps-29Jan09/lib/reax/cbklonpar.blk lammps-12Feb09/lib/reax/cbklonpar.blk
--- lammps-29Jan09/lib/reax/cbklonpar.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbklonpar.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/cbklonpar/ vlp(nat),dvlpdsbo(nat)
+
diff -Naur lammps-29Jan09/lib/reax/cbkmolec.blk lammps-12Feb09/lib/reax/cbkmolec.blk
--- lammps-29Jan09/lib/reax/cbkmolec.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkmolec.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+             
+          
+      common
+     $/cbkmolec/ nmolat2(nmolmax,nat),elmol2(nmolmax)  
+
diff -Naur lammps-29Jan09/lib/reax/cbknmolat.blk lammps-12Feb09/lib/reax/cbknmolat.blk
--- lammps-29Jan09/lib/reax/cbknmolat.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbknmolat.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+       
+             
+      common
+     $/cbknmolat/ nmolat(nmolmax,nat)       
+
diff -Naur lammps-29Jan09/lib/reax/cbknonbon.blk lammps-12Feb09/lib/reax/cbknonbon.blk
--- lammps-29Jan09/lib/reax/cbknonbon.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbknonbon.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,6 @@
+ 
+             
+      common
+     $/cbknonbon/ gamwco(nsort,nsort),sw1,p3co(nsort,nsort),
+     $            p2co(nsort,nsort),p1co(nsort,nsort)
+
diff -Naur lammps-29Jan09/lib/reax/cbknubon2.blk lammps-12Feb09/lib/reax/cbknubon2.blk
--- lammps-29Jan09/lib/reax/cbknubon2.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbknubon2.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+             
+      common
+     $/cbknubon2/ nubon1(nat,mbond), nubon2(nat,mbond)
+
diff -Naur lammps-29Jan09/lib/reax/cbknvlbo.blk lammps-12Feb09/lib/reax/cbknvlbo.blk
--- lammps-29Jan09/lib/reax/cbknvlbo.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbknvlbo.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbknvlbo/ nvlbo(nneighmax*nat)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbknvlown.blk lammps-12Feb09/lib/reax/cbknvlown.blk
--- lammps-29Jan09/lib/reax/cbknvlown.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbknvlown.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,2 @@
+      common
+     $/cbknvlown/ nvlown(nneighmax*nat)
diff -Naur lammps-29Jan09/lib/reax/cbkpairs.blk lammps-12Feb09/lib/reax/cbkpairs.blk
--- lammps-29Jan09/lib/reax/cbkpairs.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkpairs.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+      common
+     $/cbkpairs/ nvl1(nneighmax*nat),nvl2(nneighmax*nat),nvpair,nvlself
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkpres.blk lammps-12Feb09/lib/reax/cbkpres.blk
--- lammps-29Jan09/lib/reax/cbkpres.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkpres.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+ 
+      common
+     $/cbkpres/ presx,presy,presz
+
diff -Naur lammps-29Jan09/lib/reax/cbkqa.blk lammps-12Feb09/lib/reax/cbkqa.blk
--- lammps-29Jan09/lib/reax/cbkqa.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkqa.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+      character*2 qa       
+      common
+     $/cbkqa/ qa(nattot)
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkrbo.blk lammps-12Feb09/lib/reax/cbkrbo.blk
--- lammps-29Jan09/lib/reax/cbkrbo.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkrbo.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+       
+      common
+     $/cbkrbo/ rbo(nbomax),ibsym(nbomax),ib(nbomax,3)
+
diff -Naur lammps-29Jan09/lib/reax/cbkrestr.blk lammps-12Feb09/lib/reax/cbkrestr.blk
--- lammps-29Jan09/lib/reax/cbkrestr.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkrestr.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,12 @@
+      common
+     $/cbkrestr/ vkrv(mrestra),vrstra(mrestra),vkr2v(mrestra),
+     $           dismacen(mrestra),rmstra1(mrestra),
+     $           rrstra(mrestra),vkrst2(mrestra),
+     $           rmstra2(mrestra),rmstrax(mrestra),rmstray(mrestra),    
+     $           rmstraz(mrestra),cmo(nat,3),vmo1(nat),trstra(mrestra),
+     $           vkrt(mrestra),vkr2t(mrestra),vkrstr(mrestra),
+     $           irstrav(mrestra,3),irstra(mrestra,2),itend(mrestra),
+     $           irstram(mrestra,5),itstart(mrestra),irstrat(mrestra,4),
+     $           imorph
+
+
diff -Naur lammps-29Jan09/lib/reax/cbksrtbon1.blk lammps-12Feb09/lib/reax/cbksrtbon1.blk
--- lammps-29Jan09/lib/reax/cbksrtbon1.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbksrtbon1.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,13 @@
+      character*60 qmol
+      common
+     $/cbksrtbon1/ dbodr(nbomax),dbopidr(nbomax),
+     $             dbopi2dr(nbomax),
+     $             rob1(nsort,nsort),rob2(nsort,nsort),
+     $             rob3(nsort,nsort),
+     $             rat(nsort),rapt(nsort),vnq(nsort),bom(nbotym),
+     $             pdp(nbotym),ptp(nbotym),pdo(nbotym),
+     $             popi(nbotym),bop1(nbotym),bop2(nbotym),cutoff,
+     $             nbs(nbotym,2),
+     $             nsbma2,nsbmax,nboty2,nbonall,qfile(nmolset),qmol
+
+
diff -Naur lammps-29Jan09/lib/reax/cbksrthb.blk lammps-12Feb09/lib/reax/cbksrthb.blk
--- lammps-29Jan09/lib/reax/cbksrthb.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbksrthb.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,8 @@
+ 
+       
+      common
+     $/cbksrthb/ vhb1(nhbtym),vhb2(nhbtym),rhb(nhbtym),
+     $           dehb(nhbtym),ihb(nhbmax,8),nhb,
+     $           nphb(nsort),nhbs(nhbtym,3),nhbty,hbcut
+
+
diff -Naur lammps-29Jan09/lib/reax/cbktorang.blk lammps-12Feb09/lib/reax/cbktorang.blk
--- lammps-29Jan09/lib/reax/cbktorang.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbktorang.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+             
+      common
+     $/cbktorang/  dargtdc(ntomax,3,4),thg(ntomax)
+
diff -Naur lammps-29Jan09/lib/reax/cbktorsion.blk lammps-12Feb09/lib/reax/cbktorsion.blk
--- lammps-29Jan09/lib/reax/cbktorsion.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbktorsion.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,7 @@
+ 
+       
+              
+      common
+     $/cbktorsion/ nts(ntotym,4),ntoty,ntor,it(ntomax,11)
+     
+
diff -Naur lammps-29Jan09/lib/reax/cbktregime.blk lammps-12Feb09/lib/reax/cbktregime.blk
--- lammps-29Jan09/lib/reax/cbktregime.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbktregime.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,8 @@
+      common
+     $/cbktregime/ dttreg(mtreg,mtzone),tdamptreg(mtreg,mtzone),
+     $             ia1treg(mtreg,mtzone),ia2treg(mtreg,mtzone), 
+     $             tsettreg(mtreg,mtzone),nntreg(mtreg),ittc(mtreg),
+     $             nittc(mtreg),ifieldz,ifieldx,ifieldy,
+     $             nrestra,nrestram,nrestrat,nrestrav,ntrc
+
+
diff -Naur lammps-29Jan09/lib/reax/cbkvalence.blk lammps-12Feb09/lib/reax/cbkvalence.blk
--- lammps-29Jan09/lib/reax/cbkvalence.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkvalence.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+ 
+             
+      common
+     $/cbkvalence/ nval,iv(nvamax,6)
+
diff -Naur lammps-29Jan09/lib/reax/cbkvregime.blk lammps-12Feb09/lib/reax/cbkvregime.blk
--- lammps-29Jan09/lib/reax/cbkvregime.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cbkvregime.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,7 @@
+      character*5 qvtype             
+      common
+     $/cbkvregime/ ivsca(mvreg,mvzone),dvvreg(mvreg,mvzone),
+     $             nnvreg(mvreg),invrc,nitvc(mvreg),
+     $             qvtype(mvreg,mvzone)
+
+
diff -Naur lammps-29Jan09/lib/reax/cellcoord.blk lammps-12Feb09/lib/reax/cellcoord.blk
--- lammps-29Jan09/lib/reax/cellcoord.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/cellcoord.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,4 @@
+ 
+      common
+     $/cellcoord/ tm11,tm21,tm31,tm22,tm32,tm33,angle(3),angles(3)
+
diff -Naur lammps-29Jan09/lib/reax/control.blk lammps-12Feb09/lib/reax/control.blk
--- lammps-29Jan09/lib/reax/control.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/control.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,12 @@
+      common
+     $/control/ vrange,cutof2,cutof3,vlbora,tstep,range,taut,volcha,
+     $          axis1,axis2,axis3,taup,
+     $          icpres,nmethod,noutpt,inpt,napp,ianaly,ncha2,
+     $          nrand,ntscale,itstep,ndebug,icentr,itrout,
+     $          nchaudixmolo,itrans,nsav,
+     $          nrep1,ncontrol,nhop2,nsav3,ngeofor,ifreq,
+     $          nprevrun,maxstp,nvel,nsurp,ncons,
+     $          ncha,icell,imolde,nchaud
+*********************************************************************************
+
+
diff -Naur lammps-29Jan09/lib/reax/opt.blk lammps-12Feb09/lib/reax/opt.blk
--- lammps-29Jan09/lib/reax/opt.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/opt.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,23 @@
+      parameter (maxdat=5000)
+      parameter (maxmdat=2500)
+      parameter (maxkop=2500)
+      character*80 qff
+      character*60 qmdat
+      character*100 qdatid
+      character*2 qas2
+      common
+     $/opt/    fpar(7,nvatym,40),datopt(maxdat),caldat(maxdat),
+     $         compdat(maxdat),weightdat(maxdat),
+     $         devi(maxdat),vkop(maxkop),devkop(maxkop),sdy(3),
+     $         valpar,valnew,change,vchange,
+     $         molin(maxmdat,nsort),
+     $         iboo(nbotym,2),idmo(nodmtym,2),ivao(nvatym,5),
+     $         itoo(ntotym,7),ihbo(nhbtym,5),iheada(maxmdat),
+     $         ndatm(maxmdat),iheada2(maxmdat),ichn(3),
+     $         ikop1(maxkop),ikop2(maxkop),idat(maxdat),mu1(maxkop),
+     $         mu2(maxkop),
+     $         ndata,imam,iopt,iheatf,nkop,iagain,
+     $         qdatid(maxdat),qmdat(maxmdat),qff(250),qas2(nsort)
+***********************************************************************
+
+
diff -Naur lammps-29Jan09/lib/reax/reax_charges.F lammps-12Feb09/lib/reax/reax_charges.F
--- lammps-29Jan09/lib/reax/reax_charges.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_charges.F	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,85 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+**********************************************************************
+************************************************************************
+
+      subroutine taper(r,r2)
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkconst.blk"
+#include "cbkenergies.blk"
+#include "cbkinit.blk"
+#include "cbknonbon.blk"
+************************************************************************
+*                                                                      *
+*     Taper function for Coulomb interaction                           *
+*                                                                      *
+************************************************************************
+      r3=r2*r
+      SW=SWC7*R3*R3*R+SWC6*R3*R3+SWC5*R3*R2+SWC4*R2*R2+SWC3*R3+SWC2*R2+
+     $SWC1*R+SWC0
+      SW1=7.0D0*SWC7*R3*R3+6.0D0*SWC6*R3*R2+5.0D0*SWC5*R2*R2+
+     $4.0D0*SWC4*R3+THREE*SWC3*R2+TWO*SWC2*R+SWC1
+      return
+      end
+************************************************************************
+************************************************************************
+
+      subroutine tap7th
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkff.blk"
+#include "cbkh.blk"
+#include "control.blk"
+
+************************************************************************
+*                                                                      *
+*     7th order taper function setup                                   *
+*                                                                      *
+************************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In tap7th'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      D1=SWB-SWA
+      D7=D1**7.0D0
+      SWA2=SWA*SWA
+      SWA3=SWA2*SWA
+      SWB2=SWB*SWB
+      SWB3=SWB2*SWB
+ 
+************************************************************************
+*     7th order taper function                                         *
+************************************************************************
+ 
+      SWC7=  20.0D0/D7
+      SWC6= -70.0D0*(SWA+SWB)/D7
+      SWC5=  84.0D0*(SWA2+3.0D0*SWA*SWB+SWB2)/D7
+      SWC4= -35.0D0*(SWA3+9.0D0*SWA2*SWB+9.0D0*SWA*SWB2+SWB3)/D7
+      SWC3= 140.0D0*(SWA3*SWB+3.0D0*SWA2*SWB2+SWA*SWB3)/D7
+      SWC2=-210.0D0*(SWA3*SWB2+SWA2*SWB3)/D7
+      SWC1= 140.0D0*SWA3*SWB3/D7
+      SWC0=(-35.0D0*SWA3*SWB2*SWB2+21.0D0*SWA2*SWB3*SWB2+
+     $7.0D0*SWA*SWB3*SWB3+SWB3*SWB3*SWB)/D7
+ 
+      return
+      END
diff -Naur lammps-29Jan09/lib/reax/reax_connect.F lammps-12Feb09/lib/reax/reax_connect.F
--- lammps-29Jan09/lib/reax/reax_connect.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_connect.F	2009-02-12 09:09:50.000000000 -0700
@@ -0,0 +1,1545 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+**********************************************************************
+********************************************************************** 
+
+      subroutine srtatom
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkatomcoord.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkqa.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+********************************************************************** 
+*                                                                    *
+*     Determine atom types in system                                 *
+*                                                                    *
+********************************************************************** 
+*     Requires the following variables
+*     ndebug - opt.blk; determines whether to debug or not; everywhere
+*     xmasmd - cbka.blk; some sort of atmoic mass?; srtatom, reac.f
+*     molin - opt.blk; keeps info on?; srtatom
+*     nso - cbka.blk; number of atoms?; srtatom, inout.f
+*     nprob - cbka.blk; does?; connect.f, inout.f, reac.f
+*     nasort - cbka.blk; a sorting array; srtatom
+*     ia - cbka.blk; atom numbers?; poten.f, inout.f, connect.f, charges.f
+*     iag - cbka.blk; ; connect.f, inout.f, poten.f, reac.f
+*     xmasat - cbka.blk; does?; srtatom, reac.f
+*     amas - cbka.blk; ? ; srtatom, ffinpt, molanal, ovcor
+*     qa - cbka.blk; some sort of error statement variable?; srtatom, srtbon1, inout.f, radbo
+*     
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srtatom'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      xmasmd=0.0
+      do i1=1,nso
+      molin(nprob,i1)=0
+      nasort(i1)=0
+      end do
+      do i1=1,na
+      ia(i1,1)=0
+      iag(i1,1)=0
+      do i2=1,nso
+      if (qa(i1).eq.qas(i2)) then
+      ia(i1,1)=i2
+      iag(i1,1)=i2
+      molin(nprob,i2)=molin(nprob,i2)+1
+      xmasat(i1)=amas(i2)
+      xmasmd=xmasmd+amas(i2)
+      nasort(i2)=nasort(i2)+1
+      end if
+      end do
+      if (ia(i1,1).eq.0) then
+      write (*,*)'Unknown atom type: ',qa(i1)
+      stop 'Unknown atom type'
+      end if
+      end do
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine molec
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkdcell.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkmolec.blk"
+#include "cbknmolat.blk"
+#include "control.blk"
+#include "small.blk"
+      dimension nmolo2(nat),iseen(nmolmax),isee2(nmolmax)
+********************************************************************** 
+*                                                                    *
+*     Determine changes in molecules                                 *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In molec'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      npreac=0
+
+      do i1=1,nmolo
+      natmol=0
+      do i2=1,na
+      if (ia(i2,3+mbond).eq.i1) then
+      natmol=natmol+1
+      nmolat(i1,natmol+1)=i2
+      end if
+      end do
+      nmolat(i1,1)=natmol
+      end do
+
+      if (nmolo5.lt.nmolo5o) nradcount=0     !reset reaction counter
+      do i1=1,nmolo5
+      natmol=0
+      do i2=1,na
+      if (iag(i2,3+mbond).eq.i1) then
+      natmol=natmol+1
+      nmolat2(i1,natmol+1)=i2
+      end if
+      end do
+      nmolat2(i1,1)=natmol
+      end do
+      nmolo5o=nmolo5
+
+      do i1=nmolo+1,nmoloold
+      do i2=1,nmolat(i1,1)
+      nmolat(i1,1+i2)=0
+      end do
+      nmolat(i1,1)=0
+      end do
+
+      do i1=1,nmolo
+      elmol(i1)=0.0
+      do i2=1,nmolat(i1,1)
+      ihu=nmolat(i1,i2+1)
+      ity=ia(ihu,1)
+      elmol(i1)=elmol(i1)+stlp(ity)
+      end do
+      end do
+ 
+      do i1=1,nmolo5
+      elmol2(i1)=0.0
+      do i2=1,nmolat2(i1,1)
+      ihu=nmolat2(i1,i2+1)
+      ity=iag(ihu,1)
+      elmol2(i1)=elmol2(i1)+stlp(ity)
+      end do
+      end do
+ 
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine dista2 (n1,n2,dista,dx,dy,dz)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+********************************************************************** 
+*                                                                    *
+*     Determine interatomic distances                                *
+*                                                                    *
+********************************************************************** 
+c$$$*     if (ndebug.eq.1) then
+c$$$C*     open (65,file='fort.65',status='unknown',access='append')
+c$$$*     write (65,*) 'In dista2'
+c$$$*     call timer(65)
+c$$$*     close (65)
+c$$$*     end if
+      
+      dx=c(n1,1)-c(n2,1)
+      dy=c(n1,2)-c(n2,2)
+      dz=c(n1,3)-c(n2,3)
+      dista=sqrt(dx*dx+dy*dy+dz*dz)
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine srtbon1(lprune,lhb,hbcut_in)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkbosi.blk"
+#include "cbkbopi.blk"
+#include "cbkbopi2.blk"
+#include "cbkc.blk"
+#include "cbkch.blk"
+#include "cbkconst.blk"
+#include "cbkdbopidc.blk"
+#include "cbkdrdc.blk"
+#include "cbkia.blk"
+#include "cbknubon2.blk"
+#include "cbknvlbo.blk"
+#include "cbkpairs.blk"
+#include "cbknvlown.blk"
+#include "cbkqa.blk"
+#include "cbkrbo.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkdbodc.blk"
+#include "cbksrtbon1.blk"
+#include "cbkff.blk"
+#include "cbksrthb.blk"
+      logical found
+      integer nboncol(nboallmax)
+      integer iball(nboallmax,3)
+
+********************************************************************** 
+*                                                                    *
+*     Determine connections within the molecule                      *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srtbon1'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+c Transfer hbcut from C++ calling function
+      hbcut = hbcut_in
+
+      do i1=1,na
+      abo(i1)=0.0d0
+      end do
+      nbonall=0
+      nbon2=0
+      nsbmax=0
+      nsbma2=0
+
+      if (imolde.eq.0) then
+
+      nmolo=0
+      nmolo5=0
+      end if
+      if (imolde.eq.0) then
+      do i1=1,na
+      do i2=2,mbond+3
+      ia(i1,i2)=0
+      iag(i1,i2)=0
+      end do
+      end do
+     
+      else
+
+      do i1=1,na
+      do i2=2,mbond+2
+      ia(i1,i2)=0
+      iag(i1,i2)=0
+      end do
+      end do
+
+      end if
+
+      do i1=1,na
+      do i2=1,mbond
+      nubon1(i1,i2)=0
+      nubon2(i1,i2)=0
+      end do
+      end do
+
+* First detect all bonds and create preliminary list
+ 
+      do 11 ivl=1,nvpair
+      if (nvlbo(ivl).eq.0) goto 11  !not in bond order range
+      i1=nvl1(ivl)
+      i2=nvl2(ivl)
+      call dista2(i1,i2,dis,dxm,dym,dzm)
+      ih1=ia(i1,1)
+      ih2=ia(i2,1)
+      disdx=dxm/dis
+      disdy=dym/dis
+      disdz=dzm/dis
+      itype=0
+      if (ih1.gt.ih2) then
+      ih1=ia(i2,1)
+      ih2=ia(i1,1)
+      end if
+      do i3=1,nboty2
+      if (ih1.eq.nbs(i3,1).and.ih2.eq.nbs(i3,2)) itype=i3
+      end do
+      if (itype.eq.0.and.rat(ih1).gt.zero.and.rat(ih2).gt.zero) then
+c$$$      call mdsav(1,qfile(nprob))
+      write (*,*)qa(i1),'-',qa(i2),'Fatal: Unknown bond in molecule'
+      stop 
+      end if
+
+      rhulp=dis/rob1(ih1,ih2)
+ 
+********************************************************************** 
+*                                                                    *
+*     Determine bond orders                                          *
+*                                                                    *
+********************************************************************** 
+      rh2=zero
+      rh2p=zero
+      rh2pp=zero
+      ehulp=zero
+      ehulpp=zero
+      ehulppp=zero
+      bomh=bom(itype)
+      if (rapt(ih1).gt.zero.and.rapt(ih2).gt.zero) then
+      rhulp2=dis/rob2(ih1,ih2)
+      rh2p=rhulp2**ptp(itype)
+      ehulpp=bomh*exp(pdp(itype)*rh2p)
+      end if
+      if (vnq(ih1).gt.zero.and.vnq(ih2).gt.zero) then
+      rhulp3=dis/rob3(ih1,ih2)
+      rh2pp=rhulp3**popi(itype)
+      ehulppp=bomh*exp(pdo(itype)*rh2pp)
+      end if
+
+      if (rat(ih1).gt.zero.and.rat(ih2).gt.zero) then
+      rh2=rhulp**bop2(itype)
+      ehulp=bomh*(1.0+cutoff)*exp(bop1(itype)*rh2)
+      end if
+
+      bor=ehulp+ehulpp+ehulppp
+
+      j1=i1
+      j2=i2
+
+********************************************************************** 
+*                                                                    *
+*     Determine bond orders                                          *
+*                                                                    *
+********************************************************************** 
+      if (bor.gt.cutoff) then
+      nbonall=nbonall+1
+      if (nbonall.gt.nboallmax) then 
+      write (6,*)'nbonall = ',nbonall,
+     $ ' reax_defs.h::NBOALLMAXDEF = ',NBOALLMAXDEF,
+     $     ' after',ivl, ' of ',nvpair,' pairs completed.' 
+      stop 'Too many bonds; maybe wrong cell parameters.'
+      end if
+      iball(nbonall,1)=itype
+      iball(nbonall,2)=j1
+      iball(nbonall,3)=j2
+
+      ia(i1,2)=ia(i1,2)+1
+      if (ia(i1,2).gt.mbond) then 
+         write (6,*)'ia(i1,2) = ',ia(i1,2),
+     $        ' reax_defs.h::MBONDDEF = ',MBONDDEF,
+     $        ' after',ivl, ' of ',nvpair,' pairs completed.' 
+         stop 'Too many bonds on atom. Increase MBONDDEF'
+      end if
+
+      if (i1.ne.i2) then
+         ia(i2,2)=ia(i2,2)+1
+         if (ia(i2,2).gt.mbond) then 
+            write (6,*)'ia(i1,2) = ',ia(i1,2),
+     $           ' reax_defs.h::MBONDDEF = ',MBONDDEF,
+     $           ' after',ivl, ' of ',nvpair,' pairs completed.' 
+            stop 'Too many bonds on atom. Increase MBONDDEF'
+         end if
+      endif
+
+      ia(i1,ia(i1,2)+2)=i2 
+      ia(i2,ia(i2,2)+2)=i1 
+      if (abs(de1(iball(nbonall,1))).gt.-0.01) then
+      nubon2(i1,ia(i1,2))=nbonall
+      nubon2(i2,ia(i2,2))=nbonall
+      else
+      nbonall=nbonall-1      !Inorganics
+      end if
+      end if
+ 11   continue
+
+********************************************************************** 
+*                                                                    *
+*     lprune controls level of bond-pruning performed to increase    *
+*     performance. For correct results, it should be set to 4.       *
+*     However, making it smaller can speed up                        *
+*     force calculation and may not have a big effect on forces.     *
+*     Setting it to 0 turns off pruning, useful for debugging.       *
+*                                                                    *
+********************************************************************** 
+********************************************************************* 
+*                                                                    *
+*     lhb controls whether or not to unprune ghost bonds that        *
+*     may possibly form ghost hydrogen bonds.                        *
+*     Setting it to 1 causes unpruning, and so is the safe option.   *
+*     If lprune = 0, then pruning is not used, results are exact     *
+*     and lhb has no effect.                                         *
+*                                                                    *
+********************************************************************** 
+      if (lprune .gt. 0) then
+********************************************************************** 
+*                                                                    *
+*     Eliminate bonds that are not in 1-6 interaction                *
+*     with local atom, or closer.                                    *
+*     Need additional sweep to catch possible hydrogen bonds         *
+*                                                                    *
+********************************************************************** 
+
+      ntmp0 = 0
+      ntmp1 = 0
+      ntmp2 = 0
+      ntmp3 = 0
+      ntmp4 = 0
+      ntmp5 = 0
+      ntmp6 = 0
+      ntmphb = 0
+
+* color 1 are bonds with two local atoms
+* color 2 are bonds with one local atom
+* color 3 are bonds adjacent to bond with one local atom
+
+      do i1 = 1,nbonall
+         if (iball(i1,2).le.na_local) then
+            if (iball(i1,3).le.na_local) then
+               nboncol(i1) = 1
+               ntmp1 = ntmp1+1
+            else
+               nboncol(i1) = 2
+               ntmp2 = ntmp2+1
+            endif
+         else if (iball(i1,3).le.na_local) then
+            nboncol(i1) = 2
+            ntmp2 = ntmp2+1
+         else
+            nboncol(i1) = 0
+         endif
+      end do
+
+      if (lprune .ge. 3) then
+      do i1 = 1,nbonall
+         if (nboncol(i1).eq.2) then
+            if (iball(i1,2).le.na_local) then
+               i3=iball(i1,3)
+            else
+               i3=iball(i1,2)
+            endif
+           
+            do i4 = 1,ia(i3,2)
+               i5=nubon2(i3,i4)
+               if (nboncol(i5).eq.0) then
+                  nboncol(i5)=3
+                  ntmp3 = ntmp3+1
+               endif
+            end do
+         endif
+      end do
+      endif
+* color 4 bonds are part of a 1-4 interaction with local atom
+
+      if (lprune .ge. 4) then
+      do i1 = 1,nbonall
+         if (nboncol(i1).eq.3) then
+* One end definitely has a bond of color 2
+* Find it and color bonds on other end 4
+            i3=iball(i1,2)
+            i3b=0
+            do i4 = 1,ia(i3,2)
+               i5=nubon2(i3,i4)
+               if (nboncol(i5).eq.2) then
+                  i3b=iball(i1,3)
+               endif
+            end do
+
+            if (i3b.eq.0) then
+               i3=iball(i1,3)
+               i3b=0
+               do i4 = 1,ia(i3,2)
+                  i5=nubon2(i3,i4)
+                  if (nboncol(i5).eq.2) then
+                     i3b=iball(i1,2)
+                  endif
+               end do
+            endif
+
+            if (i3b.eq.0) then
+               stop 'Could not find color 2 from color 3 bond'
+            endif
+
+            do i4 = 1,ia(i3b,2)
+               i5=nubon2(i3b,i4)
+               if (nboncol(i5).eq.0) then
+                  nboncol(i5)=4
+                  ntmp4 = ntmp4+1
+               endif
+            end do
+           
+         endif
+      end do
+      endif
+
+* color 5 bonds are part of a 1-5 interaction with local atom
+
+      if (lprune .ge. 5) then
+      do i1 = 1,nbonall
+         if (nboncol(i1).eq.4) then
+* One end definitely has a bond of color 3
+* Find it and color bonds on other end 5
+            i3=iball(i1,2)
+            i3b=0
+            do i4 = 1,ia(i3,2)
+               i5=nubon2(i3,i4)
+               if (nboncol(i5).eq.3) then
+                  i3b=iball(i1,3)
+               endif
+            end do
+
+            if (i3b.eq.0) then
+               i3=iball(i1,3)
+               i3b=0
+               do i4 = 1,ia(i3,2)
+                  i5=nubon2(i3,i4)
+                  if (nboncol(i5).eq.3) then
+                     i3b=iball(i1,2)
+                  endif
+               end do
+            endif
+
+            if (i3b.eq.0) then
+               stop 'Could not find color 3 from color 4 bond'
+            endif
+
+            do i4 = 1,ia(i3b,2)
+               i5=nubon2(i3b,i4)
+               if (nboncol(i5).eq.0) then
+                  nboncol(i5)=5
+                  ntmp5 = ntmp5+1
+               endif
+            end do
+           
+         endif
+      end do
+      endif
+
+* color 6 bonds are part of a 1-6 interaction with local atom
+
+      if (lprune .ge. 6) then
+      do i1 = 1,nbonall
+         if (nboncol(i1).eq.5) then
+* One end definitely has a bond of color 4
+* Find it and color bonds on other end 6
+            i3=iball(i1,2)
+            i3b=0
+            do i4 = 1,ia(i3,2)
+               i5=nubon2(i3,i4)
+               if (nboncol(i5).eq.4) then
+                  i3b=iball(i1,3)
+               endif
+            end do
+
+            if (i3b.eq.0) then
+               i3=iball(i1,3)
+               i3b=0
+               do i4 = 1,ia(i3,2)
+                  i5=nubon2(i3,i4)
+                  if (nboncol(i5).eq.4) then
+                     i3b=iball(i1,2)
+                  endif
+               end do
+            endif
+
+            if (i3b.eq.0) then
+               stop 'Could not find color 4 from color 5 bond'
+            endif
+
+            do i4 = 1,ia(i3b,2)
+               i5=nubon2(i3b,i4)
+               if (nboncol(i5).eq.0) then
+                  nboncol(i5)=6
+                  ntmp6 = ntmp6+1
+               endif
+            end do
+           
+         endif
+      end do
+      endif
+
+* Catch all the possible hydrogen bonds
+* This section replicates the logic used in srthb()
+      if (lhb .eq. 1) then
+c  Outer loop must be Verlet list, because ia() does not store Verlet entries,
+c  but it does store bond entries in nubon2()
+      do ivl=1,nvpair    !Use Verlet-list to find donor-acceptor pairs
+
+      j1=nvl1(ivl)
+      j2=nvl2(ivl)
+      ihhb1=nphb(ia(j1,1))
+      ihhb2=nphb(ia(j2,1))
+
+      if (ihhb1.gt.ihhb2) then        !Make j1 donor(H) atom and j2 acceptor(O) atom
+      j2=nvl1(ivl)
+      j1=nvl2(ivl)
+      ihhb1=nphb(ia(j1,1))
+      ihhb2=nphb(ia(j2,1))
+      end if
+
+*     Only need to compute bonds where j1 is local
+      if (j1 .le. na_local) then
+
+      if (ihhb1.eq.1.and.ihhb2.eq.2) then
+         call dista2(j1,j2,dishb,dxm,dym,dzm)
+         if (dishb.lt.hbcut) then
+            do i23=1,ia(j1,2)   !Search for acceptor atoms bound to donor atom
+               if (nboncol(nubon2(j1,i23)).eq.0) then
+                  j3=ia(j1,2+i23)
+                  if (nphb(ia(j3,1)).eq.2.and.j3.ne.j2) then
+                     nboncol(nubon2(j1,i23))=-1
+                     ntmphb = ntmphb+1
+                  endif
+               endif
+            end do
+         end if
+      end if
+      end if
+      end do
+      end if
+
+* Compact the list, removing all uncolored bonds
+
+      nbon = 0
+      do i1 = 1,nbonall
+         if (nboncol(i1).eq.0) then
+            ntmp0=ntmp0+1
+         else
+            nbon = nbon+1
+
+            if (nbon.gt.nbomax) then 
+               write (6,*)nbon,nbomax
+               write (6,*)'nbon = ',nbon,' reax_defs.h::NBOMAXDEF = ',
+     $              NBOMAXDEF,' after',i1, ' of ',nbonall,
+     $              ' initial bonds completed.' 
+               stop 'Too many pruned bonds; increase NBOMAXDEF'
+            end if
+
+
+            ib(nbon,1) = iball(i1,1)
+            ib(nbon,2) = iball(i1,2)
+            ib(nbon,3) = iball(i1,3)
+         endif
+      end do
+
+********************************************************************** 
+*                                                                    *
+*     Do not perform ghost-bond pruning                              *
+*                                                                    *
+********************************************************************** 
+
+      else
+
+      nbon = 0
+      do i1 = 1,nbonall
+         nbon = nbon+1
+
+         if (nbon.gt.nbomax) then 
+            write (6,*)nbon,nbomax
+            write (6,*)'nbon = ',nbon,' reax_defs.h::NBOMAXDEF = ',
+     $           NBOMAXDEF,' after',i1, ' of ',nbonall,
+     $           ' initial bonds completed.' 
+            stop 'Too many pruned bonds; increase NBOMAXDEF'
+         end if
+
+         ib(nbon,1) = iball(i1,1)
+         ib(nbon,2) = iball(i1,2)
+         ib(nbon,3) = iball(i1,3)
+      end do
+
+      endif
+
+      do i1=1,na
+      do i2=2,mbond+2
+      ia(i1,i2)=0
+      iag(i1,i2)=0
+      end do
+      end do
+
+* Generate full set of bond data structures
+
+      do 10 i0 = 1,nbon
+      i1 = ib(i0,2)
+      i2 = ib(i0,3)
+      call dista2(i1,i2,dis,dxm,dym,dzm)
+*     do 10 i1=1,na-1
+*     do 10 i2=i1+1,na
+*     call dista2(i1,i2,dis,dxm,dym,dzm)
+      ih1=ia(i1,1)
+      ih2=ia(i2,1)
+*     if (dis.gt.5.0*rob) goto 10
+      disdx=dxm/dis
+      disdy=dym/dis
+      disdz=dzm/dis
+      itype=0
+      if (ih1.gt.ih2) then
+      ih1=ia(i2,1)
+      ih2=ia(i1,1)
+      end if
+      do i3=1,nboty2
+      if (ih1.eq.nbs(i3,1).and.ih2.eq.nbs(i3,2)) itype=i3
+      end do
+      if (itype.eq.0.and.rat(ih1).gt.zero.and.rat(ih2).gt.zero) then
+c$$$      call mdsav(1,qfile(nprob))
+      write (*,*)qa(i1),'-',qa(i2),'Fatal: Unknown bond in molecule'
+      stop 
+      end if
+
+      rhulp=dis/rob1(ih1,ih2)
+ 
+********************************************************************** 
+*                                                                    *
+*     Determine bond orders                                          *
+*                                                                    *
+********************************************************************** 
+      rh2=zero
+      rh2p=zero
+      rh2pp=zero
+      ehulp=zero
+      ehulpp=zero
+      ehulppp=zero
+      bomh=bom(itype)
+      if (rapt(ih1).gt.zero.and.rapt(ih2).gt.zero) then
+      rhulp2=dis/rob2(ih1,ih2)
+      rh2p=rhulp2**ptp(itype)
+      ehulpp=bomh*exp(pdp(itype)*rh2p)
+      end if
+      if (vnq(ih1).gt.zero.and.vnq(ih2).gt.zero) then
+      rhulp3=dis/rob3(ih1,ih2)
+      rh2pp=rhulp3**popi(itype)
+      ehulppp=bomh*exp(pdo(itype)*rh2pp)
+      end if
+
+      if (rat(ih1).gt.zero.and.rat(ih2).gt.zero) then
+      rh2=rhulp**bop2(itype)
+      ehulp=bomh*(1.0+cutoff)*exp(bop1(itype)*rh2)
+      end if
+
+      bor=ehulp+ehulpp+ehulppp
+      borsi=ehulp
+      borpi=ehulpp
+      borpi2=ehulppp
+      dbordrob=bop2(itype)*bop1(itype)*rh2*(1.0/dis)*ehulp+
+     $ptp(itype)*pdp(itype)*rh2p*(1.0/dis)*ehulpp+
+     $popi(itype)*pdo(itype)*rh2pp*(1.0/dis)*ehulppp
+      dborsidrob=bop2(itype)*bop1(itype)*rh2*(1.0/dis)*ehulp
+      dborpidrob=ptp(itype)*pdp(itype)*rh2p*(1.0/dis)*ehulpp
+      dborpi2drob=popi(itype)*pdo(itype)*rh2pp*(1.0/dis)*ehulppp
+     
+      nbon2=nbon2+1
+      j1=i1
+      j2=i2
+
+********************************************************************** 
+*                                                                    *
+*     Determine bond orders                                          *
+*                                                                    *
+********************************************************************** 
+      ib(i0,1)=itype
+      ib(i0,2)=j1
+      ib(i0,3)=j2
+      ibsym(i0)=ivl
+      drdc(i0,1,1)=disdx
+      drdc(i0,2,1)=disdy
+      drdc(i0,3,1)=disdz
+      drdc(i0,1,2)=-disdx
+      drdc(i0,2,2)=-disdy
+      drdc(i0,3,2)=-disdz
+      abo(i1)=abo(i1)+bor-cutoff
+      if (i1.ne.i2) abo(i2)=abo(i2)+bor-cutoff
+      bo(i0)=bor-cutoff
+      bos(i0)=bor-cutoff
+      bosi(i0)=borsi-cutoff
+      bopi(i0)=borpi
+      bopi2(i0)=borpi2
+      rbo(i0)=dis
+      dbodr(i0)=dbordrob
+*     dbosidr(i0)=dborsidrob
+      dbopidr(i0)=dborpidrob
+      dbopi2dr(i0)=dborpi2drob
+      dbodc(i0,1,1)=dbodr(i0)*drdc(i0,1,1)
+      dbodc(i0,2,1)=dbodr(i0)*drdc(i0,2,1)
+      dbodc(i0,3,1)=dbodr(i0)*drdc(i0,3,1)
+      dbodc(i0,1,2)=dbodr(i0)*drdc(i0,1,2)
+      dbodc(i0,2,2)=dbodr(i0)*drdc(i0,2,2)
+      dbodc(i0,3,2)=dbodr(i0)*drdc(i0,3,2)
+*     dbosidc(i0,1,1)=dbosidr(i0)*drdc(i0,1,1)
+*     dbosidc(i0,2,1)=dbosidr(i0)*drdc(i0,2,1)
+*     dbosidc(i0,3,1)=dbosidr(i0)*drdc(i0,3,1)
+*     dbosidc(i0,1,2)=dbosidr(i0)*drdc(i0,1,2)
+*     dbosidc(i0,2,2)=dbosidr(i0)*drdc(i0,2,2)
+*     dbosidc(i0,3,2)=dbosidr(i0)*drdc(i0,3,2)
+      dbopidc(i0,1,1)=dbopidr(i0)*drdc(i0,1,1)
+      dbopidc(i0,2,1)=dbopidr(i0)*drdc(i0,2,1)
+      dbopidc(i0,3,1)=dbopidr(i0)*drdc(i0,3,1)
+      dbopidc(i0,1,2)=dbopidr(i0)*drdc(i0,1,2)
+      dbopidc(i0,2,2)=dbopidr(i0)*drdc(i0,2,2)
+      dbopidc(i0,3,2)=dbopidr(i0)*drdc(i0,3,2)
+      dbopi2dc(i0,1,1)=dbopi2dr(i0)*drdc(i0,1,1)
+      dbopi2dc(i0,2,1)=dbopi2dr(i0)*drdc(i0,2,1)
+      dbopi2dc(i0,3,1)=dbopi2dr(i0)*drdc(i0,3,1)
+      dbopi2dc(i0,1,2)=dbopi2dr(i0)*drdc(i0,1,2)
+      dbopi2dc(i0,2,2)=dbopi2dr(i0)*drdc(i0,2,2)
+      dbopi2dc(i0,3,2)=dbopi2dr(i0)*drdc(i0,3,2)
+      ia(i1,2)=ia(i1,2)+1
+      if (i1.ne.i2) ia(i2,2)=ia(i2,2)+1
+      ia(i1,ia(i1,2)+2)=i2 
+      ia(i2,ia(i2,2)+2)=i1 
+      if (ia(i1,2).gt.nsbma2) nsbma2=ia(i1,2)
+      if (ia(i2,2).gt.nsbma2) nsbma2=ia(i2,2)
+      if (bor.gt.cutof3) then
+      iag(i1,2)=iag(i1,2)+1
+      iag(i2,2)=iag(i2,2)+1
+      iag(i1,iag(i1,2)+2)=i2 
+      iag(i2,iag(i2,2)+2)=i1 
+      nubon1(i1,iag(i1,2))=i0
+      nubon1(i2,iag(i2,2))=i0
+      if (iag(i1,2).gt.nsbmax) nsbmax=iag(i1,2)
+      if (iag(i2,2).gt.nsbmax) nsbmax=iag(i2,2)
+      end if
+      nubon2(i1,ia(i1,2))=i0
+      nubon2(i2,ia(i2,2))=i0
+
+   10 continue
+
+********************************************************************** 
+*                                                                    *
+*     Sort molecules                                                 *
+*                                                                    *
+********************************************************************** 
+      imolde = 1
+      if (imolde.eq.1) return    !fixed molecular definitions
+
+      FOUND=.FALSE.
+      DO 31 K1=1,NA
+      IF (IA(K1,3+mbond).EQ.0) FOUND=.TRUE.
+   31 IF (IA(K1,3+mbond).GT.NMOLO) NMOLO=IA(K1,3+mbond)
+      IF (.NOT.FOUND) GOTO 32
+************************************************************************
+*                                                                      *
+*     Molecule numbers are assigned. No restrictions are made for the  *
+*     sequence of the numbers in the connection table.                 *
+*                                                                      *
+************************************************************************
+      N3=1
+   34 N2=N3
+      NMOLO=NMOLO+1
+      if (nmolo.gt.nmolmax) then
+      write (*,*)nmolmax
+      write (*,*)'Too many molecules in system; increase nmolmax'
+      write (*,*)'nmolmax = ',nmolmax
+      write (*,*)'nmolo = ',nmolo
+      write (*,*)'n2 = ',n2
+      stop 'Too many molecules in system'
+      end if
+      IA(N2,3+mbond)=NMOLO
+   37 FOUND=.FALSE.
+      DO 36 N1=N2+1,NA
+      IF (IA(N1,3+mbond).NE.0) GOTO 36
+      DO 35 L=1,mbond
+      IF (IA(N1,l+2).EQ.0) GOTO 36
+      IF (IA(IA(N1,l+2),3+mbond).EQ.NMOLO) THEN
+      FOUND=.TRUE.
+      IA(N1,3+mbond)=NMOLO
+      GOTO 36
+      ENDIF
+   35 CONTINUE
+   36 CONTINUE
+      IF (FOUND) GOTO 37
+      DO 33 N3=N2+1,NA
+   33 IF (IA(N3,3+mbond).EQ.0) GOTO 34
+************************************************************************
+*                                                                      *
+*     The assigned or input molecule numbers are checked for their     *
+*     consistency.                                                     *
+*                                                                      *
+************************************************************************
+   32 FOUND=.FALSE.
+      DO 42 N1=1,NA
+      DO 41 L=1,mbond
+      IF (IA(N1,L+2).EQ.0) GOTO 42
+      IF (IA(IA(N1,L+2),3+mbond).NE.IA(N1,3+mbond)) THEN
+      FOUND=.TRUE.
+      ENDIF
+   41 CONTINUE
+   42 CONTINUE
+      IF (FOUND) THEN
+      write (7,1000)NA,qmol
+      do i1=1,NA
+      write (7,1100)i1,ia(i1,1),(ia(i1,2+i2),i2=1,nsbmax),
+     $ia(i1,3+mbond)
+      end do
+      write (7,*)tm11,tm22,tm33,angle(1),angle(2),angle(3)
+      STOP' Mol.nrs. not consistent; maybe wrong cell parameters'
+      end if
+********************************************************************** 
+*                                                                    *
+*     Sort molecules again                                           *
+*     This sort is on iag, enforces bond order cutoff                *
+*                                                                    *
+********************************************************************** 
+      FOUND=.FALSE.
+      DO 61 K1=1,NA
+      IF (IAG(K1,3+mbond).EQ.0) FOUND=.TRUE.
+   61 IF (IAG(K1,3+mbond).GT.NMOLO5) NMOLO5=IAG(K1,3+mbond)
+      IF (.NOT.FOUND) GOTO 62
+************************************************************************
+*                                                                      *
+*     Molecule numbers are assigned. No restrictions are made for the  *
+*     sequence of the numbers in the connection table.                 *
+*                                                                      *
+************************************************************************
+      N3=1
+   64 N2=N3
+      NMOLO5=NMOLO5+1
+      if (nmolo5.gt.nmolmax) stop 'Too many molecules in system'
+      IAG(N2,3+mbond)=NMOLO5
+   67 FOUND=.FALSE.
+      DO 66 N1=N2+1,NA
+      IF (IAG(N1,3+mbond).NE.0) GOTO 66
+      DO 65 L=1,mbond
+      IF (IAG(N1,l+2).EQ.0) GOTO 66
+      IF (IAG(IAG(N1,l+2),3+mbond).EQ.NMOLO5) THEN
+      FOUND=.TRUE.
+      IAG(N1,3+mbond)=NMOLO5
+      GOTO 66
+      ENDIF
+   65 CONTINUE
+   66 CONTINUE
+      IF (FOUND) GOTO 67
+      DO 63 N3=N2+1,NA
+   63 IF (IAG(N3,3+mbond).EQ.0) GOTO 64
+************************************************************************
+*                                                                      *
+*     The assigned or input molecule numbers are checked for their     *
+*     consistency.                                                     *
+*                                                                      *
+************************************************************************
+   62 FOUND=.FALSE.
+      DO 72 N1=1,NA
+      DO 71 L=1,mbond
+      IF (IAG(N1,L+2).EQ.0) GOTO 72
+      IF (IAG(IAG(N1,L+2),3+mbond).NE.IAG(N1,3+mbond)) THEN
+      FOUND=.TRUE.
+      ENDIF
+   71 CONTINUE
+   72 CONTINUE
+      IF (FOUND) THEN
+      write (7,1000)NA,qmol
+      do i1=1,NA
+      write (7,1100)i1,iag(i1,1),(iag(i1,2+i2),i2=1,nsbmax),
+     $iag(i1,3+mbond)
+      end do
+      write (7,*)tm11,tm22,tm33,angle(1),angle(2),angle(3)
+      STOP' Mol.nrs. not consistent; maybe wrong cell parameters'
+      ENDIF
+
+********************************************************************** 
+*                                                                    *
+*     Format part                                                    *
+*                                                                    *
+********************************************************************** 
+ 1000 format (i3,2x,a60)
+ 1100 format (8i3)
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine srtang
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbknubon2.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkrbo.blk"
+#include "cbkvalence.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+
+      dimension a(3),b(3),j(3)
+      dimension ityva(100)
+
+********************************************************************** 
+*                                                                    *
+*     Find valency angles in molecule                                *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srtang'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      nval=0
+      if (nvaty.eq.0) return
+      do iindexatom=1,na
+      inumbonds=ia(iindexatom,2)
+      do jindexbond=1,inumbonds-1
+      jindexbondlist = nubon2(iindexatom,jindexbond)
+      if (bo(jindexbondlist).lt.cutof2) goto 51
+      k4=ib(jindexbondlist,2)
+      k5=ib(jindexbondlist,3)
+      do kindexbond=jindexbond+1,inumbonds
+      kindexbondlist = nubon2(iindexatom,kindexbond)
+      iju=0
+      if (bo(kindexbondlist).lt.cutof2) goto 50
+      if (bo(jindexbondlist)*bo(kindexbondlist).lt.0.001) goto 50
+      k7=ib(kindexbondlist,2)
+      k8=ib(kindexbondlist,3)
+
+*     Exclude angles that have no local atoms.
+*     Angles with non-local center atom are not needed for angle
+*     energies, but are needed to construct torsions. 
+      if ( k4 .le. na_local .or. 
+     $     k5 .le. na_local .or. 
+     $     k7 .le. na_local .or. 
+     $     k8 .le. na_local) then 
+
+      if (k4.eq.k7.and.k5.eq.k8.and.k4.ne.k8.and.k5.ne.k7) then
+      nval=nval+1
+      iv(nval,2)=k5
+      iv(nval,3)=k4
+      iv(nval,4)=k8
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      nval=nval+1
+      iv(nval,2)=k4
+      iv(nval,3)=k5
+      iv(nval,4)=k7
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=2
+      write(6,*) 'Aaaah!'
+      end if
+      if (iju.eq.2) goto 50
+
+      if (k4.eq.k8.and.k5.eq.k7.and.k4.ne.k7.and.k5.ne.k8) then
+      nval=nval+1
+      iv(nval,2)=k5
+      iv(nval,3)=k4
+      iv(nval,4)=k7
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      nval=nval+1
+      iv(nval,2)=k4
+      iv(nval,3)=k5
+      iv(nval,4)=k8
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=2
+      write(6,*) 'Aaaah!'
+      end if
+      if (iju.eq.2) goto 50
+
+      if (k4.eq.k7) then
+      nval=nval+1
+      iv(nval,2)=k5
+      iv(nval,3)=k4
+      iv(nval,4)=k8
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=1
+      end if
+      if (iju.eq.1) goto 50
+
+      if (k4.eq.k8) then
+      nval=nval+1
+      iv(nval,2)=k5
+      iv(nval,3)=k4
+      iv(nval,4)=k7
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=1
+      end if
+      if (iju.eq.1) goto 50
+
+      if (k5.eq.k7) then
+      nval=nval+1
+      iv(nval,2)=k4
+      iv(nval,3)=k5
+      iv(nval,4)=k8
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=1
+      end if
+      if (iju.eq.1) goto 50
+
+      if (k5.eq.k8) then
+      nval=nval+1
+      iv(nval,2)=k4
+      iv(nval,3)=k5
+      iv(nval,4)=k7
+      iv(nval,5)=jindexbondlist
+      iv(nval,6)=kindexbondlist
+      iju=1
+      end if
+      if (iju.eq.1) goto 50
+
+      write (6,*)'nval = ',nval,
+     $        ' after',iindexatom, ' of ',na,' atoms completed.'
+      stop 'Adjacent bonds did not make an angle'
+
+      endif
+
+   50 continue
+
+      if (nval.gt.nvamax) then
+         write (6,*)'nval = ',nval,' reax_defs.h::NVAMAXDEF = ',
+     $        NVAMAXDEF,
+     $        ' after',iindexatom, ' of ',na,' atoms completed.'
+         stop 'Too many valency angles. Increase NVAMAXDEF'
+      endif
+
+      if (iju.gt.0) then
+**********************************************************************
+*                                                                    *
+*     Determine force field types of angles                          *
+*                                                                    *
+**********************************************************************
+      ityva(1)=0
+      ih1=ia(iv(nval,2),1)
+      ih2=ia(iv(nval,3),1)
+      ih3=ia(iv(nval,4),1)
+      if (ih3.lt.ih1) then
+      ih3=ia(iv(nval,2),1)
+      ih2=ia(iv(nval,3),1)
+      ih1=ia(iv(nval,4),1)
+      end if
+
+      nfound=0
+      do i3=1,nvaty
+      if (ih1.eq.nvs(i3,1).and.ih2.eq.nvs(i3,2).and.
+     $ih3.eq.nvs(i3,3)) then
+      nfound=nfound+1
+      ityva(nfound)=i3
+      end if
+      end do
+
+      if (ityva(1).eq.0.or.abs(vka(ityva(1))).lt.0.001) then   !Valence angle does not exist in force field;ignore
+      nval=nval-1
+      ihul=0
+      else
+      iv(nval,1)=ityva(1)
+      ihul=1
+
+      do i3=1,nfound-1           !Found multiple angles of the same type
+      nval=nval+1
+      iv(nval,1)=ityva(i3+1)
+      do i4=2,6
+      iv(nval,i4)=iv(nval-1,i4)
+      end do
+
+      end do
+
+      end if
+
+      if (iju.eq.2) then
+      ityva(1)=0
+      ih1=ia(iv(nval-ihul,2),1)
+      ih2=ia(iv(nval-ihul,3),1)
+      ih3=ia(iv(nval-ihul,4),1)
+      if (ih3.lt.ih1) then
+      ih3=ia(iv(nval-ihul,2),1)
+      ih2=ia(iv(nval-ihul,3),1)
+      ih1=ia(iv(nval-ihul,4),1)
+      end if
+
+      nfound=0
+      do i3=1,nvaty
+      if (ih1.eq.nvs(i3,1).and.ih2.eq.nvs(i3,2).and.
+     $ih3.eq.nvs(i3,3)) then
+      nfound=nfound+1
+      ityva(nfound)=i3
+      end if
+      end do
+
+      if (ityva(1).eq.0.or.abs(vka(ityva(1))).lt.0.001) then   !Valence angle does not exist in force field;ignore
+      if (ihul.eq.1) then
+      do i3=1,6
+      iv(nval-1,i3)=iv(nval,i3)
+      end do
+      end if
+      nval=nval-1
+      else
+      iv(nval-ihul,1)=ityva(1)
+
+      do i3=1,nfound-1           !Found multiple angles of the same type
+      nval=nval+1
+      iv(nval,1)=ityva(i3+1)
+      do i4=2,6
+      iv(nval,i4)=iv(nval-1,i4)
+      end do
+
+      end do
+
+      end if
+
+      end if
+
+      end if
+
+      end do
+   51 continue
+      end do
+      end do
+
+      nbonop=0
+     
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine srttor
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkbo.blk"
+#include "cbkrbo.blk"
+#include "cbkia.blk"
+#include "cbktorsion.blk"
+#include "cbkvalence.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbknubon2.blk"
+********************************************************************** 
+*                                                                    *
+*     Find torsion angles in molecule                                *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srttor'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      ntor=0
+      if (ntoty.eq.0) return
+      do 61 i1=1,nbon
+      k2=ib(i1,2)
+      k3=ib(i1,3)
+c     Only compute interaction if both atoms local
+c     are local or else flip a coin 
+      if (k2 .gt. na_local) go to 61
+      if (k3 .gt. na_local) then
+         if (itag(k2) .lt. itag(k3)) go to 61
+         if (itag(k2) .eq. itag(k3)) then
+            if(c(k2,3) .gt. c(k3,3)) go to 61
+            if(c(k2,3) .eq. c(k3,3) .and. 
+     $           c(k2,2) .gt. c(k3,2)) go to 61
+            if(c(k2,3) .eq. c(k3,3) .and. 
+     $           c(k2,2) .eq. c(k3,2) .and. 
+     $           c(k2,1) .gt. c(k3,1)) go to 61
+         endif
+      endif
+
+      iob1=ia(k2,2)
+      iob2=ia(k3,2)
+      do 60 i2=1,iob1        !Atoms connected to k2
+      k4=ia(k2,2+i2)
+      ibo2=nubon2(k2,i2)
+      do 60 i3=1,iob2        !Atoms connected to k3
+      k5=ia(k3,2+i3)
+      ibo3=nubon2(k3,i3)
+      bopr=bo(i1)*bo(ibo2)*bo(ibo3)
+      if (bopr.gt.cutof2.and.k2.ne.k5.and.k3.ne.k4.and.k4.ne.k5) then
+
+      ntor=ntor+1
+      it(ntor,2)=k4
+      it(ntor,3)=k2
+      it(ntor,4)=k3
+      it(ntor,5)=k5
+      it(ntor,6)=ibo2
+      it(ntor,7)=i1
+      it(ntor,8)=ibo3
+
+**********************************************************************
+*                                                                    *
+*     Determine force field types of torsion angles                  *
+*                                                                    *
+**********************************************************************
+      ity=0
+      ih1=ia(it(ntor,2),1)
+      ih2=ia(it(ntor,3),1)
+      ih3=ia(it(ntor,4),1)
+      ih4=ia(it(ntor,5),1)
+
+      if (ih2.gt.ih3) then
+      ih1=ia(it(ntor,5),1)
+      ih2=ia(it(ntor,4),1)
+      ih3=ia(it(ntor,3),1)
+      ih4=ia(it(ntor,2),1)
+      end if
+
+      if (ih2.eq.ih3.and.ih4.lt.ih1) then
+      ih1=ia(it(ntor,5),1)
+      ih2=ia(it(ntor,4),1)
+      ih3=ia(it(ntor,3),1)
+      ih4=ia(it(ntor,2),1)
+      end if
+
+      do i4=1,ntoty
+      if (ih1.eq.nts(i4,1).and.ih2.eq.nts(i4,2).and.ih3.eq.nts(i4,3)
+     $.and.ih4.eq.nts(i4,4)) ity=i4
+      end do
+
+      if (ity.eq.0) then
+      do i4=1,ntoty
+      if (nts(i4,1).eq.0.and.ih2.eq.nts(i4,2).and.ih3.eq.nts(i4,3)
+     $.and.nts(i4,4).eq.0) ity=i4
+      end do
+      end if
+
+      if (ity.eq.0) then
+      ntor=ntor-1           !Torsion angle does not exist in force field: ignore
+      else
+      it(ntor,1)=ity
+      end if
+
+      end if
+
+   60 continue
+ 61   continue
+
+      if (ntor.gt.ntomax) stop 'Too many torsion angles'
+*     do i1=1,ntor
+*     write (41,'(20i4)')i1,it(i1,1),it(i1,2),it(i1,3),
+*    $it(i1,4),it(i1,5),it(i1,6),it(i1,7),it(i1,8)
+*     end do
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine srtoop
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbkrbo.blk"
+#include "cbkvalence.blk"
+#include "control.blk"
+#include "small.blk"
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srtoop'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+**********************************************************************
+*                                                                    *
+*     Find out of plane angles in molecule                           *
+*                                                                    *
+**********************************************************************
+      noop=0
+      do i1=1,nval
+      k2=iv(i1,2)
+      k3=iv(i1,3)
+      k4=iv(i1,4)
+      k5=iv(i1,5)
+      k6=iv(i1,6)
+      do i2=1,nbon
+      k7=ib(i2,2)
+      k8=ib(i2,3)
+      if (bo(i2).gt.cutof2) then
+      if (k7.eq.k3.and.k8.ne.k4.and.k8.ne.k2) then
+      noop=noop+1 
+      ioop(noop,2)=k8
+      ioop(noop,3)=k3
+      ioop(noop,4)=k2
+      ioop(noop,5)=k4
+      ioop(noop,6)=i2
+      ioop(noop,7)=iv(i1,5)
+      ioop(noop,8)=iv(i1,6)
+      ioop(noop,9)=i1
+      end if
+      if (k8.eq.k3.and.k7.ne.k4.and.k7.ne.k2) then
+      noop=noop+1 
+      ioop(noop,2)=k7
+      ioop(noop,3)=k3
+      ioop(noop,4)=k2
+      ioop(noop,5)=k4
+      ioop(noop,6)=i2
+      ioop(noop,7)=iv(i1,5)
+      ioop(noop,8)=iv(i1,6)
+      ioop(noop,9)=i1
+      end if
+      end if
+      end do
+      end do
+      
+      do i1=1,noop
+      call caltor(ioop(i1,2),ioop(i1,3),ioop(i1,4),ioop(i1,5),hoop)
+      end do
+      
+********************************************************************** 
+      return
+      end
+**********************************************************************
+
+**********************************************************************
+
+      subroutine srthb
+
+**********************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkbo.blk"
+#include "cbkconst.blk"
+#include "cbkia.blk"
+#include "cbkrbo.blk"
+#include "cbksrthb.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkpairs.blk"
+#include "cbknvlown.blk"
+#include "cbknubon2.blk"
+**********************************************************************
+*                                                                    *
+*     Find hydrogen bonds in molecule                                *
+*                                                                    *
+**********************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In srthb'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      nhb=0
+**********************************************************************
+*                                                                    *
+*     Locate donor/acceptor bonds                                    *
+*                                                                    *
+**********************************************************************
+c  Outer loop must be Verlet list, because ia() does not store Verlet entries,
+c  but it does store bond entries in nubon2()
+c
+c The problem with using the nvlown ownership criterion
+c is that it would require that we unprune every bond that is within 
+c certain distance, as well as its first and second neighbor bonds.
+c
+c For the ownership criterion based on H atom location no unpruning is required.
+c Apparently lprune=4 is sufficient here, implying that we need to capture first and
+c second neighbor bonds of the O-H bond, and of course we need to include all hydrogen
+c bond partners within hbcut. 
+c 
+
+      do 20 ivl=1,nvpair    !Use Verlet-list to find donor-acceptor pairs
+
+      j1=nvl1(ivl)
+      j2=nvl2(ivl)
+      ity1=ia(j1,1)
+      ity2=ia(j2,1)
+      ihhb1=nphb(ia(j1,1))
+      ihhb2=nphb(ia(j2,1))
+
+      if (ihhb1.gt.ihhb2) then        !Make j1 donor(H) atom and j2 acceptor(O) atom
+      j2=nvl1(ivl)
+      j1=nvl2(ivl)
+      ity1=ia(j1,1)
+      ity2=ia(j2,1)
+      ihhb1=nphb(ia(j1,1))
+      ihhb2=nphb(ia(j2,1))
+      end if
+
+* Only need to compute bonds where j1 is local
+      if (j1 .le. na_local) then
+
+      if (ihhb1.eq.1.and.ihhb2.eq.2) then
+      call dista2(j1,j2,dishb,dxm,dym,dzm)
+      if (dishb.lt.hbcut) then
+      do 10 i23=1,ia(j1,2)                !Search for acceptor atoms bound to donor atom
+      j3=ia(j1,2+i23)
+      ity3=ia(j3,1)
+      nbohb=nubon2(j1,i23)
+      if (nphb(ity3).eq.2.and.j3.ne.j2.and.bo(nbohb).gt.0.01) then
+**********************************************************************
+*                                                                    *
+*     Accept hydrogen bond and find hydrogen bond type               *
+*                                                                    *
+**********************************************************************
+      nhb=nhb+1
+
+      if (nhb.gt.nhbmax) then
+      write (*,*)nhb,nhbmax
+      write (*,*)'Maximum number of hydrogen bonds exceeded'
+      stop 'Maximum number of hydrogen bonds exceeded'
+      end if
+
+      ihb(nhb,1)=0
+
+      do i3=1,nhbty
+      if (ity3.eq.nhbs(i3,1).and.ity1.eq.nhbs(i3,2).and.ity2.eq.
+     $nhbs(i3,3)) ihb(nhb,1)=i3
+      end do
+
+      if (ihb(nhb,1).eq.0) then    !Hydrogen bond not in force field
+      nhb=nhb-1 
+*     write (*,*)'Warning: added hydrogen bond ',ity3,ity1,ity2
+*     nhbty=nhbty+1
+*     nhbs(nhbty,1)=ity3
+*     nhbs(nhbty,2)=ity1
+*     nhbs(nhbty,3)=ity2
+*     rhb(nhbty)=2.70
+*     dehb(nhbty)=zero
+*     vhb1(nhbty)=5.0
+*     vhb2(nhbty)=20.0
+*     ihb(nhb,1)=nhbty
+      end if
+
+      ihb(nhb,2)=j3
+      ihb(nhb,3)=j1
+      ihb(nhb,4)=j2
+      ihb(nhb,5)=nbohb
+      ihb(nhb,6)=k1
+      ihb(nhb,7)=k2
+      ihb(nhb,8)=k3
+*     write (64,*)nhb,ihb(nhb,1),j3,j1,j2,nbohb,k1,k2,k3,bo(nbohb),
+*    $dishb
+      end if
+
+   10 continue
+
+      end if
+      end if
+      end if
+   20 end do
+
+*     stop 'end in srthb'
+      return
+      end
+**********************************************************************
diff -Naur lammps-29Jan09/lib/reax/reax_defs.h lammps-12Feb09/lib/reax/reax_defs.h
--- lammps-29Jan09/lib/reax/reax_defs.h	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_defs.h	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,70 @@
+#define PORTABLECOMMENTFLAG
+#ifndef PORTABLECOMMENTFLAG
+// This is just a way to have portable comments 
+// for both C++ and FORTRAN preprocessing.
+ /* ///:EOH~                                                                 */
+ /*                                                                          */
+ /* This file contains array dimension parameters for all the main           */
+ /* ReaxFF data structures, some of which need to be directly accessed       */
+ /* by Grasp C++ functions. If they are set too small, the calculation       */
+ /* will run out of allocated memory. If they are set too big, the machine   */
+ /* will not be able to allocate enough memory.                              */
+ /*                                                                          */
+ 
+ /*     NNEIGHMAXDEF =   Max number of neighbors / NATDEF                    */
+ /*     NATDEF =         Max number of atoms                                 */
+ /*     NATTOTDEF =      Max number of global atoms                          */
+ /*     NSORTDEF =       Max number of atom types                            */
+ /*     MBONDDEF =       Max number of bonds connected to one atom           */
+ /*     NAVIBDEF =       for 2nd derivatives                                 */
+ /*     NBOTYMDEF =      Max number of bond types                            */
+ /*     NVATYMDEF =      Max number of valency angle types                   */
+ /*     NTOTYMDEF =      Max number of torsion angle types                   */
+ /*     NHBTYMDEF =      Max number of hydrogen bond types                   */
+ /*     NODMTYMDEF =     Max number of off-diagonal Morse types              */
+ /*     NBOALLMAXDEF =   Max number of all bonds                             */
+ /*     NBOMAXDEF =      Max number of bonds                                 */
+ /*     NHBMAXDEF =      Max number of  hydrogen bonds                       */
+ /*     NVAMAXDEF =      Max number of valency angles                        */
+ /*     NOPMAXDEF =      Max number of out of plane angles                   */
+ /*     NTOMAXDEF =      Max number of torsion angles                        */
+ /*     NPAMAXDEF =      Max number of general parameters in force field     */
+ /*     NMOLMAXDEF =     Max number of molecules in system                   */
+ /*     NMOLSETDEF =     Max number of molecules in training set             */
+ /*     MRESTRADEF =     Max number of restraints                            */
+ /*     MTREGDEF =       Max number of temperature regimes                   */
+ /*     MTZONEDEF =      Max number of temperature zones                     */
+ /*     MVREGDEF =       Max number of volume regimes                        */
+ /*     MVZONEDEF =      Max number of volume zones                          */
+ /*     MEREGDEF =       Max number of electric field regimes                */
+ /*     MEZONEDEF =      Max number of electric field zones                  */
+#endif
+
+#define NNEIGHMAXDEF 120
+#define NATDEF 40000
+#define NATTOTDEF 39744
+#define NSORTDEF 20
+#define MBONDDEF 20
+#define NAVIBDEF 50
+#define NBOTYMDEF 200
+#define NVATYMDEF 200
+#define NTOTYMDEF 200
+#define NHBTYMDEF 200
+#define NODMTYMDEF 20
+#define NBOALLMAXDEF 180000
+#define NBOMAXDEF 90000
+#define NHBMAXDEF 400000
+#define NVAMAXDEF 300000
+#define NOPMAXDEF 00010
+#define NTOMAXDEF 65000
+#define NPAMAXDEF 50
+#define NMOLMAXDEF 2000
+#define NMOLSETDEF 1500
+#define MRESTRADEF 100
+#define MTREGDEF 100
+#define MTZONEDEF 5
+#define MVREGDEF 100
+#define MVZONEDEF 6
+#define MEREGDEF 100
+#define MEZONEDEF 3
+
diff -Naur lammps-29Jan09/lib/reax/reax_inout.F lammps-12Feb09/lib/reax/reax_inout.F
--- lammps-29Jan09/lib/reax/reax_inout.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_inout.F	2009-02-12 13:48:12.000000000 -0700
@@ -0,0 +1,3870 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+**********************************************************************
+**********************************************************************
+
+      subroutine ffinpt
+
+**********************************************************************
+#include "cbka.blk"
+#include "cbkboncor.blk"
+#include "cbkconst.blk"
+#include "cbkcovbon.blk"
+#include "cbkff.blk"
+#include "cbkfftorang.blk"
+#include "cbknonbon.blk"
+#include "cbksrthb.blk"
+#include "cbktorsion.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "valang.blk"
+#include "cbksrtbon1.blk"
+#include "cbkchb.blk"
+      dimension rcore2(nsort),ecore2(nsort),acore2(nsort)
+**********************************************************************
+*                                                                    *
+*     Read in force field                                            *
+*                                                                    *
+**********************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In ffinpt'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      open (4,file='ffield.reax',status='old')
+      rewind (4)
+      iline=0
+      read (4,'(a40)',end=990,err=990)qffield
+      iline=iline+1
+**********************************************************************
+*                                                                    *
+*     Read in general force field parameters                         *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)npar
+      iline=iline+1
+      do i1=1,npar
+      read (4,1300,end=990,err=990)vpar(i1)
+      iline=iline+1
+      end do
+      cutoff=0.01*vpar(30)
+      swa=vpar(12)
+      if (abs(swa).gt.0.01) write (*,*)
+     $'Warning: non-zero value for lower Taper-radius cutoff'
+      swb=vpar(13)
+      if (swb.lt.zero) stop 
+     $'Negative value for upper Taper-radius cutoff'
+      if (swb.lt.5.0) write (*,*)
+     $'Warning: very low value for upper Taper-radius cutoff:',swb
+**********************************************************************
+*                                                                    *
+*     Read in atom type data                                         *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990) nso
+      iline=iline+1
+      read (4,*,end=990,err=990)
+      iline=iline+1
+      read (4,*,end=990,err=990)
+      iline=iline+1
+      read (4,*,end=990,err=990)
+      iline=iline+1
+      if (nso.gt.nsort) stop 'Maximum number of atom types exceeded'
+      do i1=1,nso
+      read (4,1200,end=990,err=990)qas(i1),rat(i1),aval(i1),amas(i1),
+     $rvdw(i1),eps(i1),gam(i1),rapt(i1),stlp(i1)
+      iline=iline+1
+      read (4,1250,end=990,err=990)alf(i1),vop(i1),valf(i1),
+     $valp1(i1),valp2(i1),chi(i1),eta(i1),vnphb
+      iline=iline+1
+      read (4,1250,end=990,err=990)vnq(i1),vlp1(i1),vincr(i1),
+     $bo131(i1),bo132(i1),bo133(i1),sigqeq(i1),default
+      iline=iline+1
+      read (4,1250,end=990,err=990)vovun(i1),vval1(i1),vrom,
+     $vval3(i1),vval4(i1),rcore2(i1),ecore2(i1),acore2(i1)
+      iline=iline+1
+      idef(i1)=int(default)
+      nphb(i1)=int(vnphb)
+      end do
+**********************************************************************
+*                                                                    *
+*     Calculate van der Waals and Coulomb pair-parameters            *
+*                                                                    *
+**********************************************************************
+      do i1=1,nso
+      do i2=1,nso
+      rcore(i1,i2)=sqrt(rcore2(i1)*rcore2(i2))
+      ecore(i1,i2)=sqrt(ecore2(i1)*ecore2(i2))
+      acore(i1,i2)=sqrt(acore2(i1)*acore2(i2))
+      p1co(i1,i2)=sqrt(4.0*rvdw(i1)*rvdw(i2))
+      p2co(i1,i2)=sqrt(eps(i1)*eps(i2))
+      p3co(i1,i2)=sqrt(alf(i1)*alf(i2))
+      gamwh=sqrt(vop(i1)*vop(i2))
+      gamwco(i1,i2)=1.0/gamwh**vpar(29)
+      gamch=sqrt(gam(i1)*gam(i2))
+      gamcco(i1,i2)=1.0/gamch**3
+      rob1(i1,i2)=0.50*(rat(i1)+rat(i2))
+      rob2(i1,i2)=0.50*(rapt(i1)+rapt(i2))
+      rob3(i1,i2)=0.50*(vnq(i1)+vnq(i2))
+      end do
+      end do
+**********************************************************************
+*                                                                    *
+*     Read in bond type data                                         *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)nboty
+      iline=iline+1
+      read (4,*,end=990,err=990)
+      iline=iline+1
+      if (2*nboty.gt.nbotym) stop 'Maximum nr. of bond types exceeded'
+      ih=0
+      do i1=1,nboty
+      ih=ih+1
+      read (4,1400,end=990,err=990)nbs(ih,1),nbs(ih,2),de1(ih),
+     $de2(ih),de3(ih),psi(ih),pdo(ih),v13cor(ih),popi(ih),vover(ih)
+      iline=iline+1
+      read (4,1450,end=990,err=990)psp(ih),pdp(ih),ptp(ih),
+     $bom(ih),bop1(ih),bop2(ih),ovc(ih),vuncor(ih)
+      iline=iline+1
+      if (nbs(ih,1).ne.nbs(ih,2)) then
+      ih=ih+1
+      nbs(ih,1)=nbs(ih-1,2)
+      nbs(ih,2)=nbs(ih-1,1)
+      de1(ih)=de1(ih-1)
+      de2(ih)=de2(ih-1)
+      de3(ih)=de3(ih-1)
+      psi(ih)=psi(ih-1)
+      pdo(ih)=pdo(ih-1)
+      v13cor(ih)=v13cor(ih-1)
+      vover(ih)=vover(ih-1)
+      psp(ih)=psp(ih-1)
+      pdp(ih)=pdp(ih-1)
+      ptp(ih)=ptp(ih-1)
+      bop1(ih)=bop1(ih-1)
+      bop2(ih)=bop2(ih-1)
+*     bop3(ih)=bop3(ih-1)
+*     bop4(ih)=bop4(ih-1)
+      bom(ih)=bom(ih-1)
+      popi(ih)=popi(ih-1)
+      ovc(ih)=ovc(ih-1)
+      end if
+      end do
+      nboty2=ih
+**********************************************************************
+*                                                                    *
+*     Read in off-diagonal parameters                                *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)nodmty
+      iline=iline+1
+      if (nodmty.gt.nodmtym)
+     $stop 'Maximum nr. of off-diagonal Morse types exceeded'
+      ih=0
+      do i1=1,nodmty
+      ih=ih+1
+      read (4,1400,end=990,err=990)nodm1,nodm2,deodmh,rodmh,godmh,
+     $rsig,rpi,rpi2
+      iline=iline+1
+      if (rsig.gt.zero) rob1(nodm1,nodm2)=rsig
+      if (rsig.gt.zero) rob1(nodm2,nodm1)=rsig
+      if (rpi.gt.zero) rob2(nodm1,nodm2)=rpi
+      if (rpi.gt.zero) rob2(nodm2,nodm1)=rpi
+      if (rpi2.gt.zero) rob3(nodm1,nodm2)=rpi2
+      if (rpi2.gt.zero) rob3(nodm2,nodm1)=rpi2
+      if (rodmh.gt.zero) p1co(nodm1,nodm2)=2.0*rodmh
+      if (rodmh.gt.zero) p1co(nodm2,nodm1)=2.0*rodmh
+      if (deodmh.gt.zero) p2co(nodm1,nodm2)=deodmh
+      if (deodmh.gt.zero) p2co(nodm2,nodm1)=deodmh
+      if (godmh.gt.zero) p3co(nodm1,nodm2)=godmh
+      if (godmh.gt.zero) p3co(nodm2,nodm1)=godmh
+      end do
+**********************************************************************
+*                                                                    *
+*     Read in valency angle and conjugation type data                *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)nvaty
+      iline=iline+1
+      if (nvaty.gt.nvatym)
+     $stop 'Maximum nr. of valency angle types exceeded'
+      do i1=1,nvaty
+      read (4,1500,end=990,err=990)nvs(i1,1),nvs(i1,2),
+     $nvs(i1,3),th0(i1),vka(i1),vka3(i1),vka8(i1),vkac(i1),vkap(i1),
+     $vval2(i1)
+      iline=iline+1
+      end do
+**********************************************************************
+*                                                                    *
+*     Read in torsion angle type data                                *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)ntoty
+      iline=iline+1
+      if (ntoty.gt.ntotym)
+     $stop 'Maximum nr. of torsion angle types exceeded'
+      do i1=1,ntoty
+      read (4,1600,end=990,err=990)nts(i1,1),nts(i1,2),nts(i1,3),
+     $nts(i1,4),v1(i1),
+     $v2(i1),v3(i1),v4(i1),vconj(i1),v2bo(i1),v3bo(i1)
+      iline=iline+1
+      end do
+**********************************************************************
+*                                                                    *
+*     Read in hydrogen bond type data                                *
+*                                                                    *
+**********************************************************************
+      read (4,1100,end=990,err=990)nhbty
+      iline=iline+1
+      if (nhbty.gt.nhbtym)
+     $stop 'Maximum nr. of hydrogen bond types exceeded'
+      do i1=1,nhbty
+      read (4,1500,end=990,err=990)nhbs(i1,1),nhbs(i1,2),
+     $nhbs(i1,3),rhb(i1),dehb(i1),vhb1(i1),vhb2(i1)
+      iline=iline+1
+      end do
+**********************************************************************
+*                                                                    *
+*     Calculate vdWaals interaction parameters                       *
+*                                                                    *
+**********************************************************************
+      do i1=1,nso
+      do i2=1,nso
+      rr=(rvdw(i1)+rvdw(i2))
+      rr2=rr*rr
+      eps2=sqrt(eps(i1)*eps(i2))
+      rr6=rr2*rr2*rr2
+      pvdw1(i1,i2)=eps2*rr6*rr6
+      pvdw1(i2,i1)=eps2*rr6*rr6
+      pvdw2(i1,i2)=2.0*eps2*rr6
+      pvdw2(i2,i1)=2.0*eps2*rr6
+      end do
+      end do
+**********************************************************************
+*                                                                    *
+*     Error part                                                     *
+*                                                                    *
+**********************************************************************
+      goto 999
+  990 write (*,*)'Error or end-of-file reading unit 4 on line:',iline
+      stop
+  999 continue
+      close(4)
+**********************************************************************
+*                                                                    *
+*     Format part                                                    *
+*                                                                    *
+**********************************************************************
+ 1100 format (i3,2x,a2,3x,3d22.15)
+ 1200 format (1x,a2,10f9.4)
+ 1250 format (3x,10f9.4)
+ 1300 format (f10.4)
+ 1400 format (2i3,8f9.4)
+ 1450 format (6x,8f9.4)
+ 1500 format (3i3,7f9.4)
+ 1600 format (4i3,7f9.4)
+      return
+      end
+**********************************************************************
+***********************************************************************
+
+      subroutine mdsav(node)
+
+***********************************************************************
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkatomcoord.blk"
+#include "cbkbo.blk"
+#include "cbkc.blk"
+#include "cbkch.blk"
+#include "cbkconst.blk"
+#include "cbkdistan.blk"
+#include "cbkenergies.blk"
+#include "cbkia.blk"
+#include "cbkinit.blk"
+#include "cbklonpar.blk"
+#include "cbknubon2.blk"
+#include "cbkqa.blk"
+#include "cbktregime.blk"
+#include "cbksrtbon1.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+
+      dimension idum(mbond+3),bodum(mbond+3),qat2(2)
+      character*25 qfileh
+      character*33 qfile2
+      character*4 qext
+      character*6 qmdfi
+      character *7 var
+      character *3 qat2,pepname
+      character *1 qrtemp
+************************************************************************
+*                                                                      *
+*     Save coordinates, velocities and accelerations of MD-system      *
+*                                                                      *
+************************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In mdsav'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+************************************************************************
+c
+c     This is just for test purposes
+c
+************************************************************************
+c$$$      write(6,*) '***************************'
+c$$$      write(6,*) 'mdsav node number is ',node
+c$$$      write(6,*) '***************************'
+      return
+
+
+      qfileh='Unknown'
+      qmdfi='moldyn'
+      pepname='   '
+      ipeptide=0
+      if (ni.eq.2) qmdfi='molsav'
+
+      if (iopt.eq.0) then
+
+      do i1=1,mbond+3
+      idum(i1)=nzero
+      bodum(i1)=zero
+      end do
+C      if (napp.eq.1) 
+C     $open (7,file='fort.7',status='unknown',access='append')
+      if (napp.ne.1) 
+     $open (7,file='fort.7',status='unknown')
+      nsbmaxh=5*((nsbmax/5)+1)
+      write (7,100)na,qmol,mdstep,nsbmaxh
+      if (nbiolab.eq.1) write (67,101)na,qmol
+      do i1=1,na
+      bosum=0.0
+      do i3=1,nsbmax
+      if (iag(i1,2+i3).gt.0) bosum=bosum+bo(nubon1(i1,i3))
+      end do
+      if (nsbmax.lt.5) then
+      write (7,200)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,5-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,5-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      if (nbiolab.eq.1) then      !Delphi-connection table output
+      write (67,201)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2))
+      end if
+      else if (nsbmax.lt.10) then
+      write (7,210)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,10-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,10-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbmax.lt.15) then
+      write (7,220)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,15-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,15-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbmax.lt.20) then
+      write (7,230)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,20-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,20-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbmax.lt.25) then
+      write (7,240)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,25-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,25-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbmax.gt.25) then
+      write (7,250)i1,iag(i1,1),(iag(i1,2+i2),i2=1,iag(i1,2)),
+     $(idum(i2),i2=1,35-iag(i1,2)),
+     $iag(i1,3+mbond),(bo(nubon1(i1,i2)),i2=1,iag(i1,2)),
+     $(bodum(i2),i2=1,35-iag(i1,2)),abo(i1),vlp(i1),ch(i1)
+      end if
+      end do
+      boss=zero
+      vlps=0.0
+C      if (napp.eq.1)
+C     $open (8,file='fort.8',status='unknown',access='append')
+      if (napp.ne.1)
+     $open (8,file='fort.8',status='unknown')
+      nsbmaxh=5*((nsbma2/5)+1)
+      write (8,100)na,qmol,mdstep,nsbmaxh
+      chsum=0.0
+      do i1=1,na
+      bosum=0.0
+      do i3=1,nsbma2
+      if (ia(i1,2+i3).gt.0) bosum=bosum+bo(nubon2(i1,i3))
+      end do
+      if (nsbma2.lt.5) then
+      write (8,200)i1,ia(i1,1),(ia(i1,2+i2),i2=1,ia(i1,2)),
+     $(idum(i2),i2=1,5-ia(i1,2)),
+     $ia(i1,3+mbond),(bo(nubon2(i1,i2)),i2=1,ia(i1,2)),
+     $(bodum(i2),i2=1,5-ia(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbma2.lt.10) then
+      write (8,210)i1,ia(i1,1),(ia(i1,2+i2),i2=1,ia(i1,2)),
+     $(idum(i2),i2=1,10-ia(i1,2)),
+     $ia(i1,3+mbond),(bo(nubon2(i1,i2)),i2=1,ia(i1,2)),
+     $(bodum(i2),i2=1,10-ia(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbma2.lt.15) then
+      write (8,220)i1,ia(i1,1),(ia(i1,2+i2),i2=1,ia(i1,2)),
+     $(idum(i2),i2=1,15-ia(i1,2)),
+     $ia(i1,3+mbond),(bo(nubon2(i1,i2)),i2=1,ia(i1,2)),
+     $(bodum(i2),i2=1,15-ia(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbma2.lt.20) then
+      write (8,230)i1,ia(i1,1),(ia(i1,2+i2),i2=1,ia(i1,2)),
+     $(idum(i2),i2=1,20-ia(i1,2)),
+     $ia(i1,3+mbond),(bo(nubon2(i1,i2)),i2=1,ia(i1,2)),
+     $(bodum(i2),i2=1,20-ia(i1,2)),abo(i1),vlp(i1),ch(i1)
+      else if (nsbma2.lt.25) then
+      write (8,240)i1,ia(i1,1),(ia(i1,2+i2),i2=1,ia(i1,2)),
+     $(idum(i2),i2=1,25-ia(i1,2)),
+     $ia(i1,3+mbond),(bo(nubon2(i1,i2)),i2=1,ia(i1,2)),
+     $(bodum(i2),i2=1,25-ia(i1,2)),abo(i1),vlp(i1),ch(i1)
+      end if
+      boss=boss+bosum/2.0
+      vlps=vlps+vlp(i1)
+      chsum=chsum+ch(i1)
+      end do
+      write (7,*)2.0*boss,vlps,2.0*boss+2.0*vlps,chsum
+      close(8)
+      close(7)
+
+      end if
+
+      if (noutpt.eq.0) then
+      write (var,'(f7.4)')float(mdstep/nsav)/1d4
+      if (ni.eq.0) open (unit=67,file=qmdfi//var(3:7),
+     $status='unknown')
+      write (67,300)qmol
+      do i1=1,na
+      write (67,400)i1,qa(i1),(c(i1,i2),i2=1,3)
+      end do
+      write (67,*)
+      close(67)
+      end if
+
+      if (noutpt.eq.2) then
+C      open (88,file='moldyn.bgf',status='unknown',access='append')
+      call writebgf(88)
+      close (88)
+      end if
+
+      if ((ni.eq.1.and.iopt.eq.0).or.(ni.eq.1.and.iopt.eq.1.and.
+     $iflga.eq.1)) then
+      qrtemp=qr
+      if (qr.eq.'I') qr='C'
+      if (qfileh.eq.' ') then
+      write (*,*)'Warning: no file name given; use Unknown' 
+      qfileh='Unknown'
+      end if
+      qfile2=qfileh
+      if (imodfile.eq.0) then
+      istart=1
+      qstrana1(1:25)=qfileh
+      call stranal(istart,iend,vout,iout,1)
+      qfile2=qfileh(istart:iend-1)//".geo"
+      end if
+      call writegeo(98)
+
+      if (imodfile.eq.1.or.iopt.eq.0) then
+      open (88,file=qfile2,status='unknown')
+      call writegeo(88)
+      close (88)
+      end if 
+
+      qr=qrtemp
+
+      if (iopt.eq.0) then
+
+      do i1=1,na
+      write (56,410) i1,ch(i1)
+      write (55,410) i1,chgbgf(i1)
+      end do
+**********************************************************************
+*                                                                    *
+*     Write .pdb output file                                         *
+*                                                                    *
+**********************************************************************
+      open (unit=47,file='output.pdb',status='unknown')
+      do i1=1,na
+      write (47,412)'ATOM  ',i1,qa(i1),pepname,ipeptide,c(i1,1),
+     $c(i1,2),c(i1,3),1.0,2.2,qa(i1)
+      end do
+      write (47,*) 'TER'
+      write (47,*) 'END'
+      close (47)
+
+      if (nsurp.eq.0) then
+      if (kx.gt.0.or.ky.gt.0.or.kz.gt.0) then
+      qrtemp=qr
+**********************************************************************
+*                                                                    *
+*     Write crystal structure including periodic images              *
+*                                                                    *
+**********************************************************************
+*     mux=(1+kx+kx)
+*     muy=(1+ky+ky)
+*     muz=(1+kz+kz)
+*     qr='F'
+*     write (86,'(2x,a1,1x,a60)')qr,qmol
+*     qr=qrtemp
+*     write (86,'(3f10.4)')mux*axiss(1),muy*axiss(2),muz*axiss(3)
+*     write (86,'(3f10.4)')angle(1),angle(2),angle(3)
+*     do i1=1,na
+*     write (86,'(i4,1x,a2,3x,3d22.15)')i1,qa(i1),(c(i1,i2),i2=1,3)
+*     end do
+*     nhulp=na+1
+*     do k1=-kx,kx
+*     do k2=-ky,ky
+*     do k3=-kz,kz
+*     if (k1.ne.0.or.k2.ne.0.or.k3.ne.0) then
+*     do i1=1,na
+*     cx=c(i1,1)+k1*tm11
+*     cy=c(i1,2)+k1*tm21+k2*tm22
+*     cz=c(i1,3)+k1*tm31+k2*tm32+k3*tm33
+*     write (86,'(i4,1x,a2,3x,3d22.15)')nhulp,qa(i1),cx,cy,cz
+*     nhulp=nhulp+1
+*     end do
+*     end if
+*     end do
+*     end do
+*     end do
+*     write (86,*)
+**********************************************************************
+*                                                                    *
+*     Write crystal structure with extra unit cells                  *
+*                                                                    *
+**********************************************************************
+      mux=1+iexx
+      muy=1+iexy
+      muz=1+iexz
+      qr='F'
+      write (85,'(2x,a1,1x,a60)')qr,qmol
+      qr=qrtemp
+      write (85,'(3f10.4)')mux*axiss(1),muy*axiss(2),muz*axiss(3)
+      write (85,'(3f10.4)')angle(1),angle(2),angle(3)
+      do i1=1,na
+      write (85,'(i4,1x,a2,3x,3d22.15)')i1,qa(i1),(c(i1,i2),i2=1,3)
+      end do
+      nhulp=na+1
+      do k1=0,iexx
+      do k2=0,iexy
+      do k3=0,iexz
+      if (k1.ne.0.or.k2.ne.0.or.k3.ne.0) then
+      do i1=1,na
+      cx=c(i1,1)+k1*tm11
+      cy=c(i1,2)+k1*tm21+k2*tm22
+      cz=c(i1,3)+k1*tm31+k2*tm32+k3*tm33
+      write (85,'(i4,1x,a2,3x,3d22.15)')nhulp,qa(i1),cx,cy,cz
+      nhulp=nhulp+1
+      end do
+      end if
+      end do
+      end do
+      end do
+      write (85,*)
+
+      end if
+      end if
+      end if
+
+      end if
+
+      if (ni.eq.0.or.ni.eq.2) then
+********************************************************************** 
+*                                                                    *
+*     Write ASCII trajectory file                                    *
+*                                                                    *
+********************************************************************** 
+      if (ni.eq.0) open(unit=66,file=qmdfi//'.vel',status='unknown')
+      if (ni.eq.2) then
+      write (var,'(f7.4)')float(mdstep/nsav3)/1d4
+      open (unit=66,file=qmdfi//var(3:7),status='unknown')
+      end if
+      write (66,500)axis(1),axis(2),axis(3)
+      write (66,550)angle(1),angle(2),angle(3)
+      write (66,600)na,((c(i,j),j=1,3),qlabel(i),i=1,na)
+      write (66,700)((vel(j,i),j=1,3),i=1,na)
+      write (66,800)((accel(j,i),j=1,3),i=1,na)
+      write (66,900)((aold(j,i),j=1,3),i=1,na)
+      write (66,1000)tempmd
+      write (66,1050)
+      close (66)
+      end if
+      if (ni.ne.2.and.iopt.eq.0) then
+
+C      open (unit=68,file='xmolout',status='unknown',access='append')
+      write (68,1200)na
+      write (68,1300)qmol,mdstep+nit+nprevrun,estrc,
+     $axis(1),axis(2),axis(3),angle(1),angle(2),angle(3)
+      do i1=1,na
+      if (ixmolo.eq.0) write (68,1400)qa(i1),(c(i1,i2),i2=1,3)
+      if (ixmolo.eq.1) write (68,1400)qa(i1),(c(i1,i2),i2=1,3),
+     $(vel(i2,i1)/1e+10,i2=1,3),iag(i1,3+mbond)
+      if (ixmolo.eq.2) write (68,1401)qa(i1),(c(i1,i2),i2=1,3),
+     $iag(i1,3+mbond)
+      end do
+      close (68)
+
+      if (itrout.ne.0) then
+C      open (unit=69,file='xmolout2',status='unknown',access='append')
+      write (69,1200)na
+      write (69,1300)qmol,mdstep+nit+nprevrun,estrc,
+     $axis(1),axis(2),axis(3),angle(1),angle(2),angle(3)
+      do i1=1,na
+      if (ixmolo.eq.0) write (69,1400)qa(i1),(cp(i1,i2),i2=1,3)
+      if (ixmolo.eq.1) write (69,1400)qa(i1),(cp(i1,i2),i2=1,3),
+     $(vel(i2,i1)/1e+10,i2=1,3),iag(i1,3+mbond)
+      if (ixmolo.eq.2) write (68,1401)qa(i1),(c(i1,i2),i2=1,3),
+     $iag(i1,3+mbond)
+      end do
+      close (69)
+      end if
+
+      call molanal
+      end if
+********************************************************************** 
+*                                                                    *
+*     Generate BIOGRAF output-file                                   *
+*                                                                    *
+********************************************************************** 
+      if ((ni.eq.1.and.iopt.eq.0).or.(ni.eq.1.and.iopt.eq.1.and.
+     $iflga.eq.1)) then
+
+      if (qfileh.eq.' ') then
+      write (*,*)'Warning: no file name given; use Unknown' 
+      qfileh='Unknown'
+      end if
+      qfile2=qfileh
+      if (imodfile.eq.0) then
+      istart=1
+      qstrana1(1:25)=qfileh
+      call stranal(istart,iend,vout,iout,1)
+      qfile2=qfileh(istart:iend-1)//".bgf"
+      end if
+      call writebgf(90)
+
+      if (imodfile.eq.1.or.iopt.eq.0) then
+      open (88,file=qfile2,status='unknown')
+      call writebgf(88)
+      close (88)
+      end if
+
+      end if
+     
+      return
+********************************************************************** 
+*                                                                    *
+*     Format part                                                    *
+*                                                                    *
+********************************************************************** 
+  100 format (i4,1x,a40,'Iteration:',i8,' #Bonds:',i4)       
+  101 format (i3,2x,a40)
+  200 format (8i4,8f7.3)
+  201 format (8i3)
+  210 format (13i4,13f7.3)
+  220 format (18i4,18f7.3)
+  230 format (23i4,23f7.3)
+  240 format (28i4,28f7.3)
+  250 format (38i4,38f7.3)
+  300 format (2x,a1,1x,a60)
+  301 format (2x,a1,1x,f6.2,a60)
+  302 format (2x,a1,1x,2f6.2,a60)
+  310 format (2x,a1,1x,a60)
+  320 format (3f10.4)
+  400 format (i4,1x,a2,3x,3(d21.14,1x),1x,a5,1x,i5)
+  410 format (i4,f12.6)
+  412 format(A6,I5,1x,A2,3x,A3,2x,i4,4x,3f8.3,f6.2,f6.2,4x,2x,A6)
+  500 format (1x,'Lattice parameters:',/(3f15.8))
+  550 format (3f15.8)
+  600 format (i4,1x,'Atom coordinates (Angstrom):',/
+     $(3d24.15,1x,a5))
+  700 format (1x,'Atom velocities (Angstrom/s):',/(3d24.15))
+  800 format (1x,'Atom accelerations (Angstrom/s**2):',/(3d24.15))
+  900 format (1x,'Previous atom accelerations:',/(3d24.15))
+ 1000 format (1x,'MD-temperature (K):',/(1d24.15))
+ 1050 format (1x,'Connections, bond orders and lone pairs:')
+ 1100 format (8i3,8f8.4)
+ 1200 format (i4)
+ 1300 format (a40,i6,f12.4,6f7.2)
+ 1400 format (a2,3f10.5,3f15.5,i6)
+ 1401 format (a2,3f10.5,i6)
+ 1500 format ('BIOGRF',i4)
+ 1600 format ('XTLGRF',i4)
+ 1700 format ('DESCRP ',a60)
+ 1800 format ('REMARK ',a60)
+ 1900 format ('FFIELD ',a40)
+ 2000 format ('RUTYPE ',a40)
+ 2100 format ('CRYSTX ',6f11.5)
+ 2200 format ('CELLS ',6i5)
+ 2300 format ('#              At1 At2   R12    Force1  Force2  ',
+     $'dR12/dIteration(MD only)')
+ 2400 format ('BOND RESTRAINT ',2i4,f8.4,f8.2,f8.5,f10.7)
+ 2500 format ('#               At1 At2 At3 Angle   Force1  Force2',
+     $'  dAngle/dIteration (MD only)')
+ 2600 format ('ANGLE RESTRAINT ',3i4,2f8.2,f8.4,f9.6)
+ 2700 format ('#                 At1 At2 At3 At3 Angle   Force1  ',
+     $'Force2  dAngle/dIteration (MD only)')
+ 2800 format ('TORSION RESTRAINT ',4i4,2f8.2,f8.4,f9.6)
+ 2900 format ('FORMAT ATOM   (a6,1x,i5,1x,a5,1x,a3,1x,a1,1x,a5,',
+     $'3f10.5,1x,a5,i3,i2,1x,f8.5)')
+ 3000 format ('HETATM',1x,i5,1x,a5,1x,a3,1x,a1,1x,a5,3f10.5,1x,
+     $a5,i3,i2,1x,f8.5)
+ 3100 format ('FORMAT CONECT (a6,12i6)')
+ 3200 format ('CONECT',12i6)
+ 3300 format ('UNIT ENERGY   kcal')
+ 3400 format ('ENERGY',5x,f14.6)
+ 3500 format ('END')
+      end
+
+************************************************************************
+************************************************************************
+
+      subroutine readc
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkcha.blk"
+#include "cbkconst.blk"
+#include "cbkdistan.blk"
+#include "cbkinit.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+
+      character*6 qident
+      character*20 qhulp
+*     dimension qident(100)
+************************************************************************
+*                                                                      *
+*     Read control file                                                *
+*                                                                      *
+************************************************************************
+c$$$c      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$c      write (65,*) 'In readc'
+c$$$c      call timer(65)
+c$$$c      close (65)
+c$$$c      end if
+      if (mdstep.gt.0.or.nit.gt.0) nmmsav=nmm
+************************************************************************
+*                                                                      *
+*     Set default values                                               *
+*                                                                      *
+************************************************************************
+      nreac=0
+      axis1=200.0d0
+      axis2=200.0d0
+      axis3=200.0d0
+      cutof2=0.001d0
+      cutof3=0.300d0
+      tsetor=298.0d0
+      tset2=298.0d0
+      pset=0.0d0
+      tincr=0.0d0
+      tstep=0.5d0
+*     swa=0.0   !Moved to force field
+*     swb=12.5  !Moved to force field
+      taut=2.5d0
+      taut2=2.5d0
+      ndtau=50000
+      taup=500.0d0
+      vqnd=100.0d0
+      errnh=1.0d0
+      range=2.5d0
+      maxstp=1000
+      nequi=0
+      nmethod=3
+      ncha=3
+      ncha2=1
+      nchaud=1
+      nvlist=25
+      nrep1=5
+      nsav=50
+      icheck=0
+      ivels=0
+      itfix=0
+      ncontrol=25
+      noutpt=0
+      napp=0
+      nsurp=0
+      ncons=2
+      nrand=0
+      nmm=0
+      endpo=1.0d0
+      endpo2=1.0d0
+      nfc=50
+      nsav2=50
+      nmmax=50
+      i5758=0
+      parc1=1.0d0
+      parc2=0.001d0
+      icell=0
+      ingeo=1
+      ccpar=1.0005d0
+      icelo2=0
+      nrdd=0
+      nrddf=200000
+      nbiolab=0
+c      ngeofor=0
+      nincrop=0
+      accerr=2.50d0
+      vrange=2.50d0
+      vlbora=5.00d0
+      nsav3=1000
+      nhop2=25
+      nprevrun=0
+      ndebug=0
+      volcha=10.00d0
+      ixmolo=0
+      inpt=0
+      iconne=0
+      imolde=0
+      ianaly=0
+      icentr=0
+      itrans=0
+      itrout=0
+      tpnrad=300.0d0
+      ityrad=3
+      iexx=1
+      iexy=1
+      iexz=1
+      syscha=0.00d0
+      inmov1=0
+      inmov2=0
+      vfield=0.00d0
+      itstep=0
+      ifreq=0
+      isymm=1
+      icpres=0
+      delvib=0.0001d0
+c     shock variables
+      shock_vel = 2.d0 ! impact velocity for shock simulations (nm/ps)
+      shock_z_sep = 10.0d0 ! separation z value to apply initial velocities in shocks
+      ishock_type = 0.0d0 ! shock type. 0: simple impact; 1: compressing c axis
+c     Hugoniostat variables
+      Hug_E0 = 0.d0 ! Reference energy
+      Hug_P0 = 0.d0 ! Reference pressure
+      Hug_V0 = 0.d0 ! Reference volume
+c     Shear flow simulations for viscosity
+      xImpVcm = 1.d0 ! velocity applied in shear simulations (in nm/ps), left half mover at -xImpVcm and right at +xImpVcm
+c$$$************************************************************************
+c$$$*                                                                      *
+c$$$*     Read control-file                                                *
+c$$$*                                                                      *
+c$$$************************************************************************
+c$$$      open (10,file='control',status='old')
+c$$$   10 read (10,'(a20)',end=20,err=30)qhulp
+c$$$      if (qhulp(1:1).eq.'#') goto 10
+c$$$      read (qhulp,*,err=30)vhulp
+c$$$      read (qhulp,'(8x,a6)',err=30)qident
+c$$$      if (qident.eq.'Hug_V0') Hug_P0=vhulp
+c$$$      if (qident.eq.'Hug_P0') Hug_V0=vhulp
+c$$$      if (qident.eq.'Hug_E0') Hug_E0=vhulp
+c$$$      if (qident.eq.'shea_v') xImpVcm=vhulp
+c$$$      if (qident.eq.'shok_t') ishock_type=int(vhulp)
+c$$$      if (qident.eq.'shok_z') shock_z_sep=vhulp
+c$$$      if (qident.eq.'shok_v') shock_vel=vhulp
+c$$$      if (qident.eq.'nreac') nreac=int(vhulp)
+c$$$      if (qident.eq.'axis1') axis1=vhulp
+c$$$      if (qident.eq.'axis2') axis2=vhulp
+c$$$      if (qident.eq.'axis3') axis3=vhulp
+c$$$      if (qident.eq.'cutof2') cutof2=vhulp
+c$$$      if (qident.eq.'cutof3') cutof3=vhulp
+c$$$      if (qident.eq.'mdtemp') tsetor=vhulp
+c$$$      if (qident.eq.'mdtem2') tset2=vhulp
+c$$$      if (qident.eq.'mdpres') pset=vhulp*0.001
+c$$$      if (qident.eq.'tincr') tincr=vhulp
+c$$$      if (qident.eq.'tstep') tstep=vhulp
+c$$$*     if (qident.eq.'lowtap') swa=vhulp !Moved to force field
+c$$$*     if (qident.eq.'uptap') swb=vhulp  !Moved to force field
+c$$$      if (qident.eq.'tdamp1') taut=vhulp
+c$$$      if (qident.eq.'tdamp2') taut2=vhulp
+c$$$      if (qident.eq.'ntdamp') ndtau=int(vhulp)
+c$$$      if (qident.eq.'pdamp1') taup=vhulp
+c$$$      if (qident.eq.'tdhoov') vqnd=vhulp
+c$$$      if (qident.eq.'achoov') errnh=vhulp/100.0
+c$$$      if (qident.eq.'range') range=vhulp
+c$$$      if (qident.eq.'nmdit') maxstp=int(vhulp)
+c$$$      if (qident.eq.'nmdeqi') nequi=int(vhulp)
+c$$$      if (qident.eq.'imdmet') nmethod=int(vhulp)
+c$$$      if (qident.eq.'icharg') ncha=int(vhulp)
+          nchaold=ncha
+c$$$      if (qident.eq.'ichaen') ncha2=int(vhulp)
+c$$$      if (qident.eq.'ichupd') nchaud=int(vhulp)
+c$$$      if (qident.eq.'iout1') nrep1=int(vhulp)
+c$$$      if (qident.eq.'iout2') nsav=int(vhulp)
+c$$$      if (qident.eq.'icheck') ntest=int(vhulp)
+c$$$      if (qident.eq.'ivels') nvel=int(vhulp)
+c$$$      if (qident.eq.'itfix') ntscale=int(vhulp)
+c$$$      if (qident.eq.'irecon') ncontrol=int(vhulp)
+c$$$      if (qident.eq.'iout3') noutpt=int(vhulp)
+c$$$      if (qident.eq.'iappen') napp=int(vhulp)
+c$$$      if (qident.eq.'isurpr') nsurp=int(vhulp)
+c$$$      if (qident.eq.'itdmet') ncons=int(vhulp)
+c$$$      if (qident.eq.'iravel') nrand=int(vhulp)
+c$$$      if (qident.eq.'imetho') nmm=int(vhulp)
+c$$$      if (qident.eq.'endmm') endpo=vhulp
+          endpoold=endpo
+c$$$      if (qident.eq.'endmd') endpo2=vhulp
+c$$$      if (qident.eq.'imaxmo') nfc=int(vhulp)
+          nfcold=nfc
+c$$$      if (qident.eq.'iout4') nsav2=int(vhulp)
+c$$$      if (qident.eq.'imaxit') nmmax=int(vhulp)
+          nmmaxold=nmmax
+c$$$      if (qident.eq.'iout5') i5758=int(vhulp)
+c$$$      if (qident.eq.'parsca') parc1=vhulp
+c$$$      if (qident.eq.'parext') parc2=vhulp
+c$$$      if (qident.eq.'icelop') icell=int(vhulp)
+          icellold=icell
+c$$$      if (qident.eq.'igeopt') ingeo=int(vhulp)
+c$$$      if (qident.eq.'celopt') ccpar=vhulp
+c$$$      if (qident.eq.'icelo2') icelo2=int(vhulp)
+          icelo2old=icelo2
+c$$$      if (qident.eq.'ideve1') nrdd=int(vhulp)
+c$$$      if (qident.eq.'ideve2') nrddf=int(vhulp)
+c$$$      if (qident.eq.'ibiola') nbiolab=int(vhulp)
+c$$$c      if (qident.eq.'igeofo') ngeofor=int(vhulp)
+c$$$      if (qident.eq.'iincop') nincrop=int(vhulp)
+c$$$      if (qident.eq.'accerr') accincr=vhulp
+c$$$      if (qident.eq.'iout6') nsav3=int(vhulp)
+c$$$      if (qident.eq.'irten') nhop2=int(vhulp)
+c$$$      if (qident.eq.'npreit') nprevrun=int(vhulp)
+c$$$      if (qident.eq.'idebug') ndebug=int(vhulp)
+c$$$      if (qident.eq.'volcha') volcha=vhulp
+c$$$      if (qident.eq.'ixmolo') ixmolo=int(vhulp)
+c$$$      if (qident.eq.'inpt') inpt=int(vhulp)
+c$$$      if (qident.eq.'iconne') iconne=int(vhulp)
+c$$$      if (qident.eq.'imolde') imolde=int(vhulp)
+c$$$      if (qident.eq.'ianaly') ianaly=int(vhulp)
+c$$$      if (qident.eq.'icentr') icentr=int(vhulp)
+c$$$      if (qident.eq.'itrans') itrans=int(vhulp)
+c$$$      if (qident.eq.'itrout') itrout=int(vhulp)
+c$$$      if (qident.eq.'nvlist') nvlist=int(vhulp)
+c$$$      if (qident.eq.'vrange') vrange=vhulp
+c$$$      if (qident.eq.'vlbora') vlbora=vhulp
+c$$$      if (qident.eq.'tpnrad') tpnrad=vhulp
+c$$$      if (qident.eq.'ityrad') ityrad=int(vhulp)
+c$$$      if (qident.eq.'iexx') iexx=int(vhulp)
+c$$$      if (qident.eq.'iexy') iexy=int(vhulp)
+c$$$      if (qident.eq.'iexz') iexz=int(vhulp)
+c$$$      if (qident.eq.'syscha') syscha=vhulp
+c$$$      if (qident.eq.'inmov1') inmov1=int(vhulp)
+c$$$      if (qident.eq.'inmov2') inmov2=int(vhulp)
+c$$$      if (qident.eq.'itstep') itstep=int(vhulp)
+c$$$      if (qident.eq.'ifreq') ifreq=int(vhulp)
+c$$$      if (qident.eq.'isymm') isymm=int(vhulp)
+c$$$      if (qident.eq.'icpres') icpres=int(vhulp)
+c$$$      if (qident.eq.'delvib') delvib=vhulp
+c$$$      goto 10
+c$$$   20 continue
+      close (10)
+      axis(1)=axis1
+      axis(2)=axis2
+      axis(3)=axis3
+      if (axiss(1).gt.zero) then
+      axis(1)=axiss(1)
+      axis(2)=axiss(2)
+      axis(3)=axiss(3)
+      end if
+      if (tincr.lt.0.0001.and.tincr.gt.-0.0001) tset=tsetor
+      iequi=1
+      if (nequi.gt.0) iequi=0
+      if (iopt.eq.1.and.napp.eq.1) then
+      stop 'No fort.7 and fort.8 append with iopt=1 !'
+      end if
+      if (mdstep.gt.0.or.nit.gt.0) nmm=nmmsav
+      if (mdstep.gt.0.and.itstep.eq.1) then
+      tstepmax=tstep
+      tstep=tstep*(tsetor/tempmd)
+      if (tstep.gt.tstepmax) tstep=tstepmax
+      end if
+      tstep=1.0d-15*tstep
+      taus=taut
+      taut=1.0d-15*taut
+      taut2=1.0d-15*taut2
+      taup=1.0d-15*taup
+      ts2=tstep/2.0
+      ts22=tstep*ts2
+      return
+   30 continue
+      write (*,*)'Error reading control-file'
+      stop 'Error reading control-file'
+************************************************************************
+*                                                                      *
+*     Format part                                                      *
+*                                                                      *
+************************************************************************
+ 1050 format (f7.3)
+ 1055 format (f7.4)
+ 1056 format (f9.4)
+ 1060 format (i8)
+ 1070 format (f7.5)
+      end
+************************************************************************
+************************************************************************
+
+      subroutine staint
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkdcell.blk"
+#include "cbkqa.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+      dimension bvt(nat,4)
+************************************************************************
+*                                                                      *
+*     Generate cartesian coordinates from internal coordinate input    *
+*                                                                      *
+************************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In staint'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      k=0
+   10 read (3,1200,end=20,err=20)(ijk(k+1,k1),k1=1,3),k2,qa(k+1),
+     $bvt(k+1,3),bvt(k+1,2),bvt(k+1,1)
+      qlabel(k+1)=qa(k+1)
+      qresi1(k+1)='   '
+      qresi2(k+1)=' '
+      qresi3(k+1)='     '
+      qffty(k+1)='     '
+      if (k2.ne.k+1) then
+      write (*,*)'Wrong order in internal coordinates at atom:',k2
+      goto 20
+*     stop 'Wrong order in internal coordinates'
+      end if
+      k=k+1
+      if (k.gt.nat) then
+      write (*,*)na,nat
+      stop 'Maximum number of atoms exceeded'
+      end if
+      goto 10
+   20 continue
+      na=k
+      
+************************************************************************
+*                                                                      *
+*     CALCULATION OF CARTESIAN COORDINATES FROM INTERNAL COORDINAATES  *
+*                                                                      *
+************************************************************************
+
+   12 C(1,1)=ZERO
+      C(1,2)=ZERO
+      C(1,3)=ZERO
+      C(2,1)=BVT(2,1)
+      C(2,2)=ZERO
+      C(2,3)=ZERO
+      HR=(BVT(3,2)-90.0D0)*DGRRDN
+      C(3,1)=C(2,1)+BVT(3,1)*SIN(HR)
+      C(3,2)=BVT(3,1)*COS(HR)
+      C(3,3)=ZERO
+      DO 32 K1=4,NA
+      J=IJK(K1,2)
+      KB=K1-1
+      XH=C(J,1)
+      YH=C(J,2)
+      ZH=C(J,3)
+      DO 13 K2=1,KB
+      C(K2,1)=C(K2,1)-XH
+      C(K2,2)=C(K2,2)-YH
+      C(K2,3)=C(K2,3)-ZH
+      DO 13 K3=1,3
+   13 IF (ABS(C(K2,K3)).LT.1.0D-15) C(K2,K3)=1.0D-15
+      K=IJK(K1,3)
+      P2=C(K,2)*C(K,2)+C(K,3)*C(K,3)
+      IF (P2.NE.ZERO) THEN
+      P=SQRT(P2)
+      Q=SQRT(C(K,1)*C(K,1)+P2)
+      SA=C(K,2)/P
+      CA=C(K,3)/P
+      SB=-C(K,1)/Q
+      CB=P/Q
+      ELSE
+      SA=ZERO
+      CA=ONE
+      SB=ONE
+      CB=ZERO
+      ENDIF
+      DO 16 K2=1,KB
+      AZ=C(K2,1)
+      BZ=C(K2,2)
+      C(K2,1)=AZ*CB+BZ*SB*SA+C(K2,3)*SB*CA
+      C(K2,2)=BZ*CA-C(K2,3)*SA
+   16 C(K2,3)=-AZ*SB+BZ*CB*SA+C(K2,3)*CB*CA
+      IF (C(K,3).LE.ZERO) THEN
+      DO 17 K2=1,KB
+   17 C(K2,3)=-C(K2,3)
+      ENDIF
+      I=IJK(K1,1)
+      IF (1.0D5*ABS(C(I,1)).LE.ABS(C(I,2))) THEN
+      T1=HALF*PI
+      ELSE
+      YX=ABS(C(I,2)/C(I,1))
+      T1=ATAN(YX)
+      ENDIF
+      IF (C(I,1).GE.ZERO.AND.C(I,2).LT.ZERO) T1=TWO*PI-T1
+      IF (C(I,1).LT.ZERO.AND.C(I,2).GE.ZERO) T1=PI-T1
+      IF (C(I,1).LT.ZERO.AND.C(I,2).LT.ZERO) T1=T1+PI
+      DO 31 K2=1,KB
+      IF (C(K2,1).EQ.ZERO.AND.C(K2,2).EQ.ZERO) GOTO 31
+      IF (1.0D5*ABS(C(K2,1)).LT.ABS(C(K2,2))) THEN
+      T2=HALF*PI
+      ELSE
+      YX=ABS(C(K2,2)/C(K2,1))
+      T2=ATAN(YX)
+      ENDIF
+      IF (C(K2,1).GE.ZERO.AND.C(K2,2).LT.ZERO) T2=TWO*PI-T2
+      IF (C(K2,1).LT.ZERO.AND.C(K2,2).GE.ZERO) T2=PI-T2
+      IF (C(K2,1).LT.ZERO.AND.C(K2,2).LT.ZERO) T2=T2+PI
+      T3=T2-T1
+      IF (T3.LT.ZERO)T3=T3+TWO*PI
+      RZ=SQRT(C(K2,1)*C(K2,1)+C(K2,2)*C(K2,2))
+      C(K2,1)=RZ*COS(T3)
+      C(K2,2)=RZ*SIN(T3)
+   31 CONTINUE
+      HR=(BVT(K1,2)-90.0D0)*DGRRDN
+      HT=BVT(K1,3)*DGRRDN
+      CHR=COS(HR)
+      C(K1,1)=BVT(K1,1)*CHR*COS(HT)
+      C(K1,2)=BVT(K1,1)*CHR*SIN(HT)
+   32 C(K1,3)=C(IJK(K1,3),3)+BVT(K1,1)*SIN(HR)
+      
+      return
+ 1200 FORMAT(4I3,1X,A2,3F10.5,4X,I1,F10.5)
+      end
+************************************************************************
+************************************************************************
+
+      subroutine outint
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkconst.blk"
+#include "cbkia.blk"
+#include "cbkinit.blk"
+#include "cbknubon2.blk"
+#include "cbkqa.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbksrtbon1.blk"
+************************************************************************
+*                                                                      *
+*     Output internal coordinates                                      *
+*                                                                      *
+************************************************************************
+      dimension dvdc(3,3),dargdc(3,3)
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In outint'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      write (91,50)qmol
+      open (82,file='output.MOP',status='unknown')
+      write (82,*)
+      write (82,'(a40)')qmol
+      write (82,*)
+      close (82)
+
+*     IF (NMOLO.GT.1) THEN
+*     WRITE(6,*)' OUTPUT INTERNAL COORDINATES NOT POSSIBLE FOR ',
+*    $'CALCULATION ON MORE THAN ONE MOLECULE'
+*     RETURN
+*     END IF
+
+************************************************************************
+*                                                                      *
+*     Output of internal coordinates.                                  *
+*     First 3 atoms of other input file.                               *
+*                                                                      *
+************************************************************************
+      N1=1
+      N2=2
+      N3=3
+C      open (82,file='output.MOP',status='unknown',access='append')
+      write(91,100)N1,qa(n1)
+      write(82,'(2x,a2,f12.6,i3,f12.6,i3,f12.6,i3,1x,3i4)')qa(n1),
+     $zero,nzero,zero,nzero,zero,nzero,nzero,nzero,nzero
+      call dista2(n1,n2,rr,dx,dy,dz)
+      write(91,200)N1,N2,qa(n2),RR
+      write(82,'(2x,a2,f12.6,i3,f12.6,i3,f12.6,i3,1x,3i4)')qa(n2),
+     $rr,none,zero,nzero,zero,nzero,n1,nzero,nzero
+      close (82)
+
+      call dista2(n2,n3,rr,dx,dy,dz)
+      hv=zero
+      call calvalres(n1,n2,n3,arg,hv,dvdc,dargdc)
+      WRITE(91,300)N1,N2,N3,qa(n3),rdndgr*HV,RR
+C      open (82,file='output.MOP',status='unknown',access='append')
+      write(82,'(2x,a2,f12.6,i3,f12.6,i3,f12.6,i3,1x,3i4)')qa(n3),
+     $rr,none,rdndgr*hv,none,zero,nzero,n2,n1,nzero
+      close (82)
+
+      naih=3
+      
+      do i1=naih+1,na
+      bomax=zero
+      j1=0
+      do i2=1,ia(i1,2)
+      iob=ia(i1,2+i2)
+      ncubo=nubon2(i1,i2)
+      if (bo(ncubo).gt.bomax.and.iob.lt.i1) then
+      bomax=bo(ncubo)
+      j1=iob
+      end if
+      end do
+      if (j1.eq.0) j1=i1-1
+      call dista2(j1,i1,rr,dx,dy,dz)
+      
+      bomax=zero
+      j2=0
+      do i2=1,ia(j1,2)
+      iob=ia(j2,2+i2)
+      ncubo=nubon2(j1,i2)
+      if (bo(ncubo).gt.bomax.and.iob.lt.i1.and.
+     $abo(iob).gt.bo(ncubo)+0.2) then
+      bomax=bo(ncubo)
+      j2=iob
+      end if
+      end do
+      if (j2.eq.0) j2=i1-2
+      if (j2.eq.j1) j2=j2+1
+
+      call calvalres(j2,j1,i1,arg,hh,dvdc,dargdc)
+
+      bomax=zero
+      j3=0
+      do i2=1,ia(j2,2)
+      iob=ia(j2,2+i2)
+      ncubo=nubon2(j2,i2)
+      if (bo(ncubo).gt.bomax.and.iob.lt.i1.and.iob.ne.j1) then
+      bomax=bo(ncubo)
+      j3=iob
+      end if
+      end do
+      if (j3.eq.0) j3=i1-3
+      if (j3.eq.j2.and.j3.ne.j1-1) j3=j3+1
+      if (j3.eq.j2.and.j3.ne.j1-2) j3=j3+2
+      if (j3.eq.j1.and.j3.ne.j2-1) j3=j3+1
+      if (j3.eq.j1.and.j3.ne.j2-2) j3=j3+2
+
+      call caltor(j3,j2,j1,i1,ht)
+
+      write(91,400)j3,j2,j1,i1,qa(i1),ht,rdndgr*hh,rr
+C      open (82,file='output.MOP',status='unknown',access='append')
+      write(82,'(2x,a2,f12.6,i3,f12.6,i3,f12.6,i3,1x,3i4)')qa(i1),
+     $rr,none,rdndgr*hh,none,ht,none,j1,j2,j3
+      close (82)
+      end do
+
+      close(82)
+      return
+   50 format ('  I',2x,a60)
+  100 FORMAT(9X,I3,1x,a2)
+  200 FORMAT(6X,2I3,1x,a2,20X,F10.5)
+  300 FORMAT(3X,3I3,1x,a2,10X,2F10.5)
+  400 FORMAT(4I3,1x,a2,3F10.5)
+
+      end
+************************************************************************
+************************************************************************
+
+      subroutine outres
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbkch.blk"
+#include "cbkd.blk"
+#include "cbkenergies.blk"
+#include "cbkh.blk"
+#include "cbkimove.blk"
+#include "cbkrbo.blk"
+#include "cbktorang.blk"
+#include "cbktorsion.blk"
+#include "cbktregime.blk"
+#include "cbkvalence.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+#include "cbkinit.blk"
+
+************************************************************************
+*                                                                      *
+*     Output molecular data                                            *
+*                                                                      *
+************************************************************************
+      dimension isort(100),iad1(100),iad2(100),iad3(100),iad4(100)
+      character*60 qm2
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In outres'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      read (9,100,end=50)idata,qm2
+*     if (qm2.ne.qmol) then
+*     write (*,*)'Wrong molecule in outres-file'
+*     write (*,*)qmol
+*     write (*,*)qm2
+*     return
+*     end if
+      do 25 i1=1,idata
+      read (9,200)isort(i1),iad1(i1),iad2(i1),iad3(i1),iad4(i1)
+      ndata2=ndata2+1
+
+      if (isort(i1).eq.1) then
+*     do i2=1,nbon
+*     if (ib(i2,2).eq.iad1(i1).and.ib(i2,3).eq.iad2(i1)) then
+*     if (iopt.ne.1) write (81,*)iad1(i1),iad2(i1),rbo(i2)
+*     caldat(ndata2)=rbo(i2)
+*     end if
+*     end do
+      call dista2(iad1(i1),iad2(i1),dish,dx,dy,dz)
+      write (81,*)iad1(i1),iad2(i1),dish
+      caldat(ndata2)=dish
+      end if
+
+      if (isort(i1).eq.2) then
+      do i2=1,nval
+      if (iv(i2,2).eq.iad1(i1).and.iv(i2,3).eq.iad2(i1).and.
+     $iv(i2,4).eq.iad3(i1)) then
+      if (iopt.ne.1) write (81,*)iad1(i1),iad2(i1),
+     $iad3(i1),h(i2)*rdndgr
+      caldat(ndata2)=h(i2)*rdndgr
+      end if
+      end do
+      end if
+
+      if (isort(i1).eq.3) then
+      do i2=1,ntor
+      if (it(i2,2).eq.iad1(i1).and.it(i2,3).eq.iad2(i1).and.
+     $it(i2,4).eq.iad3(i1).and.it(i2,5).eq.iad4(i1)) then
+      if (iopt.ne.1) write (81,*)iad1(i1),iad2(i1),iad3(i1),iad4(i1),
+     $abs(thg(i2))
+      caldat(ndata2)=abs(thg(i2))
+      end if
+      end do
+      end if
+
+      if (isort(i1).eq.4) then
+      if (iopt.ne.1) write (81,*)estrmin
+      caldat(ndata2)=estrmin
+      end if
+
+      if (isort(i1).eq.5) then
+      if (iopt.ne.1) write (81,*)estrmin
+      caldat(ndata2)=estrmin
+      end if
+
+      if (isort(i1).eq.6) then
+      if (iopt.ne.1) write (81,*)iad1(i1),axiss(iad1(i1))
+      caldat(ndata2)=axiss(iad1(i1))
+      end if
+
+      if (isort(i1).eq.7) then
+      if (iopt.ne.1) write (81,*)eco
+      caldat(ndata2)=eco
+      end if
+
+      if (isort(i1).eq.8) then
+      do i2=1,nbon
+      if (ib(i2,2).eq.iad1(i1).and.ib(i2,3).eq.iad2(i1)) then
+      if (iopt.ne.1) write (81,*)iad1(i1),iad2(i1),bo(i2)
+      caldat(ndata2)=bo(i2)
+      end if
+      end do
+      end if
+
+      if (isort(i1).eq.9) then
+      if (iopt.ne.1) write (81,*)ch(iad1(i1))
+      caldat(ndata2)=ch(iad1(i1))
+      end if
+      
+      if (isort(i1).eq.10) then
+      rmsg=0.0
+      nmovh=0
+      do i2=1,na
+      do i3=1,3
+      rmsg=rmsg+imove(i2)*d(i3,i2)*d(i3,i2)
+      nmovh=nmovh+imove(i2)
+      end do
+      end do
+      rmsg=sqrt(rmsg/float(nmovh*3))
+
+      if (iopt.ne.1) write (81,*)rmsg
+      caldat(ndata2)=rmsg
+      end if
+
+      if (isort(i1).eq.11) then
+      if (iopt.ne.1) write (81,*)1000.0*pressu
+      caldat(ndata2)=1000.0*pressu
+      end if
+
+   25 continue
+      
+   50 return
+************************************************************************
+*                                                                      *
+*     Format part                                                      *
+*                                                                      *
+************************************************************************
+  100 format (i3,a60)
+  200 format (5i3)
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readgeo
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkdistan.blk"
+#include "cbkinit.blk"
+#include "cbkqa.blk"
+#include "cbksrtbon1.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+      character*80 qromb
+      character*25 qfileh
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readgeo'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      if (ngeofor.eq.-1) return
+
+********************************************************************** 
+*                                                                    *
+*     Read in system geometry                                        *
+*                                                                    *
+********************************************************************** 
+      if (ngeofor.eq.0) then
+      call readdelphi (qfileh,iend,naold)
+      namov=na
+      end if
+ 
+      if (ngeofor.eq.1) then
+      call readbgf(iend,naold)
+      end if
+ 
+
+
+      if (ngeofor.eq.2) then
+**********************************************************************
+*                                                                    *
+*     Read in free format (xmol) geometry                            *
+*                                                                    *
+**********************************************************************
+      qr='1'
+      read (3,'(i6)')na
+      namov=na
+      read (3,'(a60)')qmol
+      do i1=1,na
+      read (3,'(a80)')qromb
+      ifirstchar=80
+      do i2=1,80
+      if (qromb(i2:i2).ne.' '.and.i2.lt.ifirstchar) ifirstchar=i2
+      end do
+      read (qromb(ifirstchar:80),'(a2)')qa(i1)
+      read (qromb(ifirstchar+2:80),*)c(i1,1),c(i1,2),c(i1,3)
+      qlabel(i1)=qa(i1)
+      qresi1(i1)='   '
+      qresi2(i1)=' '
+      qresi3(i1)='     '
+      qffty(i1)='     '
+      end do
+      ibity=1
+      axiss(1)=-1.0
+      end if
+ 
+ 
+      if (ngeofor.eq.3) then
+**********************************************************************
+*                                                                    *
+*     Read in ChemDraw CC1-file                                      *
+*                                                                    *
+**********************************************************************
+      qr='1'
+      read (3,*)na
+      namov=na
+      read (3,'(a60)')qmol
+      do i1=1,na
+      read (3,'(2x,a2,5x,3f12.6)')qa(i1),c(i1,1),c(i1,2),c(i1,3)
+      end do
+      end if
+
+      if (ngeofor.eq.4) then
+**********************************************************************
+*                                                                    *
+*     Read in .pdb-format                                            *
+*                                                                    *
+**********************************************************************
+      qr='C'
+      call readpdb(iendf)
+      namov=na
+      ibity=1
+      axiss(1)=-1.0
+      qfile(nprob)=qmol
+      if (iendf.eq.1) stop 'End-of-file while reading in .pdb'
+      end if
+
+**********************************************************************
+*                                                                    *
+*     Set up periodic system                                         *
+*                                                                    *
+**********************************************************************
+      axis(1)=axiss(1)
+      axis(2)=axiss(2)
+      axis(3)=axiss(3)
+      angle(1)=angles(1)
+      angle(2)=angles(2)
+      angle(3)=angles(3)
+      if (axiss(1).lt.zero) then
+      axis(1)=axis1
+      axis(2)=axis2
+      axis(3)=axis3
+      angle(1)=90.0
+      angle(2)=90.0
+      angle(3)=90.0
+      end if
+      halfa=angle(1)*dgrrdn
+      hbeta=angle(2)*dgrrdn
+      hgamma=angle(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axis(1)*sinbet*sinphi
+      tm21=axis(1)*sinbet*cosphi
+      tm31=axis(1)*cosbet
+      tm22=axis(2)*sinalf
+      tm32=axis(2)*cosalf
+      tm33=axis(3)
+
+      return
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readdelphi (qfileh,iend,naold)
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkdistan.blk"
+#include "cbkff.blk"
+#include "cbkh.blk"
+#include "cbkinit.blk"
+#include "cbkqa.blk"
+#include "cbkrestr.blk"
+#include "cbksrtbon1.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+      character*25 qfileh
+********************************************************************** 
+*                                                                    *
+*     Read in geometries in Delphi-format (xyz)                      *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readdelphi'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      if (imodfile.eq.1) then
+      open (3,file=qfileh,status='old')
+      end if
+      nmmax=nmmaxold
+      nfc=nfcold
+      ibity=1
+      iredo=1
+      endpo=endpoold
+      icell=icellold
+      icelo2=icelo2old
+      iend=0
+      read (3,1000,end=900)qr,qmol 
+********************************************************************** 
+*                                                                    *
+*     Read in restraint information (optional)                       *
+*                                                                    *
+********************************************************************** 
+      if (qr.eq.'R'.or.qr.eq.'P'.or.qr.eq.'X') then
+      qmol=qmol(7:60)
+      qmolset(nuge)=qmol
+      read (18,1070,end=4,err=4) nrestra
+      do i1=1,nrestra
+      read (18,1090)irstra(i1,1),irstra(i1,2),rrstra(i1),vkrstr(i1),
+     $vkrst2(i1),rrcha(i1)
+      end do
+    4 continue
+      end if
+********************************************************************** 
+*                                                                    *
+*     Read in torsion restraint information (optional)               *
+*                                                                    *
+********************************************************************** 
+      if (qr.eq.'T'.or.qr.eq.'X') then
+      if (qr.eq.'T') then
+      qmol=qmol(7:60)
+      qmolset(nuge)=qmol
+      end if
+      read (28,1070,end=6,err=6) nrestrat
+      do i1=1,nrestrat
+      read (28,1091)irstrat(i1,1),irstrat(i1,2),irstrat(i1,3),
+     $irstrat(i1,4),trstra(i1),vkrt(i1),vkr2t(i1),rtcha(i1)
+      end do
+    6 continue
+      end if
+********************************************************************** 
+*                                                                    *
+*     Read in valency angle restraint information (optional)         *
+*                                                                    *
+********************************************************************** 
+      if (qr.eq.'V') then
+      qmol=qmol(7:60)
+      qmolset(nuge)=qmol
+      read (38,1070,end=7,err=7) nrestrav
+      do i1=1,nrestrav
+      read (38,1092)irstrav(i1,1),irstrav(i1,2),irstrav(i1,3),
+     $vrstra(i1),vkrv(i1),vkr2v(i1)
+      end do
+    7 continue
+      end if
+********************************************************************** 
+*                                                                    *
+*     Read in geometry                                               *
+*                                                                    *
+********************************************************************** 
+      ibh2=0
+      iequi=1
+      iexco=0
+      if (nequi.gt.0) iequi=0
+      axiss(1)=-1.0
+
+      if (qr.eq.'O'.or.qr.eq.'L') stop 'Not xyz-format'
+
+      if (qr.eq.'I') then      !Delphi internal coordinates
+      if (nsurp.ge.2) stop 'Int.coordinates only with 1 gemetry' 
+      call staint
+      goto 20
+      end if
+
+      if (qr.eq.'B') then      !Previous geometry with volume reduction
+      read (3,*)
+      vred=(1.0-0.01*volcha)**(0.33333)
+      iexco=1
+      na=naold
+      do i1=1,3
+      qmol=qmol
+      axiss(i1)=vred*axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      c(i2,i1)=vred*c(i2,i1)
+      end do
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+
+      goto 20
+      end if
+
+      if (qr.eq.'S') then      !Previous geometry with volume expansion
+      read (3,*)
+      vexp=(1.0+0.01*volcha)**(0.33333)
+      na=naold
+      iexco=1
+      do i1=1,3
+      qmol=qmol
+      axiss(i1)=vexp*axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      c(i2,i1)=vexp*c(i2,i1)
+      end do
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+
+      goto 20
+      end if
+
+      if (qr.eq.'F'.or.qr.eq.'Y'.or.qr.eq.'3'.or.qr.eq.'5'.
+     $or.qr.eq.'P') then 
+      kx=0
+      ky=0
+      kz=0
+      ibity=2
+      read(3,1005)axiss(1),axiss(2),axiss(3)
+      read(3,1005)angles(1),angles(2),angles(3)
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+
+      end if
+
+      if (qr.eq.'M'.or.qr.eq.'A') then 
+      nmmsav=nmm
+      nmm=2 
+      end if
+
+      if (qr.eq.'A') nmm=1
+
+      if (qr.eq.'D') then
+      endpo=endpo/25 
+      nmmax=nmmax*5
+      qruid='HIGH PRECISION'
+      end if
+
+      if (qr.eq.'H') then
+      nmmax=nmmax/10
+      qruid='LOW PRECISION'
+      end if
+
+      if (qr.eq.'1'.or.qr.eq.'5') then
+      nmm=1
+      nmmax=1
+      qruid='SINGLE POINT'
+      end if
+
+      if (qr.eq.'Y') then
+      icell=0
+      qruid='NO CELL OPT'
+      end if
+
+   10 read (3,1100,end=20,err=20)ir,qa(na+1),(c(na+1,i2),i2=1,3)
+      qlabel(na+1)=qa(na+1)
+      qresi1(na+1)='   '
+      qresi2(na+1)=' '
+      qresi3(na+1)='     '
+      qffty(na+1)='     '
+      if (ir.eq.0) goto 20
+      na=na+1
+
+      if (na.gt.nat) then
+      write (*,*)'Maximum number of atom exceeded ',na,nat
+      stop 'Maximum number of atoms exceeded'
+      end if
+
+      goto 10
+   20 continue
+
+      if (imodfile.eq.1) close (3)
+
+      return
+  900 iend=1
+      return
+ 1000 format (2x,a1,1x,a60)
+ 1005 format (3f10.4)
+ 1070 format (i3)
+ 1090 format (2i4,2f8.4,f8.6,f10.8)
+ 1091 format (4i4,2f8.4,3f8.6)
+ 1092 format (3i4,2f8.4,2f8.6)
+ 1100 format (i4,1x,a2,3x,3d22.15,1x,a5,1x,i5)
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readbgf(iendf,naold)
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkcha.blk"
+#include "cbkcharmol.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkdistan.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkh.blk"
+#include "cbkimove.blk"
+#include "cbkinit.blk"
+#include "cbkqa.blk"
+#include "cbkrestr.blk"
+#include "cbksrtbon1.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+      character*80 qromb
+      character*2 qrom
+      character*5 quen
+      character*5 qlabhulp
+      character*25 qfileh
+      character*200 qhulp
+********************************************************************** 
+*                                                                    *
+*     Read in BIOGRAF-geometry                                       *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readbgf'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      iendf=0
+      ienread=0
+      iredo=0
+      qremark(1)=' '
+      enmol=zero
+      formol=zero
+c$$$      if (imodfile.eq.1) then
+c$$$      open (3,file=qfileh,status='old')
+c$$$      end if
+      open (3,file='fort.3',status='old')
+      read (3,'(a40)',end=900)qromb
+      ibity=0
+      if (qromb(1:6).eq.'BIOGRF') ibity=1
+      if (qromb(1:6).eq.'XTLGRF') ibity=2
+      if (ibity.eq.0) then
+      write (*,*)qromb(1:6)
+      stop 'Unknown Biograf-file'
+      end if
+      read (qromb,'(6x,i4)')ibgfversion
+      if (ibity.eq.1) qr='C'
+      if (ibity.eq.2) qr='F'
+      iremark=0
+      iformat=0
+      iline=0
+      iexco=0
+      iruid=1
+      vvol=1.0
+      nmcharge=0
+      nmmax=nmmaxold
+      nfc=nfcold
+      ncha=nchaold
+      endpo=endpoold
+      icell=icellold
+      icelo2=icelo2old
+      axiss(1)=-1.0
+
+   30 read (3,'(a200)',end=46,err=40)qhulp
+      qstrana1(1:200)=qhulp
+      iline=iline+1
+      irecog=0
+
+      if (qhulp(1:6).eq.'DESCRP') then
+      read (qhulp,'(7x,a40)',end=46,err=46)qmol
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'REMARK') then
+      if (iremark.lt.20) iremark=iremark+1
+      read (qhulp,'(7x,a40)',end=46,err=46)qremark(iremark)
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'FORMAT') then
+      if (iformat.lt.20) iformat=iformat+1
+      read(qhulp,'(7x,a40)',end=46,err=46)qformat(iformat)
+      irecog=1
+      end if
+
+      if (qhulp(1:7).eq.'VCHANGE') then
+      read (qhulp(8:60),*)vvol
+      vred=(1.0+(vvol-1.0))**(0.33333333)
+      iexco=1
+      na=naold
+      qmol=qmol
+      do i1=1,3
+      axiss(i1)=vred*axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      cglobal(i2,i1)=vred*cglobal(i2,i1)
+      end do
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+      irecog=1
+      end if
+
+      if (qhulp(1:7).eq.'VCHANGX') then
+      read (qhulp(8:60),*)vvol
+      vred=vvol
+      iexco=1
+      na=naold
+      qmol=qmol
+      do i1=1,3
+      axiss(i1)=axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      cglobal(i2,i1)=cglobal(i2,i1)
+      end do
+      end do
+
+      axiss(1)=vred*axiss(1)
+      do i2=1,na
+      cglobal(i2,1)=vred*cglobal(i2,1)
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+      irecog=1
+      end if
+
+      if (qhulp(1:7).eq.'VCHANGY') then
+      read (qhulp(8:60),*)vvol
+      vred=vvol
+      iexco=1
+      na=naold
+      qmol=qmol
+      do i1=1,3
+      axiss(i1)=axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      cglobal(i2,i1)=cglobal(i2,i1)
+      end do
+      end do
+
+      axiss(2)=vred*axiss(2)
+      do i2=1,na
+      cglobal(i2,2)=vred*cglobal(i2,2)
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+      irecog=1
+      end if
+
+      if (qhulp(1:7).eq.'VCHANGZ') then
+      read (qhulp(8:60),*)vvol
+      vred=vvol
+      iexco=1
+      na=naold
+      qmol=qmol
+
+      do i1=1,3
+      axiss(i1)=axis(i1)
+      angles(i1)=angle(i1)
+      do i2=1,na
+      cglobal(i2,i1)=cglobal(i2,i1)
+      end do
+      end do
+
+      axiss(3)=vred*axiss(3)
+      do i2=1,na
+      cglobal(i2,3)=vred*cglobal(i2,3)
+      end do
+
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      ibity=2
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'CRYSTX') then
+      read (qhulp,'(8x,6f11.5)',end=46,err=46)axiss(1),
+     $axiss(2),axiss(3),angles(1),angles(2),angles(3)
+      kx=0
+      ky=0
+      kz=0
+      halfa=angles(1)*dgrrdn
+      hbeta=angles(2)*dgrrdn
+      hgamma=angles(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axiss(1)*sinbet*sinphi
+      tm21=axiss(1)*sinbet*cosphi
+      tm31=axiss(1)*cosbet
+      tm22=axiss(2)*sinalf
+      tm32=axiss(2)*cosalf
+      tm33=axiss(3)
+      kx=int(2.0*swb/tm11)
+      ky=int(2.0*swb/tm22)
+      kz=int(2.0*swb/tm33)
+      qr='F'
+      if (nmmax.eq.1.and.nmmaxold.gt.1) qr='5'
+      if (icell.eq.0.and.icellold.gt.0) qr='Y'
+      ibity=2
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'PERIOD') then
+      read (qhulp,'(7x,i3)',end=46,err=46)iperiod
+      irecog=1
+      end if
+
+      if (qhulp(1:4).eq.'AXES') then
+      read (qhulp,'(7x,a3)',end=46,err=46)qbgfaxes
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'SGNAME') then
+      read (qhulp,'(7x,a3)',end=46,err=46)qbgfsgn
+      irecog=1
+      end if
+
+*     if (qhulp(1:5).eq.'CELLS') then
+*     read (qhulp,'(7x,*)',end=40,err=40)kx,ky,kz
+*     irecog=1
+*     end if
+
+      if (qhulp(1:6).eq.'HETATM') then
+      if (ibgfversion.lt.400) then
+      read (qhulp,
+     $'(7x,i5,1x,a5,1x,a3,1x,a1,1x,a5,3f10.5,1x,a5,i3,i2,1x,f8.5)'
+     $,end=40,err=40)
+     $ir,qlabel(na+1),qresi1(na+1),qresi2(na+1),qresi3(na+1),
+     $cglobal(na+1,1),cglobal(na+1,2),
+     $cglobal(na+1,3),qffty(na+1),ibgr1(na+1),ibgr2(na+1),
+     $chgglobal(na+1)
+      else
+      stop 'Unsupported Biograf-version'
+      end if
+      qlabhulp=qlabel(na+1)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:5)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:4)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:3)
+      if (qlabhulp(1:1).eq.'C ') qa(na+1)='C '
+      if (qlabhulp(1:2).eq.'Ca') qa(na+1)='Ca'
+      if (qlabhulp(1:2).eq.'Cl') qa(na+1)='Cl'
+      if (qlabhulp(1:2).eq.'Cu') qa(na+1)='Cu'
+      if (qlabhulp(1:2).eq.'Co') qa(na+1)='Co'
+      if (qlabhulp(1:1).eq.'H ') qa(na+1)='H '
+      if (qlabhulp(1:2).eq.'He') qa(na+1)='He'
+      if (qlabhulp(1:1).eq.'N ') qa(na+1)='N '
+      if (qlabhulp(1:2).eq.'Ni') qa(na+1)='Ni'
+      if (qlabhulp(1:1).eq.'O ') qa(na+1)='O '
+      if (qlabhulp(1:1).eq.'B ') qa(na+1)='B '
+      if (qlabhulp(1:1).eq.'F ') qa(na+1)='F '
+      if (qlabhulp(1:2).eq.'Fe') qa(na+1)='Fe'
+      if (qlabhulp(1:1).eq.'P ') qa(na+1)='P '
+      if (qlabhulp(1:1).eq.'S ') qa(na+1)='S '
+      if (qlabhulp(1:1).eq.'Y ') qa(na+1)='Y '
+      if (qlabhulp(1:2).eq.'Al ') qa(na+1)='Al'
+      if (qlabhulp(1:2).eq.'Au ') qa(na+1)='Au'
+      if (qlabhulp(1:2).eq.'Si') qa(na+1)='Si'
+      if (qlabhulp(1:2).eq.'Pt') qa(na+1)='Pt'
+      if (qlabhulp(1:2).eq.'Mo') qa(na+1)='Mo'
+      if (qlabhulp(1:2).eq.'Mg') qa(na+1)='Mg'
+      if (qlabhulp(1:2).eq.'Ar') qa(na+1)='Ar'
+      if (qlabhulp(1:2).eq.'Zr') qa(na+1)='Zr'
+      if (qlabhulp(1:2).eq.'Ti') qa(na+1)='Ti'
+      if (qlabhulp(1:2).eq.'Ru') qa(na+1)='Ru'
+      if (qlabhulp(1:2).eq.'Ba') qa(na+1)='Ba'
+      if (qlabhulp(1:2).eq.'Bi') qa(na+1)='Bi'
+      if (qlabhulp(1:2).eq.'Li') qa(na+1)='Li'
+      if (qlabhulp(1:2).eq.'V ') qa(na+1)='V '
+      if (qlabhulp(1:2).eq.'X ') qa(na+1)='X '
+      na=na+1
+      if (na.gt.nattot) then
+      write (*,*)'Number of atoms:read ',na
+      write (*,*)'Maximum number of atoms: ',nattot
+      stop 
+     $'Maximum number of atoms exceeded; increase nattot in cbka.blk'
+      end if
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'RUTYPE') then          !run-type identifiers
+      irecrun=0
+      read (qhulp,'(7x,a40)',end=46,err=46)qruid
+
+      if (qruid(1:10).eq.'NORMAL RUN') then
+      iruid=0
+      irecrun=1
+      end if
+
+      if (qruid(1:14).eq.'HIGH PRECISION') then
+      endpo=endpo/25 
+      nmmax=nmmax*5
+      qr='D'
+      iruid=1
+      irecrun=1
+      end if
+
+      if (qruid(1:13).eq.'LOW PRECISION') then
+      nmmax=nmmax/10
+      qr='H'
+      iruid=1
+      irecrun=1
+      end if
+
+      if (qruid(1:12).eq.'SINGLE POINT') then
+      iruid=1
+      nmmax=1
+      qr='1'
+      if (ibity.eq.2) qr='5'
+      irecrun=1
+      end if
+
+      if (qruid(1:11).eq.'NO CELL OPT') then
+      iruid=1
+      icell=0
+      if (ibity.eq.2) qr='Y'
+      irecrun=1
+      end if
+
+      if (qruid(1:8).eq.'CELL OPT') then
+      iruid=1
+      icell=1
+      iexco=0   !Override from VCHANGE
+      read (qruid,'(8x,i6)',end=46,err=46)ncellopt
+      if (ncellopt.eq.2) icell=2 !cell optimisation during energy minimisation 
+      if (ncellopt.eq.3) icelo2=4  !c/a optimisation
+      if (ncellopt.eq.4) icelo2=1  !only a optimisation
+      if (ncellopt.eq.5) icelo2=2  !only b optimisation
+      if (ncellopt.eq.6) icelo2=3  !only c optimisation
+      if (ncellopt.eq.7) then
+      icelo2=4  !c/a optimisation
+      icell=2 !cell optimisation during energy minimisation
+      end if
+      if (ibity.eq.2) qr='F'
+      irecrun=1
+      end if
+
+      if (qruid(1:6).eq.'MAXMOV') then
+      iruid=1
+      read (qruid,'(6x,i6)',end=46,err=46)nfc
+      irecrun=1
+      end if
+
+      if (qruid(1:4).eq.'REDO') then
+      iruid=1
+      read (qruid,'(4x,i6)',end=46,err=46)iredo
+      irecrun=1
+      end if
+
+      if (qruid(1:5).eq.'MAXIT') then
+      iruid=1
+      read (qruid,'(6x,i6)',end=46,err=46)nmmax
+      if (qruid(14:18).eq.'ENDPO') then
+      read (qruid,'(18x,f6.3)',end=46,err=46)endpo
+      end if
+      irecrun=1
+      end if
+      if (qruid(1:5).eq.'ENDPO') then
+      iruid=1
+      read (qruid,'(6x,f6.3)',end=46,err=46)endpo
+      irecrun=1
+      end if
+      
+      if (qruid(1:9).eq.'CHARGEMET') then
+      iruid=1
+      read (qruid,'(9x,i6)',end=46,err=46)ncha
+      irecrun=1
+      end if
+
+      if (irecrun.eq.0) then
+      write (*,*)'Warning: ignored RUTYPE identifier ',qruid(1:12)
+      end if
+
+      irecog=1
+      end if
+
+      if (qhulp(1:14).eq.'BOND RESTRAINT') then  
+      nrestra=nrestra+1
+      istart=15
+      call stranal(istart,iend,vout,iout,1)
+      irstra(nrestra,1)=iout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      irstra(nrestra,2)=iout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      rrstra(nrestra)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      vkrstr(nrestra)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      vkrst2(nrestra)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      rrcha(nrestra)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      itstart(nrestra)=iout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      itend(nrestra)=iout
+      istart=iend
+*     read (qhulp,'(15x,2i4,f8.4,f8.2,f8.5,f10.7)',end=46,err=46)
+*    $irstra(nrestra,1),irstra(nrestra,2),rrstra(nrestra),
+*    $vkrstr(nrestra),vkrst2(nrestra),rrcha(nrestra)
+      qr='R'
+      irecog=1
+      end if
+
+      if (qhulp(1:15).eq.'ANGLE RESTRAINT') then  
+      nrestrav=nrestrav+1
+      read (qhulp,'(16x,3i4,2f8.2,f8.4,f9.6)',end=46,err=46)
+     $irstrav(nrestrav,1),irstrav(nrestrav,2),irstrav(nrestrav,3),
+     $vrstra(nrestrav),vkrv(nrestrav),vkr2v(nrestrav),
+     $rvcha(nrestrav)
+      qr='V'
+      irecog=1
+      end if
+
+      if (qhulp(1:17).eq.'TORSION RESTRAINT') then  
+      nrestrat=nrestrat+1
+      read (qhulp,'(18x,4i4,2f8.2,f8.4,f9.6)',end=46,err=46)
+     $irstrat(nrestrat,1),irstrat(nrestrat,2),irstrat(nrestrat,3),
+     $irstrat(nrestrat,4),trstra(nrestrat),vkrt(nrestrat),
+     $vkr2t(nrestrat),rtcha(nrestrat)
+      qr='T'
+      irecog=1
+      end if
+
+      if (qhulp(1:16).eq.'MASCEN RESTRAINT') then  
+      nrestram=nrestram+1
+      istart=17
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      irstram(nrestram,1)=0
+      if (qstrana2.eq.'x') irstram(nrestram,1)=1 
+      if (qstrana2.eq.'y') irstram(nrestram,1)=2 
+      if (qstrana2.eq.'z') irstram(nrestram,1)=3 
+      if (qstrana2.eq.'p') irstram(nrestram,1)=4 !fixed center of mass
+      if (irstram(nrestram,1).eq.0) 
+     $stop 'Error in mass centre restraint'
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      irstram(nrestram,2)=iout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      irstram(nrestram,3)=iout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      rmstra1(nrestram)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      if (irstram(nrestram,1).le.3) irstram(nrestram,4)=iout
+      if (irstram(nrestram,1).eq.4) rmstra2(nrestram)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      if (irstram(nrestram,1).le.3) irstram(nrestram,5)=iout
+      if (irstram(nrestram,1).eq.4) rmstra3(nrestram)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      if (irstram(nrestram,1).le.3) rmstra2(nrestram)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      if (irstram(nrestram,1).le.3) rmstra3(nrestram)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      if (irstram(nrestram,1).le.3) rmcha(nrestram)=vout
+      irecog=1
+      end if
+
+      if (qhulp(1:9).eq.'MOLCHARGE') then
+      nmcharge=nmcharge+1
+      istart=10
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      iat1mc(nmcharge)=iout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      iat2mc(nmcharge)=iout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      vmcha(nmcharge)=vout
+      irecog=1
+      end if
+      
+      if (qhulp(1:8).eq.'FIXATOMS') then
+      istart=9
+      call stranal(istart,iend,vout,iout,1)
+      if1=iout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      if2=iout
+      do i12=if1,if2
+      imove(i12)=0
+      end do
+      irecog=1
+      end if
+
+      if (qhulp(1:11).eq.'UNIT ENERGY') then
+      eenconv=zero
+      read (qhulp,'(14x,a5)',end=46,err=46)quen
+      if (quen.eq.'eV') eenconv=23.0408
+      if (quen.eq.'EV') eenconv=23.0408
+      if (quen.eq.'ev') eenconv=23.0408
+      if (quen.eq.'h') eenconv=627.5
+      if (quen.eq.'H') eenconv=627.5
+      if (quen.eq.'kcal') eenconv=1.0
+      if (quen.eq.'kCal') eenconv=1.0
+      if (quen.eq.'KCAL') eenconv=1.0
+      if (eenconv.eq.zero) then 
+      write (*,*)quen,': unknown energy unit; assuming kcal/mol'
+      eenconv=1.0
+      end if
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'ENERGY') then
+      read (qhulp(7:80),*,end=46,err=46)enmol
+      ienread=1
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'GEOUPD') then
+      icgeopt(nprob)=0
+      icgeo=0
+      irecog=1
+      end if
+ 
+      if (qhulp(1:9).eq.'NO GEOUPD') then
+      icgeopt(nprob)=1
+      icgeo=1
+      irecog=1
+      end if
+
+      if (qhulp(1:9).eq.'FREQUENCY') then
+      ifreqset(nprob)=1
+      ifreq=1
+      irecog=1
+      end if
+
+*     if (qhulp(1:5).eq.'FORCE') then
+*     read (qhulp(6:80),*,end=46,err=46)formol
+*     ienread=1
+*     irecog=1
+*     end if
+
+      if (qhulp(1:6).eq.'FFIELD') goto 30 
+      if (qhulp(1:6).eq.'CONECT') goto 30
+      if (qhulp(1:5).eq.'ORDER') goto 30
+      if (qhulp(1:1).eq.'#') goto 30
+      if (qhulp(1:3).eq.'END') goto 45
+
+      if (irecog.eq.0) then
+      write (*,*)'Warning: ignored line starting with: ',qhulp(1:10)
+      end if
+ 
+      goto 30
+      
+   40 write (*,*)'Error on line ',iline+1,' of Biograf-input'
+      stop
+   45 read (3,*,err=46,end=46)
+   46 continue
+      if (ienread.eq.1) then 
+      if (eenconv.eq.zero) then
+      write (*,*)'No energy unit given; assuming kcal/mol' 
+      eenconv=1.0
+      end if
+      enmol=enmol*eenconv                !Convert energies to kcal/mol
+      end if
+      
+      namov=0                            !calculate number of moving atoms
+      do i1=1,na
+      if (imove(i1).eq.1) namov=namov+1
+      end do
+
+      if (imodfile.eq.1) close (3)
+      return
+  900 iendf=1
+      return
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readpdb (iendf)
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkqa.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+#include "cbksrtbon1.blk"
+      character*200 qhulp
+********************************************************************** 
+*                                                                    *
+*     Read in .pdb-geometry                                          *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readpdb'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      iendf=1
+      qmol='pdb_in'
+    5 read (3,'(a200)',end=10,err=900) qhulp
+      qstrana1(1:200)=qhulp
+      istart=1
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+
+      if (qstrana2(1:6).eq.'HEADER') then
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      qmol=qstrana2(1:20)
+      end if
+
+      if (qstrana2(1:6).eq.'HETATM'.or.qstrana2(1:4).eq.'ATOM') then
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      qa(na+1)=qstrana2(1:2)
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      c(na+1,1)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      c(na+1,2)=vout
+      call stranal(istart,iend,vout,iout,1)
+      istart=iend
+      c(na+1,3)=vout
+      na=na+1
+      end if
+
+      if (qstrana2(1:3).eq.'END'.or.qstrana2(2:4).eq.'END') then
+      iendf=0
+      goto 10
+      end if
+
+      goto 5
+   10 continue
+      return
+  900 write (*,*)'Error reading in .pdb-format'
+      stop 'Error reading in .pdb-format'
+      end 
+************************************************************************
+************************************************************************
+
+      subroutine readtreg
+
+************************************************************************
+#include "cbka.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "small.blk"
+      dimension isumattreg(mtreg)
+      character*200 qrom
+********************************************************************** 
+*                                                                    *
+*     Read in temperature regime                                     *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readtreg'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      ntrc=0
+      open (19,file='tregime.in',status='old',err=60)
+   10 read (19,'(a200)',end=50,err=900)qrom
+      qstrana1(1:200)=qrom
+      if (qrom(1:1).eq.'#') goto 10
+      istart=1
+      ntrc=ntrc+1
+      if (ntrc.gt.mtreg) then
+      write (*,*)'Too many temperature regimes in tregime.in;',
+     $' inrease mtreg in cbka.blk'
+      stop 'Too many temperature regimes in tregime.in'
+      end if
+      call stranal(istart,iend,vout,iout,1)
+      nittc(ntrc)=iout
+      istart=iend
+
+      if (ntrc.gt.1) then
+      if (nittc(ntrc).lt.nittc(ntrc-1)) then
+      ntrc=ntrc-1
+      write (*,*)'Warning: wrong order or empty line in tregime.in'
+      write (*,*)'Ignored lines below iteration:',nittc(ntrc)
+      goto 50
+      end if
+      end if
+
+      call stranal(istart,iend,vout,iout,1)
+      nntreg(ntrc)=iout
+      if (nntreg(ntrc).gt.mtzone) then
+      write (*,*)'Too many temperature zones in tregime.in;',
+     $' inrease mtzone in cbka.blk'
+      stop 'Too many temperature zones in tregime.in'
+      end if
+      istart=iend
+      isumattreg(ntrc)=0
+      do i1=1,nntreg(ntrc)
+      call stranal(istart,iend,vout,iout,1)
+      ia1treg(ntrc,i1)=iout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      ia2treg(ntrc,i1)=iout
+      istart=iend
+      isumattreg(ntrc)=isumattreg(ntrc)+1+ia2treg(ntrc,i1)-
+     $ia1treg(ntrc,i1)
+      call stranal(istart,iend,vout,iout,1)
+      tsettreg(ntrc,i1)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      tdamptreg(ntrc,i1)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      dttreg(ntrc,i1)=vout
+      istart=iend
+      end do
+      goto 10
+   50 continue
+      close (19)
+   60 continue
+**********************************************************************
+*                                                                    *
+*     Check consistency temperature programs in tregime.in           *
+*                                                                    *
+**********************************************************************
+      if (ntrc.gt.0) then
+      do i1=1,ntrc
+      if (isumattreg(i1).ne.na) then
+      write (*,*)'Inconsistency in temperature regime nr.',i1
+      write (*,*)'Number of atoms defined in tregime.in:',
+     $isumattreg(i1)
+      write (*,*)'Number of atoms in system:',na
+      stop 'Inconsistency in tregime.in'
+      end if
+      end do
+      end if
+
+      return
+  900 stop 'Error reading tregime.in'
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readvreg
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkvregime.blk"
+#include "control.blk"
+      character*200 qrom
+********************************************************************** 
+*                                                                    *
+*     Read in volume regime                                          *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readvreg'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      nvrc=0
+      open (19,file='vregime.in',status='old',err=60)
+   10 read (19,'(a200)',end=50,err=900)qrom
+      qstrana1(1:200)=qrom
+      if (qrom(1:1).eq.'#') goto 10
+      istart=1
+      nvrc=nvrc+1
+      if (nvrc.gt.mvreg) then
+      write (*,*)'Too many volume regimes in vregime.in;',
+     $' inrease mvreg in cbka.blk'
+      stop 'Too many volume regimes in vregime.in'
+      end if
+
+      call stranal(istart,iend,vout,iout,1)
+      nitvc(nvrc)=iout
+      istart=iend
+
+      if (nvrc.gt.1) then
+      if (nitvc(nvrc).lt.nitvc(nvrc-1)) then
+      nvrc=nvrc-1
+      write (*,*)'Warning: wrong order or empty line in vregime.in'
+      write (*,*)'Ignored lines below iteration:',nitvc(nvrc)
+      goto 50
+      end if
+      end if
+
+      call stranal(istart,iend,vout,iout,1)
+      nnvreg(nvrc)=iout
+      if (nnvreg(nvrc).gt.mvzone) then
+      write (*,*)'Too many volume regimes in vregime.in;',
+     $' inrease mvzone in cbka.blk'
+      stop 'Too many volume zones in vregime.in'
+      end if
+      istart=iend
+      do i1=1,nnvreg(nvrc)
+      call stranal(istart,iend,vout,iout,1)
+      if (qstrana2(1:1).ne.'a'.and.qstrana2(1:1).ne.'b'.and.
+     $qstrana2(1:1).ne.'c'.and.qstrana2(1:4).ne.'alfa'.and.
+     $qstrana2(1:4).ne.'beta'.and.qstrana2(1:5).ne.'gamma') then
+      write (*,*)qstrana2
+      write (*,*)'Invalid cell parameter type in vregime.in ;',
+     $' use a,b,c,alfa,beta or gamma'
+      stop 'Invalid cell parameter type in vregime.in'
+      end if
+      qvtype(nvrc,i1)=qstrana2
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      dvvreg(nvrc,i1)=vout
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      ivsca(nvrc,i1)=1
+      if (qstrana2(1:1).eq.'n') ivsca(nvrc,i1)=0
+      istart=iend
+      end do
+      goto 10
+   50 continue
+      close (19)
+   60 continue
+      return
+  900 stop 'Error reading vregime.in'
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readereg
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkeregime.blk"
+#include "control.blk"
+      character*200 qrom
+********************************************************************** 
+*                                                                    *
+*     Read in electric field regime                                  *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readereg'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      nerc=0
+      open (19,file='eregime.in',status='old',err=60)
+   10 read (19,'(a200)',end=50,err=900)qrom
+      qstrana1(1:200)=qrom
+      if (qrom(1:1).eq.'#') goto 10
+      istart=1
+      nerc=nerc+1
+      if (nerc.gt.mereg) then
+      write (*,*)'Too many electric field regimes in eregime.in;',
+     $' inrease mereg in cbka.blk'
+      stop 'Too many electric field regimes in eregime.in'
+      end if
+      call stranal(istart,iend,vout,iout,1)
+      nitec(nerc)=iout
+
+      if (nerc.gt.1) then
+      if (nitec(nerc).lt.nitec(nerc-1)) then
+      nerc=nerc-1
+      write (*,*)'Warning: wrong order or empty line in eregime.in'
+      write (*,*)'Ignored lines below iteration:',nitec(nerc)
+      goto 50
+      end if
+      end if
+      
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      nnereg(nerc)=iout
+      if (nnereg(nerc).gt.mezone) then
+      write (*,*)'Too many electric field zones in eregime.in;',
+     $' inrease mezone in cbka.blk'
+      stop 'Too many electric field zones in vregime.in'
+      end if
+      istart=iend
+      do i1=1,nnereg(nerc)
+      call stranal(istart,iend,vout,iout,1)
+      if (qstrana2(1:1).ne.'x'.and.qstrana2(1:1).ne.'y'.and.
+     $qstrana2(1:1).ne.'z') then
+      write (*,*)qstrana2
+      write (*,*)'Invalid field direction in eregime.in ;',
+     $' use x,y or z'
+      stop 'Invalid field direction in eregime.in'
+      end if
+      qetype(nerc,i1)=qstrana2
+      istart=iend
+      call stranal(istart,iend,vout,iout,1)
+      ereg(nerc,i1)=vout
+      istart=iend
+      end do
+      goto 10
+   50 continue
+      close (19)
+   60 continue
+      return
+  900 stop 'Error reading vregime.in'
+      end
+************************************************************************
+************************************************************************
+
+      subroutine readaddmol
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkatomcoord.blk"
+#include "cbkc.blk"
+#include "cbkff.blk"
+#include "cbkh.blk"
+#include "control.blk"
+      character*80 qromb
+      character*200 qhulp
+      character*5 qlabhulp
+********************************************************************** 
+*                                                                    *
+*     Read in molecule coordinates. This molecule will be added to   *
+*     the system at regular intervals                                *
+*     Accepts only .bgf-format                                       *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readaddmol'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+********************************************************************** 
+*                                                                    *
+*     Set default values                                             *
+*                                                                    *
+********************************************************************** 
+      iaddfreq=-1   !frequency of molecule addition; <0: no addition
+      xadd=-9000.0  !x-coordinate for added molecule; <-5000.0: random
+      yadd=-9000.0  !y-coordinate for added molecule; <-5000.0: random
+      zadd=-9000.0  !z-coordinate for added molecule; <-5000.0: random
+      iveladd=1     !1: random initial velocities; 2: read in velocities
+                    !from addmol.vel
+      addist=-1.00  !Minimum distance between added molecule and rest
+                    !of system. < 0.0: do not check
+      nadattempt=10  !Number of attempts at adding the molecule
+      taddmol=-1.0  !Temperature added molecule. <0.0: system temperature
+      open (19,file='addmol.bgf',status='old',err=60)
+      read (19,'(a40)',end=900,err=900)qromb
+      if (qromb(1:6).ne.'BIOGRF') then
+      write (*,*)'addmol.bgf should start with BIOGRF'
+      stop 'addmol.bgf should start with BIOGRF'
+      end if
+      naa=0
+      iline=0
+   30 read (19,'(a200)',end=900,err=900)qhulp
+      irecog=0
+      iline=iline+1
+
+      if (qhulp(1:6).eq.'DESCRP') then
+      irecog=1
+      end if
+ 
+      if (qhulp(1:6).eq.'FORMAT') then
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'REMARK') then
+      irecog=1
+      end if
+
+      if (qhulp(1:6).eq.'HETATM') then
+      irecog=1
+      read (qhulp,'(7x,i5,1x,a5,1x,3x,1x,1x,1x,5x,3f10.5)'
+     $,end=900,err=900)
+     $ir,qlabhulp,cadd(naa+1,1),cadd(naa+1,2),cadd(naa+1,3)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:5)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:4)
+      if (qlabhulp(1:1).eq.' ') qlabhulp=qlabhulp(2:3)
+      if (qlabhulp(1:1).eq.'C ') qadd(naa+1)='C '
+      if (qlabhulp(1:2).eq.'Ca') qadd(naa+1)='Ca'
+      if (qlabhulp(1:2).eq.'Cl') qadd(naa+1)='Cl'
+      if (qlabhulp(1:2).eq.'Cu') qadd(naa+1)='Cu'
+      if (qlabhulp(1:2).eq.'Co') qadd(naa+1)='Co'
+      if (qlabhulp(1:1).eq.'H ') qadd(naa+1)='H '
+      if (qlabhulp(1:2).eq.'He') qadd(naa+1)='He'
+      if (qlabhulp(1:1).eq.'N ') qadd(naa+1)='N '
+      if (qlabhulp(1:2).eq.'Ni') qadd(naa+1)='Ni'
+      if (qlabhulp(1:1).eq.'O ') qadd(naa+1)='O '
+      if (qlabhulp(1:1).eq.'B ') qadd(naa+1)='B '
+      if (qlabhulp(1:1).eq.'F ') qadd(naa+1)='F '
+      if (qlabhulp(1:2).eq.'Fe') qadd(naa+1)='Fe'
+      if (qlabhulp(1:1).eq.'P ') qadd(naa+1)='P '
+      if (qlabhulp(1:1).eq.'S ') qadd(naa+1)='S '
+      if (qlabhulp(1:1).eq.'Y ') qadd(naa+1)='Y '
+      if (qlabhulp(1:2).eq.'Al') qadd(naa+1)='Al'
+      if (qlabhulp(1:2).eq.'Au') qadd(naa+1)='Au'
+      if (qlabhulp(1:2).eq.'Si') qadd(naa+1)='Si'
+      if (qlabhulp(1:2).eq.'Pt') qadd(naa+1)='Pt'
+      if (qlabhulp(1:2).eq.'Mo') qadd(naa+1)='Mo'
+      if (qlabhulp(1:2).eq.'Mg') qadd(naa+1)='Mg'
+      if (qlabhulp(1:2).eq.'Ar') qadd(naa+1)='Ar'
+      if (qlabhulp(1:2).eq.'Zr') qadd(naa+1)='Zr'
+      if (qlabhulp(1:2).eq.'Ba') qadd(naa+1)='Ba'
+      if (qlabhulp(1:2).eq.'X ') qadd(naa+1)='X '
+      ityadd(naa+1)=0
+      do i1=1,nso  !Find force field type
+      if (qadd(naa+1).eq.qas(i1)) ityadd(naa+1)=i1 
+      end do
+      if (ityadd(naa+1).eq.0) then
+      write (*,*) 'Unknown atom type:',qadd(naa+1)
+      stop 'Unknown atom type'
+      end if
+      naa=naa+1
+      end if
+
+      if (qhulp(1:7).eq.'FREQADD') then
+      irecog=1
+      read (qhulp,'(8x,i6)',end=900,err=900) iaddfreq
+      end if
+
+      if (qhulp(1:6).eq.'VELADD') then
+      irecog=1
+      read (qhulp,'(8x,i6)',end=900,err=900) iveladd
+      end if
+
+      if (qhulp(1:6).eq.'STARTX') then
+      irecog=1
+      read (qhulp,'(7x,f8.2)',end=900,err=900) xadd
+      end if
+
+      if (qhulp(1:6).eq.'STARTY') then
+      irecog=1
+      read (qhulp,'(7x,f8.2)',end=900,err=900) yadd
+      end if
+
+      if (qhulp(1:6).eq.'STARTZ') then
+      irecog=1
+      read (qhulp,'(7x,f8.2)',end=900,err=900) zadd
+      end if
+
+      if (qhulp(1:6).eq.'ADDIST') then
+      irecog=1
+      read (qhulp,'(7x,f8.2)',end=900,err=900) addist
+      end if
+
+      if (qhulp(1:8).eq.'NATTEMPT') then
+      irecog=1
+      read (qhulp,'(9x,i6)',end=900,err=900) nadattempt
+      end if
+
+      if (qhulp(1:7).eq.'TADDMOL') then
+      irecog=1
+      read (qhulp,'(8x,f8.2)',end=900,err=900) taddmol
+      end if
+
+      if (qhulp(1:6).eq.'FFIELD') goto 30
+      if (qhulp(1:6).eq.'CONECT') goto 30
+      if (qhulp(1:5).eq.'ORDER') goto 30
+      if (qhulp(1:1).eq.'#') goto 30
+      if (qhulp(1:3).eq.'END') goto 45
+
+      if (irecog.eq.0) then
+      write (*,*)'Warning: ignored line starting with: ',qhulp(1:10)
+      end if
+
+      goto 30
+
+   45 continue
+      close (19)
+      if (iveladd.eq.2) then
+      open (19,file='addmol.vel',status='old',err=800)
+      read (19,*)
+      read (19,'(3d24.15)',err=850,end=850)
+     $((veladd(j,i),j=1,3),i=1,naa)       
+      close (19)
+      end if
+************************************************************************
+*                                                                      *
+*     Place molecule at origin                                         *
+*                                                                      *
+************************************************************************
+      ccx=0.0
+      ccy=0.0
+      ccz=0.0
+      do i1=1,naa
+      ccx=ccx+cadd(i1,1)/float(naa)
+      ccy=ccy+cadd(i1,2)/float(naa)
+      ccz=ccz+cadd(i1,3)/float(naa)
+      end do
+      do i1=1,naa
+      cadd(i1,1)=cadd(i1,1)-ccx
+      cadd(i1,2)=cadd(i1,2)-ccy
+      cadd(i1,3)=cadd(i1,3)-ccz
+      end do
+
+   60 continue
+      return
+  800 stop 'Error opening addmol.vel'
+  850 stop 'Error or end of file reading addmol.vel'
+  900 write (*,*)'Error or end-of-file reading addmol.bgf on line:',
+     $iline
+      return
+      end
+************************************************************************
+**********************************************************************
+
+      subroutine writegeo(nunit1)
+
+**********************************************************************   
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkqa.blk"
+#include "cbkrestr.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+#include "cbksrtbon1.blk"
+#include "cbkinit.blk"
+**********************************************************************   
+*                                                                    *
+*     Copy new geometries to unit nunit1                             *
+*                                                                    *
+**********************************************************************   
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In writegeo'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      if (axiss(1).lt.zero) then
+      if (nrestra.eq.0.and.nrestrat.eq.0.and.
+     $nrestrav.eq.0) 
+     $write (nunit1,300)qr,qmol
+      if (nrestra.gt.0) write (nunit1,301)qr,
+     $rrstra(1),qmol
+      if (nrestrav.gt.0) write (nunit1,301)qr,
+     $vrstra(1),qmol
+      if (nrestrat.gt.0) write (nunit1,301)qr,
+     $trstra(1),qmol
+      else
+      write (nunit1,310)qr,qmol
+      write (nunit1,320)axiss(1),axiss(2),axiss(3)
+      write (nunit1,320)angles(1),angles(2),angles(3)
+      end if
+      do i1=1,na
+      if (nbiolab.ne.1) write (nunit1,400)i1,qa(i1),(c(i1,i2),i2=1,3)
+      if (nbiolab.eq.1) write (nunit1,401)i1,qa(i1),(c(i1,i2),i2=1,3) !Delphi-format
+      end do
+      if (nbiolab.ne.1) write (nunit1,*)
+     
+      return
+
+  300 format (2x,a1,1x,a60)
+  301 format (2x,a1,1x,f6.2,a60)
+  310 format (2x,a1,1x,a60)
+  320 format (3f10.4)
+  400 format (i4,1x,a2,3x,3(d21.14,1x),1x,a5,1x,i5)
+  401 format (i3,2x,a2,3x,3(d21.14,1x),1x,a5,1x,i5)
+      end
+**********************************************************************
+**********************************************************************
+
+      subroutine writebgf(nunit1)
+
+**********************************************************************   
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkcha.blk"
+#include "cbkcharmol.blk"
+#include "cbkconst.blk"
+#include "cbkenergies.blk"
+#include "cbkia.blk"
+#include "cbkimove.blk"
+#include "cbkinit.blk"
+#include "cbkqa.blk"
+#include "cbkrestr.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "cbksrtbon1.blk"
+#include "small.blk"
+
+      dimension qdir(3) 
+      character*2 qt
+      character*1 qdir
+**********************************************************************   
+*                                                                    *
+*     Copy new Biograf-geometries to unit nunit1                     *
+*                                                                    *
+**********************************************************************   
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In newbgf'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      irom=1
+      qdir(1)='x'
+      qdir(2)='y'
+      qdir(3)='z'
+      ibgfversion=200
+      if (ibity.eq.1) write (nunit1,1500)ibgfversion
+      if (ibity.eq.2) write (nunit1,1600)ibgfversion
+*     if (qr.ne.'F'.and.qr.ne.'5'.and.qr.ne.'Y') 
+*    $write (nunit1,1500)ibgfversion
+*     if (qr.eq.'F'.or.qr.eq.'5'.or.qr.eq.'Y') 
+*    $write (nunit1,1600)ibgfversion
+      write (nunit1,1700)qmol
+*     write (nunit1,1700)qkeyw(nprob)
+      do i1=1,iremark
+      write (nunit1,1800)qremark(i1)
+      end do
+      qruid='NORMAL RUN'
+      if (iruid.eq.0) then
+      write (nunit1,2000)
+      else
+      if (abs(endpo-endpoold).gt.1e-5) write (nunit1,2010)endpo
+      if (nmmax.ne.nmmaxold) write (nunit1,2020)nmmax
+      if (nfc.ne.nfcold) write (nunit1,2030)nfc
+      if (ncha.ne.nchaold) write (nunit1,2036)ncha
+      if (iredo.gt.1) write (nunit1,2035)iredo
+      if (icell.ne.icellold) then
+      if (icell.eq.0) write (nunit1,2033)
+      if (icell.gt.0) write (nunit1,2034)ncellopt
+      end if
+      end if
+      if (iexco.ne.0.and.nsurp.gt.0) then
+      write (nunit1,2040)vvol
+      write (nunit1,3500)
+      write (nunit1,*)
+      return
+      end if
+      if (nmcharge.gt.0) then
+      do i3=1,nmcharge
+      write (nunit1,2050)iat1mc(i3),iat2mc(i3),vmcha(i3)
+      end do
+      end if
+
+      ims=0
+      do i1=1,na
+      if (ims.eq.0.and.imove(i1).eq.0) then
+      if1=i1
+      ims=1
+      end if
+      if (ims.eq.1.and.imove(i1).eq.1) then
+      write (nunit1,2060)if1,i1-1
+      ims=0
+      end if
+      end do
+      if (ims.eq.1) then
+      write (nunit1,2060)if1,na
+      end if
+
+*     if (qr.eq.'F'.or.qr.eq.'5'.or.qr.eq.'Y') 
+      if (ibity.eq.2)
+     $write (nunit1,2100)axiss(1),axiss(2),axiss(3),angles(1),
+     $angles(2),angles(3)
+
+      if (nrestra.gt.0) write (nunit1,2300)
+      do i2=1,nrestra
+      write (nunit1,2400)
+     $irstra(i2,1),irstra(i2,2),rrstra(i2),
+     $vkrstr(i2),vkrst2(i2),rrcha(i2),itstart(i2),itend(i2)
+      end do
+
+      if (nrestrav.gt.0) write (nunit1,2500)
+      do i2=1,nrestrav
+      write (nunit1,2600)
+     $irstrav(i2,1),irstrav(i2,2),irstrav(i2,3),
+     $vrstra(i2),vkrv(i2),vkr2v(i2),zero
+      end do
+
+      if (nrestrat.gt.0) write (nunit1,2700)
+      do i2=1,nrestrat
+      write (nunit1,2800)
+     $irstrat(i2,1),irstrat(i2,2),irstrat(i2,3),
+     $irstrat(i2,4),trstra(i2),vkrt(i2),
+     $vkr2t(i2),zero
+      end do
+
+      if (nrestram.gt.0) write (nunit1,2810)
+      do i2=1,nrestram
+      write (nunit1,2820)
+     $qdir(irstram(i2,1)),irstram(i2,2),irstram(i2,3),
+     $rmstra1(i2),irstram(i2,4),irstram(i2,5),rmstra2(i2),
+     $rmstra3(i2),rmcha(i2)
+      end do
+
+      if (icgeo.eq.0.and.ingeo.eq.0) write (nunit1,2830)
+      if (icgeo.eq.1.and.ingeo.eq.1) write (nunit1,2840)
+      if (ifreq.eq.1) write (nunit1,2850)
+      write (nunit1,2900)
+      do i2=1,na
+      write (nunit1,3000)i2,qa(i2),c(i2,1),c(i2,2),c(i2,3),
+     $qa(i2),irom,irom,chgbgf(i2)
+      end do
+      write (nunit1,3100)
+      if (nsurp.lt.2) then
+      do i1=1,na
+      write (nunit1,3200)i1,(iag(i1,2+i2),i2=1,iag(i1,2))
+      end do
+      write (nunit1,3300)
+      write (nunit1,3400)estrc
+      end if
+
+      write (nunit1,3500)
+      write (nunit1,*)
+     
+      return
+ 1500 format ('BIOGRF',i4)
+ 1600 format ('XTLGRF',i4)
+ 1700 format ('DESCRP ',a60)
+ 1800 format ('REMARK ',a60)
+ 1900 format ('FFIELD ',a40)
+ 2000 format ('RUTYPE NORMAL RUN')
+ 2010 format ('RUTYPE ENDPO',f6.3)
+ 2020 format ('RUTYPE MAXIT',i6)
+ 2030 format ('RUTYPE MAXMOV',i6)
+ 2033 format ('RUTYPE NO CELL OPT')
+ 2034 format ('RUTYPE CELL OPT',i6)
+ 2035 format ('RUTYPE REDO',i6)
+ 2036 format ('RUTYPE CHARGEMET',i6)
+ 2040 format ('VCHANGE',f8.4)
+ 2050 format ('MOLCHARGE',2i4,f6.2)
+ 2060 format ('FIXATOMS',2i6)    
+ 2100 format ('CRYSTX ',6f11.5)
+ 2200 format ('CELLS ',6i5)
+ 2300 format ('#              At1 At2   R12    Force1  Force2  ',
+     $'dR12/dIter(MD) Start (MD) End (MD)')
+ 2400 format ('BOND RESTRAINT ',2i4,f8.4,f8.2,f8.4,1x,f10.7,2i8)
+ 2500 format ('#               At1 At2 At3 Angle   Force1  Force2',
+     $'  dAngle/dIteration (MD only)')
+ 2600 format ('ANGLE RESTRAINT ',3i4,2f8.2,f8.4,f9.6)
+ 2700 format ('#                 At1 At2 At3 At3 Angle   Force1  ',
+     $'Force2  dAngle/dIteration (MD only)')
+ 2800 format ('TORSION RESTRAINT ',4i4,2f8.2,f8.4,f9.6)
+ 2810 format ('#              x/y/z At1 At2    R   At3 At4 Force1',
+     $'  Force2  dR/dIteration (MD only)')
+ 2820 format ('MASCEN RESTRAINT ',a1,1x,2i4,f8.2,2i4,2f8.2,f9.6)
+ 2830 format ('GEOUPD')
+ 2840 format ('NO GEOUPD')
+ 2850 format ('FREQUENCY')
+ 2900 format ('FORMAT ATOM   (a6,1x,i5,1x,a5,1x,a3,1x,a1,1x,a5,',
+     $'3f10.5,1x,a5,i3,i2,1x,f8.5)')
+ 3000 format ('HETATM',1x,i5,1x,a2,3x,1x,3x,1x,1x,1x,5x,3f10.5,1x,
+     $a5,i3,i2,1x,f8.5)
+ 3100 format ('FORMAT CONECT (a6,12i6)')
+ 3200 format ('CONECT',12i6)
+ 3300 format ('UNIT ENERGY   kcal')
+ 3400 format ('ENERGY',5x,f14.6)
+ 3500 format ('END')
+
+      end
+**********************************************************************
+**********************************************************************
+
+      subroutine writeen(tottime,sum1,sdev,sdeva,sum12,sumt,sump,
+     $sumtt,tmax,eaver,eav2,eav3,etot2,ediff)
+**********************************************************************   
+#include "cbka.blk"
+#include "cbkcha.blk"
+#include "cbkenergies.blk"
+#include "cbkrestr.blk"
+#include "cbktorang.blk"
+#include "cbktorsion.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "small.blk"
+
+      dimension disres(mrestra)
+**********************************************************************
+*                                                                    *
+*     Write out MD statistics to units 71,73 and 76                  *
+*                                                                    *
+**********************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In writeen'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      if (nrep1.gt.1)
+     $sdev=sqrt((sum12-sum1*sum1/float(nrep1))/float(nrep1-1))
+      eavn=eaver/float(mdstep)
+      if (mdstep.gt.1)
+     $sdeva=sqrt((eav3-eav2*eav2/float(mdstep))/float(mdstep-1))
+C      open (71,file='fort.71',status='unknown',access='append')
+C      open (73,file='fort.73',status='unknown',access='append')
+      write (71,'(i8,2i4,1x,19(f10.2,1x))')mdstep+nprevrun,nmolo,
+     $nmolo5,estrc,ekin,estrc+ekin,tempmd,sum1/float(nrep1),eavn,
+     $sumt/float(nrep1),tmax,sump/float(nrep1),sdev,sdeva,tset,
+     $tstep*1d+15,rmsg,tottime
+      write (73,'(i8,1x,14(f10.2,1x))')mdstep+nprevrun,eb,ea,elp,
+     $emol,ev,ecoa,ehb,et,eco,ew,ep,ech,efi
+      close (71)
+      close (73)
+ 
+      if ((sumt/float(nrep1)).gt.tset) then
+      if (invt.eq.0) write (*,*)'Switched to NVT in iteration',mdstep
+      invt=1
+      end if
+ 
+C      if (nrestra.gt.0.or.nrestrat.gt.0)
+C     $open (76,file='fort.76',status='unknown',access='append')
+ 
+      if (nrestra.gt.0) then
+      do i2=1,nrestra
+      call dista2(irstra(i2,1),irstra(i2,2),disres(i2),dx,dy,dz)
+      end do
+C      open (76,file='fort.76',status='unknown',access='append')
+      write (76,'(i8,1x,40f12.4)')mdstep,eres,estrc,
+     $(rrstra(i2),disres(i2),i2=1,nrestra)
+      end if
+ 
+      if (nrestrat.gt.0) then
+C      open (76,file='fort.76',status='unknown',access='append')
+      do i2=1,nrestrat
+      do i3=1,ntor
+      ih1=irstrat(i2,1)
+      ih2=irstrat(i2,2)
+      ih3=irstrat(i2,3)
+      ih4=irstrat(i2,4)
+      if (ih1.eq.it(i3,2).and.ih2.eq.it(i3,3).and.ih3.eq.it(i3,4)
+     $.and.ih4.eq.it(i3,5)) ittr=i3
+      end do
+      write (76,'(i8,1x,40f12.4)')mdstep,eres,
+     $trstra(i2),thg(ittr)
+      end do
+      end if
+ 
+      if (nrestra.gt.0.or.nrestrat.gt.0) close(76)
+ 
+      if (nrestram.gt.0) then
+C      open (76,file='fort.76',status='unknown',access='append')
+      do i2=1,nrestram
+      write (76,'(2i8,1x,20f12.4)')mdstep,i2,eres,rmstra1(i2),
+     $dismacen(i2)
+      end do
+      close (76)
+      end if
+
+      return
+      end
+**********************************************************************
+************************************************************************
+
+      subroutine molanal
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbkconst.blk"
+#include "cbkdcell.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkrbo.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+#include "cbksrtbon1.blk"
+      dimension iam(nat,mbond+3),nmolata(nmolmax,nat)
+      dimension molfra(nmolmax,nsort),ndup(nmolmax)
+      character*40 qmolan1
+      character*100 qmolan
+      logical found
+************************************************************************
+*                                                                      *
+*     Analyse and output molecular fragments                           *
+*                                                                      *
+************************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In molanal'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      do i1=1,nmolmax
+      do i2=1,nsort
+      molfra(i1,i2)=0
+      end do
+      ndup(i1)=1
+      end do
+
+      do i1=1,na
+      do i2=1,mbond+3
+      iam(i1,i2)=0
+      end do
+      end do
+************************************************************************
+*                                                                      *
+*     Create connection table based on corrected bond orders           *
+*                                                                      *
+************************************************************************
+      do i1=1,nbon
+      if (bo(i1).gt.cutof3) then
+      j1=ib(i1,2)
+      j2=ib(i1,3)
+      iam(j1,2)=iam(j1,2)+1
+      iam(j1,2+iam(j1,2))=j2
+      iam(j2,2)=iam(j2,2)+1
+      iam(j2,2+iam(j2,2))=j1
+      end if
+      end do
+**********************************************************************
+*                                                                    *
+*     Find molecules                                                 *
+*                                                                    *
+**********************************************************************
+      nmolo6=0
+      found=.FALSE.
+      DO 61 k1=1,na
+      IF (iam(K1,3+mbond).EQ.0) found=.TRUE.
+   61 IF (iam(K1,3+mbond).GT.nmolo6) nmolo6=iam(K1,3+mbond)
+      IF (.NOT.FOUND) GOTO 62
+************************************************************************
+*                                                                      *
+*     Molecule numbers are assigned. No restrictions are made for the  *
+*     sequence of the numbers in the connection table.                 *
+*                                                                      *
+************************************************************************
+      N3=1
+   64 N2=N3
+      nmolo6=nmolo6+1
+      if (nmolo6.gt.nmolmax) stop 'Too many molecules in system'
+      iam(N2,3+mbond)=nmolo6
+   67 FOUND=.FALSE.
+      DO 66 N1=N2+1,na
+      IF (iam(N1,3+mbond).NE.0) GOTO 66
+      DO 65 L=1,mbond
+      IF (iam(N1,l+2).EQ.0) GOTO 66
+      IF (iam(iam(N1,l+2),3+mbond).EQ.nmolo6) THEN
+      FOUND=.TRUE.
+      iam(N1,3+mbond)=nmolo6
+      GOTO 66
+      ENDIF
+   65 CONTINUE
+   66 CONTINUE
+      IF (FOUND) GOTO 67
+      DO 63 N3=N2+1,NA
+   63 if (iam(N3,3+mbond).eq.0) goto 64
+************************************************************************
+*                                                                      *
+*     The assigned or input molecule numbers are checked for their     *
+*     consistency.                                                     *
+*                                                                      *
+************************************************************************
+   62 FOUND=.FALSE.
+      DO 72 N1=1,NA
+      DO 71 L=1,mbond
+      IF (iam(N1,L+2).EQ.0) GOTO 72
+      IF (iam(iam(N1,L+2),3+mbond).NE.iam(N1,3+mbond)) THEN
+      FOUND=.TRUE.
+      ENDIF
+   71 CONTINUE
+   72 CONTINUE
+      IF (FOUND) THEN
+      write (7,'(i4,a40)')na,qmol
+      do i1=1,na
+      write (7,'(40i4)')i1,iam(i1,1),(iam(i1,2+i2),i2=1,nsbmax),
+     $iam(i1,3+mbond)
+      end do
+      STOP' Mol.nrs. not consistent; maybe wrong cell parameters'
+      ENDIF
+
+      do i1=1,nmolo6
+      natmol=0
+      do i2=1,na
+      if (iam(i2,3+mbond).eq.i1) then
+      natmol=natmol+1
+      nmolata(i1,natmol+1)=i2
+      end if
+      end do
+      nmolata(i1,1)=natmol
+      end do
+************************************************************************
+*                                                                      *
+*     Analyze molecules                                                *
+*                                                                      *
+************************************************************************
+      do i1=1,nmolo6
+      do i2=1,nmolata(i1,1)
+      i3=nmolata(i1,1+i2)
+      ityp=ia(i3,1)
+      molfra(i1,ityp)=molfra(i1,ityp)+1
+      end do
+      end do
+
+      do i1=1,nmolo6
+      isee=0
+      do i2=1,nmolo6
+      isee2=1
+      do i3=1,nso
+      if (molfra(i1,i3).ne.molfra(i2,i3)) isee2=0
+      end do
+      if (isee2.eq.1.and.i1.gt.i2.and.isee.eq.0) then  !molecule type already exists
+      ndup(i2)=ndup(i2)+1
+      ndup(i1)=0
+      isee=1
+      end if
+
+      end do
+      end do
+
+C      open (45,file='molfra.out',status='unknown',access='append')
+      if (mdstep.eq.0) write (45,100)cutof3
+      write (45,110)
+      ntotmol=0
+      ntotat=0
+      vtotmass=zero
+      do i1=1,nmolo6
+      if (ndup(i1).gt.0) then
+*     write (45,110)i1,(molfra(i1,i2),i2=1,nso),ndup(i1)
+      ntotmol=ntotmol+ndup(i1)
+      qmolan=' '
+      qmolan1=' '
+      istart=-4
+      ihulp=0
+      vmass=zero
+      do i2=1,nso
+      vmass=vmass+molfra(i1,i2)*amas(i2)
+      ntotat=ntotat+molfra(i1,i2)*ndup(i1)
+      if (molfra(i1,i2).gt.0) then
+      istart=istart+6
+      iend=istart+5
+      if (molfra(i1,i2).gt.1) then
+      write (qmolan(istart:iend),'(a2,i3)')qas(i2),molfra(i1,i2)
+      else
+      write (qmolan(istart:iend-2),'(a2)')qas(i2)
+      end if
+      end if
+      end do
+      ihulp=1
+      do i2=1,iend
+      if (qmolan(i2:i2).ne.' ') then
+      qmolan1(ihulp:ihulp)=qmolan(i2:i2)
+      ihulp=ihulp+1
+      end if
+      end do
+
+*     write (45,120)ndup(i1),qmolan(1:iend),vmass
+      write (45,120)mdstep,ndup(i1),qmolan1,vmass
+      vtotmass=vtotmass+ndup(i1)*vmass
+      end if
+      end do
+      write (45,*)'Total number of molecules:',ntotmol
+      write (45,*)'Total number of atoms:',ntotat
+      write (45,*)'Total system mass:',vtotmass
+      close (45)
+      return
+  100 format('Bond order cutoff:',f6.4)
+  110 format('Iteration Freq. Molecular formula',15x,'Molecular mass')
+  120 format(i8,i4,' x  ',a35,f10.4)
+      end
+************************************************************************
+************************************************************************
+
+      subroutine stranal(istart,iend,vout,iout,icheck)
+
+************************************************************************
+#include "cbka.blk"
+#include "cbkconst.blk"
+#include "opt.blk"
+
+      character*1 qchar
+      dimension qchar(5)
+**********************************************************************
+*                                                                    *
+*     Analyze string for special characters; find words in string    *
+*                                                                    *
+**********************************************************************
+      qchar(1)=' '
+      qchar(2)='/'
+      
+      ifound1=0
+      do i1=istart,200
+      ifound2=0
+      do i2=1,icheck
+
+      if (qstrana1(i1:i1).eq.qchar(i2)) then
+      ifound2=1
+      if (ifound1.eq.1) then     !End of word
+      iend=i1
+      goto 10
+      end if
+
+      end if
+
+      end do
+
+      if (ifound2.eq.0.and.ifound1.eq.0) then     !Start of word
+      istart2=i1
+      ifound1=1
+      end if
+
+      end do
+
+   10 continue
+      qstrana2=' '
+      vout=zero
+      iout=0
+
+      if (ifound1.eq.1) then
+      qstrana2=qstrana1(istart2:iend-1)
+      istart=istart2
+      vout=zero
+      read (qstrana2,*,end=20,err=20) vout
+   20 iout=int(vout)
+      end if
+
+      return
+      end
+************************************************************************
+********************************************************************** 
+
+      subroutine dipmom(naold,dpmm,xdip,ydip,zdip,xdir,ydir,zdir)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkch.blk"
+#include "cbkconst.blk"
+#include "control.blk"
+#include "small.blk"
+********************************************************************** 
+*                                                                    *
+*     Calculate and output dipole moment                             *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In dipmom'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+************************************************************************
+*                                                                      *
+*     CONVERSION FACTOR TO DEBYE UNITS IS CALCULATED                   *
+*     THE CALCULATION IS INITIALIZED                                   *
+*                                                                      *
+************************************************************************
+ 
+      ELCHG=1.60217733D-19       ! [C]       = [As]
+      CLIGHT=2.99792458D8        !             [m/s]
+      DBCONV=ONE/(CLIGHT*ELCHG*1.0D11)
+ 
+      CHCPX=ZERO
+      CHCPY=ZERO
+      CHCPZ=ZERO
+      CHCMX=ZERO
+      CHCMY=ZERO
+      CHCMZ=ZERO
+      XDIP=ZERO
+      YDIP=ZERO
+      ZDIP=ZERO
+      XGRD=ZERO
+      YGRD=ZERO
+      ZGRD=ZERO
+************************************************************************
+*                                                                      *
+*     CALCULATION OF MAGNITUDE AND CENTRES OF POSITIVE AND NEGATIVE    *
+*     CHARGES                                                          *
+*                                                                      *
+************************************************************************
+ 
+      if (na.eq.0) na=naold
+      CHRG=ZERO
+      DO 4 K1=1,NA
+      CHK1=CH(K1)
+      IF (CHK1.EQ.ZERO) GOTO 4
+      IF (CHK1.LT.ZERO) GOTO 3
+      CHRG=CHRG+CHK1
+      CHCPX=CHCPX+CHK1*C(K1,1)
+      CHCPY=CHCPY+CHK1*C(K1,2)
+      CHCPZ=CHCPZ+CHK1*C(K1,3)
+      GOTO 4
+    3 CHCMX=CHCMX-CHK1*C(K1,1)
+      CHCMY=CHCMY-CHK1*C(K1,2)
+      CHCMZ=CHCMZ-CHK1*C(K1,3)
+    4 CONTINUE
+ 
+************************************************************************
+*                                                                      *
+*     CALCULATION OF DISTANCE BETWEEN CENTRES AND OF DIPOLE MOMENT     *
+*     IN DEBIJE UNITS                                                  *
+*                                                                      *
+************************************************************************
+ 
+      CHDSTX=CHCPX-CHCMX
+      CHDSTY=CHCPY-CHCMY
+      CHDSTZ=CHCPZ-CHCMZ
+      DPMM=SQRT(CHDSTX*CHDSTX+CHDSTY*CHDSTY+CHDSTZ*CHDSTZ)/DBCONV
+      IF(DPMM.LT.1.0D-4)RETURN
+      XDIP=HALF*(CHCPX+CHCMX)/CHRG
+      YDIP=HALF*(CHCPY+CHCMY)/CHRG
+      ZDIP=HALF*(CHCPZ+CHCMZ)/CHRG
+      GRTST=MAX(CHDSTX,CHDSTY,CHDSTZ)
+      XDIR=-CHDSTX/GRTST
+      YDIR=-CHDSTY/GRTST
+      ZDIR=-CHDSTZ/GRTST
+      open (64,file='dipole.out',status='unknown')
+      write (64,100)dpmm,xdip,ydip,zdip,xdir,ydir,zdir
+      close (64)
+ 
+  100 format ('Dipole moment (Debye):',f12.4,' Location:',3f12.4,
+     $' Direction (-side):',3f12.4) 
+      return
+      end
+************************************************************************
+**********************************************************************
+
+      subroutine readtraj(ivels)
+
+**********************************************************************
+#include "cbka.blk"
+#include "cbkatomcoord.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkdistan.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkinit.blk"
+**********************************************************************
+*                                                                    *
+*     Read in trajectory file                                        *
+*                                                                    *
+**********************************************************************
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In readtraj'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      open(unit=66,file='moldyn.vel',status='old',err=10)
+      ivels=1
+      read (66,*)
+      read (66,100)aaxis,baxis,caxis
+      read (66,100)angles(1),angles(2),angles(3)
+      if (qr.eq.'F'.or.qr.eq.'P'.or.ngeofor.eq.1) then
+      axis(1)=aaxis
+      axis(2)=baxis
+      axis(3)=caxis
+      axiss(1)=axis(1)
+      axiss(2)=axis(2)
+      axiss(3)=axis(3)
+      angle(1)=angles(1)
+      angle(2)=angles(2)
+      angle(3)=angles(3)
+      halfa=angle(1)*dgrrdn
+      hbeta=angle(2)*dgrrdn
+      hgamma=angle(3)*dgrrdn
+      sinalf=sin(halfa)
+      cosalf=cos(halfa)
+      sinbet=sin(hbeta)
+      cosbet=cos(hbeta)
+      cosphi=(cos(hgamma)-cosalf*cosbet)/(sinalf*sinbet)
+      if (cosphi.gt.1.0) cosphi=1.0
+      sinphi=sqrt(one-cosphi*cosphi)
+      tm11=axis(1)*sinbet*sinphi
+      tm21=axis(1)*sinbet*cosphi
+      tm31=axis(1)*cosbet
+      tm22=axis(2)*sinalf
+      tm32=axis(2)*cosalf
+      tm33=axis(3)
+      end if
+      if (aaxis.ne.axis(1).or.baxis.ne.axis(2).or.caxis.ne.axis(3))
+     $stop 'Wrong cell parameters in moldyn.vel'
+      read (66,200)nan
+      if (nan.ne.na) stop 'Wrong number of atoms in moldyn.vel-file'
+      if (nbiolab.eq.1) write (*,*)'Warning: using labels in vels-file'
+      read (66,250)((c(i,j),j=1,3),qlabel(i),i=1,na)
+      read (66,*)
+      read (66,300)((vel(j,i),j=1,3),i=1,na)
+      read (66,*)
+      read (66,300)((accel(j,i),j=1,3),i=1,na)
+      read (66,*)
+      read (66,300,end=10,err=10)((aold(j,i),j=1,3),i=1,na)
+      read (66,*)
+      read (66,300,end=10,err=10)tempmd
+      read (66,*)
+      read (66,350,end=10,err=10)nsbma2
+   10 continue
+**********************************************************************
+*                                                                    *
+*     Format part                                                    *
+*                                                                    *
+**********************************************************************
+  100 format(3d15.8)
+  200 format(i4)
+  250 format(3d24.15,1x,a5)
+  300 format(3d24.15)
+  350 format(i3)
+  400 format (8i3,8f8.4)
+      return
+      end
+**********************************************************************
diff -Naur lammps-29Jan09/lib/reax/reax_lammps.F lammps-12Feb09/lib/reax/reax_lammps.F
--- lammps-29Jan09/lib/reax/reax_lammps.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_lammps.F	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,392 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+********************************************************************** 
+********************************************************************** 
+
+      subroutine getswb(swb_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkff.blk"
+      real*8 swb_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of swb                                        *
+*                                                                    *
+********************************************************************** 
+
+      swb_tmp = swb
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getswa(swa_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkff.blk"
+      real*8 swa_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of swa                                        *
+*                                                                    *
+********************************************************************** 
+
+      swa_tmp = swa
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getvrange(vrange_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "control.blk"
+      real*8 vrange_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of vrange                                     *
+*                                                                    *
+********************************************************************** 
+
+      vrange_tmp = vrange
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnvlist(nvlist_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer nvlist_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nvlist                                     *
+*                                                                    *
+********************************************************************** 
+
+      nvlist_tmp = nvlist
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getvlbora(vlbora_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "control.blk"
+      real*8 vlbora_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of vlbora                                        *
+*                                                                    *
+********************************************************************** 
+
+      vlbora_tmp = vlbora
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnval(nval_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkvalence.blk"
+      integer nval_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nval                                       *
+*                                                                    *
+********************************************************************** 
+
+      nval_tmp = nval
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getntor(ntor_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbktorsion.blk"
+      integer ntor_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of ntor                                       *
+*                                                                    *
+********************************************************************** 
+
+      ntor_tmp = ntor
+
+      return
+      end
+
+
+********************************************************************** 
+
+      subroutine getnhb(nhb_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbksrthb.blk"
+      integer nhb_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nhb                                       *
+*                                                                    *
+********************************************************************** 
+
+      nhb_tmp = nhb
+
+      return
+      end
+
+
+********************************************************************** 
+
+      subroutine getnbonall(nbonall_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbksrtbon1.blk"
+      integer nbonall_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nbonall                                    *
+*                                                                    *
+********************************************************************** 
+
+      nbonall_tmp = nbonall
+
+      return
+      end
+
+
+********************************************************************** 
+
+      subroutine getnneighmax(nneighmax_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer nneighmax_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nneighmax                                       *
+*                                                                    *
+********************************************************************** 
+
+      nneighmax_tmp = nneighmax
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnat(nat_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer nat_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nat                                       *
+*                                                                    *
+********************************************************************** 
+
+      nat_tmp = nat
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnattot(nattot_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer nattot_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nattot                                       *
+*                                                                    *
+********************************************************************** 
+
+      nattot_tmp = nattot
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnsort(nsort_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer nsort_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nsort                                       *
+*                                                                    *
+********************************************************************** 
+
+      nsort_tmp = nsort 
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getmbond(mbond_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+      integer mbond_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of mbond                                       *
+*                                                                    *
+********************************************************************** 
+
+      mbond_tmp = mbond 
+
+      return
+      end
+
+********************************************************************** 
+
+      subroutine getnso(nso_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkff.blk"
+      integer nso_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Report the value of nso                                        *
+*                                                                    *
+********************************************************************** 
+
+      nso_tmp = nso
+
+      return
+      end
+
+
+********************************************************************** 
+
+      subroutine setngeofor(ngeofor_tmp)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "control.blk"
+      integer ngeofor_tmp
+
+********************************************************************** 
+*                                                                    *
+*     Set value of ngeofor
+*                                                                    *
+********************************************************************** 
+
+      ngeofor = ngeofor_tmp
+      return
+      end
+
+**********************************************************************
+ 
+      subroutine getnsbmax(nsbmax_tmp)
+ 
+**********************************************************************
+#include "cbka.blk"
+#include "cbksrtbon1.blk"
+      integer nsbmax_tmp
+ 
+**********************************************************************
+*                                                                    *
+*     Report the value of nsbmax                                     *
+*                                                                    *
+**********************************************************************
+ 
+      nsbmax_tmp = nsbmax
+ 
+      return
+      end
+ 
+**********************************************************************
+ 
+      subroutine getnsbma2(nsbma2_tmp)
+ 
+**********************************************************************
+#include "cbka.blk"
+#include "cbksrtbon1.blk"
+      integer nsbma2_tmp
+ 
+**********************************************************************
+*                                                                    *
+*     Report the value of nsbma2                                     *
+*                                                                    *
+**********************************************************************
+ 
+      nsbma2_tmp = nsbma2
+ 
+      return
+      end
+ 
+**********************************************************************
+ 
+      subroutine getcutof3(cutof3_tmp)
+ 
+**********************************************************************
+#include "cbka.blk"
+#include "control.blk"
+      real*8 cutof3_tmp
+ 
+**********************************************************************
+*                                                                    *
+*     Report the value of cutof3                                     *
+*                                                                    *
+**********************************************************************
+ 
+      cutof3_tmp = cutof3
+ 
+      return
+      end
+
diff -Naur lammps-29Jan09/lib/reax/reax_poten.F lammps-12Feb09/lib/reax/reax_poten.F
--- lammps-29Jan09/lib/reax/reax_poten.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_poten.F	2009-02-12 09:09:50.000000000 -0700
@@ -0,0 +1,3971 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+**********************************************************************
+******************************************************************** 
+
+      subroutine calval
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkdhdc.blk"
+#include "cbkdrdc.blk"
+#include "cbkh.blk"
+#include "cbkrbo.blk"
+#include "cbkvalence.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+      dimension a(3),b(3),j(3),dradc(3,3),drbdc(3,3),dtdc(3,3),
+     $dargdc(3,3),dndc(3,3),dadc(3),dbdc(3)
+********************************************************************** 
+*                                                                    *
+*     Calculate valency angles and their derivatives to cartesian    *
+*     coordinates                                                    *
+*     Valency angle energies are calculated in valang                *
+*                                                                    *
+********************************************************************** 
+********************************************************************** 
+*     Description of variables used in this routine.       
+*                                                          
+*     ndebug: stored in cbka.blk; control-parameter
+*     third: local variable                  
+*     twothird: local variable    
+*     dadc(3): local array; stores derivative distance to cartesians    
+*     dbdc(3): local array; stores derivative distance to cartesians
+*     i1: local do-loop counter
+*     i2: local do-loop counter
+*     k1: local do-loop counter
+*     k2: local do-loop counter
+*     dradc(3,3): local array; stores derivatives bond lengths to
+*                 cartesians
+*     drbdc(3,3): local array; stores derivatives bond lengths to
+*                 cartesians
+*     nval: stored in cbka.blk; number of valence angles
+*     ity: local integer; atom type                        
+*     iv(nvalmax,6): stored in cbka.blk; valence angle identifiers
+*     j(3): local integer array; stores valence angle atom numbers
+*     la: local integer: stores bond numbers in valence angle
+*     lb: local integer: stores bond numbers in valence angle
+*     ivl1: local integer; stores symmetric copy number of bond
+*     ivl2: local integer; stores symmetric copy number of bond
+*     ibsym(nbomax): stored in cbka.blk; symmetric copy number of bond
+*     isign1: local integer; -1 or 1                       
+*     isign2: local integer; -1 or 1                       
+*     rla: local variable; stores bond length for bond la
+*     rlb: local variable; stores bond length for bond lb
+*     rbo(nbomax): stored in cbka.blk; stores bond lengths
+*     ix1,iy1,iz1,ix2,iy2,iz2: local integers; periodic cell shifts
+*     a(3): local variable; distance in x,y and z-direction between atoms
+*     b(3): local variable; distance in x,y and z-direction between atoms
+*     c(nat,3): stored in cbka.blk; cartesian coordinate array
+*     tm11,tm21,tm22,tm31,tm32,tm33: stored in cbka.blk; periodic cell
+*                  matrix                                  
+*     poem: local variable; product of bond lengths                                 
+*     tel: local variable; cross-product of x,y and z-interatomic
+*                  distances                    
+*     arg: local variable; cosine of angle between bonds a and b
+*     arg2: local variable; square of arg
+*     s1ma22: local variable; used to check whether angle gets to 180
+*                  degrees
+*     s1ma2: local variable; square root of s1ma22                         
+*     hl: local variable; angle (in radians) between bonds a and b
+*     h(nvamax): stored in cbka.blk; angle (in radians) between bonds a
+*                  and b
+*     ib(nbomax,3): stored in cbka.blk: bond distance identifiers                   
+*     drdc(nbomax,3,2): stored in cbka.blk; derivatives bond distances
+*                  to cartesian coordinates
+*     dndc(3,3): local variable; temporary storage for calculating
+*                  derivatives of valence angle to cartesians
+*     dtdc(3,3): local variable; temporary storage for calculating
+*                  derivatives of valence angle to cartesians
+*     dargdc(3,3): local variable; temporary storage for calculating
+*                  derivatives of valence angle to cartesians
+*     dhdc(nvamax,3,3): stored in cbka.blk; derivatives of valence angle 
+*                  to cartesians
+*                                                          
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In calval'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+
+      third=1.0/3.0
+      twothird=2.0/3.0
+      dadc(1)=-1.0
+      dadc(2)=1.0
+      dadc(3)=0.0
+      dbdc(1)=0.0
+      dbdc(2)=1.0
+      dbdc(3)=-1.0
+      do k1=1,3
+      do k2=1,3
+      dradc(k1,k2)=0.0
+      drbdc(k1,k2)=0.0
+      end do
+      end do
+      if (nval.eq.0) return
+ 
+      do 10 i1=1,nval
+      ity=iv(i1,1)
+      j(1)=iv(i1,2)
+      j(2)=iv(i1,3)
+      j(3)=iv(i1,4)
+**********************************************************************
+*                                                                    *
+*     Determine valency angle                                        *
+*                                                                    *
+**********************************************************************
+      la=iv(i1,5)
+      lb=iv(i1,6)
+      ivl1=ibsym(la)
+      ivl2=ibsym(lb)
+      isign1=1
+      isign2=1
+      rla=rbo(la)
+      rlb=rbo(lb)
+ 
+      call dista2(j(2),j(1),dis,a(1),a(2),a(3))
+      call dista2(j(2),j(3),dis,b(1),b(2),b(3))
+
+      poem=rla*rlb
+      tel=a(1)*b(1)+a(2)*b(2)+a(3)*b(3)
+      arg=tel/poem
+      arg2=arg*arg
+      s1ma22=1.0-arg2
+      if (s1ma22.lt.1.0d-10) s1ma22=1.0d-10
+      s1ma2=sqrt(s1ma22)
+      if (arg.gt.1.0) arg=1.0
+      if (arg.lt.-1.0) arg=-1.0
+      hl=acos(arg)
+      h(i1)=hl
+**********************************************************************
+*                                                                    *
+*     Calculate derivative valency angle to cartesian coordinates    *
+*                                                                    *
+**********************************************************************
+      if (j(1).eq.ib(la,2)) then
+      do k1=1,3
+      dradc(k1,1)=drdc(la,k1,1)
+      dradc(k1,2)=drdc(la,k1,2)
+      end do
+      else
+      do k1=1,3
+      dradc(k1,1)=drdc(la,k1,2)
+      dradc(k1,2)=drdc(la,k1,1)
+      end do
+      end if
+      if (j(2).eq.ib(lb,2)) then
+      do k1=1,3
+      drbdc(k1,2)=drdc(lb,k1,1)
+      drbdc(k1,3)=drdc(lb,k1,2)
+      end do
+      else
+      do k1=1,3
+      drbdc(k1,2)=drdc(lb,k1,2)
+      drbdc(k1,3)=drdc(lb,k1,1)
+      end do
+      end if
+      do k1=1,3
+      do k2=1,3
+      dndc(k1,k2)=rla*drbdc(k1,k2)+rlb*dradc(k1,k2)
+      dtdc(k1,k2)=a(k1)*dbdc(k2)+b(k1)*dadc(k2)
+      dargdc(k1,k2)=(dtdc(k1,k2)-arg*dndc(k1,k2))/poem
+      dhdc(i1,k1,k2)=-dargdc(k1,k2)/s1ma2
+      end do
+      end do
+      
+   10 continue
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine boncor
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkc.blk"
+#include "cbkbo.blk"
+#include "cbkboncor.blk"
+#include "cbkbosi.blk"
+#include "cbkbopi.blk"
+#include "cbkbopi2.blk"
+#include "cbkconst.blk"
+#include "cbkdbopi2ndc.blk"
+#include "cbkdbopidc.blk"
+#include "cbkdbopindc.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbknubon2.blk"
+#include "cbkrbo.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkdbodc.blk"
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In boncor'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+********************************************************************** 
+*                                                                    *
+*     Correction for overcoordination and 1-3 bond orders            *
+*                                                                    *
+********************************************************************** 
+********************************************************************** 
+*     Description of variables used in this routine.       
+*                                                          
+*     ndebug: stored in cbka.blk; control-parameter
+*     i1: local do-loop counter
+*     i2: local do-loop counter
+*     k1: local do-loop counter
+*     k2: local do-loop counter
+*     nbon: stored in cbka.blk; number of bonds in system
+*     ibt: local integer; stores bond type
+*     ib(nbomax,3): stored in cbka.blk: bond distance identifiers                   
+*     j1: local integer; stores atom number 1st atom in bond
+*     j2: local integer; stores atom number 2nd atom in bond
+*     ovc(nbotym): stored in cbka.blk: force field parameter for
+*                  overcoordination correction
+*     v13cor(nbotym): stored in cbka.blk: force field parameter for
+*                  1-3 bond order correction
+*     idbo1(nbomax): stored in cbka.blk; number of atoms in the
+*                  derivative of the bond order
+*     idbo(nbomax,2*mbond): stored in cbka.blk; atom numbers of the
+*                  atoms in the derivative of the bond order
+*     dbondc(nbomax,3,2*mbond): stored in cbka.blk; derivative of
+*                  corrected total bond orders to cartesians
+*     dbosindc(nbomax,3,2*mbond): stored in cbka.blk; derivative of
+*                  corrected sigma bond orders to cartesians
+*     dbopindc(nbomax,3,2*mbond): stored in cbka.blk; derivative of
+*                  corrected pi bond orders to cartesians
+*     dbopi2ndc(nbomax,3,2*mbond): stored in cbka.blk; derivative of
+*                  corrected double pi bond orders to cartesians
+*     dbodc(nbomax,3,2): stored in cbka.blk; derivative of
+*                  uncorrected total bond orders to cartesians
+*     dbosidc(nbomax,3,2): stored in cbka.blk; derivative of
+*                  uncorrected sigma bond orders to cartesians
+*     dbopidc(nbomax,3,2): stored in cbka.blk; derivative of
+*                  uncorrected pi bond orders to cartesians
+*     dbopi2dc(nbomax,3,2): stored in cbka.blk; derivative of
+*                  uncorrected double pi bond orders to cartesians
+*     boo: local variable; storage of uncorrected total bond order
+*     bo(nbomax): stored in cbka.blk; total bond order          
+*     bopi(nbomax): stored in cbka.blk; pi bond order          
+*     bopi2(nbomax): stored in cbka.blk; double pi bond order          
+*     bopio: local variable; storage of uncorrected pi bond order
+*     bopi2o: local variable; storage of uncorrected double pi bond order
+*     iti: local integer; atom type first atom in bond     
+*     itj: local integer; atom type second atom in bond     
+*     ia(nat,mbond+3): stored in cbka.blk; connection table without bond
+*                  order cutoff
+*     aboi: local variable: total bond order around atom i
+*     aboj: local variable: total bond order around atom j
+*     abo(nat): stored in cbka.blk; total bond order around atoms
+*     vp131: local variable; force field cross-term        
+*     vp132: local variable; force field cross-term        
+*     vp133: local variable; force field cross-term        
+*     bo131(nsort): stored in cbka.blk; force field parameter for 1-3
+*                  bond order correction
+*     bo132(nsort): stored in cbka.blk; force field parameter for 1-3
+*                  bond order correction
+*     bo133(nsort): stored in cbka.blk; force field parameter for 1-3
+*                  bond order correction
+*     corrtot:local variable; total correction on bond order
+*     dbodsboi1: local variable; derivative of bond order to sum of bond
+*                  orders around atom i
+*     dbodsboj1: local variable; derivative of bond order to sum of bond
+*                  orders around atom j
+*     ovi: local variable; overcoordination on atom i      
+*     ovj: local variable; overcoordination on atom j      
+*     aval(nat): stored in cbka.blk; nr. of valence electrons on atom       
+*     exphu1: local variable; stores exponential
+*     exphu2: local variable; stores exponential
+*     exp11: local variable; stores exponential
+*     exp21: local variable; stores exponential
+*     vpar(npamax): stored in cbka.blk: general parameters                                  
+*     exphu12: local variable; stores sum of exponential
+*     ovcor: local variable; temporary storage for BO/ovcor corr.
+*     huli: local variable; temporary storage for BO/ovcor corr.
+*     hulj: local variable; temporary storage for BO/ovcor corr.
+*     corr1: local variable; temporary storage for BO/ovcor corr.
+*     corr2: local variable; temporary storage for BO/ovcor corr.
+*     dbodsboi2: local variable; derivative of 1-3 BO correction to sum 
+*                  of bond orders around atom i 
+*     dbodsboj2: local variable; derivative of 1-3 BO correction to sum 
+*                  of bond orders around atom i 
+*     bocor1: local variable; 1-3 bond order correction                            
+*     bocor2: local variable; 1-3 bond order correction                            
+*     ovi2: local variable; overcoordination on atom i with reference to
+*                  total number of electrons on atom i, including lone
+*                  pairs     
+*     ovj2: local variable; overcoordination on atom j with reference to
+*                  total number of electrons on atom j, including lone
+*                  pairs     
+*     valf(nsort): stored in cbka.blk; total number of electrons on 
+*                  atom, including lone pairs
+*     cor1: local variable; temporary storage for BO/1-3 bond corr.
+*     cor2: local variable; temporary storage for BO/1-3 bond corr.
+*     exphu3: local variable; storage exponential
+*     exphu4: local variable; storage exponential
+*     corrtot2: local variable; square of corrtot                                  
+*     dbodboo: local variable; derivative of corrected total bond order to 
+*                   uncorrected bond order
+*     dbopidbopio: local variable; derivative of corrected pi bond order
+*                   to uncorrected pi bond order
+*     dbopidboo: local variable; derivative of corrected pi bond order
+*                   to uncorrected total bond order
+*     dbopi2dbopi2o: local variable; derivative of corrected double pi bond order
+*                   to uncorrected double pi bond order
+*     dbopi2dboo: local variable; derivative of corrected double pi bond order
+*                   to uncorrected total bond order
+*     dbodsboit: local variable; derivative of total bond order to sum
+*                   of bond orders around atom i
+*     dbodsbojt: local variable; derivative of total bond order to sum
+*                   of bond orders around atom j
+*     vhui: local variable; temporary storage              
+*     vhuj: local variable; temporary storage              
+*     dbopidsboit: local variable; derivative of pi bond order to sum
+*                   of bond orders around atom i
+*     dbopidsbojt: local variable; derivative of pi bond order to sum
+*                   of bond orders around atom j
+*     dbopi2dsboit: local variable; derivative of pi bond order to sum
+*                   of bond orders around atom i
+*     dbopi2dsbojt: local variable; derivative of pi bond order to sum
+*                   of bond orders around atom j
+*     nco: local integer; counter for number of atoms in derivative
+*     ihl: local integer; helps to access right dbodc-term
+*     nubon2(nat,mbond): stored in cbka.blk; stored bond number as a
+*                   function of atom number and connection number
+*     iob: local integer; atom number of second atom in bond
+*     ncubo: local integer; stores number of current bond  
+*     na: stored in cbka.blk: number of atoms in system 
+*     zero: stored in cbka.blk: value 0.00
+*                                                          
+********************************************************************** 
+      do 10 i1=1,nbon
+      ibt=ib(i1,1)
+      j1=ib(i1,2)
+      j2=ib(i1,3)
+      if (ovc(ibt).lt.0.001.and.v13cor(ibt).lt.0.001) then
+      idbo1(i1)=2
+      idbo(i1,1)=j1
+      idbo(i1,2)=j2
+      do k1=1,3
+      dbondc(i1,k1,1)=dbodc(i1,k1,1)
+      dbondc(i1,k1,2)=dbodc(i1,k1,2)
+      dbosindc(i1,k1,1)=dbosidc(i1,k1,1)
+      dbosindc(i1,k1,2)=dbosidc(i1,k1,2)
+      dbopindc(i1,k1,1)=dbopidc(i1,k1,1)
+      dbopindc(i1,k1,2)=dbopidc(i1,k1,2)
+      dbopi2ndc(i1,k1,1)=dbopi2dc(i1,k1,1)
+      dbopi2ndc(i1,k1,2)=dbopi2dc(i1,k1,2)
+      end do
+      goto 10
+      end if
+      boo=bo(i1)
+      bopio=bopi(i1)
+      bopi2o=bopi2(i1)
+      iti=ia(j1,1)
+      itj=ia(j2,1)
+      aboi=abo(j1)
+      aboj=abo(j2)
+      vp131=sqrt(bo131(iti)*bo131(itj))
+      vp132=sqrt(bo132(iti)*bo132(itj))
+      vp133=sqrt(bo133(iti)*bo133(itj))
+      corrtot=1.0
+      dbodsboi1=zero
+      dbodsboj1=zero
+      if (ovc(ibt).gt.0.001) then
+      ovi=aboi-aval(iti)
+      ovj=aboj-aval(itj)
+
+********************************************************************** 
+*                                                                    *
+*     Correction for overcoordination                                *
+*                                                                    *
+********************************************************************** 
+      exphu1=exp(-vpar(2)*ovi)
+      exphu2=exp(-vpar(2)*ovj)
+      exp11=exp(-vpar(1)*ovi)
+      exp21=exp(-vpar(1)*ovj)
+      exphu12=(exphu1+exphu2)
+      ovcor=-(1.0/vpar(2))*log(0.50*exphu12)
+*     huli=((1.0/ovc(ibt))*aval(iti)+exp11+exp21)
+*     hulj=((1.0/ovc(ibt))*aval(itj)+exp11+exp21)
+      huli=aval(iti)+exp11+exp21
+      hulj=aval(itj)+exp11+exp21
+      corr1=huli/(huli+ovcor)
+      corr2=hulj/(hulj+ovcor)
+      corrtot=0.50*(corr1+corr2)
+
+      dbodsboi1=0.50*(-vpar(1)*exp11/(huli+ovcor)-
+     $(corr1/(huli+ovcor))*
+     $(-vpar(1)*exp11+exphu1/exphu12)-vpar(1)*exp11/(hulj+ovcor)-
+     $(corr2/(hulj+ovcor))*(-vpar(1)*exp11+exphu1/exphu12))
+      dbodsboj1=0.50*(-vpar(1)*exp21/(huli+ovcor)-
+     $(corr1/(huli+ovcor))*
+     $(-vpar(1)*exp21+exphu2/exphu12)-vpar(1)*exp21/(hulj+ovcor)-
+     $(corr2/(hulj+ovcor))*(-vpar(1)*exp21+exphu2/exphu12))
+      end if
+********************************************************************** 
+*                                                                    *
+*     Correction for 1-3 bond orders                                 *
+*                                                                    *
+********************************************************************** 
+      dbodsboi2=zero
+      dbodsboj2=zero
+      bocor1=1.0
+      bocor2=1.0
+      if (v13cor(ibt).gt.0.001) then
+      ovi2=aboi-vval3(iti)                  !Modification for metal surfaces
+      ovj2=aboj-vval3(itj)
+*     ovi2=aboi-valf(iti)
+*     ovj2=aboj-valf(itj)
+*     ovi2=aboi-aval(iti)
+*     ovj2=aboj-aval(itj)
+      cor1=vp131*boo*boo-ovi2
+      cor2=vp131*boo*boo-ovj2
+*     exphu3=v13cor(ibt)*exp(-vp132*cor1+vp133)
+*     exphu4=v13cor(ibt)*exp(-vp132*cor2+vp133)
+      exphu3=exp(-vp132*cor1+vp133)
+      exphu4=exp(-vp132*cor2+vp133)
+      bocor1=1.0/(1.0+exphu3)
+      bocor2=1.0/(1.0+exphu4)
+      dbodsboi2=-bocor1*bocor1*bocor2*vp132*exphu3
+      dbodsboj2=-bocor1*bocor2*bocor2*vp132*exphu4
+      end if
+
+      bo(i1)=boo*corrtot*bocor1*bocor2
+      if (bo(i1).lt.1e-10) bo(i1)=zero
+      corrtot2=corrtot*corrtot
+      bopi(i1)=bopio*corrtot2*bocor1*bocor2
+      bopi2(i1)=bopi2o*corrtot2*bocor1*bocor2
+      if (bopi(i1).lt.1e-10) bopi(i1)=zero
+      if (bopi2(i1).lt.1e-10) bopi2(i1)=zero
+
+      dbodboo=corrtot*bocor1*bocor2+corrtot*
+     $bocor1*bocor1*bocor2*boo*vp132*vp131*2.0*boo*exphu3+
+     $corrtot*bocor1*bocor2*bocor2*boo*
+     $vp132*vp131*exphu4*2.0*boo
+
+      dbopidbopio=corrtot2*bocor1*bocor2
+
+      dbopidboo=corrtot2*
+     $bocor1*bocor1*bocor2*boo*vp132*vp131*2.0*bopio*exphu3+
+     $corrtot2*bocor1*bocor2*bocor2*boo*
+     $vp132*vp131*exphu4*2.0*bopio
+
+      dbopi2dbopi2o=corrtot2*bocor1*bocor2
+
+      dbopi2dboo=corrtot2*
+     $bocor1*bocor1*bocor2*boo*vp132*vp131*2.0*bopi2o*exphu3+
+     $corrtot2*bocor1*bocor2*bocor2*boo*
+     $vp132*vp131*exphu4*2.0*bopi2o
+
+      dbodsboit=boo*dbodsboi1*bocor1*bocor2+boo*corrtot*dbodsboi2
+      dbodsbojt=boo*dbodsboj1*bocor1*bocor2+boo*corrtot*dbodsboj2
+
+      vhui=2.0*corrtot*dbodsboi1*bocor1*bocor2+corrtot2*dbodsboi2
+      vhuj=2.0*corrtot*dbodsboj1*bocor1*bocor2+corrtot2*dbodsboj2
+      dbopidsboit=bopio*vhui
+      dbopidsbojt=bopio*vhuj
+
+      dbopi2dsboit=bopi2o*vhui
+      dbopi2dsbojt=bopi2o*vhuj
+
+********************************************************************** 
+*                                                                    *
+*     Calculate bond order derivatives                               *
+*                                                                    *
+********************************************************************** 
+      idbo1(i1)=2+ia(j1,2)+ia(j2,2)
+      idbo(i1,1)=j1
+      idbo(i1,2)=j2
+      nco=0
+      do k1=1,3
+      dbondc(i1,k1,1)=dbodc(i1,k1,1)*dbodboo
+      dbondc(i1,k1,2)=dbodc(i1,k1,2)*dbodboo
+*     dbosindc(i1,k1,1)=dbosidc(i1,k1,1)*dbosidboo
+*     dbosindc(i1,k1,2)=dbosidc(i1,k1,2)*dbosidboo
+      dbopindc(i1,k1,1)=dbopidc(i1,k1,1)*dbopidbopio+
+     $dbodc(i1,k1,1)*dbopidboo
+      dbopindc(i1,k1,2)=dbopidc(i1,k1,2)*dbopidbopio+
+     $dbodc(i1,k1,2)*dbopidboo
+      dbopi2ndc(i1,k1,1)=dbopi2dc(i1,k1,1)*dbopi2dbopi2o+
+     $dbodc(i1,k1,1)*dbopi2dboo
+      dbopi2ndc(i1,k1,2)=dbopi2dc(i1,k1,2)*dbopi2dbopi2o+
+     $dbodc(i1,k1,2)*dbopi2dboo
+      end do
+      do i2=1,ia(j1,2)
+      ihl=0
+      iob=ia(j1,2+i2)
+      if (iob.lt.j1) ihl=1
+      ncubo=nubon2(j1,i2)
+      idbo(i1,2+nco+1)=iob
+      do k1=1,3
+      dbondc(i1,k1,1)=dbondc(i1,k1,1)+dbodc(ncubo,k1,1+ihl)*dbodsboit
+      dbondc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbodsboit
+
+*     dbosindc(i1,k1,1)=dbosindc(i1,k1,1)+
+*    $dbodc(ncubo,k1,1+ihl)*dbosidsboit
+*     dbosindc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbosidsboit
+
+      dbopindc(i1,k1,1)=dbopindc(i1,k1,1)+
+     $dbodc(ncubo,k1,1+ihl)*dbopidsboit
+      dbopindc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbopidsboit
+
+      dbopi2ndc(i1,k1,1)=dbopi2ndc(i1,k1,1)+
+     $dbodc(ncubo,k1,1+ihl)*dbopi2dsboit
+      dbopi2ndc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbopi2dsboit
+
+      end do
+      nco=nco+1
+      end do
+      do i2=1,ia(j2,2)
+      ihl=0
+      iob=ia(j2,2+i2)
+      if (iob.lt.j2) ihl=1
+      ncubo=nubon2(j2,i2)
+      idbo(i1,2+nco+1)=iob
+      do k1=1,3
+
+      dbondc(i1,k1,2)=dbondc(i1,k1,2)+dbodc(ncubo,k1,1+ihl)*dbodsbojt
+      dbondc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbodsbojt
+
+*     dbosindc(i1,k1,2)=dbosindc(i1,k1,2)+
+*    $dbodc(ncubo,k1,1+ihl)*dbosidsbojt
+*     dbosindc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbosidsbojt
+
+      dbopindc(i1,k1,2)=dbopindc(i1,k1,2)+
+     $dbodc(ncubo,k1,1+ihl)*dbopidsbojt
+      dbopindc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbopidsbojt
+
+      dbopi2ndc(i1,k1,2)=dbopi2ndc(i1,k1,2)+
+     $dbodc(ncubo,k1,1+ihl)*dbopi2dsbojt
+      dbopi2ndc(i1,k1,2+nco+1)=dbodc(ncubo,k1,2-ihl)*dbopi2dsbojt
+
+      end do
+      nco=nco+1
+      end do
+
+   10 continue
+
+      do i1=1,na
+      abo(i1)=zero
+      end do
+*     do i1=1,na
+*     do i2=1,ia(i1,2)
+*     iob=ia(i1,2+i2)
+*     ncubo=nubon2(i1,i2)
+*     abo(i1)=abo(i1)+bo(ncubo)
+*     end do
+*     end do
+      do i1=1,nbon
+      j1=ib(i1,2)
+      j2=ib(i1,3)
+      abo(j1)=abo(j1)+bo(i1)
+      if (j1.ne.j2) abo(j2)=abo(j2)+bo(i1)
+      end do
+
+   15 continue
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine lonpar
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkconst.blk"
+#include "cbkc.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbklonpar.blk"
+#include "cbknubon2.blk"
+#include "control.blk"
+#include "small.blk"
+      dimension virial_tmp(3,3),virialsym(6)
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In lonpar'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+**********************************************************************
+*                                                                    *
+*     Calculate lone pair energy and first derivatives               *
+*                                                                    *
+**********************************************************************
+      elp=zero
+      do i1=1,na
+**********************************************************************
+*                                                                    *
+*     Determine number of lone pairs on atoms
+*                                                                    *
+**********************************************************************
+      ity=ia(i1,1)
+      voptlp=0.50*(stlp(ity)-aval(ity))
+      vlp(i1)=zero
+      vund=abo(i1)-stlp(ity)
+      vlph=2.0*int(vund/2.0)
+      vlpex=vund-vlph
+      vp16h=vpar(16)-1.0
+
+      expvlp=exp(-vpar(16)*(2.0+vlpex)*(2.0+vlpex))
+      dvlpdsbo(i1)=-vpar(16)*2.0*(2.0+vlpex)*expvlp
+      vlp(i1)=expvlp-int(vund/2.0)
+*     expvlp=exp(-vpar(16)*(2.0+vlpex))
+*     dvlpdsbo(i1)=-vpar(16)*expvlp
+*     expvlp=exp(-6.0*((-0.50*vlpex)**vpar(16)))
+*     vlp(i1)=(1.0-expvlp)-int(vund/2.0)
+*     dvlpdsbo(i1)=-0.5*6.0*vpar(16)*((-0.5*vlpex)**vp16h)*
+*    $expvlp
+**********************************************************************
+*                                                                    *
+*     Calculate lone pair energy                                     *
+*                                                                    *
+**********************************************************************
+      if (i1 .le. na_local) then
+
+      diffvlp=voptlp-vlp(i1)
+      exphu1=exp(-75.0*diffvlp)
+      hulp1=1.0/(1.0+exphu1)
+      elph=vlp1(ity)*diffvlp*hulp1
+*     elph=vlp1(ity)*diffvlp
+      delpdvlp=-vlp1(ity)*hulp1-vlp1(ity)*diffvlp*hulp1*hulp1*
+     $75.0*exphu1
+
+      elp=elp+elph
+      estrain(i1)=estrain(i1)+elph !atom energy
+
+      delpdsbo=delpdvlp*dvlpdsbo(i1)
+**********************************************************************
+*                                                                    *
+*     Calculate first derivative of lone pair energy to              *
+*     cartesian coordinates                                          *
+*                                                                    *
+**********************************************************************
+      do i3=1,ia(i1,2)
+      iob=ia(i1,2+i3)
+      ncubo=nubon2(i1,i3)
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = delpdsbo*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+         do k1p=1,3
+            virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+         end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+      endif
+
+      end do
+      endif
+
+      end do
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine covbon
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkbosi.blk"
+#include "cbkbopi.blk"
+#include "cbkbopi2.blk"
+#include "cbkconst.blk"
+#include "cbkcovbon.blk"
+#include "cbkd.blk"
+#include "cbkdbopi2ndc.blk"
+#include "cbkdbopindc.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbknubon2.blk"
+#include "cbkqa.blk"
+#include "cbkrbo.blk"
+#include "control.blk"
+#include "small.blk"
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate bond energy and first derivatives                    *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In covbon'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      eb=0.0d0
+      if (nbon.eq.0) return
+********************************************************************** 
+*                                                                    *
+*     Calculate bond energies                                        *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write(65,*) 'Bond forces'
+c$$$      write(65,*) 'nbon = ',nbon
+c$$$      endif
+
+      do 20 i1=1,nbon
+
+      boa=bo(i1)
+*     if (boa.lt.cutof2) goto 20
+      j1=ib(i1,2)
+      j2=ib(i1,3)
+
+c     Only compute interaction if both atoms
+c     are local or else flip a coin 
+      if (j1 .gt. na_local) go to 20
+      if (j2 .gt. na_local) then
+         if (itag(j1) .lt. itag(j2)) go to 20
+         if (itag(j1) .eq. itag(j2)) then
+            if(c(j1,3) .gt. c(j2,3)) go to 20
+            if(c(j1,3) .eq. c(j2,3) .and. 
+     $           c(j1,2) .gt. c(j2,2)) go to 20
+            if(c(j1,3) .eq. c(j2,3) .and. 
+     $           c(j1,2) .eq. c(j2,2) .and. 
+     $           c(j1,1) .gt. c(j2,1)) go to 20
+         endif
+      endif
+      vsymm=1.0
+      if (j1.eq.j2) vsymm=0.5
+
+      bopia=bopi(i1)
+      bopi2a=bopi2(i1)
+      bosia=boa-bopia-bopi2a
+      if (bosia.lt.zero) bosia=zero
+      it1=ia(j1,1)
+      it2=ia(j2,1)
+      ibt=ib(i1,1)
+      de1h=vsymm*de1(ibt)
+      de2h=vsymm*de2(ibt)
+      de3h=vsymm*de3(ibt)
+
+      bopo1=bosia**psp(ibt)
+      exphu1=exp(psi(ibt)*(1.0-bopo1))
+      ebh=-de1h*bosia*exphu1-de2h*bopia-de3h*bopi2a
+
+      debdbo=-de1h*exphu1+de1h*exphu1*psp(ibt)*psi(ibt)*bopo1
+      debdbopi=-de2h
+      debdbopi2=-de3h
+
+      eb=eb+ebh
+      estrain(j1)=estrain(j1)+0.50*ebh !1st atom energy
+      estrain(j2)=estrain(j2)+0.50*ebh !2nd atom energy
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(i1)
+      ihu=idbo(i1,i2)
+      do k1=1,3
+      ftmp = debdbo*(dbondc(i1,k1,i2)-dbopindc(i1,k1,i2)-
+     $dbopi2ndc(i1,k1,i2))+
+     $debdbopi*dbopindc(i1,k1,i2)+
+     $debdbopi2*dbopi2ndc(i1,k1,i2)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(i1)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(i1)
+                  ihu=idbo(i1,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+**********************************************************************
+*                                                                    *
+*     Stabilisation terminal triple bond in CO                       *
+*                                                                    *
+**********************************************************************
+      if (boa.lt.1.00) goto 20
+* Stabilization for all triple bonds (not just for CO) in ReaxFF combustion FF
+*      if ((qa(j1).eq.'C '.and.qa(j2).eq.'O ').or.
+*     $(qa(j1).eq.'O '.and.qa(j2).eq.'C ')) then
+      ba=(boa-2.50)*(boa-2.50)
+      exphu=exp(-vpar(8)*ba)
+      oboa=abo(j1)-boa
+      obob=abo(j2)-boa
+      exphua1=exp(-vpar(4)*oboa)
+      exphub1=exp(-vpar(4)*obob)
+      ovoab=abo(j1)-aval(it1)+abo(j2)-aval(it2)
+      exphuov=exp(vpar(5)*ovoab)
+      hulpov=1.0/(1.0+25.0*exphuov)
+      
+      estriph=vpar(11)*exphu*hulpov*(exphua1+exphub1)
+
+      eb=eb+estriph
+      estrain(j1)=estrain(j1)+0.50*estriph !1st atom energy
+      estrain(j2)=estrain(j2)+0.50*estriph !2nd atom energy
+
+      decobdbo=vpar(4)*vpar(11)*exphu*hulpov*(exphua1+exphub1)
+     $-2.0*vpar(11)*vpar(8)*(boa-2.50)*hulpov*exphu*
+     $(exphua1+exphub1)
+      decobdboua=-25.0*vpar(5)*vpar(11)*exphu*exphuov*hulpov*hulpov*
+     $(exphua1+exphub1)-vpar(11)*exphu*vpar(4)*hulpov*exphua1
+      decobdboub=-25.0*vpar(5)*vpar(11)*exphu*exphuov*hulpov*hulpov*
+     $(exphua1+exphub1)-vpar(11)*exphu*vpar(4)*hulpov*exphub1
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(i1)
+      ihu=idbo(i1,i2)
+      do k1=1,3
+      ftmp = decobdbo*dbondc(i1,k1,i2)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(i1)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(i1)
+                  ihu=idbo(i1,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      do i3=1,ia(j1,2)
+      iob=ia(j1,2+i3)
+      ncubo=nubon2(j1,i3)
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = decobdboua*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      end do
+
+      do i3=1,ia(j2,2)
+      iob=ia(j2,2+i3)
+      ncubo=nubon2(j2,i3)
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = decobdboub*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      end do
+
+*      endif
+
+   20 continue
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine ovcor
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkbopi.blk"
+#include "cbkbopi2.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdbopi2ndc.blk"
+#include "cbkdbopindc.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbklonpar.blk"
+#include "cbknubon2.blk"
+#include "cbkrbo.blk"
+#include "control.blk"
+#include "small.blk"
+********************************************************************** 
+*                                                                    *
+*     Calculate atom energy                                          *
+*     Correction for over- and undercoordinated atoms                *
+*                                                                    *
+********************************************************************** 
+      dimension vlptemp(nat)
+      dimension virial_tmp(3,3),virialsym(6)
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In ovcor'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      do i1=1,na
+      ity1=ia(i1,1)
+      vlptemp(i1)=vlp(i1)
+      if (amas(ity1).gt.21.0) vlptemp(i1)=0.50*(stlp(ity1)-aval(ity1))  !Only for 1st-row elements
+      end do
+   25 ea=zero
+      eaot=zero
+      eaut=zero
+      epen=0.0
+
+      do 30 i1=1,na_local
+      ity1=ia(i1,1)
+      dfvl=1.0                         
+      if (amas(ity1).gt.21.0) dfvl=0.0  !Only for 1st-row elements
+********************************************************************** 
+*                                                                    *
+*     Calculate overcoordination energy                              *
+*     Valency is corrected for lone pairs                            *
+*                                                                    *
+********************************************************************** 
+
+      voptlp=0.50*(stlp(ity1)-aval(ity1))
+      diffvlph=dfvl*(voptlp-vlptemp(i1))
+********************************************************************** 
+*                                                                    *
+*     Determine coordination neighboring atoms                       *
+*                                                                    *
+********************************************************************** 
+      sumov=0.0
+      sumov2=0.0
+      do i3=1,ia(i1,2)
+      iat2=ia(i1,2+i3)
+      ity2=ia(iat2,1)
+      ncubo=nubon2(i1,i3)
+      if (bo(ncubo).gt.0.0) then
+      ibt=ib(ncubo,1)
+      voptlp2=0.50*(stlp(ity2)-aval(ity2))
+      diffvlp2=dfvl*(voptlp2-vlptemp(iat2))
+      sumov=sumov+(bopi(ncubo)+bopi2(ncubo))*
+     $(abo(iat2)-aval(ity2)-diffvlp2)
+      sumov2=sumov2+vover(ibt)*de1(ibt)*bo(ncubo)
+      endif
+      end do
+
+      exphu1=exp(vpar(32)*sumov)
+      vho=1.0/(1.0+vpar(33)*exphu1)
+      diffvlp=diffvlph*vho
+      
+      vov1=abo(i1)-aval(ity1)-diffvlp
+      dvov1dsumov=diffvlph*vpar(32)*vpar(33)*vho*vho*exphu1
+      exphuo=exp(vovun(ity1)*vov1)
+      hulpo=1.0/(1.0+exphuo)
+
+      hulpp=(1.0/(vov1+aval(ity1)+1e-8))
+
+      eah=sumov2*hulpp*hulpo*vov1
+      deadvov1=-sumov2*hulpp*hulpp*vov1*hulpo+
+     $sumov2*hulpp*hulpo-sumov2*hulpp*vov1*vovun(ity1)*
+     $hulpo*hulpo*exphuo
+
+      ea=ea+eah
+      estrain(i1)=estrain(i1)+eah !atom energy
+********************************************************************** 
+*                                                                    *
+*     Calculate first derivative of overcoordination energy to       *
+*     cartesian coordinates                                          *
+*                                                                    *
+********************************************************************** 
+      do i3=1,ia(i1,2)
+      iob=ia(i1,2+i3)
+      ncubo=nubon2(i1,i3)
+      if (bo(ncubo).gt.0.0) then
+      ibt=ib(ncubo,1)
+      deadbo=vover(ibt)*de1(ibt)*hulpp*hulpo*vov1
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = deadvov1*(1.0+dfvl*vho*dvlpdsbo(i1))*
+     $dbondc(ncubo,k1,i4)+deadbo*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+ 
+      do i2=1,ia(i1,2)
+ 
+      iat2=ia(i1,2+i2)
+      ity2=ia(iat2,1)
+      nbosa=nubon2(i1,i2)
+      if (bo(nbosa).gt.0.0) then
+      deadvov2=deadvov1*dvov1dsumov*(bopi(nbosa)+bopi2(nbosa))
+ 
+      voptlp2=0.50*(stlp(ity2)-aval(ity2))
+      diffvlp2=dfvl*(voptlp2-vlptemp(iat2))
+      deadpibo=deadvov1*dvov1dsumov*(abo(iat2)-aval(ity2)-diffvlp2)
+ 
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(nbosa)
+      ihu=idbo(nbosa,i4)
+      do k1=1,3
+      ftmp = deadpibo*(dbopindc(nbosa,k1,i4)+
+     $dbopi2ndc(nbosa,k1,i4))
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(nbosa)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(nbosa)
+                  ihu=idbo(nbosa,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+      endif
+ 
+      do i3=1,ia(iat2,2)
+      iob=ia(iat2,2+i3)
+      ncubo=nubon2(iat2,i3)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = deadvov2*(1.0+dfvl*dvlpdsbo(iat2))*
+     $dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+ 
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+
+      endif
+
+      end do
+
+********************************************************************** 
+*                                                                    *
+*     Calculate undercoordination energy                             *
+*                                                                    *
+********************************************************************** 
+      if (valp1(ity1).lt.zero) goto 30  !skip undercoordination
+      exphu2=exp(vpar(10)*sumov)
+      vuhu1=1.0+vpar(9)*exphu2
+      hulpu2=1.0/vuhu1
+
+      exphu3=-exp(vpar(7)*vov1)
+      hulpu3=-(1.0+exphu3)
+
+      dise2=valp1(ity1)
+      exphuu=exp(-vovun(ity1)*vov1)
+      hulpu=1.0/(1.0+exphuu)
+      eahu=dise2*hulpu*hulpu2*hulpu3
+      deaudvov1=dise2*hulpu2*vovun(ity1)*hulpu*hulpu*exphuu*hulpu3-
+     $dise2*hulpu*hulpu2*vpar(7)*exphu3
+
+      ea=ea+eahu
+      estrain(i1)=estrain(i1)+eahu !atom energy
+
+      deaudsumov=-dise2*hulpu*vpar(9)*vpar(10)*hulpu3*exphu2*
+     $hulpu2*hulpu2
+
+********************************************************************** 
+*                                                                    *
+*     Calculate first derivative of atom energy to cartesian         *
+*     coordinates                                                    *
+*                                                                    *
+********************************************************************** 
+
+      do i3=1,ia(i1,2)
+      iob=ia(i1,2+i3)
+      ncubo=nubon2(i1,i3)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = deaudvov1*(1.0+dfvl*vho*dvlpdsbo(i1))*
+     $dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+ 
+      do i2=1,ia(i1,2)
+ 
+      iat2=ia(i1,2+i2)
+      ity2=ia(iat2,1)
+      nbosa=nubon2(i1,i2)
+      if (bo(nbosa).gt.0.0) then
+      deadvov2=(deaudsumov+dvov1dsumov*deaudvov1)*
+     $(bopi(nbosa)+bopi2(nbosa))
+ 
+      voptlp2=0.50*(stlp(ity2)-aval(ity2))
+      diffvlp2=dfvl*(voptlp2-vlptemp(iat2))
+      deadpibo1=(dvov1dsumov*deaudvov1+deaudsumov)*
+     $(abo(iat2)-aval(ity2)-diffvlp2)
+ 
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(nbosa)
+      ihu=idbo(nbosa,i4)
+      do k1=1,3
+      ftmp = deadpibo1*
+     $(dbopindc(nbosa,k1,i4)+dbopi2ndc(nbosa,k1,i4))
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(nbosa)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(nbosa)
+                  ihu=idbo(nbosa,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      do i3=1,ia(iat2,2)
+      iob=ia(iat2,2+i3)
+      ncubo=nubon2(iat2,i3)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = deadvov2*(1.0+dfvl*dvlpdsbo(iat2))*
+     $dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+ 
+      endif
+
+      end do
+
+
+   30 continue
+ 
+**********************************************************************
+*                                                                    *
+*     Calculate correction for C2                                    *
+*                                                                    *
+**********************************************************************
+      if (abs(vpar(6)).gt.0.001) then
+      do 40 i1=1,na_local
+      ity1=ia(i1,1)
+      vov4=abo(i1)-aval(ity1)
+ 
+      do i2=1,ia(i1,2)
+      iat2=ia(i1,2+i2)
+      nbohu=nubon2(i1,i2)
+      if (bo(nbohu).gt.0.0) then
+ 
+      ibt=ib(nbohu,1)
+      elph=zero
+      deahu2dbo=zero
+      deahu2dsbo=zero
+      vov3=bo(nbohu)-vov4-0.040*(vov4**4)
+      if (vov3.gt.3.0) then
+      elph=vpar(6)*(vov3-3.0)*(vov3-3.0)
+      deahu2dbo=2.0*vpar(6)*(vov3-3.0)
+      deahu2dsbo=2.0*vpar(6)*(vov3-3.0)*(-1.0-
+     $0.16*(vov4**3))
+      end if
+ 
+      elp=elp+elph
+      estrain(i1)=estrain(i1)+elph !atom energy
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(nbohu)
+      ihu=idbo(nbohu,i3)
+      do k1=1,3
+      ftmp = deahu2dbo*dbondc(nbohu,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(nbohu)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(nbohu)
+                  ihu=idbo(nbohu,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      do i3=1,ia(i1,2)
+      iob=ia(i1,2+i3)
+      ncubo=nubon2(i1,i3)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = deahu2dsbo*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      end if
+      end do
+
+      end if
+      end do
+ 
+   40 continue
+      end if
+
+      return
+      end
+**********************************************************************
+********************************************************************** 
+
+      subroutine molen
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbkconst.blk"
+#include "cbkc.blk"
+#include "cbkd.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbknmolat.blk"
+#include "cbknubon2.blk"
+#include "control.blk"
+#include "small.blk"
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate molecular energy and first derivatives               *
+*     Only used to prevent creating virtual electrons                *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In molen'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      emol=zero
+      return
+      do i1=1,nmolo
+
+      enelm=0.0
+      do i2=1,na
+      if (ia(i2,3+mbond).eq.i1) then
+      it1=ia(i2,1)
+      enelm=enelm+aval(it1)
+      end if
+      end do
+
+      na1m=nmolat(i1,1)
+
+      enelm=2*int(enelm*0.50)
+*     enelm=elmol(i1)
+      bomsum=zero
+      do i2=1,na1m
+      ihu=nmolat(i1,i2+1)
+      do i3=1,ia(ihu,2)
+      ihu2=nubon2(ihu,i3)
+      bomsum=bomsum+bo(ihu2)
+      end do
+      end do
+      diff=(bomsum-enelm)
+      exphu=exp(-vpar(37)*diff)
+      exphu2=1.0/(1.0+15.0*exphu)
+      emolh=zero
+      demoldsbo=zero
+      emolh=vpar(38)*exphu2
+      emol=emol+emolh
+      demoldsbo=vpar(38)*vpar(37)*15.0*exphu2*exphu2*exphu
+
+      do i2=1,na1m
+      ihu1=nmolat(i1,i2+1)
+      do i3=1,ia(ihu1,2)
+      iob=ia(ihu1,2+i3)
+      ncubo=nubon2(ihu1,i3)
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i4=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i4)
+      do k1=1,3
+      ftmp = demoldsbo*dbondc(ncubo,k1,i4)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i4=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i4)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      end do
+      end do
+
+
+      end do
+
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine valang
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkbopi.blk"
+#include "cbkbopi2.blk"
+#include "cbkconst.blk"
+#include "cbkc.blk"
+#include "cbkd.blk"
+#include "cbkdbopi2ndc.blk"
+#include "cbkdbopindc.blk"
+#include "cbkdcell.blk"
+#include "cbkdhdc.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkh.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbklonpar.blk"
+#include "cbknubon2.blk"
+#include "cbkvalence.blk"
+#include "control.blk"
+#include "valang.blk"
+#include "small.blk"
+      dimension j(3)
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate valency angle energies and first derivatives         *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In valang'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+*     eco=0.0
+      ev=0.0
+      ecoa=0.0
+      if (nval.eq.0) return
+
+      do 10 i1=1,nval
+      ity=iv(i1,1)
+      j(1)=iv(i1,2)
+      j(2)=iv(i1,3)
+      j(3)=iv(i1,4)
+
+      if (j(2) .le. na_local) then
+
+      la=iv(i1,5)
+      lb=iv(i1,6)
+      boa=bo(la)-cutof2
+      bob=bo(lb)-cutof2
+      if (boa.lt.zero.or.bob.lt.zero) goto 10
+
+      hl=h(i1)     ! Calculated earlier in routine calval
+********************************************************************** 
+*                                                                    *
+*     Calculate valency angle energy                                 *
+*                                                                    *
+********************************************************************** 
+      nbocen=ia(j(2),2)
+      sbo2=0.0
+      vmbo=1.0
+     
+      do i2=1,nbocen
+      ibv=nubon2(j(2),i2)
+      if (bo(ibv).gt.0.0) then
+      vmbo=vmbo*exp(-bo(ibv)**8)
+      sbo2=sbo2+bopi(ibv)+bopi2(ibv)
+      endif
+      end do
+
+      ity2=ia(j(2),1)
+*     exbo=abo(j(2))-stlp(ia(j(2),1))
+      exbo=abo(j(2))-valf(ity2)
+*     if (exbo.gt.zero) exbo=zero
+*     expov=exp(vka8(ity)*exbo)
+*     expov2=exp(-vpar(13)*exbo)
+*     htov1=2.0+expov2
+*     htov2=1.0+expov+expov2
+*     evboadj=htov1/htov2
+      evboadj=1.0
+      expun=exp(-vkac(ity)*exbo)
+      expun2=exp(vpar(15)*exbo)
+      htun1=2.0+expun2
+      htun2=1.0+expun+expun2
+      evboadj2=vval4(ity2)-(vval4(ity2)-1.0)*htun1/htun2
+********************************************************************** 
+*                                                                    *
+*     Calculate number of lone pairs                                 *
+*                                                                    *
+********************************************************************** 
+      dsbo2dvlp=(1.0-vmbo)
+      vlpadj=zero
+      exlp1=abo(j(2))-stlp(ia(j(2),1))
+      exlp2=2.0*int(exlp1/2.0)
+      exlp=exlp1-exlp2
+      if (exlp.lt.zero) then
+*     expvlp=exp(-vpar(16)*(2.0+exlp)*(2.0+exlp))
+*     vlpadj=expvlp-int(exlp1/2.0)
+*     dsbo2dvlp=(1.0-vmbo)*(1.0-vpar(34)*2.0*
+*     $(2.0+exlp)*vpar(16)*expvlp)
+      vlpadj=vlp(j(2))
+      dsbo2dvlp=(1.0-vmbo)*(1.0+vpar(34)*dvlpdsbo(j(2)))
+      end if
+
+      sbo2=sbo2+(1.0-vmbo)*(-exbo-vpar(34)*vlpadj)
+      dsbo2dvmbo=exbo+vpar(34)*vlpadj
+
+      sbo2h=sbo2
+      powv=vpar(17)
+      if (sbo2.le.0.0) sbo2h=0.0
+      if (sbo2.gt.0.0.and.sbo2.le.1.0) sbo2h=sbo2**powv
+      if (sbo2.gt.1.0.and.sbo2.lt.2.0) sbo2h=2.0-(2.0-sbo2)**powv
+      if (sbo2.gt.2.0) sbo2h=2.0
+      thba=th0(ity)
+      expsbo=exp(-vpar(18)*(2.0-sbo2h))
+      thetao=180.0-thba*(1.0-expsbo)
+
+      thetao=thetao*dgrrdn
+      thdif=(thetao-hl)
+      thdi2=thdif*thdif
+      dthsbo=dgrrdn*thba*vpar(18)*expsbo
+      if (sbo2.lt.0.0) dthsbo=zero
+      if (sbo2.gt.0.0.and.sbo2.le.1.0) 
+     $dthsbo=powv*(sbo2**(powv-1.0))*dgrrdn*thba*vpar(18)*expsbo
+      if (sbo2.gt.1.0.and.sbo2.lt.2.0) 
+     $dthsbo=powv*((2.0-sbo2)**(powv-1.0))*dgrrdn*thba*vpar(18)*expsbo
+      if (sbo2.gt.2.0) dthsbo=zero
+
+      exphu=vka(ity)*exp(-vka3(ity)*thdi2)
+      exphu2=vka(ity)-exphu
+      if (vka(ity).lt.zero) exphu2=exphu2-vka(ity)             !To avoid linear Me-H-Me angles (6/6/06)
+      boap=boa**vval2(ity)
+      boap2=boa**(vval2(ity)-1.0)
+      bobp=bob**vval2(ity)
+      bobp2=bob**(vval2(ity)-1.0)
+      exa=exp(-vval1(ity2)*boap)
+      exb=exp(-vval1(ity2)*bobp)
+      dexadboa=vval2(ity)*vval1(ity2)*exa*boap2
+      dexbdbob=vval2(ity)*vval1(ity2)*exb*bobp2
+      exa2=(1.0-exa)
+      exb2=(1.0-exb)
+
+      evh=evboadj2*evboadj*exa2*exb2*exphu2
+      devdlb=evboadj2*evboadj*dexbdbob*exa2*exphu2
+      devdla=evboadj2*evboadj*dexadboa*exb2*exphu2
+      devdsbo=2.0*evboadj2*evboadj*dthsbo*exa2*exb2*
+     $vka3(ity)*thdif*exphu
+      devdh=-2.0*evboadj2*evboadj*exa2*exb2*vka3(ity)*thdif*exphu
+
+      devdsbo2=
+     $evboadj*exa2*exb2*exphu2*(vval4(ity2)-1.0)*(-vpar(15)*expun2/htun2
+     $+htun1*(vpar(15)*expun2-vkac(ity)*expun)/(htun2*htun2))
+
+*     devdsbo2=-evboadj2*exa2*exb2*exphu2*(vpar(13)*expov2/htov2+
+*    $htov1*(vka8(ity)*expov-vpar(13)*expov2)/(htov2*htov2))+
+*    $evboadj*exa2*exb2*exphu2*(vpar(14)-1.0)*(-vpar(15)*expun2/htun2
+*    $+htun1*(vpar(15)*expun2-vkac(ity)*expun)/(htun2*htun2))
+
+      if (j(2) .le. na_local) then
+         ev=ev+evh
+         estrain(j(2))=estrain(j(2))+evh         !central atom energy
+      endif
+
+*     write (64,'(4i8,18f8.2)')mdstep,j(1),j(2),j(3),sbo2,sbo2h,
+*    $thetao*rdndgr,hl*rdndgr,bo(la),bo(lb),bopi(la),
+*    $vlp(j(2)),exbo,vlpadj,vmbo,evh,ev,vka(ity)
+********************************************************************** 
+*                                                                    *
+*     Calculate penalty for two double bonds in valency angle        *
+*                                                                    *
+********************************************************************** 
+      exbo=abo(j(2))-aval(ia(j(2),1))
+      expov=exp(vpar(22)*exbo)
+      expov2=exp(-vpar(21)*exbo)
+      htov1=2.0+expov2
+      htov2=1.0+expov+expov2
+      ecsboadj=htov1/htov2
+      exphu1=exp(-vpar(20)*(boa-2.0)*(boa-2.0))
+      exphu2=exp(-vpar(20)*(bob-2.0)*(bob-2.0))
+
+      epenh=vkap(ity)*ecsboadj*exphu1*exphu2
+      estrain(j(2))=estrain(j(2))+epenh
+      epen=epen+epenh
+      decoadboa=-2.0*vpar(20)*epenh*(boa-2.0)
+      decoadbob=-2.0*vpar(20)*epenh*(bob-2.0)
+
+      decdsbo2=-vkap(ity)*exphu1*exphu2*(vpar(21)*expov2/htov2+htov1*
+     $(vpar(22)*expov-vpar(21)*expov2)/(htov2*htov2))
+**********************************************************************
+*                                                                    *
+*     Calculate valency angle conjugation energy                     *
+*                                                                    *
+**********************************************************************
+      unda=abo(j(1))-boa
+*     ovb=abo(j(2))-valf(ia(j(2),1))
+      ovb=abo(j(2))-vval3(ia(j(2),1))    !Modification for Ru  7/6/2004
+
+      undc=abo(j(3))-bob
+      ba=(boa-1.50)*(boa-1.50)
+      bb=(bob-1.50)*(bob-1.50)
+      exphua=exp(-vpar(31)*ba)
+      exphub=exp(-vpar(31)*bb)
+      exphuua=exp(-vpar(39)*unda*unda)
+      exphuob=exp(vpar(3)*ovb)
+      exphuuc=exp(-vpar(39)*undc*undc)
+      hulpob=1.0/(1.0+exphuob)
+      ecoah=vka8(ity)*exphua*exphub*exphuua*exphuuc*hulpob
+      decodbola=-2.0*vka8(ity)*(boa-1.50)*vpar(31)*exphua*exphub
+     $*exphuua*exphuuc*hulpob+vpar(39)*vka8(ity)*exphua*exphub*
+     $exphuua*exphuuc*hulpob*2.0*unda
+      decodbolb=-2.0*vka8(ity)*(bob-1.50)*vpar(31)*exphua*exphub
+     $*exphuua*exphuuc*hulpob+vpar(39)*vka8(ity)*exphua*exphub*
+     $exphuua*exphuuc*hulpob*2.0*undc
+      decodboua=-2.0*unda*vka8(ity)*vpar(39)*exphua*exphub
+     $*exphuua*exphuuc*hulpob
+      decodbouc=-2.0*undc*vka8(ity)*vpar(39)*exphua*exphub
+     $*exphuua*exphuuc*hulpob
+      decodboob=-vka8(ity)*exphua*exphub*exphuua*exphuuc*hulpob*
+     $hulpob*vpar(3)*exphuob
+*     decodboob=zero
+*     decodboua=zero
+*     decodbouc=zero
+
+      ecoa=ecoa+ecoah
+      estrain(j(2))=estrain(j(2))+ecoah !central atom energy
+
+********************************************************************** 
+*                                                                    *
+*     Calculate derivative valency energy to cartesian coordinates   *
+*                                                                    *
+********************************************************************** 
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do k1=1,3
+      do k2=1,3
+      ftmp = devdh*dhdc(i1,k1,k2)
+      d(k1,j(k2))=d(k1,j(k2))+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(j(k2),k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/3
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do k2=1,3
+                  ihu=j(k2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(la)
+      ihu=idbo(la,i2)
+      do k1=1,3
+      ftmp = (devdla+decoadboa+decodbola)*
+     $dbondc(la,k1,i2)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(la)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(la)
+                  ihu=idbo(la,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(lb)
+      ihu=idbo(lb,i2)
+      do k1=1,3
+      ftmp = (devdlb+decoadbob+decodbolb)*
+     $dbondc(lb,k1,i2)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(lb)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(lb)
+                  ihu=idbo(lb,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      do i2=1,nbocen
+      j5=ia(j(2),2+i2)
+      ibv=nubon2(j(2),i2)
+      if (bo(ibv).gt.0.0) then
+      dvmbodbo=-vmbo*8.0*bo(ibv)**7
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ibv)
+      ihu=idbo(ibv,i3)
+      do k1=1,3
+      ftmp = (-dsbo2dvlp*devdsbo+devdsbo2+decdsbo2
+     $+dvmbodbo*dsbo2dvmbo*devdsbo)*
+     $dbondc(ibv,k1,i3)+devdsbo*(dbopindc(ibv,k1,i3)+
+     $dbopi2ndc(ibv,k1,i3))
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ibv)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ibv)
+                  ihu=idbo(ibv,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+ 
+      do i2=1,ia(j(1),2)
+      j5=ia(j(1),2+i2)
+      ibv=nubon2(j(1),i2)
+      if (bo(ibv).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ibv)
+      ihu=idbo(ibv,i3)
+      do k1=1,3
+      ftmp = decodboua*dbondc(ibv,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ibv)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ibv)
+                  ihu=idbo(ibv,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+ 
+      do i2=1,ia(j(2),2)
+      j5=ia(j(2),2+i2)
+      ibv=nubon2(j(2),i2)
+      if (bo(ibv).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ibv)
+      ihu=idbo(ibv,i3)
+      do k1=1,3
+      ftmp = decodboob*dbondc(ibv,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ibv)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ibv)
+                  ihu=idbo(ibv,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+
+      do i2=1,ia(j(3),2)
+      j5=ia(j(3),2+i2)
+      ibv=nubon2(j(3),i2)
+      if (bo(ibv).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ibv)
+      ihu=idbo(ibv,i3)
+      do k1=1,3
+      ftmp = decodbouc*dbondc(ibv,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ibv)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ibv)
+                  ihu=idbo(ibv,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+
+      endif
+
+   10 continue
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine hbond
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkbo.blk"
+#include "cbkconst.blk"
+#include "cbkc.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cbkidbo.blk"
+#include "cbksrthb.blk"
+#include "control.blk"
+#include "cbkhbond.blk"
+#include "small.blk"
+      dimension drda(3),j(3),dvdc(3,3),dargdc(3,3)
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate hydrogen bond energies and first derivatives         *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In hbond'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      ehb=zero
+      do 10 i1=1,nhb
+      ityhb=ihb(i1,1)
+      j(1)=ihb(i1,2)
+      j(2)=ihb(i1,3)
+      j(3)=ihb(i1,4)
+      la=ihb(i1,5)
+      boa=bo(la)
+      call dista2(j(2),j(3),rda,dxm,dym,dzm)
+      drda(1)=dxm/rda
+      drda(2)=dym/rda
+      drda(3)=dzm/rda
+      call calvalhb(j(1),j(2),j(3),ix,iy,iz,arg,hhb(i1),dvdc,dargdc)
+      rhu1=rhb(ityhb)/rda
+      rhu2=rda/rhb(ityhb)
+      sinhu=sin(hhb(i1)/2.0)
+      sin2=sinhu*sinhu
+      exphu1=exp(-vhb1(ityhb)*boa)
+      exphu2=exp(-vhb2(ityhb)*(rhu1+rhu2-2.0))
+      ehbh=(1.0-exphu1)*dehb(ityhb)*exphu2*sin2*sin2*sin2*sin2
+      ehb=ehb+ehbh
+      estrain(j(2))=estrain(j(2))+ehbh !2nd atom energy
+
+********************************************************************** 
+*                                                                    *
+*     Calculate first derivatives                                    *
+*                                                                    *
+********************************************************************** 
+      dehbdbo=vhb1(ityhb)*exphu1*dehb(ityhb)*exphu2*sin2*sin2*
+     $sin2*sin2
+      dehbdv=(1.0-exphu1)*dehb(ityhb)*exphu2*
+     $4.0*sin2*sin2*sin2*sinhu*cos(hhb(i1)/2.0)
+      dehbdrda=(1.0-exphu1)*dehb(ityhb)*sin2*sin2*sin2*sin2*
+     $vhb2(ityhb)*(rhb(ityhb)/(rda*rda)-1.0/rhb(ityhb))*exphu2
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do k1=1,3
+      ftmp = dehbdrda*drda(k1)
+      d(k1,j(2))=d(k1,j(2))+ftmp
+      d(k1,j(3))=d(k1,j(3))-ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+
+     $        ftmp*c(j(2),k1p)-ftmp*c(j(3),k1p)
+      end do
+      endif
+
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/2
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               ihu = j(2)
+               atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               ihu = j(3)
+               atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do k1=1,3
+      do k2=1,3
+      ftmp = dehbdv*dvdc(k1,k2)
+      d(k1,j(k2))=d(k1,j(k2))+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(j(k2),k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/3
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do k2=1,3
+                  ihu=j(k2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(la)
+      ihu=idbo(la,i2)
+      do k1=1,3
+      ftmp = dehbdbo*dbondc(la,k1,i2)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(la)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(la)
+                  ihu=idbo(la,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+   10 continue
+      return
+      end 
+
+********************************************************************** 
+********************************************************************** 
+
+      subroutine torang
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkabo.blk"
+#include "cbkbo.blk"
+#include "cbkbopi.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdbopindc.blk"
+#include "cbkdcell.blk"
+#include "cbkdhdc.blk"
+#include "cbkdrdc.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkfftorang.blk"
+#include "cbkh.blk"
+#include "cbkia.blk"
+#include "cbkidbo.blk"
+#include "cbkinit.blk"
+#include "cbknubon2.blk"
+#include "cbkrbo.blk"
+#include "cbktorang.blk"
+#include "cbktorsion.blk"
+#include "cbktregime.blk"
+#include "cbkvalence.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+
+      DIMENSION  A(3),DRDA(3),DADC(4),DRADC(3,4),DRBDC(3,4),
+     $DRCDC(3,4),DHDDC(3,4),DHEDC(3,4),DRVDC(3,4),DTDC(3,4),
+     $DNDC(3,4)
+      dimension j(4),dh1rdc(3,3),dh2rdc(3,3),dargdc(3,3)
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate torsion angle energies and first derivatives         *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In torang'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      do k1=1,3
+      do k2=1,4
+      dhddc(k1,k2)=0.0
+      dhedc(k1,k2)=0.0
+      dradc(k1,k2)=0.0
+      drbdc(k1,k2)=0.0
+      drcdc(k1,k2)=0.0
+      end do
+      end do
+      et=0.0
+      eth12=0.0
+      eco=0.0
+      dadc(1)=1.0
+      dadc(2)=0.0
+      dadc(3)=0.0
+      dadc(4)=-1.0
+      if (ntor.eq.0) return
+
+      do 10 i1=1,ntor
+      j(1)=it(i1,2)
+      j(2)=it(i1,3)
+      j(3)=it(i1,4)
+      j(4)=it(i1,5)
+
+      ity=it(i1,1)  
+      la=it(i1,6)
+      lb=it(i1,7)
+      lc=it(i1,8)
+      call calvalres(j(1),j(2),j(3),arg1,ht1,dh1rdc,dargdc)
+      call calvalres(j(2),j(3),j(4),arg2,ht2,dh2rdc,dargdc)
+      boa=bo(la)-cutof2
+      bob=bo(lb)-cutof2
+      boc=bo(lc)-cutof2
+      if (boa.lt.zero.or.bob.lt.zero.or.boc.lt.zero) 
+     $goto 10
+      r42=0.0
+      ivl1=ibsym(la)
+      ivl2=ibsym(lb)
+      ivl3=ibsym(lc)
+      isign1=1
+      isign2=1
+      isign3=1
+      rla=rbo(la)
+      rlb=rbo(lb)
+ 
+      call dista2(j(1),j(4),r4,a(1),a(2),a(3))
+********************************************************************** 
+*                                                                    *
+*     Determine torsion angle                                        *
+*                                                                    *
+********************************************************************** 
+      d142=r4*r4
+      rla=rbo(la)
+      rlb=rbo(lb)
+      rlc=rbo(lc)
+      coshd=cos(ht1)
+      coshe=cos(ht2)
+      sinhd=sin(ht1)
+      sinhe=sin(ht2)
+      poem=2.0*rla*rlc*sinhd*sinhe
+      poem2=poem*poem
+      tel=rla*rla+rlb*rlb+rlc*rlc-d142-2.0*(rla*rlb*coshd-rla*rlc*
+     $coshd*coshe+rlb*rlc*coshe)
+      if (poem.lt.1e-20) poem=1e-20
+      arg=tel/poem
+      if (arg.gt.1.0) arg=1.0
+      if (arg.lt.-1.0) arg=-1.0
+      arg2=arg*arg
+      thg(i1)=acos(arg)*rdndgr
+      k1=j(1)
+      k2=j(2)
+      k3=j(3)
+      k4=j(4)
+      call dista2(k3,k2,dis,x3,y3,z3)
+      y32z32=y3*y3+z3*z3
+      wort1=sqrt(y32z32)+1e-6
+      wort2=sqrt(y32z32+x3*x3)+1e-6
+*     if (wort1.lt.1e-6) wort1=1e-6
+*     if (wort2.lt.1e-6) wort2=1e-6
+      sinalf=y3/wort1
+      cosalf=z3/wort1
+      sinbet=x3/wort2
+      cosbet=wort1/wort2
+      call dista2(k1,k2,dis,x1,y1,z1)
+      x1=x1*cosbet-y1*sinalf*sinbet-z1*cosalf*sinbet
+      y1=y1*cosalf-z1*sinalf
+      wort3=sqrt(x1*x1+y1*y1)+1e-6
+*     if (wort3.lt.1e-6) wort3=1e-6
+      singam=y1/wort3
+      cosgam=x1/wort3
+      call dista2(k4,k2,dis,x4,y4,z4)
+      x4=x4*cosbet-y4*sinalf*sinbet-z4*cosalf*sinbet
+      y4=y4*cosalf-z4*sinalf
+      y4=x4*singam-y4*cosgam
+      if (y4.gt.0.0) thg(i1)=-thg(i1)
+      if (thg(i1).lt.-179.999999d0) thg(i1)=-179.999999d0
+      if (thg(i1).gt.179.999999d0) thg(i1)=179.999999d0
+      th2=thg(i1)*dgrrdn
+********************************************************************** 
+*                                                                    *
+*     Calculate torsion angle energy                                 *
+*                                                                    *
+********************************************************************** 
+      exbo1=abo(j(2))-valf(ia(j(2),1))
+      exbo2=abo(j(3))-valf(ia(j(3),1))
+      htovt=exbo1+exbo2
+      expov=exp(vpar(26)*htovt)
+      expov2=exp(-vpar(25)*(htovt))
+      htov1=2.0+expov2
+      htov2=1.0+expov+expov2
+      etboadj=htov1/htov2
+
+      btb2=bopi(lb)-1.0+etboadj
+      bo2t=1.0-btb2
+      bo2p=bo2t*bo2t
+      bocor2=exp(v4(ity)*bo2p)
+
+      hsin=sinhd*sinhe
+      ethhulp=0.50*v1(ity)*(1.0+arg)+v2(ity)*bocor2*(1.0-arg2)+
+     $v3(ity)*(0.50+2.0*arg2*arg-1.50*arg)
+
+      exphua=exp(-vpar(24)*boa)
+      exphub=exp(-vpar(24)*bob)
+      exphuc=exp(-vpar(24)*boc)
+      bocor4=(1.0-exphua)*(1.0-exphub)*(1.0-exphuc)
+      eth=hsin*ethhulp*bocor4
+
+      detdar=hsin*bocor4*(0.50*v1(ity)-2.0*v2(ity)*bocor2*arg+
+     $v3(ity)*(6.0*arg2-1.5d0))
+      detdhd=coshd*sinhe*bocor4*ethhulp
+      detdhe=sinhd*coshe*bocor4*ethhulp
+
+      detdboa=vpar(24)*exphua*(1.0-exphub)*(1.0-exphuc)*ethhulp*hsin
+      detdbopib=-bocor4*2.0*v4(ity)*v2(ity)*
+     $bo2t*bocor2*(1.0-arg2)*hsin
+      detdbob=vpar(24)*exphub*(1.0-exphua)*
+     $(1.0-exphuc)*ethhulp*hsin
+      detdboc=vpar(24)*exphuc*(1.0-exphua)*
+     $(1.0-exphub)*ethhulp*hsin
+
+      detdsbo1=-(detdbopib)*
+     $(vpar(25)*expov2/htov2+htov1*
+     $(vpar(26)*expov-vpar(25)*expov2)/(htov2*htov2))
+
+      et=et+eth
+      estrain(j(2))=estrain(j(2))+0.50*eth !2nd atom energy
+      estrain(j(3))=estrain(j(3))+0.50*eth !3rd atom energy
+
+********************************************************************** 
+*                                                                    *
+*     Calculate conjugation energy                                   *
+*                                                                    *
+********************************************************************** 
+      ba=(boa-1.50)*(boa-1.50)
+      bb=(bob-1.50)*(bob-1.50)
+      bc=(boc-1.50)*(boc-1.50)
+      exphua1=exp(-vpar(28)*ba)
+      exphub1=exp(-vpar(28)*bb)
+      exphuc1=exp(-vpar(28)*bc)
+      sbo=exphua1*exphub1*exphuc1
+      dbohua=-2.0*(boa-1.50)*vpar(28)*exphua1*exphub1*exphuc1
+      dbohub=-2.0*(bob-1.50)*vpar(28)*exphua1*exphub1*exphuc1
+      dbohuc=-2.0*(boc-1.50)*vpar(28)*exphua1*exphub1*exphuc1
+      arghu0=(arg2-1.0)*sinhd*sinhe
+      ehulp=vconj(ity)*(arghu0+1.0)
+      ecoh=ehulp*sbo
+      decodar=sbo*vconj(ity)*2.0*arg*sinhd*sinhe
+      decodbola=dbohua*ehulp
+      decodbolb=dbohub*ehulp
+      decodbolc=dbohuc*ehulp
+      decodhd=coshd*sinhe*vconj(ity)*sbo*(arg2-1.0)
+      decodhe=coshe*sinhd*vconj(ity)*sbo*(arg2-1.0)
+
+      eco=eco+ecoh
+      estrain(j(2))=estrain(j(2))+0.50*ecoh !2nd atom energy
+      estrain(j(3))=estrain(j(3))+0.50*ecoh !3rd atom energy
+
+    1 continue
+********************************************************************** 
+*                                                                    *
+*     Calculate derivative torsion angle and conjugation energy      *
+*     to cartesian coordinates                                       *
+*                                                                    *
+********************************************************************** 
+      SINTH=SIN(THG(i1)*DGRRDN)
+      IF (SINTH.GE.0.0.AND.SINTH.LT.1.0D-10) SINTH=1.0D-10
+      IF (SINTH.LT.0.0.AND.SINTH.GT.-1.0D-10) SINTH=-1.0D-10
+      IF (j(1).EQ.IB(LA,2)) THEN
+      DO  K1=1,3
+      DRADC(K1,1)=DRDC(LA,K1,1)
+      DRADC(K1,2)=DRDC(LA,K1,2)
+      end do
+      ELSE
+      DO  K1=1,3
+      DRADC(K1,1)=DRDC(LA,K1,2)
+      DRADC(K1,2)=DRDC(LA,K1,1)
+      end do
+      ENDIF
+      IF (j(2).EQ.IB(LB,2)) THEN
+      DO  K1=1,3
+      DRBDC(K1,2)=DRDC(LB,K1,1)
+      DRBDC(K1,3)=DRDC(LB,K1,2)
+      end do
+      ELSE
+      DO K1=1,3
+      DRBDC(K1,2)=DRDC(LB,K1,2)
+      DRBDC(K1,3)=DRDC(LB,K1,1)
+      end do
+      ENDIF
+      IF (j(3).EQ.IB(LC,2)) THEN
+      DO K1=1,3
+      DRCDC(K1,3)=DRDC(LC,K1,1)
+      DRCDC(K1,4)=DRDC(LC,K1,2)
+      end do
+      ELSE
+      DO K1=1,3
+      DRCDC(K1,3)=DRDC(LC,K1,2)
+      DRCDC(K1,4)=DRDC(LC,K1,1)
+      end do
+      ENDIF
+
+      do k1=1,3
+      dhddc(1,k1)=dh1rdc(1,k1)
+      dhddc(2,k1)=dh1rdc(2,k1)
+      dhddc(3,k1)=dh1rdc(3,k1)
+      dhedc(1,k1+1)=dh2rdc(1,k1)
+      dhedc(2,k1+1)=dh2rdc(2,k1)
+      dhedc(3,k1+1)=dh2rdc(3,k1)
+      end do
+
+********************************************************************** 
+*     write (64,*)j(1),j(2),j(3),j(4)
+*     do k1=1,3
+*     write (64,'(10f12.4)')(dh1rdc(k1,k2),k2=1,3),
+*    $(dhdc(ld,k1,k2),k2=1,3),(dhddc(k1,k2),k2=1,4)
+*     write (64,'(10f12.4)')(dh2rdc(k1,k2),k2=1,3),
+*    $(dhdc(le,k1,k2),k2=1,3),(dhedc(k1,k2),k2=1,4)
+*     end do
+*     write (64,*)
+********************************************************************** 
+      HTRA=RLA+COSHD*(RLC*COSHE-RLB)
+      HTRB=RLB-RLA*COSHD-RLC*COSHE
+      HTRC=RLC+COSHE*(RLA*COSHD-RLB)
+      HTHD=RLA*SINHD*(RLB-RLC*COSHE)
+      HTHE=RLC*SINHE*(RLB-RLA*COSHD)
+      HNRA=RLC*SINHD*SINHE
+      HNRC=RLA*SINHD*SINHE
+      HNHD=RLA*RLC*COSHD*SINHE
+      HNHE=RLA*RLC*SINHD*COSHE
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      DO  K1=1,3
+      DRDA(K1)=A(K1)/R4
+      DO  K2=1,4
+      DRVDC(K1,K2)=DRDA(K1)*DADC(K2)
+      DTDC(K1,K2)=2.0*(DRADC(K1,K2)*HTRA+DRBDC(K1,K2)*HTRB+DRCDC(K1,K2
+     $)*HTRC-DRVDC(K1,K2)*R4+DHDDC(K1,K2)*HTHD+DHEDC(K1,K2)*HTHE)
+      DNDC(K1,K2)=2.0*(DRADC(K1,K2)*HNRA+DRCDC(K1,K2)*HNRC+DHDDC(K1,K2
+     $)*HNHD+DHEDC(K1,K2)*HNHE)
+      DARGTDC(i1,K1,K2)=(DTDC(K1,K2)-ARG*DNDC(K1,K2))/POEM
+ 
+      ftmp = DARGTDC(i1,K1,K2)*detdar+
+     $dargtdc(i1,k1,k2)*decodar+(detdhd+decodhd)*dhddc(k1,k2)+
+     $(detdhe+decodhe)*dhedc(k1,k2)
+      D(K1,J(K2))=D(K1,J(K2))+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(j(k2),k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/4
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do k2=1,4
+                  ihu=j(k2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(la)
+      ihu=idbo(la,i2)
+      do k1=1,3
+      ftmp = dbondc(la,k1,i2)*(detdboa+decodbola)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(la)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(la)
+                  ihu=idbo(la,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(lb)
+      ihu=idbo(lb,i2)
+      do k1=1,3
+         ftmp = dbondc(lb,k1,i2)*(detdbob+decodbolb)
+     $   +dbopindc(lb,k1,i2)*detdbopib
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(lb)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(lb)
+                  ihu=idbo(lb,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i2=1,idbo1(lc)
+      ihu=idbo(lc,i2)
+      do k1=1,3
+      ftmp = dbondc(lc,k1,i2)*(detdboc+decodbolc)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(lc)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i2=1,idbo1(lc)
+                  ihu=idbo(lc,i2)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      do i2=1,ia(j(2),2)
+      iob=ia(j(2),2+i2)
+      ncubo=nubon2(j(2),i2)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i3)
+      do k1=1,3
+      ftmp = detdsbo1*dbondc(ncubo,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+
+      do i2=1,ia(j(3),2)
+      iob=ia(j(3),2+i2)
+      ncubo=nubon2(j(3),i2)
+      if (bo(ncubo).gt.0.0) then
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do i3=1,idbo1(ncubo)
+      ihu=idbo(ncubo,i3)
+      do k1=1,3
+      ftmp = detdsbo1*dbondc(ncubo,k1,i3)
+      d(k1,ihu)=d(k1,ihu)+ftmp
+
+      if (Lvirial.eq.1) then
+      do k1p=1,3
+      virial_tmp(k1,k1p)=virial_tmp(k1,k1p)+ftmp*c(ihu,k1p)
+      end do
+      endif
+
+      end do
+      end do
+
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/idbo1(ncubo)
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               do i3=1,idbo1(ncubo)
+                  ihu=idbo(ncubo,i3)
+                  atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               end do
+            end do
+         endif
+
+      endif
+
+      endif
+      end do
+
+   10 continue 
+
+      return
+      end 
+********************************************************************** 
+********************************************************************** 
+
+      subroutine nonbon
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkch.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cbkff.blk"
+#include "cbkia.blk"
+#include "cbknonbon.blk"
+#include "cbkpairs.blk"
+#include "cbknvlown.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+
+      dimension a(3),da(6)
+      dimension virial_tmp(3,3),virialsym(6)
+********************************************************************** 
+*                                                                    *
+*     Calculate vdWaals and Coulomb energies and derivatives         *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In nonbon'
+c$$$      call timer(65)
+c$$$      end if
+
+      ew=0.0
+      ep=0.0
+
+      c1c=332.0638
+      third=one/three
+      fothird=4.0/3.0
+      twothird=2.0/3.0
+      h15=(vpar(29)-1.0)/vpar(29)
+
+      nptmp=0
+      nstmp=0
+      do 10 ivl=1,nvpair-nvlself
+c Use precomputed midpoint criterion to decide if interaction is owned.
+      if (nvlown(ivl).eq.1) then
+
+      i1=nvl1(ivl)
+      i2=nvl2(ivl)
+
+      call dista2(i1,i2,rr,a(1),a(2),a(3))
+      if (rr.gt.swb.or.rr.lt.0.001) goto 10
+
+      ity1=ia(i1,1)
+      ity2=ia(i2,1)
+      imol1=iag(i1,3+mbond)
+      imol2=iag(i2,3+mbond)
+      rr2=rr*rr
+
+      sw=1.0
+      sw1=0.0
+      call taper(rr,rr2)
+**********************************************************************
+*                                                                    *
+*     Calculate vdWaals energy                                       *
+*                                                                    *
+**********************************************************************
+      p1=p1co(ity1,ity2)
+      p2=p2co(ity1,ity2)
+      p3=p3co(ity1,ity2)
+      hulpw=(rr**vpar(29)+gamwco(ity1,ity2))
+      rrw=hulpw**(1.0/vpar(29))
+      h1=exp(p3*(1.0-rrw/p1))
+      h2=exp(0.50*p3*(1.0-rrw/p1))
+
+      ewh=p2*(h1-2.0*h2)
+      rrhuw=rr**(vpar(29)-1.0)
+      dewdr=(p2*p3/p1)*(h2-h1)*rrhuw*(hulpw**(-h15))
+
+**********************************************************************
+*                                                                    *
+*     Calculate Coulomb energy                                       *
+*                                                                    *
+**********************************************************************
+      q1q2=ch(i1)*ch(i2)
+      hulp1=(rr2*rr+gamcco(ity1,ity2))
+      eph=c1c*q1q2/(hulp1**third)
+      depdr=-c1c*q1q2*rr2/(hulp1**fothird)
+**********************************************************************
+*                                                                    *
+*     Taper correction                                               *
+*                                                                    *
+**********************************************************************
+      ephtap=eph*sw
+      depdrtap=depdr*sw+eph*sw1
+      ewhtap=ewh*sw
+      dewdrtap=dewdr*sw+ewh*sw1
+
+*     write (64,*)i1,i2,p1,p2,p3,gamwco(ity1,ity2),vpar(29),ewh,ew
+      ew=ew+ewhtap
+      ep=ep+ephtap
+      estrain(i1)=estrain(i1)+0.50*(ewhtap+ephtap) !1st atom energy
+      estrain(i2)=estrain(i2)+0.50*(ewhtap+ephtap) !2nd atom energy
+
+**********************************************************************
+*                                                                    *
+*     Calculate derivatives vdWaals energy to cartesian              *
+*     coordinates                                                    *
+*                                                                    *
+**********************************************************************
+
+      if (Lvirial.eq.1) then
+         do k1=1,3
+         do k2=1,3
+            virial_tmp(k1,k2) = 0.0
+         end do
+         end do
+      endif
+
+      do k4=1,3
+         ftmp = (dewdrtap+depdrtap)*(a(k4)/rr)
+         d(k4,i1)=d(k4,i1)+ftmp
+         d(k4,i2)=d(k4,i2)-ftmp
+         if (Lvirial.eq.1) then
+            do k1p=1,3
+               virial_tmp(k4,k1p)=virial_tmp(k4,k1p)+
+     $              ftmp*c(i1,k1p)-ftmp*c(i2,k1p)
+            end do
+         endif
+      end do
+
+      if (Lvirial.eq.1) then
+         virialsym(1) = virial_tmp(1,1)
+         virialsym(2) = virial_tmp(2,2)
+         virialsym(3) = virial_tmp(3,3)
+         virialsym(4) = virial_tmp(1,2)
+         virialsym(5) = virial_tmp(1,3)
+         virialsym(6) = virial_tmp(2,3)
+         do k1 = 1,6
+            virial(k1) = virial(k1) + virialsym(k1)
+         end do
+
+         if (Latomvirial.eq.1) then
+            frac = 1.0d0/2
+            do k1 = 1,6
+               vtmp = virialsym(k1)*frac
+               ihu=i1
+               atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+               ihu=i2
+               atomvirial(k1,ihu) = atomvirial(k1,ihu) + vtmp
+            end do
+         endif
+
+      endif
+
+      endif
+
+   10 continue
+
+      return
+      end
+
+********************************************************************** 
+**********************************************************************
+ 
+      subroutine efield
+ 
+**********************************************************************
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkch.blk"
+#include "cbkcha.blk"
+#include "cbkd.blk"
+#include "cbkefield.blk"
+#include "cbkenergies.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "small.blk"
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In efield'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+**********************************************************************
+*                                                                    *
+*     Electric field                                                 *
+*                                                                    *
+**********************************************************************
+      efi=0.0
+      efix=0.0
+      efiy=0.0
+      efiz=0.0
+      c1c=332.0638       !Coulomb energy conversion
+      c1=23.02           !conversion from kcal to eV
+ 
+      if (ifieldx.eq.1) then
+      do i1=1,na
+      efih=vfieldx*c1*c1c*ch(i1)*c(i1,1)
+      efix=efix+efih
+      estrain(i1)=estrain(i1)+efih               !atom energy
+
+      defidc=c1*c1c*vfieldx*ch(i1)
+      d(1,i1)=d(1,i1)+defidc
+      end do
+      end if
+ 
+      if (ifieldy.eq.1) then
+      do i1=1,na
+      efih=vfieldy*c1*c1c*ch(i1)*c(i1,2)
+      efiy=efiy+efih
+      estrain(i1)=estrain(i1)+efih               !atom energy
+
+      defidc=c1*c1c*vfieldy*ch(i1)
+      d(2,i1)=d(2,i1)+defidc
+      end do
+      end if
+ 
+      if (ifieldz.eq.1) then
+      do i1=1,na
+      efih=vfieldz*c1*c1c*ch(i1)*c(i1,3)
+      efiz=efiz+efih
+      estrain(i1)=estrain(i1)+efih               !atom energy
+
+      defidc=c1*c1c*vfieldz*ch(i1)
+      d(3,i1)=d(3,i1)+defidc
+      end do
+      end if
+ 
+      efi=efix+efiy+efiz
+      return
+      end
+**********************************************************************
+********************************************************************** 
+
+      subroutine restraint
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkatomcoord.blk"
+#include "cbkc.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkenergies.blk"
+#include "cbkrestr.blk"
+#include "cbktorang.blk"
+#include "cbktorsion.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "small.blk"
+#include "cbkinit.blk"
+      dimension drda(3),j(4),dhrdc(3,3),dargdc(3,3)
+********************************************************************** 
+*                                                                    *
+*     Calculate distance restraint energy                            *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In restraint'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      do i1=1,nrestra
+      ih1=irstra(i1,1)
+      ih2=irstra(i1,2)
+      if (itend(i1).eq.0.or.(mdstep.gt.itstart(i1).and.mdstep.lt.
+     $itend(i1))) then
+      call dista2(ih1,ih2,rr,dx,dy,dz)
+      diffr=rr-rrstra(i1)
+*     diffr=rrstra(i1)
+      exphu=exp(-vkrst2(i1)*(diffr*diffr))
+      erh=vkrstr(i1)*(1.0-exphu)
+      deresdr=2.0*vkrst2(i1)*diffr*vkrstr(i1)*exphu
+*     deresdr=-2.0*vkrst2(i1)*diffr*vkrstr(i1)*exphu
+      eres=eres+erh
+      drda(1)=dx/rr
+      drda(2)=dy/rr
+      drda(3)=dz/rr
+      do k1=1,3
+      d(k1,ih1)=d(k1,ih1)+deresdr*drda(k1)
+      d(k1,ih2)=d(k1,ih2)-deresdr*drda(k1)
+      end do
+      end if
+      end do
+      
+**********************************************************************
+*                                                                    *
+*     Calculate angle restraint energy                               *
+*                                                                    *
+**********************************************************************
+      do i1=1,nrestrav
+      j(1)=irstrav(i1,1)
+      j(2)=irstrav(i1,2)
+      j(3)=irstrav(i1,3)
+      ittr=0
+*     do i2=1,nval
+*     if (j(1).eq.iv(i2,2).and.j(2).eq.iv(i2,3).and.j(3).eq.iv(i2,4))
+*    $ittr=i2
+*     end do
+*     if (ittr.eq.0) stop 'Wrong valence angle restraint'
+      call calvalres(j(1),j(2),j(3),arg,hr,dhrdc,dargdc)
+      vaval=hr*rdndgr
+      diffv=-(vaval-vrstra(i1))*dgrrdn
+      exphu=exp(-vkr2v(i1)*(diffv*diffv))
+      erh=vkrv(i1)*(1.0-exphu)
+      deresdv=-2.0*vkr2v(i1)*diffv*vkrv(i1)*exphu
+      eres=eres+erh
+      do k1=1,3
+      do k2=1,3
+      d(k1,j(k2))=d(k1,j(k2))+deresdv*dhrdc(k1,k2)
+      end do
+      end do
+
+      end do
+
+********************************************************************** 
+*                                                                    *
+*     Calculate torsion restraint energy                             *
+*                                                                    *
+********************************************************************** 
+      do i1=1,nrestrat
+      j(1)=irstrat(i1,1)
+      j(2)=irstrat(i1,2)
+      j(3)=irstrat(i1,3)
+      j(4)=irstrat(i1,4)
+      ittr=0
+      do i2=1,ntor
+      if (j(1).eq.it(i2,2).and.j(2).eq.it(i2,3).and.j(3).eq.it(i2,4)
+     $.and.j(4).eq.it(i2,5)) ittr=i2
+      if (j(4).eq.it(i2,2).and.j(3).eq.it(i2,3).and.j(2).eq.it(i2,4)
+     $.and.j(1).eq.it(i2,5)) ittr=i2
+      end do
+      if (ittr.eq.0) then
+      write (*,*)'Wrong torsion restraint'
+      write (*,*)i1,j(1),j(2),j(3),j(4)
+      stop 'Wrong torsion restraint'
+      end if
+      vtor=thg(ittr)
+      difft=-(vtor-trstra(i1))*dgrrdn
+      exphu=exp(-vkr2t(i1)*(difft*difft))
+      erh=vkrt(i1)*(1.0-exphu)
+      deresdt=2.0*vkr2t(i1)*difft*vkrt(i1)*exphu
+      if (vtor.lt.zero) deresdt=-deresdt
+      eres=eres+erh
+      do k1=1,3
+      do k2=1,4
+      d(k1,j(k2))=d(k1,j(k2))+deresdt*dargtdc(ittr,k1,k2)
+      end do
+      end do
+
+      end do
+********************************************************************** 
+*                                                                    *
+*     Calculate mass centre restraint energy                         *
+*                                                                    *
+********************************************************************** 
+      do i1=1,nrestram
+      j1=irstram(i1,2)
+      j2=irstram(i1,3)
+      j3=irstram(i1,4)
+      j4=irstram(i1,5)
+      kdir=irstram(i1,1)
+      cmx1=0.0 
+      cmy1=0.0 
+      cmz1=0.0 
+      cmx2=0.0 
+      cmy2=0.0 
+      cmz2=0.0 
+      summas1=0.0
+      summas2=0.0
+      do i2=j1,j2
+      cmx1=cmx1+c(i2,1)*xmasat(i2)
+      cmy1=cmy1+c(i2,2)*xmasat(i2)
+      cmz1=cmz1+c(i2,3)*xmasat(i2)
+      summas1=summas1+xmasat(i2)
+      end do
+      cmx1=cmx1/summas1
+      cmy1=cmy1/summas1
+      cmz1=cmz1/summas1
+      if (mdstep.lt.2) then
+      rmstrax(i1)=cmx1
+      rmstray(i1)=cmy1
+      rmstraz(i1)=cmz1
+      end if
+      if (kdir.le.3) then
+      do i2=j3,j4
+      cmx2=cmx2+c(i2,1)*xmasat(i2)
+      cmy2=cmy2+c(i2,2)*xmasat(i2)
+      cmz2=cmz2+c(i2,3)*xmasat(i2)
+      summas2=summas2+xmasat(i2)
+      end do
+      cmx2=cmx2/summas2
+      cmy2=cmy2/summas2
+      cmz2=cmz2/summas2
+      end if
+      if (kdir.eq.1) dist=cmx1-cmx2
+      if (kdir.eq.2) dist=cmy1-cmy2
+      if (kdir.eq.3) dist=cmz1-cmz2
+      if (kdir.eq.4) then
+      distx=cmx1-rmstrax(i1)
+      disty=cmy1-rmstray(i1)
+      distz=cmz1-rmstraz(i1)
+      dist=sqrt(distx*distx+disty*disty+distz*distz)
+      end if
+      dismacen(i1)=dist
+      dist=dist-rmstra1(i1)
+      erh=rmstra2(i1)*dist*dist
+      deresdr=2.0*dist*rmstra2(i1)
+*     exphu=exp(-rmstra3(i1)*(dist*dist))
+*     erh=rmstra2(i1)*(1.0-exphu)
+*     deresdr=2.0*rmstra3(i1)*dist*rmstra2(i1)*exphu
+      eres=eres+erh
+      if (kdir.le.3) then
+      do i2=j1,j2
+      d(kdir,i2)=d(kdir,i2)+deresdr*xmasat(i2)/summas1
+      end do
+      do i2=j3,j4
+      d(kdir,i2)=d(kdir,i2)-deresdr*xmasat(i2)/summas2
+      end do
+      end if
+      if (kdir.eq.4.and.mdstep.gt.5) then
+      do i2=j1,j2
+      d(1,i2)=d(1,i2)+deresdr*(distx/dist)*(xmasat(i2)/summas1)
+      d(2,i2)=d(2,i2)+deresdr*(disty/dist)*(xmasat(i2)/summas1)
+      d(3,i2)=d(3,i2)+deresdr*(distz/dist)*(xmasat(i2)/summas1)
+      end do
+      end if
+      end do
+********************************************************************** 
+*                                                                    *
+*     Calculate morphing energy                                      *
+*                                                                    *
+********************************************************************** 
+      if (imorph.eq.1) then
+      distot=zero
+      do i1=1,na
+      dmx=c(i1,1)-cmo(i1,1)
+      dmy=c(i1,2)-cmo(i1,2)
+      dmz=c(i1,3)-cmo(i1,3)
+      dism=sqrt(dmx*dmx+dmy*dmy+dmz*dmz)
+      distot=distot+dism
+*     exphu=exp(-vmo2(i1)*(dism*dism))
+*     erh=vmo1(i1)*(1.0-exphu)
+      erh=vmo1(i1)*dism
+      eres=eres+erh
+*     deresddis=2.0*vmo2(i1)*dism*vmo1(i1)*exphu
+      deresddis=vmo1(i1)
+      drda1=dmx/dism
+      drda2=dmy/dism
+      drda3=dmz/dism
+      d(1,i1)=d(1,i1)+deresddis*drda1
+      d(2,i1)=d(2,i1)+deresddis*drda2
+      d(3,i1)=d(3,i1)+deresddis*drda3
+      end do
+  
+      end if
+      
+      
+      return
+      end
+********************************************************************** 
+******************************************************************** 
+
+      subroutine calvalres (ja1,ja2,ja3,arg,hr,dhrdc,dargdc)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+      dimension a(3),b(3),j(3),dradc(3,3),drbdc(3,3),dtdc(3,3),
+     $dargdc(3,3),dndc(3,3),dadc(3),dbdc(3),dhrdc(3,3)
+********************************************************************** 
+*                                                                    *
+*     Calculate valency angles and their derivatives to cartesian    *
+*     coordinates  for restraint calculations                        *
+*                                                                    *
+********************************************************************** 
+c$$$*     if (ndebug.eq.1) then
+c$$$C*     open (65,file='fort.65',status='unknown',access='append')
+c$$$*     write (65,*) 'In calvalres'
+c$$$*     call timer(65)
+c$$$*     close (65)
+c$$$*     end if
+
+      dadc(1)=-1.0
+      dadc(2)=1.0
+      dadc(3)=0.0
+      dbdc(1)=0.0
+      dbdc(2)=1.0
+      dbdc(3)=-1.0
+      do k1=1,3
+      do k2=1,3
+      dradc(k1,k2)=0.0
+      drbdc(k1,k2)=0.0
+      end do
+      end do
+**********************************************************************
+*                                                                    *
+*     Determine valency angle                                        *
+*                                                                    *
+**********************************************************************
+      call dista2(ja1,ja2,rla,dx1,dy1,dz1)
+      call dista2(ja2,ja3,rlb,dx2,dy2,dz2)
+ 
+      a(1)=-dx1
+      a(2)=-dy1
+      a(3)=-dz1
+      b(1)=dx2
+      b(2)=dy2
+      b(3)=dz2
+      poem=rla*rlb
+      tel=a(1)*b(1)+a(2)*b(2)+a(3)*b(3)
+      arg=tel/poem
+      arg2=arg*arg
+      s1ma22=1.0-arg2
+      if (s1ma22.lt.1.0d-10) s1ma22=1.0d-10
+      s1ma2=sqrt(s1ma22)
+      if (arg.gt.1.0) arg=1.0
+      if (arg.lt.-1.0) arg=-1.0
+      hr=acos(arg)
+**********************************************************************
+*                                                                    *
+*     Calculate derivative valency angle to cartesian coordinates    *
+*                                                                    *
+**********************************************************************
+      do k1=1,3
+      dradc(k1,1)=-a(k1)/rla
+      dradc(k1,2)=a(k1)/rla
+      end do
+
+      do k1=1,3
+      drbdc(k1,2)=b(k1)/rlb
+      drbdc(k1,3)=-b(k1)/rlb
+      end do
+
+      do k1=1,3
+      do k2=1,3
+      dndc(k1,k2)=rla*drbdc(k1,k2)+rlb*dradc(k1,k2)
+      dtdc(k1,k2)=a(k1)*dbdc(k2)+b(k1)*dadc(k2)
+      dargdc(k1,k2)=(dtdc(k1,k2)-arg*dndc(k1,k2))/poem
+      dhrdc(k1,k2)=-dargdc(k1,k2)/s1ma2
+      end do
+      end do
+      
+   10 continue
+
+      return
+      end
+********************************************************************** 
+******************************************************************** 
+
+      subroutine calvalhb (ja1,ja2,ja3,ix,iy,iz,arg,hr,dhrdc,dargdc)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+      dimension a(3),b(3),j(3),dradc(3,3),drbdc(3,3),dtdc(3,3),
+     $dargdc(3,3),dndc(3,3),dadc(3),dbdc(3),dhrdc(3,3)
+********************************************************************** 
+*                                                                    *
+*     Calculate valency angles and their derivatives to cartesian    *
+*     coordinates  for hydrogen bond calculations                    *
+*                                                                    *
+********************************************************************** 
+c$$$*     if (ndebug.eq.1) then
+c$$$*     open (65,file='fort.65',status='unknown',access='append')
+c$$$*     write (65,*) 'In calvalhb'
+c$$$*     call timer(65)
+c$$$*     close (65)
+c$$$*     end if
+
+      dadc(1)=-1.0
+      dadc(2)=1.0
+      dadc(3)=0.0
+      dbdc(1)=0.0
+      dbdc(2)=1.0
+      dbdc(3)=-1.0
+      do k1=1,3
+      do k2=1,3
+      dradc(k1,k2)=0.0
+      drbdc(k1,k2)=0.0
+      end do
+      end do
+**********************************************************************
+*                                                                    *
+*     Determine valency angle                                        *
+*                                                                    *
+**********************************************************************
+      call dista2(ja1,ja2,rla,dx1,dy1,dz1)
+      call dista2(ja2,ja3,rlb,dx2,dy2,dz2)
+
+      a(1)=-dx1
+      a(2)=-dy1
+      a(3)=-dz1
+      b(1)=dx2
+      b(2)=dy2
+      b(3)=dz2
+      poem=rla*rlb
+      tel=a(1)*b(1)+a(2)*b(2)+a(3)*b(3)
+      arg=tel/poem
+      arg2=arg*arg
+      s1ma22=1.0-arg2
+      if (s1ma22.lt.1.0d-10) s1ma22=1.0d-10
+      s1ma2=sqrt(s1ma22)
+      if (arg.gt.1.0) arg=1.0
+      if (arg.lt.-1.0) arg=-1.0
+      hr=acos(arg)
+**********************************************************************
+*                                                                    *
+*     Calculate derivative valency angle to cartesian coordinates    *
+*                                                                    *
+**********************************************************************
+      do k1=1,3
+      dradc(k1,1)=-a(k1)/rla
+      dradc(k1,2)=a(k1)/rla
+      end do
+
+      do k1=1,3
+      drbdc(k1,2)=b(k1)/rlb
+      drbdc(k1,3)=-b(k1)/rlb
+      end do
+
+      do k1=1,3
+      do k2=1,3
+      dndc(k1,k2)=rla*drbdc(k1,k2)+rlb*dradc(k1,k2)
+      dtdc(k1,k2)=a(k1)*dbdc(k2)+b(k1)*dadc(k2)
+      dargdc(k1,k2)=(dtdc(k1,k2)-arg*dndc(k1,k2))/poem
+      dhrdc(k1,k2)=-dargdc(k1,k2)/s1ma2
+      end do
+      end do
+      
+   10 continue
+
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine caltor(ja1,ja2,ja3,ja4,ht)
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkenergies.blk"
+#include "cbktregime.blk"
+#include "control.blk"
+#include "cbkinit.blk"
+      DIMENSION  A(3),DRDA(3),DADC(4),DRADC(3,4),DRBDC(3,4),
+     $DRCDC(3,4),DHDDC(3,4),DHEDC(3,4),DRVDC(3,4),DTDC(3,4),
+     $DNDC(3,4)
+      dimension j(4),dvdc1(3,3),dargdc1(3,3),dvdc2(3,3),dargdc2(3,3)
+********************************************************************** 
+*                                                                    *
+*     Calculate torsion angle (for internal coordinates output)      *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In caltor'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      do k1=1,3
+      do k2=1,4
+      dhddc(k1,k2)=0.0
+      dhedc(k1,k2)=0.0
+      dradc(k1,k2)=0.0
+      drbdc(k1,k2)=0.0
+      drcdc(k1,k2)=0.0
+      end do
+      end do
+      et=0.0
+      eco=0.0
+      dadc(1)=1.0
+      dadc(2)=0.0
+      dadc(3)=0.0
+      dadc(4)=-1.0
+      call dista2(ja1,ja2,rla,dx1,dy1,dz1)
+      call dista2(ja2,ja3,rlb,dx2,dy2,dz2)
+      call dista2(ja3,ja4,rlc,dx2,dy2,dz2)
+      call dista2(ja1,ja4,r4,dx2,dy2,dz2)
+      call calvalres(ja1,ja2,ja3,arg1,h1,dvdc1,dargdc1)
+      call calvalres(ja2,ja3,ja4,arg2,h2,dvdc2,dargdc2)
+********************************************************************** 
+*                                                                    *
+*     Determine torsion angle                                        *
+*                                                                    *
+********************************************************************** 
+      d142=r4*r4
+      coshd=cos(h1)
+      coshe=cos(h2)
+      sinhd=sin(h1)
+      sinhe=sin(h2)
+      poem=2.0*rla*rlc*sinhd*sinhe
+      poem2=poem*poem
+      tel=rla*rla+rlb*rlb+rlc*rlc-d142-2.0*(rla*rlb*coshd-rla*rlc*
+     $coshd*coshe+rlb*rlc*coshe)
+      arg=tel/poem
+      if (arg.gt.1.0) arg=1.0
+      if (arg.lt.-1.0) arg=-1.0
+      arg2=arg*arg
+      ht=acos(arg)*rdndgr
+      k1=ja1
+      k2=ja2
+      k3=ja3
+      k4=ja4
+      call dista2(k3,k2,dis,x3,y3,z3)
+      y32z32=y3*y3+z3*z3
+      wort1=sqrt(y32z32)+1e-6
+      wort2=sqrt(y32z32+x3*x3)+1e-6
+      sinalf=y3/wort1
+      cosalf=z3/wort1
+      sinbet=x3/wort2
+      cosbet=wort1/wort2
+      call dista2(k1,k2,dis,x1,y1,z1)
+      x1=x1*cosbet-y1*sinalf*sinbet-z1*cosalf*sinbet
+      y1=y1*cosalf-z1*sinalf
+      wort3=sqrt(x1*x1+y1*y1)+1e-6
+      singam=y1/wort3
+      cosgam=x1/wort3
+      call dista2(k4,k2,dis,x4,y4,z4)
+      x4=x4*cosbet-y4*sinalf*sinbet-z4*cosalf*sinbet
+      y4=y4*cosalf-z4*sinalf
+      y4=x4*singam-y4*cosgam
+      if (y4.gt.0.0) ht=-ht
+      if (ht.lt.-179.999999d0) ht=-179.999999d0
+      if (ht.gt.179.999999d0) ht=179.999999d0
+
+      return
+      end 
+********************************************************************** 
diff -Naur lammps-29Jan09/lib/reax/reax_reac.F lammps-12Feb09/lib/reax/reax_reac.F
--- lammps-29Jan09/lib/reax/reax_reac.F	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/reax_reac.F	2009-02-12 14:03:20.000000000 -0700
@@ -0,0 +1,312 @@
+**********************************************************************
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+********************************************************************** 
+********************************************************************** 
+*                                                                    *
+*     REAXFF Reactive force field program                            *
+*                                                                    *
+*     Developed and written by Adri van Duin, duin@wag.caltech.edu   *
+*                                                                    *
+*     Copyright (c) 2001-2010 California Institute of Technology     *
+*                                                                    *
+*     This is an open-source program. Feel free to modify its        *
+*     contents. Please keep me informed of any useful modification   *
+*     or addition that you made. Please do not distribute this       *
+*     program to others; if people are interested in obtaining       *
+*     a copy of this program let them contact me first.              *
+*                                                                    *
+********************************************************************** 
+********************************************************************** 
+
+      subroutine encalc
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkc.blk"
+#include "cbkcha.blk"
+#include "cbkconst.blk"
+#include "cbkd.blk"
+#include "cbkdcell.blk"
+#include "cbkenergies.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "small.blk"
+********************************************************************** 
+*                                                                    *
+*     Calculate energy and first derivatives                         *
+*                                                                    *
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In encalc'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+      estrc=0.0
+      do i1=1,na
+      do i2=1,3
+      d(i2,i1)=0.0
+      estrain(i1)=0.0
+      end do
+      end do
+      eb=zero
+      ea=zero
+      elp=zero
+      emol=zero
+      ev=zero
+      ehb=zero
+      ecoa=zero
+      epen=zero
+      et=zero
+      eco=zero
+      eres=zero
+      eradbo=zero
+      efi=zero
+
+      if(Lvirial.eq.1) then
+         do k1 = 1,6
+            virial(k1) = zero
+         end do
+      endif
+
+      if (Latomvirial.eq.1) then
+      do i1=1,na
+      do i2=1,6
+      atomvirial(i2,i1)=0.0
+      end do
+      end do
+      endif
+
+      call boncor
+      call lonpar
+      call covbon
+      call ovcor
+
+      call srtang   !Determine valency angles
+      call srttor   !Determine torsion angles
+*     call srtoop   !Determine out of plane angles
+      call srthb    !Determine hydrogen bonds
+  
+      call calval
+      call valang
+  
+*     call oopang
+
+      call torang
+      call hbond
+      !print *, 'called hbond'
+      !print *, nchaud
+
+      call nonbon
+      call efield
+
+      call restraint
+
+c
+c     Use this to print out fort.73-style energies
+c     It only works correctly in serial mode
+c
+c      write (6,'(i8,1x,14(f21.10,1x))')mdstep+nprevrun,eb,ea,elp,
+c     $emol,ev+epen,ecoa,ehb,et,eco,ew,ep,ech,efi
+
+      estrc=eb+ea+elp+ev+ecoa+emol+epen+et+ehb+eco+ew+ep+ncha2*ech+efi
+      if (estrc.gt.zero) return
+      if (estrc.le.zero) then
+      goto 10
+      else
+      write (*,*)mdstep
+      write (92,*)eb,ea,elp,ev,ecoa,emol,epen,eoop,et,eco,ew,
+     $ep,ech,eres,eradbo
+      stop 'Energy not a number'
+      end if
+
+   10 continue
+      return
+      end
+********************************************************************** 
+********************************************************************** 
+
+      subroutine init
+
+********************************************************************** 
+#include "cbka.blk"
+#include "cbkatomcoord.blk"
+#include "cbkc.blk"
+#include "cbkcha.blk"
+#include "cbkconst.blk"
+#include "cbkdcell.blk"
+#include "cbkdistan.blk"
+#include "cbkenergies.blk"
+#include "cbkia.blk"
+#include "cbkimove.blk"
+#include "cbkinit.blk"
+#include "cbktregime.blk"
+#include "cellcoord.blk"
+#include "control.blk"
+#include "opt.blk"
+#include "small.blk"
+********************************************************************** 
+c$$$      if (ndebug.eq.1) then
+c$$$C      open (65,file='fort.65',status='unknown',access='append')
+c$$$      write (65,*) 'In init'
+c$$$      call timer(65)
+c$$$      close (65)
+c$$$      end if
+********************************************************************** 
+*                                                                    *
+*     Initialize variables                                           *
+*                                                                    *
+********************************************************************** 
+      convmd=4.184*1.0d26
+      pi=3.14159265
+      avognr=6.0221367d23
+      rdndgr=180.0/pi
+      dgrrdn=1.0/rdndgr
+      rgasc=8.314510
+      caljou=4.184
+      xjouca=1.0/caljou
+      ech=zero
+      zero=0.0
+      one=1.0
+      two=2.0
+      three=3.0
+      half=one/two
+      nzero=0
+      none=1
+      ntwo=2
+      nthree=3
+      invt=0
+      ndata2=0
+      iheatf=0
+      nradcount=0
+      itemp=1
+      xinh=zero
+      ifieldx=0
+      ifieldy=0
+      ifieldz=0
+      mdstep=0
+      kx=0
+      ky=0
+      kz=0
+      nit=0
+      nbon=0
+      angle(1)=90.0
+      angle(2)=90.0
+      angle(3)=90.0
+      axiss(1)=zero
+      axiss(2)=zero
+      axiss(3)=zero
+      do i1=1,nat
+      id(i1,1)=0
+      id(i1,2)=0
+      id(i1,3)=0
+      end do
+      icgeo=0
+      sumhe=zero
+      ustime=zero
+      systime=zero
+      vpmax=zero
+      vpmin=zero
+      dseed=0
+      iagain=0
+      do i1=1,nat
+      do i2=1,mbond+3
+      ia(i1,i2)=0
+      iag(i1,i2)=0
+      end do
+      end do
+
+      ioldchg=0
+      na=0
+      nrestra=0
+      nrestrav=0
+      nrestrat=0
+      nrestram=0
+      tset=tsetor
+      tm11=axis(1)
+      tm21=zero
+      tm31=zero
+      tm22=axis(2)
+      tm32=zero
+      tm33=axis(3)
+      qruid='NORMAL RUN'
+c$$$      do i1=1,nat
+c$$$      imove(i1)=1
+c$$$      end do
+
+********************************************************************** 
+*                                                                    *
+*     Write file headers                                             *
+*                                                                    *
+********************************************************************** 
+Cc      open (71,file='fort.71',status='unknown',access='append')
+c      write (71,10)
+c      close (71)
+Cc      open (73,file='fort.73',status='unknown',access='append')
+c      write (73,20)
+c      close (73)
+c      if (ntrc.gt.0) then
+Cc      open (75,file='fort.75',status='unknown',access='append')
+c      write (75,30)
+c      close (75)
+c      end if
+c      if (nmethod.eq.4) then
+Cc      open (59,file='fort.59',status='unknown',access='append')
+c      write (59,40)
+c      close (59)
+c      end if
+
+      return
+********************************************************************** 
+*                                                                    *
+*     Format part                                                    *
+*                                                                    *
+********************************************************************** 
+   10 format ('   Iter. Nmol    Epot         Ekin      Etot ',
+     $'       T(K)  Eaver(block) Eaver(total) Taver      Tmax   ',
+     $' Pres(MPa)   sdev(Epot)  sdev(Eaver)    Tset      Timestep',
+     $'    RMSG     Totaltime')
+   20 format ('  Iter.      Ebond       Eatom       Elp        Emol',
+     $'       Eval       Ecoa       Ehbo       Etors      Econj',
+     $'      Evdw      Ecoul    Echarge  Efield')
+   30 format ('   Iter.  Tsys    Tzone1  Tset1   Tzone2  Tset2')
+   40 format ('    Iter.     a             b          c        px',
+     $'(MPa)    py(MPa)      pz(MPa)     pset(MPa)  Volume ')
+      end
+********************************************************************** 
+************************************************************************
+ 
+c      subroutine timer(nunit)
+ 
+************************************************************************
+c#include "cbka.blk"
+c#include "cbkinit.blk"
+c      real timear
+c      real tarray(2)
+c#ifdef _IBM
+c      call dtime_(tarray,timear)
+c#else
+c      call dtime(tarray,timear)
+c#endif
+
+c      ustime=ustime+tarray(1)
+c      systime=systime+tarray(2)
+c      write (nunit,100)ustime,systime,ustime+systime
+c      return
+c  100 format ('User time:',f20.4,' System time:',f20.4,
+c     $' Total time:',f20.4)
+c      end
+************************************************************************
+************************************************************************
diff -Naur lammps-29Jan09/lib/reax/small.blk lammps-12Feb09/lib/reax/small.blk
--- lammps-29Jan09/lib/reax/small.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/small.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,5 @@
+      common
+     $/rsmall/ tset,dseed,tempmd,ts2,ts22,nmolo,nmolo5,nbon,na,namov,
+     $	      na_local
+
+
diff -Naur lammps-29Jan09/lib/reax/valang.blk lammps-12Feb09/lib/reax/valang.blk
--- lammps-29Jan09/lib/reax/valang.blk	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/lib/reax/valang.blk	2009-02-06 09:39:43.000000000 -0700
@@ -0,0 +1,9 @@
+ 
+       
+             
+      common
+     $/cbkvalang/ vval1(nsort),vval2(nvatym),
+     $            vval4(nsort),vkac(nvatym),vkap(nvatym),
+     $            vka3(nvatym),vka8(nvatym),th0(nvatym)
+                 
+
diff -Naur lammps-29Jan09/potentials/README lammps-12Feb09/potentials/README
--- lammps-29Jan09/potentials/README	2007-06-20 07:40:55.000000000 -0600
+++ lammps-12Feb09/potentials/README	2009-02-06 09:10:15.000000000 -0700
@@ -16,10 +16,11 @@
 
 The suffix of each file indicates the pair style it is used with:
 
+airebo	      AI-REBO (Brenner) potential
 eam	      embedded atom method (EAM) single element, DYNAMO funcfl format
 eam.alloy     EAM multi-element alloy, DYNAMO setfl format
 eam.fs	      Finnis-Sinclair EAM format (single element or alloy)
 meam	      modified EAM (MEAM) library and individual elements/alloys
+reax	      ReaxFF potential
 sw	      Stillinger-Weber potential
 tersoff	      Tersoff potential
-airebo	      AI-REBO (Brenner) potential
diff -Naur lammps-29Jan09/potentials/ffield.reax lammps-12Feb09/potentials/ffield.reax
--- lammps-29Jan09/potentials/ffield.reax	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/potentials/ffield.reax	2009-02-06 09:10:15.000000000 -0700
@@ -0,0 +1,210 @@
+Reactive MD-force field                                                         
+ 39       ! Number of general parameters                                        
+   50.0000 !Overcoordination parameter                                          
+    9.5469 !Overcoordination parameter                                          
+  127.8302 !Valency angle conjugation parameter                                 
+    3.0000 !Triple bond stabilisation parameter                                 
+    6.5000 !Triple bond stabilisation parameter                                 
+    0.0000 !C2-correction                                                       
+    1.0496 !Undercoordination parameter                                         
+    9.0000 !Triple bond stabilisation parameter                                 
+   11.5054 !Undercoordination parameter                                         
+   13.4059 !Undercoordination parameter                                         
+    0.0000 !Triple bond stabilization energy                                    
+    0.0000 !Lower Taper-radius                                                  
+   10.0000 !Upper Taper-radius                                                  
+    2.8793 !Not used                                                            
+   33.8667 !Valency undercoordination                                           
+    7.0994 !Valency angle/lone pair parameter                                   
+    1.0563 !Valency angle                                                       
+    2.0384 !Valency angle parameter                                             
+    6.1431 !Not used                                                            
+    6.9290 !Double bond/angle parameter                                         
+    0.3989 !Double bond/angle parameter: overcoord                              
+    3.9954 !Double bond/angle parameter: overcoord                              
+   -2.4837 !Not used                                                            
+    5.7796 !Torsion/BO parameter                                                
+   10.0000 !Torsion overcoordination                                            
+    1.9487 !Torsion overcoordination                                            
+   -1.2327 !Conjugation 0 (not used)                                            
+    2.1645 !Conjugation                                                         
+    1.5591 !vdWaals shielding                                                   
+    0.1000 !Cutoff for bond order (*100)                                        
+    2.0038 !Valency angle conjugation parameter                                 
+    0.6121 !Overcoordination parameter                                          
+    1.2172 !Overcoordination parameter                                          
+    1.8512 !Valency/lone pair parameter                                         
+    0.5000 !Not used                                                            
+   20.0000 !Not used                                                            
+    5.0000 !Molecular energy (not used)                                         
+    0.0000 !Molecular energy (not used)                                         
+    3.6942 !Valency angle conjugation parameter                                 
+  6    ! Nr of atoms; cov.r; valency;a.m;Rvdw;Evdw;gammaEEM;cov.r2;#            
+            alfa;gammavdW;valency;Eunder;Eover;chiEEM;etaEEM;n.u.               
+            cov r3;Elp;Heat inc.;n.u.;n.u.;n.u.;n.u.                            
+            ov/un;val1;n.u.;val3,vval4                                          
+ C    1.3763   4.0000  12.0000   1.8857   0.1818   0.8712   1.2596   4.0000     
+      9.5928   2.0784   4.0000  22.6732  79.5548   5.7254   6.9235   0.0000     
+      1.2065   0.0000  -0.8579   4.9417  28.3475  11.9957   0.8563   0.0000     
+     -2.8846   4.1590   1.0564   4.0000   2.9663   0.0000   0.0000   0.0000     
+ H    0.6646   1.0000   1.0080   1.6030   0.0600   0.7625  -0.1000   1.0000     
+      9.3951   4.4187   1.0000   0.0000 121.1250   3.8196   9.8832   1.0000     
+     -0.1000   0.0000  -0.1339   3.5803   2.8733   1.0000   1.0698   0.0000     
+    -13.0615   3.0626   1.0338   1.0000   2.8793   0.0000   0.0000   0.0000     
+ O    1.2699   2.0000  15.9990   1.9741   0.0880   1.0804   1.0624   6.0000     
+     10.2186   7.7719   4.0000  27.3264 116.0768   8.5000   7.8386   2.0000     
+      0.9446   8.6170  -1.2371  17.0845   3.7082   0.5350   0.9745   0.0000     
+     -3.1456   2.6656   1.0493   4.0000   2.9225   0.0000   0.0000   0.0000     
+ N    1.2226   3.0000  14.0000   1.9324   0.1376   0.8596   1.1839   5.0000     
+     10.0667   7.8431   4.0000  32.5000 100.0000   6.8418   6.3404   2.0000     
+      1.0497  14.5853  -1.1222   2.0637   3.2584   3.1136   0.9745   0.0000     
+     -4.2059   2.6491   1.0183   4.0000   2.8793   0.0000   0.0000   0.0000     
+ S    1.9405   2.0000  32.0600   2.0677   0.2099   1.0336   1.5479   6.0000     
+      9.9575   4.9055   4.0000  52.9998 112.1416   6.5000   8.2545   2.0000     
+      1.4601   9.7177  -2.3700   5.7487  23.2859  12.7147   0.9745   0.0000     
+    -11.0000   2.7466   1.0338   4.0000   2.8793   0.0000   0.0000   0.0000     
+ Si   2.0276   4.0000  28.0600   2.2042   0.1322   0.8218   1.5758   4.0000     
+     11.9413   2.0618   4.0000  11.8211 136.4845   1.8038   7.3852   0.0000     
+     -1.0000   0.0000  -2.3700   6.4918   8.5961   0.2368   0.8563   0.0000     
+     -3.8112   3.1873   1.0338   4.0000   2.5791   0.0000   0.0000   0.0000     
+ 18      ! Nr of bonds; Edis1;LPpen;n.u.;pbe1;pbo5;13corr;pbo6                  
+                         pbe2;pbo3;pbo4;n.u.;pbo1;pbo2;ovcorr                   
+  1  1 145.4070 103.0681  73.7841   0.2176  -0.7816   1.0000  28.4167   0.3217  
+         0.1111  -0.1940   8.6733   1.0000  -0.0994   5.9724   1.0000   0.0000  
+  1  2 167.1752   0.0000   0.0000  -0.4421   0.0000   1.0000   6.0000   0.5969  
+        17.4194   1.0000   0.0000   1.0000  -0.0099   8.5445   0.0000   0.0000  
+  2  2 188.1606   0.0000   0.0000  -0.3140   0.0000   1.0000   6.0000   0.6816  
+         8.6247   1.0000   0.0000   1.0000  -0.0183   5.7082   0.0000   0.0000  
+  1  3 171.0470  67.2480 130.3792   0.3600  -0.1696   1.0000  12.0338   0.3796  
+         0.3647  -0.2660   7.4396   1.0000  -0.1661   5.0637   0.0000   0.0000  
+  3  3  90.2465 160.9645  40.0000   0.9950  -0.2435   1.0000  28.1614   0.9704  
+         0.8145  -0.1850   7.5281   1.0000  -0.1283   6.2396   1.0000   0.0000  
+  1  4 134.9992 139.6314  78.5681   0.0420  -0.1370   1.0000  23.6247   0.2415  
+         0.1522  -0.3161   7.0000   1.0000  -0.1301   5.4980   1.0000   0.0000  
+  3  4 127.7074 177.1058  40.0000   0.4561  -0.1481   1.0000  31.4801   0.2000  
+         0.8968  -0.3555   7.0000   1.0000  -0.1219   7.0000   1.0000   0.0000  
+  4  4 151.9142  87.1928 151.4761   0.4280  -0.1001   1.0000  12.3631   0.6229  
+         0.1721  -0.1614  12.1345   1.0000  -0.0882   5.3056   1.0000   0.0000  
+  2  3 216.6018   0.0000   0.0000  -0.4201   0.0000   1.0000   6.0000   0.9143  
+         4.7737   1.0000   0.0000   1.0000  -0.0591   5.9451   0.0000   0.0000  
+  2  4 223.1853   0.0000   0.0000  -0.4661   0.0000   1.0000   6.0000   0.5178  
+         7.8731   1.0000   0.0000   1.0000  -0.0306   6.1506   0.0000   0.0000  
+  1  5 128.9942  74.5848  55.2528   0.1035  -0.5211   1.0000  18.9617   0.6000  
+         0.2949  -0.2398   8.1175   1.0000  -0.1029   5.6731   1.0000   0.0000  
+  2  5 151.5159   0.0000   0.0000  -0.4721   0.0000   1.0000   6.0000   0.6000  
+         9.4366   1.0000   0.0000   1.0000  -0.0290   7.0050   1.0000   0.0000  
+  3  5   0.0000   0.0000   0.0000   0.5563  -0.4038   1.0000  49.5611   0.6000  
+         0.4259  -0.4577  12.7569   1.0000  -0.1100   7.1145   1.0000   0.0000  
+  4  5   0.0000   0.0000   0.0000   0.4438  -0.2034   1.0000  40.3399   0.6000  
+         0.3296  -0.3153   9.1227   1.0000  -0.1805   5.6864   1.0000   0.0000  
+  5  5  96.1871  93.7006  68.6860   0.0955  -0.4781   1.0000  17.8574   0.6000  
+         0.2723  -0.2373   9.7875   1.0000  -0.0950   6.4757   1.0000   0.0000  
+  6  6 109.1904  70.8314  30.0000   0.2765  -0.3000   1.0000  16.0000   0.1583  
+         0.2804  -0.1994   8.1117   1.0000  -0.0675   8.2993   0.0000   0.0000  
+  2  6 137.1002   0.0000   0.0000  -0.1902   0.0000   1.0000   6.0000   0.4256  
+        17.7186   1.0000   0.0000   1.0000  -0.0377   6.4281   0.0000   0.0000  
+  3  6 191.1743  52.0733  43.3991  -0.2584  -0.3000   1.0000  36.0000   0.8764  
+         1.0248  -0.3658   4.2151   1.0000  -0.5004   4.2605   1.0000   0.0000  
+  8    ! Nr of off-diagonal terms; Ediss;Ro;gamma;rsigma;rpi;rpi2               
+  1  2   0.0455   1.7218  10.4236   1.0379  -1.0000  -1.0000                    
+  2  3   0.0469   1.9185  10.3707   0.9406  -1.0000  -1.0000                    
+  2  4   0.0999   1.8372   9.6539   0.9692  -1.0000  -1.0000                    
+  1  3   0.1186   1.9820   9.5927   1.2936   1.1203   1.0805                    
+  1  4   0.1486   1.8922   9.7989   1.3746   1.2091   1.1427                    
+  3  4   0.1051   2.0060  10.0691   1.3307   1.1034   1.0060                    
+  2  6   0.0470   1.6738  11.6877   1.1931  -1.0000  -1.0000                    
+  3  6   0.1263   1.8163  10.6833   1.6266   1.2052  -1.0000                    
+ 62    ! Nr of angles;at1;at2;at3;Thetao,o;ka;kb;pv1;pv2                        
+  1  1  1  70.0265  13.6338   2.1884   0.0000   0.1676  26.3587   1.0400        
+  1  1  2  69.7786  10.3544   8.4326   0.0000   0.1153   0.0000   1.0400        
+  2  1  2  74.6020  11.8629   2.9294   0.0000   0.1367   0.0000   1.0400        
+  1  2  2   0.0000   0.0000   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  1   0.0000   3.4110   7.7350   0.0000   0.0000   0.0000   1.0400        
+  2  2  2   0.0000  27.9213   5.8635   0.0000   0.0000   0.0000   1.0400        
+  1  1  3  72.9588  16.7105   3.5244   0.0000   1.1127   0.0000   1.1880        
+  3  1  3  80.0708  45.0000   2.1487   0.0000   1.1127 -35.0000   1.1880        
+  1  1  4  61.5055  45.0000   1.2242   0.0000   1.1127   0.0000   1.1880        
+  3  1  4  71.9345  45.0000   1.5052   0.0000   1.1127   0.0000   1.1880        
+  4  1  4  51.3604  45.0000   0.6846   0.0000   1.1127   0.0000   1.1880        
+  2  1  3  66.6150  13.6403   3.8212   0.0000   0.0755   0.0000   1.0500        
+  2  1  4  68.9632  16.3575   3.1449   0.0000   0.0755   0.0000   1.0500        
+  1  2  4   0.0000   0.0019   6.3000   0.0000   0.0000   0.0000   1.0400        
+  1  3  1  79.1091  45.0000   0.7067   0.0000   0.6142   0.0000   1.0783        
+  1  3  3  83.7151  42.6867   0.9699   0.0000   0.6142   0.0000   1.0783        
+  1  3  4  79.5876  45.0000   1.1761   0.0000   0.6142   0.0000   1.0783        
+  3  3  3  80.0108  38.3716   1.1572 -38.4200   0.6142   0.0000   1.0783        
+  3  3  4  81.5614  19.8012   3.9968   0.0000   0.6142   0.0000   1.0783        
+  4  3  4  85.3564  36.5858   1.7504   0.0000   0.6142   0.0000   1.0783        
+  1  3  2  78.1533  44.7226   1.3136   0.0000   0.1218   0.0000   1.0500        
+  2  3  3  84.1057   9.6413   7.5000   0.0000   0.1218   0.0000   1.0500        
+  2  3  4  79.4629  44.0409   2.2959   0.0000   0.1218   0.0000   1.0500        
+  2  3  2  79.2954  26.3838   2.2044   0.0000   0.1218   0.0000   1.0500        
+  1  4  1  66.1477  22.9891   1.5923   0.0000   1.6777   0.0000   1.0500        
+  1  4  3  91.9273  38.0207   0.5387   0.0000   1.6777   0.0000   1.0500        
+  1  4  4  92.6933   9.9708   1.6094   0.0000   1.6777   0.0000   1.0500        
+  3  4  3  73.4749  42.7640   1.7325 -17.5007   1.6777   0.0000   1.0500        
+  3  4  4  73.9183  44.8857   1.1980  -0.9193   1.6777   0.0000   1.0500        
+  4  4  4  74.0572  15.4709   5.4220   0.0000   1.6777   0.0000   1.0500        
+  1  4  2  72.7016  33.4153   1.0224   0.0000   0.0222   0.0000   1.0500        
+  2  4  3  82.4368  44.1900   1.9273   0.0000   0.0222   0.0000   1.0500        
+  2  4  4  82.6883  39.9831   1.1916   0.0000   0.0222   0.0000   1.0500        
+  2  4  2  71.2183  14.4528   3.6870   0.0000   0.0222   0.0000   1.0500        
+  1  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  2  5   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  3  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  3  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  4  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  2  2  3   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  2  2  4   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+  1  1  5  74.9397  25.0560   1.8787   0.1463   0.0559   0.0000   1.0400        
+  1  5  1  86.9521  36.9951   2.0903   0.1463   0.0559   0.0000   1.0400        
+  2  1  5  74.9397  25.0560   1.8787   0.0000   0.0000   0.0000   1.0400        
+  1  5  2  86.1791  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  1  5  5  85.3644  36.9951   2.0903   0.1463   0.0559   0.0000   1.0400        
+  2  5  2  93.1959  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  2  5  5  84.3331  36.9951   2.0903   0.0000   0.0000   0.0000   1.0400        
+  6  6  6  69.3456  21.7361   1.4283   0.0000  -0.2101   0.0000   1.3241        
+  2  6  6  75.6168  21.5317   1.0435   0.0000   2.5179   0.0000   1.0400        
+  2  6  2  78.3939  20.9772   0.8630   0.0000   2.8421   0.0000   1.0400        
+  3  6  6  70.3016  15.4081   1.3267   0.0000   2.1459   0.0000   1.0400        
+  2  6  3  73.8232  16.6592   3.7425   0.0000   0.8613   0.0000   1.0400        
+  3  6  3  90.0344   7.7656   1.7264   0.0000   0.7689   0.0000   1.0400        
+  6  3  6  22.1715   3.6615   0.3160   0.0000   4.1125   0.0000   1.0400        
+  2  3  6  83.7634   5.6693   2.7780   0.0000   1.6982   0.0000   1.0400        
+  3  3  6  73.4663  25.0761   0.9143   0.0000   2.2466   0.0000   1.0400        
+  2  2  6   0.0000  47.1300   6.0000   0.0000   1.6371   0.0000   1.0400        
+  6  2  6   0.0000  31.5209   6.0000   0.0000   1.6371   0.0000   1.0400        
+  3  2  6   0.0000  31.0427   4.5625   0.0000   1.6371   0.0000   1.0400        
+  2  2  5   0.0000   0.0019   6.0000   0.0000   0.0000   0.0000   1.0400        
+ 20    ! Nr of torsions;at1;at2;at3;at4;;V1;V2;V3;V2(BO);vconj;n.u;n            
+  1  1  1  1   0.0000  23.2168   0.1811  -4.6220  -1.9387   0.0000   0.0000     
+  1  1  1  2   0.0000  45.7984   0.3590  -5.7106  -2.9459   0.0000   0.0000     
+  2  1  1  2   0.0000  44.6445   0.3486  -5.1725  -0.8717   0.0000   0.0000     
+  0  1  2  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  2  2  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  1  3  0   5.0520  16.7344   0.5590  -3.0181  -2.0000   0.0000   0.0000     
+  0  2  3  0   0.0000   0.1000   0.0200  -2.5415   0.0000   0.0000   0.0000     
+  0  3  3  0   0.0115  68.9706   0.8253 -28.4693   0.0000   0.0000   0.0000     
+  0  1  4  0  -4.0616  66.2036   0.3855  -4.4414  -2.0000   0.0000   0.0000     
+  0  2  4  0   0.0000   0.1000   0.0200  -2.5415   0.0000   0.0000   0.0000     
+  0  3  4  0   1.1130  14.8049   0.0231 -10.7175  -2.0000   0.0000   0.0000     
+  0  4  4  0  -0.0851  37.4200   0.0107  -3.5209  -2.0000   0.0000   0.0000     
+  0  1  1  0   0.0000   0.9305   0.0000 -24.2568   0.0000   0.0000   0.0000     
+  4  1  4  4  -3.6064  43.6430   0.0004 -11.5507  -2.0000   0.0000   0.0000     
+  0  1  5  0   3.3423  30.3435   0.0365  -2.7171   0.0000   0.0000   0.0000     
+  0  5  5  0  -0.0555 -42.7738   0.1515  -2.2056   0.0000   0.0000   0.0000     
+  0  2  5  0   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000   0.0000     
+  0  6  6  0   0.0000   0.0000   0.1200  -2.4426   0.0000   0.0000   0.0000     
+  0  2  6  0   0.0000   0.0000   0.1200  -2.4847   0.0000   0.0000   0.0000     
+  0  3  6  0   0.0000   0.0000   0.1200  -2.4703   0.0000   0.0000   0.0000     
+  9    ! Nr of hydrogen bonds;at1;at2;at3;Rhb;Dehb;vhb1                         
+  3  2  3   2.0431  -6.6813   3.5000   1.7295                                   
+  3  2  4   1.6740 -10.9581   3.5000   1.7295                                   
+  4  2  3   1.4889  -9.6465   3.5000   1.7295                                   
+  4  2  4   1.8324  -8.0074   3.5000   1.7295                                   
+  3  2  5   2.6644  -3.9547   3.5000   1.7295                                   
+  4  2  5   4.0476  -5.7038   3.5000   1.7295                                   
+  5  2  3   2.1126  -4.5790   3.5000   1.7295                                   
+  5  2  4   2.2066  -5.7038   3.5000   1.7295                                   
+  5  2  5   1.9461  -4.0000   3.5000   1.7295                                   
diff -Naur lammps-29Jan09/src/KSPACE/pppm.cpp lammps-12Feb09/src/KSPACE/pppm.cpp
--- lammps-29Jan09/src/KSPACE/pppm.cpp	2009-01-09 14:31:31.000000000 -0700
+++ lammps-12Feb09/src/KSPACE/pppm.cpp	2009-01-29 08:10:38.000000000 -0700
@@ -733,18 +733,20 @@
     memory->create_3d_double_array(nzlo_out,nzhi_out,nylo_out,nyhi_out,
 				   nxlo_out,nxhi_out,"pppm:vdz_brick");
 
-  density_fft = new double[nfft_both];
-  greensfn = new double[nfft_both];
-  work1 = new double[2*nfft_both];
-  work2 = new double[2*nfft_both];
+  density_fft = 
+    (double *) memory->smalloc(nfft_both*sizeof(double),"pppm:density_fft");
+  greensfn = 
+    (double *) memory->smalloc(nfft_both*sizeof(double),"pppm:greensfn");
+  work1 = (double *) memory->smalloc(2*nfft_both*sizeof(double),"pppm:work1");
+  work2 = (double *) memory->smalloc(2*nfft_both*sizeof(double),"pppm:work2");
   vg = memory->create_2d_double_array(nfft_both,6,"pppm:vg");
 
   fkx = memory->create_1d_double_array(nxlo_fft,nxhi_fft,"pppm:fkx");
   fky = memory->create_1d_double_array(nylo_fft,nyhi_fft,"pppm:fky");
   fkz = memory->create_1d_double_array(nzlo_fft,nzhi_fft,"pppm:fkz");
 
-  buf1 = new double[nbuf];
-  buf2 = new double[nbuf];
+  buf1 = (double *) memory->smalloc(nbuf*sizeof(double),"pppm:buf1");
+  buf2 = (double *) memory->smalloc(nbuf*sizeof(double),"pppm:buf2");
 
   // summation coeffs
 
@@ -787,18 +789,18 @@
   memory->destroy_3d_double_array(vdy_brick,nzlo_out,nylo_out,nxlo_out);
   memory->destroy_3d_double_array(vdz_brick,nzlo_out,nylo_out,nxlo_out);
 
-  delete [] density_fft;
-  delete [] greensfn;
-  delete [] work1;
-  delete [] work2;
+  memory->sfree(density_fft);
+  memory->sfree(greensfn);
+  memory->sfree(work1);
+  memory->sfree(work2);
   memory->destroy_2d_double_array(vg);
 
   memory->destroy_1d_double_array(fkx,nxlo_fft);
   memory->destroy_1d_double_array(fky,nylo_fft);
   memory->destroy_1d_double_array(fkz,nzlo_fft);
 
-  delete [] buf1;
-  delete [] buf2;
+  memory->sfree(buf1);
+  memory->sfree(buf2);
 
   delete [] gf_b;
   memory->destroy_2d_double_array(rho1d,-order/2);
diff -Naur lammps-29Jan09/src/MAKE/Makefile.g++_reax lammps-12Feb09/src/MAKE/Makefile.g++_reax
--- lammps-29Jan09/src/MAKE/Makefile.g++_reax	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/MAKE/Makefile.g++_reax	2009-02-10 11:20:30.000000000 -0700
@@ -0,0 +1,41 @@
+# g++_reax = RedHat Linux box, g++, MPICH2, FFTW, REAX lib
+
+SHELL = /bin/sh
+
+# System-specific settings
+
+CC =		g++
+CCFLAGS =	-g -O -I../../lib/reax \
+		-DFFT_FFTW -DLAMMPS_GZIP -DMPICH_IGNORE_CXX_SEEK
+DEPFLAGS =	-M
+LINK =		g++
+LINKFLAGS =	-g -O  -L../../lib/reax -L/sw/lib/gcc4.2/lib
+USRLIB =	-lfftw -lmpich -lreax
+SYSLIB =	-lpthread -lg2c
+ARCHIVE =	ar
+ARFLAGS =	-rc
+SIZE =		size
+
+# Link target
+
+$(EXE):	$(OBJ)
+	$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
+	$(SIZE) $(EXE)
+
+# Library target
+
+lib:	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
+
+# Compilation rules
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $<
+
+%.d:%.cpp
+	$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
+
+# Individual dependencies
+
+DEPENDS = $(OBJ:.o=.d)
+include $(DEPENDS)
diff -Naur lammps-29Jan09/src/MAKE/Makefile.linux_reax lammps-12Feb09/src/MAKE/Makefile.linux_reax
--- lammps-29Jan09/src/MAKE/Makefile.linux_reax	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/MAKE/Makefile.linux_reax	2009-02-10 11:20:30.000000000 -0700
@@ -0,0 +1,41 @@
+# linux_reax = RedHat Linux box, Intel icc, MPICH2, FFTW, REAX lib
+
+SHELL = /bin/sh
+
+# System-specific settings
+
+CC =		icc
+CCFLAGS =	-O -I../../lib/reax \
+		-DFFT_FFTW -DLAMMPS_GZIP -DMPICH_IGNORE_CXX_SEEK
+DEPFLAGS =	-M
+LINK =		icc
+LINKFLAGS =	-O -L../../lib/reax -L/opt/intel/fce/10.0.023/lib
+USRLIB =	-lfftw -lmpich -lreax
+SYSLIB =	-lpthread -lstdc++ -lifcore -lsvml -lompstub -limf
+ARCHIVE =	ar
+ARFLAGS =	-rc
+SIZE =		size
+
+# Link target
+
+$(EXE):	$(OBJ)
+	$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
+	$(SIZE) $(EXE)
+
+# Library target
+
+lib:	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
+
+# Compilation rules
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $<
+
+%.d:%.cpp
+	$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
+
+# Individual dependencies
+
+DEPENDS = $(OBJ:.o=.d)
+include $(DEPENDS)
diff -Naur lammps-29Jan09/src/MAKE/Makefile.mac_reax lammps-12Feb09/src/MAKE/Makefile.mac_reax
--- lammps-29Jan09/src/MAKE/Makefile.mac_reax	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/MAKE/Makefile.mac_reax	2009-02-06 11:30:45.000000000 -0700
@@ -0,0 +1,32 @@
+# mac_reax = Apple PowerBook G4 laptop, Finked LAM/MPI, Finked FFTW 2.1.5, REAX lib
+
+SHELL = /bin/sh
+
+# System-specific settings
+
+FFTW =	/sw
+
+CC =		mpic++
+CCFLAGS =	-O -MMD	-MG -DFFT_FFTW -I../../lib/reax -I${FFTW}/include \
+		-DOMPI_SKIP_MPICXX
+LINK =		mpic++
+LINKFLAGS =	-O  -L${FFTW}/lib -L../../lib/reax -L/sw/lib/gcc4.2/lib
+USRLIB =	-lfftw -lreax
+SYSLIB =	-lgfortran 
+SIZE =		size
+
+# Link rule
+
+$(EXE):	$(OBJ)
+	$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
+	$(SIZE) $(EXE)
+
+# Compilation rules
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $<
+
+# Individual dependencies
+
+DEPENDS = $(OBJ:.o=.d)
+-include $(DEPENDS)
diff -Naur lammps-29Jan09/src/MAKE/Makefile.tacc lammps-12Feb09/src/MAKE/Makefile.tacc
--- lammps-29Jan09/src/MAKE/Makefile.tacc	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/MAKE/Makefile.tacc	2009-02-05 07:43:04.000000000 -0700
@@ -0,0 +1,44 @@
+# g++ = UT Lonestar TACC machine, mpiCC, MPI, FFTW
+
+SHELL = /bin/sh
+
+# System-specific settings
+
+FFTW_INC = ${TACC_FFTW2_INC}
+FFTW_LIB = ${TACC_FFTW2_LIB}
+
+CC =		mpiCC
+CCFLAGS =	-O -DFFT_FFTW -I${FFTW_INC}
+DEPFLAGS =	-M
+LINK =		mpiCC
+LINKFLAGS =	-O -L${FFTW_LIB}
+USRLIB =	${FFTW_LIB}/libfftw.a
+SYSLIB =	-L/opt/apps/intel/10.1/fc/lib -lifcore
+#SYSLIB =	-L/opt/apps/intel/10.1/fc/lib -lifcore (use if linking to MEAM)
+ARCHIVE =	ar
+ARFLAGS =	-rc
+SIZE =		size
+
+# Link target
+
+$(EXE):	$(OBJ)
+	$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
+	$(SIZE) $(EXE)
+
+# Library target
+
+lib:	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
+
+# Compilation rules
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $<
+
+%.d:%.cpp
+	$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
+
+# Individual dependencies
+
+DEPENDS = $(OBJ:.o=.d)
+include $(DEPENDS)
diff -Naur lammps-29Jan09/src/Makefile lammps-12Feb09/src/Makefile
--- lammps-29Jan09/src/Makefile	2008-07-24 14:46:29.000000000 -0600
+++ lammps-12Feb09/src/Makefile	2009-02-06 10:05:59.000000000 -0700
@@ -14,7 +14,7 @@
 # Package variables
 
 PACKAGE = asphere class2 colloid dipole dpd granular \
-	  kspace manybody meam molecule opt peri poems xtc
+	  kspace manybody meam molecule opt peri poems reax xtc
 
 PACKUSER = user-ackland user-cg-cmm user-ewaldn user-smd
 
diff -Naur lammps-29Jan09/src/Makefile.list lammps-12Feb09/src/Makefile.list
--- lammps-29Jan09/src/Makefile.list	2009-01-09 15:28:07.000000000 -0700
+++ lammps-12Feb09/src/Makefile.list	2009-02-12 13:45:05.000000000 -0700
@@ -7,9 +7,9 @@
 ROOT =	lmp
 EXE =	$(ROOT)_$@
 
-SRC =	angle.cpp angle_charmm.cpp angle_cosine.cpp angle_cosine_delta.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_vec.cpp atom_vec_angle.cpp atom_vec_atomic.cpp atom_vec_bond.cpp atom_vec_charge.cpp atom_vec_full.cpp atom_vec_hybrid.cpp atom_vec_molecular.cpp bond.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp change_box.cpp comm.cpp compute.cpp compute_centro_atom.cpp compute_coord_atom.cpp compute_displace_atom.cpp compute_erotate_sphere.cpp compute_group_group.cpp compute_ke.cpp compute_ke_atom.cpp compute_pe.cpp compute_pe_atom.cpp compute_pressure.cpp compute_reduce.cpp compute_stress_atom.cpp compute_temp.cpp compute_temp_com.cpp compute_temp_deform.cpp compute_temp_partial.cpp compute_temp_ramp.cpp compute_temp_region.cpp compute_temp_sphere.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp displace_box.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xyz.cpp error.cpp ewald.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_atom.cpp fix_ave_force.cpp fix_ave_spatial.cpp fix_ave_time.cpp fix_bond_break.cpp fix_bond_create.cpp fix_bond_swap.cpp fix_com.cpp fix_coord_original.cpp fix_deform.cpp fix_deposit.cpp fix_drag.cpp fix_dt_reset.cpp fix_efield.cpp fix_enforce2d.cpp fix_gravity.cpp fix_gyration.cpp fix_heat.cpp fix_indent.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_npt_sphere.cpp fix_nve.cpp fix_nve_limit.cpp fix_nve_noforce.cpp fix_nve_sphere.cpp fix_nvt.cpp fix_nvt_sllod.cpp fix_nvt_sphere.cpp fix_orient_fcc.cpp fix_plane_force.cpp fix_press_berendsen.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_temp_berendsen.cpp fix_temp_rescale.cpp fix_thermal_conductivity.cpp fix_tmd.cpp fix_viscosity.cpp fix_viscous.cpp fix_wall_lj126.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp integrate.cpp kspace.cpp lammps.cpp lattice.cpp library.cpp main.cpp memory.cpp min.cpp min_cg.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_derive.cpp neigh_full.cpp neigh_gran.cpp neigh_half_bin.cpp neigh_half_multi.cpp neigh_half_nsq.cpp neigh_list.cpp neigh_request.cpp neigh_respa.cpp neigh_stencil.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_airebo.cpp pair_buck.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_coul_cut.cpp pair_coul_debye.cpp pair_coul_long.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_fs.cpp pair_hybrid.cpp pair_hybrid_overlay.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_expand.cpp pair_lj_gromacs.cpp pair_lj_gromacs_coul_gromacs.cpp pair_lj_smooth.cpp pair_morse.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_tersoff_zbl.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp temper.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp
+SRC =	angle.cpp angle_cg_cmm.cpp angle_charmm.cpp angle_class2.cpp angle_cosine.cpp angle_cosine_delta.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_vec.cpp atom_vec_angle.cpp atom_vec_atomic.cpp atom_vec_bond.cpp atom_vec_charge.cpp atom_vec_dipole.cpp atom_vec_dpd.cpp atom_vec_ellipsoid.cpp atom_vec_full.cpp atom_vec_granular.cpp atom_vec_hybrid.cpp atom_vec_molecular.cpp atom_vec_peri.cpp bond.cpp bond_class2.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp cg_cmm_parms.cpp change_box.cpp comm.cpp compute.cpp compute_ackland_atom.cpp compute_centro_atom.cpp compute_cna_atom.cpp compute_coord_atom.cpp compute_damage_atom.cpp compute_displace_atom.cpp compute_erotate_asphere.cpp compute_erotate_sphere.cpp compute_group_group.cpp compute_ke.cpp compute_ke_atom.cpp compute_pe.cpp compute_pe_atom.cpp compute_pressure.cpp compute_reduce.cpp compute_stress_atom.cpp compute_temp.cpp compute_temp_asphere.cpp compute_temp_com.cpp compute_temp_deform.cpp compute_temp_partial.cpp compute_temp_ramp.cpp compute_temp_region.cpp compute_temp_sphere.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_class2.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp displace_box.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xtc.cpp dump_xyz.cpp error.cpp ewald.cpp ewald_n.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_atom.cpp fix_ave_force.cpp fix_ave_spatial.cpp fix_ave_time.cpp fix_bond_break.cpp fix_bond_create.cpp fix_bond_swap.cpp fix_com.cpp fix_coord_original.cpp fix_deform.cpp fix_deposit.cpp fix_drag.cpp fix_dt_reset.cpp fix_efield.cpp fix_enforce2d.cpp fix_freeze.cpp fix_gravity.cpp fix_gyration.cpp fix_heat.cpp fix_indent.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_npt_asphere.cpp fix_npt_sphere.cpp fix_nve.cpp fix_nve_asphere.cpp fix_nve_limit.cpp fix_nve_noforce.cpp fix_nve_sphere.cpp fix_nvt.cpp fix_nvt_asphere.cpp fix_nvt_sllod.cpp fix_nvt_sphere.cpp fix_orient_fcc.cpp fix_peri_neigh.cpp fix_plane_force.cpp fix_pour.cpp fix_press_berendsen.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_rigid2.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_smd.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_temp_berendsen.cpp fix_temp_rescale.cpp fix_thermal_conductivity.cpp fix_tmd.cpp fix_viscosity.cpp fix_viscous.cpp fix_wall_gran.cpp fix_wall_lj126.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_class2.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp integrate.cpp kspace.cpp lammps.cpp lattice.cpp library.cpp main.cpp memory.cpp min.cpp min_cg.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_derive.cpp neigh_full.cpp neigh_gran.cpp neigh_half_bin.cpp neigh_half_multi.cpp neigh_half_nsq.cpp neigh_list.cpp neigh_request.cpp neigh_respa.cpp neigh_stencil.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_airebo.cpp pair_buck.cpp pair_buck_coul.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_cg_cmm.cpp pair_cg_cmm_coul_cut.cpp pair_cg_cmm_coul_long.cpp pair_cmm_common.cpp pair_colloid.cpp pair_coul_cut.cpp pair_coul_debye.cpp pair_coul_long.cpp pair_dipole_cut.cpp pair_dpd.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_alloy_opt.cpp pair_eam_fs.cpp pair_eam_fs_opt.cpp pair_eam_opt.cpp pair_gayberne.cpp pair_gran_hertz_history.cpp pair_gran_hooke.cpp pair_gran_hooke_history.cpp pair_hybrid.cpp pair_hybrid_overlay.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_charmm_coul_long_opt.cpp pair_lj_class2.cpp pair_lj_class2_coul_cut.cpp pair_lj_class2_coul_long.cpp pair_lj_coul.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_cut_opt.cpp pair_lj_expand.cpp pair_lj_gromacs.cpp pair_lj_gromacs_coul_gromacs.cpp pair_lj_smooth.cpp pair_lubricate.cpp pair_morse.cpp pair_morse_opt.cpp pair_peri_pmb.cpp pair_resquared.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_tersoff_zbl.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp temper.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp xdr_compat.cpp
 
-INC =	angle.h angle_charmm.h angle_cosine.h angle_cosine_delta.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_vec.h atom_vec_angle.h atom_vec_atomic.h atom_vec_bond.h atom_vec_charge.h atom_vec_full.h atom_vec_hybrid.h atom_vec_molecular.h bond.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h change_box.h comm.h compute.h compute_centro_atom.h compute_coord_atom.h compute_displace_atom.h compute_erotate_sphere.h compute_group_group.h compute_ke.h compute_ke_atom.h compute_pe.h compute_pe_atom.h compute_pressure.h compute_reduce.h compute_stress_atom.h compute_temp.h compute_temp_com.h compute_temp_deform.h compute_temp_partial.h compute_temp_ramp.h compute_temp_region.h compute_temp_sphere.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h displace_box.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xyz.h error.h ewald.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_atom.h fix_ave_force.h fix_ave_spatial.h fix_ave_time.h fix_bond_break.h fix_bond_create.h fix_bond_swap.h fix_com.h fix_coord_original.h fix_deform.h fix_deposit.h fix_drag.h fix_dt_reset.h fix_efield.h fix_enforce2d.h fix_gravity.h fix_gyration.h fix_heat.h fix_indent.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_npt_sphere.h fix_nve.h fix_nve_limit.h fix_nve_noforce.h fix_nve_sphere.h fix_nvt.h fix_nvt_sllod.h fix_nvt_sphere.h fix_orient_fcc.h fix_plane_force.h fix_press_berendsen.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_set_force.h fix_shake.h fix_shear_history.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_temp_berendsen.h fix_temp_rescale.h fix_thermal_conductivity.h fix_tmd.h fix_viscosity.h fix_viscous.h fix_wall_lj126.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h lattice.h library.h math_extra.h memory.h min.h min_cg.h min_sd.h minimize.h modify.h neigh_list.h neigh_request.h neighbor.h output.h pack.h pair.h pair_airebo.h pair_buck.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_coul_cut.h pair_coul_debye.h pair_coul_long.h pair_eam.h pair_eam_alloy.h pair_eam_fs.h pair_hybrid.h pair_hybrid_overlay.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_expand.h pair_lj_gromacs.h pair_lj_gromacs_coul_gromacs.h pair_lj_smooth.h pair_morse.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_tersoff_zbl.h pair_yukawa.h pointers.h pppm.h pppm_tip4p.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_asphere.h style_class2.h style_colloid.h style_dipole.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_meam.h style_molecule.h style_opt.h style_peri.h style_poems.h style_sd.h style_user.h style_user_ackland.h style_user_cg_cmm.h style_user_ewaldn.h style_user_packages.h style_user_smd.h style_xtc.h temper.h thermo.h timer.h universe.h update.h variable.h velocity.h verlet.h write_restart.h
+INC =	angle.h angle_cg_cmm.h angle_charmm.h angle_class2.h angle_cosine.h angle_cosine_delta.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_vec.h atom_vec_angle.h atom_vec_atomic.h atom_vec_bond.h atom_vec_charge.h atom_vec_dipole.h atom_vec_dpd.h atom_vec_ellipsoid.h atom_vec_full.h atom_vec_granular.h atom_vec_hybrid.h atom_vec_molecular.h atom_vec_peri.h bond.h bond_class2.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h cg_cmm_parms.h change_box.h comm.h compute.h compute_ackland_atom.h compute_centro_atom.h compute_cna_atom.h compute_coord_atom.h compute_damage_atom.h compute_displace_atom.h compute_erotate_asphere.h compute_erotate_sphere.h compute_group_group.h compute_ke.h compute_ke_atom.h compute_pe.h compute_pe_atom.h compute_pressure.h compute_reduce.h compute_stress_atom.h compute_temp.h compute_temp_asphere.h compute_temp_com.h compute_temp_deform.h compute_temp_partial.h compute_temp_ramp.h compute_temp_region.h compute_temp_sphere.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_class2.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h displace_box.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xtc.h dump_xyz.h error.h ewald.h ewald_n.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_atom.h fix_ave_force.h fix_ave_spatial.h fix_ave_time.h fix_bond_break.h fix_bond_create.h fix_bond_swap.h fix_com.h fix_coord_original.h fix_deform.h fix_deposit.h fix_drag.h fix_dt_reset.h fix_efield.h fix_enforce2d.h fix_freeze.h fix_gravity.h fix_gyration.h fix_heat.h fix_indent.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_npt_asphere.h fix_npt_sphere.h fix_nve.h fix_nve_asphere.h fix_nve_limit.h fix_nve_noforce.h fix_nve_sphere.h fix_nvt.h fix_nvt_asphere.h fix_nvt_sllod.h fix_nvt_sphere.h fix_orient_fcc.h fix_peri_neigh.h fix_plane_force.h fix_pour.h fix_press_berendsen.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_rigid2.h fix_set_force.h fix_shake.h fix_shear_history.h fix_smd.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_temp_berendsen.h fix_temp_rescale.h fix_thermal_conductivity.h fix_tmd.h fix_viscosity.h fix_viscous.h fix_wall_gran.h fix_wall_lj126.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_class2.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h lattice.h library.h math_complex.h math_extra.h math_vector.h memory.h min.h min_cg.h min_sd.h minimize.h modify.h neigh_list.h neigh_request.h neighbor.h output.h pack.h pair.h pair_airebo.h pair_buck.h pair_buck_coul.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_cg_cmm.h pair_cg_cmm_coul_cut.h pair_cg_cmm_coul_long.h pair_cmm_common.h pair_colloid.h pair_coul_cut.h pair_coul_debye.h pair_coul_long.h pair_dipole_cut.h pair_dpd.h pair_eam.h pair_eam_alloy.h pair_eam_alloy_opt.h pair_eam_fs.h pair_eam_fs_opt.h pair_eam_opt.h pair_gayberne.h pair_gran_hertz_history.h pair_gran_hooke.h pair_gran_hooke_history.h pair_hybrid.h pair_hybrid_overlay.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_charmm_coul_long_opt.h pair_lj_class2.h pair_lj_class2_coul_cut.h pair_lj_class2_coul_long.h pair_lj_coul.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_cut_opt.h pair_lj_expand.h pair_lj_gromacs.h pair_lj_gromacs_coul_gromacs.h pair_lj_smooth.h pair_lubricate.h pair_morse.h pair_morse_opt.h pair_peri_pmb.h pair_resquared.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_tersoff_zbl.h pair_yukawa.h pointers.h pppm.h pppm_tip4p.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_asphere.h style_class2.h style_colloid.h style_dipole.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_meam.h style_molecule.h style_opt.h style_peri.h style_poems.h style_user.h style_user_ackland.h style_user_cg_cmm.h style_user_ewaldn.h style_user_packages.h style_user_smd.h style_xtc.h temper.h thermo.h timer.h universe.h update.h variable.h velocity.h verlet.h write_restart.h xdr_compat.h
 
 OBJ = 	$(SRC:.cpp=.o)
 
diff -Naur lammps-29Jan09/src/REAX/Install.csh lammps-12Feb09/src/REAX/Install.csh
--- lammps-29Jan09/src/REAX/Install.csh	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/REAX/Install.csh	2009-02-11 15:26:01.000000000 -0700
@@ -0,0 +1,22 @@
+# Install/unInstall package classes in LAMMPS
+
+if ($1 == 1) then
+
+  cp style_reax.h ..
+
+  cp pair_reax.cpp ..
+
+  cp pair_reax.h ..
+  cp pair_reax_fortran.h ..
+
+else if ($1 == 0) then
+
+  rm ../style_reax.h
+  touch ../style_reax.h
+
+  rm ../pair_reax.cpp
+
+  rm ../pair_reax.h
+  rm ../pair_reax_fortran.h
+
+endif
diff -Naur lammps-29Jan09/src/REAX/pair_reax.cpp lammps-12Feb09/src/REAX/pair_reax.cpp
--- lammps-29Jan09/src/REAX/pair_reax.cpp	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/REAX/pair_reax.cpp	2009-02-12 14:13:22.000000000 -0700
@@ -0,0 +1,1032 @@
+/* ----------------------------------------------------------------------
+   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 authors: Aidan Thompson (Sandia, athomps@sandia.gov)
+                         Hansohl Cho (MIT, hansohl@mit.edu)
+   LAMMPS implementation of the Reactive Force Field (ReaxFF) is based on
+     Aidan Thompson's GRASP code
+       (General Reactive Atomistic Simulation Program)
+     and Ardi Van Duin's original ReaxFF code
+------------------------------------------------------------------------- */
+
+#include "mpi.h"
+#include "math.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+#include "pair_reax.h"
+#include "pair_reax_fortran.h"
+#include "atom.h"
+#include "update.h"
+#include "force.h"
+#include "comm.h"
+#include "neighbor.h"
+#include "neigh_list.h"
+#include "neigh_request.h"
+#include "memory.h"
+#include "error.h"
+
+using namespace LAMMPS_NS;
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define SMALL 0.0001
+
+/* ---------------------------------------------------------------------- */
+
+PairREAX::PairREAX(LAMMPS *lmp) : Pair(lmp)
+{
+  single_enable = 0;
+  one_coeff = 1;
+  no_virial_compute = 1;
+  
+  cutmax = 0.0;
+  hbcut = 6.0;
+  iprune = 4;
+  ihb = 1;
+  chpot = 0;
+
+  nmax = 0;
+  arow_ptr = NULL;
+  ch = NULL;
+  elcvec = NULL;
+  rcg = NULL;
+  wcg = NULL;
+  pcg = NULL;
+  poldcg = NULL;
+  qcg = NULL;
+
+  matmax = 0;
+  aval = NULL;
+  acol_ind = NULL;
+
+  comm_forward = 1;
+  comm_reverse = 1;
+
+  precision = 1.0e-6;
+}
+
+/* ----------------------------------------------------------------------
+   free all arrays
+   check if allocated, since class can be destructed when incomplete
+------------------------------------------------------------------------- */
+
+PairREAX::~PairREAX()
+{
+  if (allocated) {
+    memory->destroy_2d_int_array(setflag);
+    memory->destroy_2d_double_array(cutsq);
+
+    for (int i = 1; i <= atom->ntypes; i++)
+      delete [] param_list[i].params;
+    delete [] param_list;
+
+    delete [] map;
+  }
+
+  memory->sfree(arow_ptr);
+  memory->sfree(ch);
+  memory->sfree(elcvec);
+  memory->sfree(rcg);
+  memory->sfree(wcg);
+  memory->sfree(pcg);
+  memory->sfree(poldcg);
+  memory->sfree(qcg);
+
+  memory->sfree(aval);
+  memory->sfree(acol_ind);
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::compute(int eflag, int vflag)
+{
+  int i,j;
+  double evdwl,ecoul;
+  double energy_charge_equilibration;
+
+  evdwl = ecoul = 0.0;
+  if (eflag || vflag) ev_setup(eflag,vflag);
+  else evflag = vflag_fdotr = 0;
+
+  if (vflag_global) FORTRAN(cbkvirial, CBKVIRIAL).Lvirial = 1;
+  else FORTRAN(cbkvirial, CBKVIRIAL).Lvirial = 0;
+
+  if (vflag_atom) FORTRAN(cbkvirial, CBKVIRIAL).Latomvirial = 1;
+  else FORTRAN(cbkvirial, CBKVIRIAL).Latomvirial = 0;
+
+  // reallocate charge equilibration and CG arrays if necessary
+
+  if (atom->nmax > nmax) {
+    memory->sfree(rcg);
+    memory->sfree(wcg);
+    memory->sfree(pcg);
+    memory->sfree(poldcg);
+    memory->sfree(qcg);
+
+    nmax = atom->nmax;
+    int n = nmax+1;
+
+    arow_ptr = (int *) memory->smalloc(n*sizeof(int),"reax:arow_ptr");
+    ch = (double *) memory->smalloc(n*sizeof(double),"reax:ch");
+    elcvec = (double *) memory->smalloc(n*sizeof(double),"reax:elcvec");
+    rcg = (double *) memory->smalloc(n*sizeof(double),"reax:rcg");
+    wcg = (double *) memory->smalloc(n*sizeof(double),"reax:wcg");
+    pcg = (double *) memory->smalloc(n*sizeof(double),"reax:pcg");
+    poldcg = (double *) memory->smalloc(n*sizeof(double),"reax:poldcg");
+    qcg = (double *) memory->smalloc(n*sizeof(double),"reax:qcg");
+  }
+
+  // calculate the atomic charge distribution
+ 
+  compute_charge(energy_charge_equilibration);
+
+  // transfer LAMMPS positions and neighbor lists to REAX
+
+  write_reax_positions();
+  write_reax_vlist();
+
+  // determine whether this bond is owned by the processor or not
+
+  FORTRAN(srtbon1, SRTBON1)(&iprune, &ihb, &hbcut);
+
+  // communicate with other processors for the atomic bond order calculations
+
+  FORTRAN(cbkabo, CBKABO).abo;
+
+  // communicate local atomic bond order to ghost atomic bond order
+
+  packflag = 0;
+  comm->comm_pair(this);
+
+  FORTRAN(molec, MOLEC)();
+  FORTRAN(encalc, ENCALC)();
+  FORTRAN(mdsav, MDSAV)(&comm->me);
+
+  // read forces from ReaxFF Fortran
+
+  read_reax_forces();
+
+  // extract global and per-atom energy from ReaxFF Fortran
+  // compute_charge already contributed to eatom
+
+  if (eflag_global) {
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).eb;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).ea;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).elp;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).emol;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).ev;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).epen;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).ecoa;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).ehb;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).et;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).eco;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).ew;
+    evdwl += FORTRAN(cbkenergies, CBKENERGIES).efi;
+
+    ecoul += FORTRAN(cbkenergies, CBKENERGIES).ep;
+    ecoul += energy_charge_equilibration;
+    
+    eng_vdwl += evdwl;
+    eng_coul += ecoul;
+  }
+
+  if (eflag_atom) {
+    int ntotal = atom->nlocal + atom->nghost;
+    for (i = 0; i < ntotal; i++)
+      eatom[i] += FORTRAN(cbkd,CBKD).estrain[i];
+  }
+
+  // extract global and per-atom virial from ReaxFF Fortran
+
+  if (vflag_global) {
+    virial[0] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[0];
+    virial[1] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[1];
+    virial[2] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[2];
+    virial[3] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[3];
+    virial[4] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[4];
+    virial[5] = -FORTRAN(cbkvirial, CBKVIRIAL).virial[5];
+  }
+
+  if (vflag_atom) {
+    int ntotal = atom->nlocal + atom->nghost;
+    j = 0;
+    for (i = 0; i < ntotal; i++) {
+      vatom[i][0] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+0];
+      vatom[i][1] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+1];
+      vatom[i][2] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+2];
+      vatom[i][3] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+3];
+      vatom[i][4] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+4];
+      vatom[i][5] = -FORTRAN(cbkvirial, CBKVIRIAL).atomvirial[j+5];
+      j += 6;
+    }
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::write_reax_positions()
+{
+  double xtmp, ytmp, ztmp;
+  int j, jx, jy, jz, jia;
+
+  double **x = atom->x;
+  double *q = atom->q;
+  int *type = atom->type;
+  int *tag = atom->tag;
+  int nlocal = atom->nlocal;
+  int nghost = atom->nghost;
+
+  FORTRAN(rsmall, RSMALL).na = nlocal+nghost;
+  FORTRAN(rsmall, RSMALL).na_local = nlocal;
+
+  jx = 0;
+  jy = ReaxParams::nat;
+  jz = 2*ReaxParams::nat;
+  jia = 0;
+
+  j = 0;
+  for (int i = 0; i < nlocal+nghost; i++, j++) {
+    FORTRAN(cbkc, CBKC).c[j+jx] = x[i][0];
+    FORTRAN(cbkc, CBKC).c[j+jy] = x[i][1];
+    FORTRAN(cbkc, CBKC).c[j+jz] = x[i][2];
+    FORTRAN(cbkch, CBKCH).ch[j] = q[i];
+    FORTRAN(cbkia, CBKIA).ia[j+jia] = map[type[i]];
+    FORTRAN(cbkia, CBKIA).iag[j+jia] = map[type[i]];
+    FORTRAN(cbkc, CBKC).itag[j] = tag[i];
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::write_reax_vlist()
+{
+  int ii, jj, i, j, iii, jjj;
+  double xitmp, yitmp, zitmp;
+  double xjtmp, yjtmp, zjtmp;
+  int itag,jtag;
+  int nvpair, nvlself, nvpairmax;
+  int nbond;
+  int inum,jnum;
+  int *ilist;
+  int *jlist;
+  int *numneigh,**firstneigh;
+  double delr2;
+  double delx, dely, delz;
+  double rtmp[3];
+
+  double **x = atom->x;
+  int *tag = atom->tag;
+  int nlocal = atom->nlocal;
+  int nghost = atom->nghost;
+
+  nvpairmax = ReaxParams::nneighmax * ReaxParams::nat;
+
+  nvpair = 0;
+  nvlself =0;
+  nbond = 0;
+
+  inum = list->inum;
+  ilist = list->ilist;
+  numneigh = list->numneigh;
+  firstneigh = list->firstneigh;
+
+  for (ii = 0; ii < inum; ii++) {
+    i = ilist[ii];
+    xitmp = x[i][0];
+    yitmp = x[i][1];
+    zitmp = x[i][2];
+    itag = tag[i];
+    jlist = firstneigh[i];
+    jnum = numneigh[i];
+    
+    for (jj = 0; jj < jnum; jj++) {
+      j = jlist[jj];
+      xjtmp = x[j][0];
+      yjtmp = x[j][1];
+      zjtmp = x[j][2];
+      jtag = tag[j];
+      
+      delx = xitmp - xjtmp;
+      dely = yitmp - yjtmp;
+      delz = zitmp - zjtmp;
+      
+      delr2 = delx*delx+dely*dely+delz*delz;
+      
+      if (delr2 <= rcutvsq) {
+	if (i < j) {
+	  iii = i+1;
+	  jjj = j+1;
+	} else {
+	  iii = j+1;
+	  jjj = i+1;
+	}
+	if (nvpair >= nvpairmax) break;
+	
+	FORTRAN(cbkpairs, CBKPAIRS).nvl1[nvpair] = iii;
+	FORTRAN(cbkpairs, CBKPAIRS).nvl2[nvpair] = jjj;
+	FORTRAN(cbknvlbo, CBKNVLBO).nvlbo[nvpair] = 0;
+	
+	if (delr2 <= rcutbsq) {
+	  FORTRAN(cbknvlbo, CBKNVLBO).nvlbo[nvpair] = 1;
+	  nbond++;
+	}
+	
+	FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 0;
+	
+	if (j < nlocal)
+	  FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 1;
+	else if (itag < jtag)
+	  FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 1;
+	else if (itag == jtag) {
+	  if (delz > SMALL)
+	    FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 1;
+	  else if (fabs(delz) < SMALL) {
+	    if (dely > SMALL)
+	      FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 1;
+	    else if (fabs(dely) < SMALL && delx > SMALL)
+	      FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 1;
+	  }
+	}
+	nvpair++;
+      }
+    }
+  }
+
+  int ntotal = nlocal + nghost;
+
+  for (int i = nlocal; i < ntotal; i++) {
+    xitmp = x[i][0];
+    yitmp = x[i][1];
+    zitmp = x[i][2];
+    itag = tag[i];
+
+    for (int j = i+1; j < ntotal; j++) {
+      xjtmp = x[j][0];
+      yjtmp = x[j][1];
+      zjtmp = x[j][2];
+      jtag = tag[j];
+      
+      delx = xitmp - xjtmp;
+      dely = yitmp - yjtmp;
+      delz = zitmp - zjtmp;
+      
+      delr2 = delx*delx+dely*dely+delz*delz;
+      
+      // don't need to check the double count since i < j in the ghost region
+
+      if (delr2 <= rcutvsq) {
+	iii = i+1;
+	jjj = j+1;
+	      
+	if (nvpair >= nvpairmax) break;
+	
+	FORTRAN(cbkpairs, CBKPAIRS).nvl1[nvpair] = iii;
+	FORTRAN(cbkpairs, CBKPAIRS).nvl2[nvpair] = jjj;
+	FORTRAN(cbknvlbo, CBKNVLBO).nvlbo[nvpair] = 0;
+
+	if (delr2 <= rcutbsq) {
+	  FORTRAN(cbknvlbo, CBKNVLBO).nvlbo[nvpair] = 1;
+	  nbond++;
+	}
+	
+	FORTRAN(cbknvlown, CBKNVLOWN).nvlown[nvpair] = 0;
+	nvpair++;
+      }
+    }
+  }
+
+  FORTRAN(cbkpairs, CBKPAIRS).nvpair = nvpair;
+  FORTRAN(cbkpairs, CBKPAIRS).nvlself = nvlself;
+}
+					      
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::read_reax_forces()
+{
+  double ftmp[3];
+
+  double **f = atom->f;
+  int ntotal = atom->nlocal + atom->nghost;
+
+  int j = 0;
+  for (int i = 0; i < ntotal; i++) {
+    ftmp[0] = -FORTRAN(cbkd, CBKD).d[j];
+    ftmp[1] = -FORTRAN(cbkd, CBKD).d[j+1];
+    ftmp[2] = -FORTRAN(cbkd, CBKD).d[j+2];
+    f[i][0] = ftmp[0];
+    f[i][1] = ftmp[1];
+    f[i][2] = ftmp[2];
+    j += 3;
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::allocate()
+{
+  allocated = 1;
+  int n = atom->ntypes;
+
+  setflag = memory->create_2d_int_array(n+1,n+1,"pair:setflag");
+  cutsq = memory->create_2d_double_array(n+1,n+1,"pair:cutsq");
+
+  param_list = new ff_params[n+1];
+  for (int i = 1; i <= n; i++)
+    param_list[i].params = new double[5];
+
+  map = new int[n+1];
+}
+
+/* ----------------------------------------------------------------------
+   global settings 
+------------------------------------------------------------------------- */
+
+void PairREAX::settings(int narg, char **arg)
+{
+  if (narg != 0 && narg !=2) error->all("Illegal pair_style command");
+  
+  if (narg == 2) {
+    hbcut = atof(arg[0]);
+    precision = atof(arg[1]);
+
+    if (hbcut <= 0.0 || precision <= 0.0)
+      error->all("Illegal pair_style command");
+  }
+}
+
+/* ----------------------------------------------------------------------
+   set coeffs for one or more type pairs
+------------------------------------------------------------------------- */
+
+void PairREAX::coeff(int narg, char **arg)
+{
+  if (!allocated) allocate();
+
+  if (narg != 3 + atom->ntypes)
+    error->all("Incorrect args for pair coefficients");
+
+  // insure I,J args are * *
+
+  if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
+    error->all("Incorrect args for pair coefficients");
+
+  // insure filename is ffield.reax
+
+  if (strcmp(arg[2],"ffield.reax") != 0) 
+    error->all("Incorrect args for pair coefficients");
+
+  // read args that map atom types to elements in potential file
+  // map[i] = which element the Ith atom type is, -1 if NULL
+
+  for (int i = 3; i < narg; i++) {
+    if (strcmp(arg[i],"NULL") == 0) {
+      map[i-2] = -1;
+      continue;
+    }
+    map[i-2] = atoi(arg[i]);
+  }
+
+  int n = atom->ntypes;
+
+  int count = 0;
+  for (int i = 1; i <= n; i++)
+    for (int j = i; j <= n; j++) {
+      setflag[i][j] = 1;
+      count++;
+    }
+
+  if (count == 0) error->all("Incorrect args for pair coefficients");
+}
+
+/* ----------------------------------------------------------------------
+   init specific to this pair style
+------------------------------------------------------------------------- */
+
+void PairREAX::init_style()
+{
+  if (atom->tag_enable == 0)
+    error->all("Pair style reax requires atom IDs");
+  if (force->newton_pair == 0)
+    error->all("Pair style reax requires newton pair on");
+  if (strcmp(update->unit_style,"real") != 0 && comm->me == 0)
+    error->warning("Not using real units with pair reax");
+
+  int irequest = neighbor->request(this);
+  neighbor->requests[irequest]->newton = 2;
+
+  FORTRAN(readc, READC)();
+  FORTRAN(init, INIT)();
+  FORTRAN(ffinpt, FFINPT)();
+  FORTRAN(tap7th, TAP7TH)();
+
+  // turn off read_in by fort.3 in REAX Fortran
+
+  int ngeofor_tmp = -1;
+  FORTRAN(setngeofor, SETNGEOFOR)(&ngeofor_tmp);
+  if (comm->me == 0) FORTRAN(readgeo, READGEO)();
+
+  // initial setup for cutoff radius of VLIST and BLIST in ReaxFF
+
+  double vlbora;
+  
+  FORTRAN(getswb, GETSWB)(&swb);
+  cutmax=MAX(swb, hbcut);
+  rcutvsq=cutmax*cutmax;
+  FORTRAN(getvlbora, GETVLBORA)(&vlbora);
+  rcutbsq=vlbora*vlbora;
+
+  // parameters for charge equilibration from ReaxFF input, fort.4
+  // verify that no LAMMPS type to REAX type mapping was invalid
+
+  int nelements;
+  FORTRAN(getnso, GETNSO)(&nelements);
+
+  FORTRAN(getswa, GETSWA)(&swa);
+  double chi, eta, gamma;
+  for (int itype = 1; itype <= atom->ntypes; itype++) {
+    if (map[itype] < 1 || map[itype] > nelements)
+      error->all("Invalid REAX atom type");
+    chi = FORTRAN(cbkchb, CBKCHB).chi[map[itype]-1];
+    eta = FORTRAN(cbkchb, CBKCHB).eta[map[itype]-1];
+    gamma = FORTRAN(cbkchb, CBKCHB).gam[map[itype]-1];
+    param_list[itype].np = 5;
+    param_list[itype].rcutsq = cutmax;
+    param_list[itype].params[0] = chi;
+    param_list[itype].params[1] = eta;
+    param_list[itype].params[2] = gamma;
+    param_list[itype].params[3] = swa;
+    param_list[itype].params[4] = swb;
+  }
+
+  taper_setup();
+}
+
+/* ----------------------------------------------------------------------
+   init for one type pair i,j and corresponding j,i
+------------------------------------------------------------------------- */
+
+double PairREAX::init_one(int i, int j)
+{
+  return cutmax;
+}
+
+/* ---------------------------------------------------------------------- */
+
+int PairREAX::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc)
+{
+  int i,j,m;
+
+  m = 0;
+
+  if (packflag == 0) {
+    for (i = 0; i < n; i++) {
+      j = list[i];
+      buf[m++] = FORTRAN(cbkabo, CBKABO).abo[j];
+    }
+
+  } else {
+    for (i = 0; i < n; i++) {
+      j = list[i];
+      buf[m++] = wcg[j];
+    }
+  }
+
+  return 1;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::unpack_comm(int n, int first, double *buf)
+{
+  int i,m,last;
+
+  m = 0;
+  last = first + n;
+
+  if (packflag == 0) {
+    for (i = first; i < last; i++)
+      FORTRAN(cbkabo, CBKABO).abo[i] = buf[m++];
+
+  } else {
+    for (i = first; i < last; i++)
+      wcg[i] = buf[m++];
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+int PairREAX::pack_reverse_comm(int n, int first, double *buf)
+{
+  int i,k,m,last,size;
+
+  m = 0;
+  last = first + n;
+  for (i = first; i < last; i++) 
+    buf[m++] = wcg[i];
+
+  return 1;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::unpack_reverse_comm(int n, int *list, double *buf)
+{
+  int i,j,k,m;
+
+  m = 0;
+  for (i = 0; i < n; i++) {
+    j = list[i];
+    wcg[j] += buf[m++];
+  }
+}
+
+/* ----------------------------------------------------------------------
+   charge equilibration routines
+------------------------------------------------------------------------- */
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::taper_setup()
+{
+  double swb2,swa2,swb3,swa3,d1,d7;
+
+  d1=swb-swa;
+  d7=pow(d1,7);
+  swa2=swa*swa;
+  swa3=swa2*swa;
+  swb2=swb*swb;
+  swb3=swb2*swb;
+ 
+  swc7=  20.0e0/d7;
+  swc6= -70.0e0*(swa+swb)/d7;
+  swc5=  84.0e0*(swa2+3.0e0*swa*swb+swb2)/d7;
+  swc4= -35.0e0*(swa3+9.0e0*swa2*swb+9.0e0*swa*swb2+swb3)/d7;
+  swc3= 140.0e0*(swa3*swb+3.0e0*swa2*swb2+swa*swb3)/d7;
+  swc2=-210.0e0*(swa3*swb2+swa2*swb3)/d7;
+  swc1= 140.0e0*swa3*swb3/d7;
+  swc0=(-35.0e0*swa3*swb2*swb2+21.0e0*swa2*swb3*swb2+
+	7.0e0*swa*swb3*swb3+swb3*swb3*swb)/d7;
+}
+
+/* ---------------------------------------------------------------------- */
+
+double PairREAX::taper_E(const double &r, const double &r2)
+{
+  double r3=r2*r;
+  return swc7*r3*r3*r+swc6*r3*r3+swc5*r3*r2+swc4*r2*r2+swc3*r3+swc2*r2+
+     swc1*r+swc0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+double PairREAX::taper_F(const double &r, const double &r2)
+{
+  double r3=r2*r;
+  return 7.0e0*swc7*r3*r3+6.0e0*swc6*r3*r2+5.0e0*swc5*r2*r2+
+    4.0e0*swc4*r3+3.0e0*swc3*r2+2.0e0*swc2*r+swc1;
+}
+
+/* ----------------------------------------------------------------------
+   compute current charge distributions based on the charge equilibration
+------------------------------------------------------------------------- */
+
+void PairREAX::compute_charge(double &energy_charge_equilibration)
+{
+  double xitmp, yitmp, zitmp;
+  double xjtmp, yjtmp, zjtmp;
+  int itype, jtype, itag, jtag;
+  int ii, jj, i, j;
+  double delr2, delr_norm, gamt, hulp1, hulp2;
+  double delx, dely, delz;
+  double qsum,qi;
+  int nmatentries;
+  double sw;
+  double rtmp[3];
+  int inum,jnum;
+  int *ilist;
+  int *jlist;
+  int *numneigh,**firstneigh;
+
+  double **x = atom->x;
+  double *q = atom->q;
+  int *type = atom->type;
+  int *tag = atom->tag;
+
+  int nlocal = atom->nlocal;
+  int nghost = atom->nghost;
+
+  inum = list->inum;
+  ilist = list->ilist;
+  numneigh = list->numneigh;
+  firstneigh = list->firstneigh;
+
+  // realloc neighbor based arrays if necessary
+
+  int numneigh_total = 0;
+  for (ii = 0; ii < inum; ii++)
+    numneigh_total += numneigh[ilist[ii]];
+
+  if (numneigh_total + 2*nlocal > matmax) {
+    memory->sfree(aval);
+    memory->sfree(acol_ind);
+    matmax = numneigh_total + 2*nlocal;
+    aval = (double *) memory->smalloc(matmax*sizeof(double),"reax:aval");
+    acol_ind = (int *) memory->smalloc(matmax*sizeof(int),"reax:acol_ind");
+  }
+
+  // build linear system
+
+  nmatentries = 0;
+
+  for (ii = 0; ii < inum; ii++) {
+    i = ilist[ii];
+    xitmp = x[i][0];
+    yitmp = x[i][1];
+    zitmp = x[i][2];
+    itype = type[i];
+    itag = tag[i];
+    jlist = firstneigh[i];
+    jnum = numneigh[i];
+    
+    arow_ptr[i] = nmatentries;
+    aval[nmatentries] = 2.0*param_list[itype].params[1];
+    acol_ind[nmatentries] = i;
+    nmatentries++;
+    
+    aval[nmatentries] = 1.0;
+    acol_ind[nmatentries] = nlocal + nghost;
+    nmatentries++;   
+    
+    for (jj = 0; jj < jnum; jj++) {
+      j = jlist[jj];
+      xjtmp = x[j][0];
+      yjtmp = x[j][1];
+      zjtmp = x[j][2];
+      jtype = type[j];
+      jtag = tag[j];
+      
+      delx = xitmp - xjtmp;
+      dely = yitmp - yjtmp;
+      delz = zitmp - zjtmp;
+      
+      delr2 = delx*delx+dely*dely+delz*delz;
+      
+      // avoid counting local-ghost pair twice since
+      // ReaxFF uses half neigh list with newton off
+
+      if (j >= nlocal) {
+	if (itag > jtag) {
+	  if ((itag+jtag) % 2 == 0) continue;
+	} else if (itag < jtag) {
+	  if ((itag+jtag) % 2 == 1) continue;
+	} else {
+	  if (zjtmp < zitmp) continue;
+	  if (zjtmp == zitmp && yjtmp < yitmp) continue;
+	  if (zjtmp == zitmp && yjtmp == yitmp && xjtmp < xitmp) continue;
+	}
+      }
+
+      // rcutvsq = cutmax*cutmax, in ReaxFF
+
+      if (delr2 <= rcutvsq) {
+	gamt = sqrt(param_list[itype].params[2]*param_list[jtype].params[2]);
+	delr_norm = sqrt(delr2);
+	sw = taper_E(delr_norm, delr2);	
+	hulp1=(delr_norm*delr2+(1.0/(gamt*gamt*gamt)));
+	hulp2=sw*14.40/cbrt(hulp1);
+	aval[nmatentries] = hulp2;
+	acol_ind[nmatentries] = j;
+	nmatentries++;
+      }
+    }
+  }
+
+  // in this case, we don't use Midpoint method
+  // so, we don't need to consider ghost-ghost interactions
+  // but, need to fill the arow_ptr[] arrays for the ghost atoms
+
+  for (i = nlocal; i < nlocal+nghost; i++)
+    arow_ptr[i] = nmatentries;
+  arow_ptr[nlocal+nghost] = nmatentries;
+
+  // add rhs matentries to linear system
+ 
+  for (ii =0; ii<inum; ii++) {
+    i = ilist[ii];
+    itype = type[i];
+    elcvec[i] = -param_list[itype].params[0];
+  }
+
+  for (i = nlocal; i < nlocal+nghost; i++) elcvec[i] = 0.0;
+
+  // assign current charges to charge vector
+
+  qsum = 0.0;
+  for (ii = 0; ii < inum; ii++) {
+    i = ilist[ii];
+    qi = q[i];
+    ch[i] = qi;
+    if (i < nlocal) qsum += qi;
+  }
+
+  for (i = nlocal; i < nlocal+nghost; i++) {
+    qi = q[i];
+    ch[i] = qi;
+  }
+
+  double qtot;
+  MPI_Allreduce(&qsum,&qtot,1,MPI_DOUBLE,MPI_SUM,world);
+  elcvec[nlocal+nghost] = 0.0;
+  ch[nlocal+nghost] = chpot;
+
+  // solve the linear system using CG sover
+
+  charge_reax(nlocal,nghost,ch,aval,acol_ind,arow_ptr,elcvec);
+
+  // calculate the charge equilibration energy
+
+  energy_charge_equilibration = 0;
+
+  // have already updated charge distributions for the current structure
+
+  for (ii = 0; ii < inum; ii++) {
+    i = ilist[ii];
+    itype = type[i];
+
+    // 23.02 is the ReaxFF conversion from eV to kcal/mol
+    // should really use constants.evfactor ~23.06
+    // but that would break consistency with serial ReaxFF code
+    // NOTE: this hard-wired real units
+    //       if want other units would have to change params[] in file
+
+    qi = 23.02 * (param_list[itype].params[0]*ch[i]+
+		  param_list[itype].params[1]*ch[i]*ch[i]);
+    energy_charge_equilibration += qi;
+    if (eflag_atom) eatom[i] += qi;
+  }
+
+  // copy charge vector back to particles from the calculated values
+
+  for (i = 0; i < nlocal+nghost; i++) q[i] = ch[i];
+  chpot = ch[nlocal+nghost];
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairREAX::charge_reax(const int & nlocal, const int & nghost,
+			   double ch[], double aval[], int acol_ind[],
+			   int arow_ptr[], double elcvec[])
+{
+  double chpottmp, suma;
+  double sumtmp;
+
+  cg_solve(nlocal,nghost,aval,acol_ind,arow_ptr,ch,elcvec);
+}
+
+/* ----------------------------------------------------------------------
+   CG solver for linear systems
+------------------------------------------------------------------------- */
+
+void PairREAX::cg_solve(const int & nlocal, const int & nghost, 
+			double aval[], int acol_ind[], int arow_ptr[],
+			double x[], double b[])
+{
+  double one, zero, rho, rho_old, alpha, beta, gamma;
+  int iter, maxiter;
+  int n;
+  double sumtmp;
+
+  // parallel CG method by A. P. Thompson
+  // distributed (partial) vectors: b, r, q, A
+  // accumulated (full) vectors: x, w, p
+  // r = b-A.x
+  // w = r            (ReverseComm + Comm)
+  
+  double *r = rcg;
+  double *w = wcg;
+  double *p = pcg;
+  double *p_old = poldcg;
+  double *q = qcg;
+
+  n = nlocal+nghost+1;
+
+  one = 1.0;
+  zero = 0.0;
+  maxiter = 100;
+
+  for (int i = 0; i < n; i++) w[i] = 0;
+  
+  // construct r = b-Ax
+
+  sparse_product(n, nlocal, nghost, aval, acol_ind, arow_ptr, x, r);
+  
+  // not using BLAS library
+
+  for (int i=0; i<n; i++) {
+    r[i] = b[i] - r[i];
+    w[i] = r[i];
+  }
+  
+  packflag = 1;
+  comm->reverse_comm_pair(this);
+  comm->comm_pair(this);
+  
+  MPI_Allreduce(&w[n-1], &sumtmp, 1, MPI_DOUBLE, MPI_SUM, world);
+  w[n-1] = sumtmp;
+  rho_old = one;
+
+  for (iter = 1; iter < maxiter; iter++) {
+    rho = 0.0;
+    for (int i=0; i<nlocal; i++) rho += w[i]*w[i];
+
+    MPI_Allreduce(&rho, &sumtmp, 1, MPI_DOUBLE, MPI_SUM, world);
+    rho = sumtmp + w[n-1]*w[n-1];
+    if (rho < precision) break;
+
+    for (int i = 0; i<n; i++) p[i] = w[i];
+
+    if (iter > 1) {
+      beta = rho/rho_old;
+      for (int i = 0; i<n; i++) p[i] += beta*p_old[i];
+    }
+
+    sparse_product(n, nlocal, nghost, aval, acol_ind, arow_ptr, p, q);
+    
+    gamma = 0.0;
+    for (int i=0; i<n; i++) gamma += p[i]*q[i];
+    MPI_Allreduce(&gamma, &sumtmp, 1, MPI_DOUBLE, MPI_SUM, world);
+
+    gamma = sumtmp;
+    alpha = rho/gamma;
+
+    for (int i=0; i<n; i++) {
+      x[i] += alpha*p[i];
+      r[i] -= alpha*q[i];
+      w[i] = r[i];
+    }
+      
+    comm->reverse_comm_pair(this);
+    comm->comm_pair(this);
+
+    MPI_Allreduce(&w[n-1], &sumtmp, 1, MPI_DOUBLE, MPI_SUM, world);
+    w[n-1] = sumtmp;
+
+    for (int i=0; i<n; i++) p_old[i] = p[i];
+    rho_old = rho;
+  }
+}
+
+/* ----------------------------------------------------------------------
+   sparse maxtrix operations
+------------------------------------------------------------------------- */
+
+void PairREAX::sparse_product(const int &n, const int &nlocal,
+			      const int &nghost,
+			      double aval[], int acol_ind[], int arow_ptr[],
+			      double *x, double *r)
+{
+  int i,j,jj;
+
+  for (i=0; i<n; i++) r[i] = 0.0;
+
+  for (i=0; i<nlocal; i++) {
+    r[i] += aval[arow_ptr[i]]*x[i];
+    for (j=arow_ptr[i]+1; j<arow_ptr[i+1]; j++) {
+      jj = acol_ind[j];
+      r[i] += aval[j]*x[jj];
+      r[jj] += aval[j]*x[i];
+    }
+  }
+  
+  for (i=nlocal; i<nlocal+nghost; i++)
+    for (j=arow_ptr[i]; j<arow_ptr[i+1]; j++) {
+      jj = acol_ind[j];
+      r[i] += aval[j]*x[jj];
+      r[jj] += aval[j]*x[i];
+    }
+}
+
+/* ----------------------------------------------------------------------
+   memory usage of local atom-based arrays 
+------------------------------------------------------------------------- */
+
+double PairREAX::memory_usage()
+{
+  double bytes = nmax * sizeof(int);
+  bytes += 7 * nmax * sizeof(double);
+  bytes += matmax * sizeof(int);
+  bytes += matmax * sizeof(double);
+  return bytes;
+}
diff -Naur lammps-29Jan09/src/REAX/pair_reax.h lammps-12Feb09/src/REAX/pair_reax.h
--- lammps-29Jan09/src/REAX/pair_reax.h	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/REAX/pair_reax.h	2009-02-12 13:45:31.000000000 -0700
@@ -0,0 +1,89 @@
+/* ----------------------------------------------------------------------
+   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.
+------------------------------------------------------------------------- */
+
+#ifndef PAIR_REAX_H
+#define PAIR_REAX_H
+
+#include "pair.h"
+
+namespace LAMMPS_NS {
+
+class PairREAX : public Pair {
+ public:
+  PairREAX(class LAMMPS *);
+  ~PairREAX();
+
+  void compute(int, int);
+  void settings(int, char **);
+  void coeff(int, char **);
+  void init_style();
+  double init_one(int, int);
+  double memory_usage();
+
+  int pack_comm(int, int *, double *, int, int *);
+  void unpack_comm(int, int, double *);
+  int pack_reverse_comm(int, int, double *);
+  void unpack_reverse_comm(int, int *, double *);
+  
+ private:
+  double cutmax;
+  double rcutvsq,rcutbsq; 
+  int iprune,ihb;
+  double hbcut,swb;
+  double swa;
+  double swc0, swc1, swc2, swc3, swc4, swc5, swc6, swc7;
+  double precision;
+  int packflag;
+
+  struct ff_params {
+    double rcutsq;
+    int np;
+    double *params;
+  };
+  ff_params *param_list;
+  int *map;
+
+  int nentries;
+  double chpot;
+  int *arow_ptr,*acol_ind;
+  double *ch,*elcvec;
+  double *rcg,*wcg,*pcg,*poldcg,*qcg;
+  double *aval;
+  int nmax,matmax;
+
+  void allocate();
+  void read_files(char *, char *);
+  void neigh_f2c(int, int *, int *, int **);
+  void neigh_c2f(int, int *, int *, int **);
+
+  void write_reax_positions();
+  void write_reax_vlist();
+  void read_reax_forces();
+  void read_reax_atom_virial();
+
+  void taper_setup();
+  double taper_E(const double &, const double &);
+  double taper_F(const double &, const double &);
+
+  void compute_charge(double &);
+  void sparse_product(const int &, const int &, const int &, double[],
+		      int[], int[], double[], double[]);
+  void cg_solve(const int &, const int &, double[], int[], 
+		       int[], double[], double[]);
+  void charge_reax(const int &, const int &, double[],
+		   double[], int[], int[], double[]);
+};
+
+}
+
+#endif
diff -Naur lammps-29Jan09/src/REAX/pair_reax_fortran.h lammps-12Feb09/src/REAX/pair_reax_fortran.h
--- lammps-29Jan09/src/REAX/pair_reax_fortran.h	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/REAX/pair_reax_fortran.h	2009-02-11 15:30:27.000000000 -0700
@@ -0,0 +1,202 @@
+/* ----------------------------------------------------------------------
+   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.
+------------------------------------------------------------------------- */
+
+// machine-specific C++ -> Fortran calling syntax
+// CONS(a,b) should return ab, the concatenation of its arguments
+
+#if  __STDC__ 
+#define CONS(a,b) a##b
+#else
+#define CONS(a,b) a/**/b
+#endif
+
+#ifdef _ARDENT
+#define FORTRAN(lcname,ucname)  ucname
+#endif
+
+#ifdef _IBM
+#define FORTRAN(lcname,ucname)  lcname
+#endif
+
+#ifdef _HP
+#define FORTRAN(lcname,ucname)  lcname
+#endif
+
+#ifdef _F2C_LINUX
+#define FORTRAN(lcname,ucname)  CONS(lcname,__)
+#endif
+
+#ifndef FORTRAN
+#define FORTRAN(lcname,ucname)  CONS(lcname,_)
+#endif
+
+// hard-wired array sizes set in Fortran library
+// accesses include file from Fortran library
+
+#include "reax_defs.h"
+
+class ReaxParams {
+ public:
+  enum {nneighmax=NNEIGHMAXDEF, 
+	nat=NATDEF, 
+	nattot=NATTOTDEF, 
+        nsort=NSORTDEF,
+	mbond=MBONDDEF, 
+        nbomax=NBOMAXDEF,
+  };
+};
+
+// data structures corresponding to values in Fortran library
+
+extern struct {
+  double abo[ReaxParams::nat];
+} FORTRAN(cbkabo,CBKABO);
+
+extern struct {
+  double bo[ReaxParams::nbomax];
+} FORTRAN(cbkbo,CBKBO);
+
+extern struct {
+  double c[3*ReaxParams::nat]; double cglobal[3*ReaxParams::nattot];
+  int itag[ReaxParams::nat];
+} FORTRAN(cbkc,CBKC);
+
+extern struct {
+double ch[ReaxParams::nat];
+} FORTRAN(cbkch,CBKCH);
+
+extern struct {
+  double chi[ReaxParams::nsort];
+  double eta[ReaxParams::nsort];
+  double gam[ReaxParams::nsort];
+} FORTRAN(cbkchb,CBKCHB);
+
+extern struct {
+  double d[3*ReaxParams::nat]; double estrain[ReaxParams::nat];
+} FORTRAN(cbkd,CBKD);
+
+extern struct {
+  double atomvirial[6*ReaxParams::nat];
+  double virial[6]; 
+  int Lvirial;
+  int Latomvirial;
+} FORTRAN(cbkvirial,CBKVIRIAL);
+
+extern struct {
+  int ia[ReaxParams::nat*(ReaxParams::mbond+3)];
+  int iag[ReaxParams::nat*(ReaxParams::mbond+3)];
+} FORTRAN(cbkia,CBKIA);
+
+extern struct {
+  double vlp[ReaxParams::nat];
+  double dvlpdsbo[ReaxParams::nat];
+} FORTRAN(cbklonpar,CBKLONPAR);
+
+extern struct {
+  int nubon1[ReaxParams::nat*(ReaxParams::mbond)];
+  int nubon2[ReaxParams::nat*(ReaxParams::mbond)];
+} FORTRAN(cbknubon2,CBKNUBON2);
+
+extern struct {
+  int nvl1[ReaxParams::nneighmax * ReaxParams::nat];
+  int nvl2[ReaxParams::nneighmax * ReaxParams::nat];
+  int nvpair;
+  int nvlself;
+} FORTRAN(cbkpairs,CBKPAIRS);
+
+extern struct {
+  int nvlbo[ReaxParams::nneighmax * ReaxParams::nat];
+} FORTRAN(cbknvlbo,CBKNVLBO);
+
+extern struct {
+  int nvlown[ReaxParams::nneighmax * ReaxParams::nat];
+} FORTRAN(cbknvlown,CBKNVLOWN);
+
+extern struct {
+  char qa[20*ReaxParams::nattot+10];
+} FORTRAN(cbkqa,CBKQA);
+
+extern struct {
+  double eb;
+  double eoop;
+  double epen;
+  double estrc;
+  double deda[3];
+  double pressu;
+  double efi;
+  double elp;
+  double emol;
+  double ea;
+  double eres;
+  double et;
+  double eradbo;
+  double ev;
+  double eco;
+  double ecoa;
+  double ehb;
+  double sw;
+  double ew;
+  double ep;
+  double ekin;
+} FORTRAN(cbkenergies,CBKENERGIES);
+
+extern struct {
+  double tset; 
+  double dseed; 
+  double tempmd; 
+  double ts2; 
+  double ts22; 
+  int nmolo; 
+  int nmolo5; 
+  int nbon; 
+  int na; 
+  int namov;
+  int na_local;
+} FORTRAN(rsmall,RSMALL);
+
+// external routines provided by Fortran library
+
+extern "C" void FORTRAN(readc,READC)();
+extern "C" void FORTRAN(init,INIT)();
+extern "C" void FORTRAN(ffinpt,FFINPT)();
+extern "C" void FORTRAN(tap7th,TAP7TH)();
+extern "C" void FORTRAN(taper,TAPER)(double*,double*);
+extern "C" void FORTRAN(readgeo,READGEO)();
+extern "C" void FORTRAN(srtatom,SRTATOM)();
+extern "C" void FORTRAN(vlist,VLIST) ();
+extern "C" void FORTRAN(srtbon1,SRTBON1)(int*,int*,double*);
+extern "C" void FORTRAN(molec,MOLEC)();
+extern "C" void FORTRAN(encalc,ENCALC)();
+extern "C" void FORTRAN(getswb,GETSWB)(double*);
+extern "C" void FORTRAN(getswa,GETSWA)(double*);
+extern "C" void FORTRAN(getvrange,GET_VRANGE)(double*);
+extern "C" void FORTRAN(getnvlist,GET_NVLIST)(int*);
+extern "C" void FORTRAN(getvlbora,GETVLBORA)(double*);
+extern "C" void FORTRAN(cgsolve,CGSOLVE)
+  (int*,double*,int*,double*,double*,int*);
+extern "C" void FORTRAN(getnval,GETNVAL)(int*);
+extern "C" void FORTRAN(getntor,GETNTOR)(int*);
+extern "C" void FORTRAN(getnhb,GETNHB)(int*);
+extern "C" void FORTRAN(getnbonall,GETNBONALL)(int*);
+extern "C" void FORTRAN(getnneighmax,GETNNEIGHMAX)(int*);
+extern "C" void FORTRAN(getnat,GETNAT)(int*);
+extern "C" void FORTRAN(getnattot,GETNATTOT)(int*);
+extern "C" void FORTRAN(getnsort,GETNSORT)(int*);
+extern "C" void FORTRAN(getmbond,GETMBOND)(int*);
+extern "C" void FORTRAN(getnso,GETNSO)(int*);
+extern "C" void FORTRAN(setngeofor,SETNGEOFOR)(int*);
+extern "C" void FORTRAN(mdsav,MDSAV)(int*);
+extern "C" void FORTRAN(getnsbmax,GETNSBMAX)(int*);
+extern "C" void FORTRAN(getnsbma2,GETNSBMA2)(int*);
+extern "C" void FORTRAN(getcutof3,GETCUTOF3)(double*);
+
diff -Naur lammps-29Jan09/src/REAX/style_reax.h lammps-12Feb09/src/REAX/style_reax.h
--- lammps-29Jan09/src/REAX/style_reax.h	1969-12-31 17:00:00.000000000 -0700
+++ lammps-12Feb09/src/REAX/style_reax.h	2009-02-06 09:42:00.000000000 -0700
@@ -0,0 +1,20 @@
+/* ----------------------------------------------------------------------
+   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 PairInclude
+#include "pair_reax.h"
+#endif
+
+#ifdef PairClass
+PairStyle(reax,PairREAX)
+#endif
diff -Naur lammps-29Jan09/src/neigh_request.cpp lammps-12Feb09/src/neigh_request.cpp
--- lammps-29Jan09/src/neigh_request.cpp	2007-10-03 10:26:20.000000000 -0600
+++ lammps-12Feb09/src/neigh_request.cpp	2009-02-12 13:14:58.000000000 -0700
@@ -38,6 +38,10 @@
   respainner = respamiddle = respaouter = 0;
   half_from_full = 0;
 
+  // default is use newton_pair setting in force
+
+  newton = 0;
+
   // default is every reneighboring
 
   occasional = 0;
@@ -89,6 +93,7 @@
   if (respaouter != other->respaouter) same = 0;
   if (half_from_full != other->half_from_full) same = 0;
 
+  if (newton != other->newton) same = 0;
   if (occasional != other->occasional) same = 0;
   if (dnum != other->dnum) same = 0;
 
@@ -116,29 +121,12 @@
   if (respamiddle != other->respamiddle) same = 0;
   if (respaouter != other->respaouter) same = 0;
   if (half_from_full != other->half_from_full) same = 0;
+  if (newton != other->newton) same = 0;
 
   return same;
 }
 
 /* ----------------------------------------------------------------------
-   set kind value of this request to that of other request
-------------------------------------------------------------------------- */
-
-void NeighRequest::copy_kind(NeighRequest *other)
-{
-  half = 0;
-
-  if (other->half) half = 1;
-  if (other->full) full = 1;
-  if (other->gran) gran = 1;
-  if (other->granhistory) granhistory = 1;
-  if (other->respainner) respainner = 1;
-  if (other->respamiddle) respamiddle = 1;
-  if (other->respaouter) respaouter = 1;
-  if (other->half_from_full) half_from_full = 1;
-}
-
-/* ----------------------------------------------------------------------
    compare skip attributes of this request to other request
    return 1 if same, 0 if different
 ------------------------------------------------------------------------- */
@@ -162,3 +150,23 @@
   return same;
 }
 
+/* ----------------------------------------------------------------------
+   set kind and other values of this request to that of other request
+------------------------------------------------------------------------- */
+
+void NeighRequest::copy_request(NeighRequest *other)
+{
+  half = 0;
+
+  if (other->half) half = 1;
+  if (other->full) full = 1;
+  if (other->gran) gran = 1;
+  if (other->granhistory) granhistory = 1;
+  if (other->respainner) respainner = 1;
+  if (other->respamiddle) respamiddle = 1;
+  if (other->respaouter) respaouter = 1;
+  if (other->half_from_full) half_from_full = 1;
+
+  newton = other->newton;
+  dnum = other->dnum;
+}
diff -Naur lammps-29Jan09/src/neigh_request.h lammps-12Feb09/src/neigh_request.h
--- lammps-29Jan09/src/neigh_request.h	2007-10-04 17:59:26.000000000 -0600
+++ lammps-12Feb09/src/neigh_request.h	2009-02-12 13:14:58.000000000 -0700
@@ -52,6 +52,12 @@
 
   int occasional;
 
+  // 0 if use force::newton_pair setting
+  // 1 if override with pair newton on
+  // 2 if override with pair newton off
+
+  int newton;
+
   // number of auxiliary floating point values to store, 0 if none
   // set by requesting class
 
@@ -74,8 +80,8 @@
   ~NeighRequest();
   int identical(NeighRequest *);
   int same_kind(NeighRequest *);
-  void copy_kind(NeighRequest *);
   int same_skip(NeighRequest *);
+  void copy_request(NeighRequest *);
 };
 
 }
diff -Naur lammps-29Jan09/src/neighbor.cpp lammps-12Feb09/src/neighbor.cpp
--- lammps-29Jan09/src/neighbor.cpp	2008-12-16 12:46:30.000000000 -0700
+++ lammps-12Feb09/src/neighbor.cpp	2009-02-12 13:14:33.000000000 -0700
@@ -750,7 +750,8 @@
    skip -> granular function if gran with granhistory
            respa function if respaouter
 	   skip_from function for everything else
-   half_from_full, half, full, gran, respaouter -> choose by newton and tri
+   half_from_full, half, full, gran, respaouter ->
+     choose by newton and rq->newton and tri settings
      style NSQ options = newton off, newton on
      style BIN options = newton off, newton on and not tri, newton on and tri
      stlye MULTI options = same options as BIN
@@ -776,16 +777,38 @@
 
   } else if (rq->half) {
     if (style == NSQ) {
-      if (newton_pair == 0) pb = &Neighbor::half_nsq_no_newton;
-      else if (newton_pair == 1) pb = &Neighbor::half_nsq_newton;
+      if (rq->newton == 0) {
+	if (newton_pair == 0)
+	  pb = &Neighbor::half_nsq_no_newton;
+	else if (newton_pair == 1)
+	  pb = &Neighbor::half_nsq_newton;
+      } else if (rq->newton == 1) {
+	pb = &Neighbor::half_nsq_newton;
+      } else if (rq->newton == 2) {
+	pb = &Neighbor::half_nsq_no_newton;
+      }
     } else if (style == BIN) {
-      if (newton_pair == 0) pb = &Neighbor::half_bin_no_newton;
-      else if (triclinic == 0) pb = &Neighbor::half_bin_newton;
-      else if (triclinic == 1) pb = &Neighbor::half_bin_newton_tri;
+      if (rq->newton == 0) {
+	if (newton_pair == 0) pb = &Neighbor::half_bin_no_newton;
+	else if (triclinic == 0) pb = &Neighbor::half_bin_newton;
+	else if (triclinic == 1) pb = &Neighbor::half_bin_newton_tri;
+      } else if (rq->newton == 1) {
+	if (triclinic == 0) pb = &Neighbor::half_bin_newton;
+	else if (triclinic == 1) pb = &Neighbor::half_bin_newton_tri;
+      } else if (rq->newton == 2) {
+	pb = &Neighbor::half_bin_no_newton;
+      }
     } else if (style == MULTI) {
-      if (newton_pair == 0) pb = &Neighbor::half_multi_no_newton;
-      else if (triclinic == 0) pb = &Neighbor::half_multi_newton;
-      else if (triclinic == 1) pb = &Neighbor::half_multi_newton_tri;
+      if (rq->newton == 0) {
+	if (newton_pair == 0) pb = &Neighbor::half_multi_no_newton;
+	else if (triclinic == 0) pb = &Neighbor::half_multi_newton;
+	else if (triclinic == 1) pb = &Neighbor::half_multi_newton_tri;
+      } else if (rq->newton == 1) {
+	if (triclinic == 0) pb = &Neighbor::half_multi_newton;
+	else if (triclinic == 1) pb = &Neighbor::half_multi_newton_tri;
+      } else if (rq->newton == 2) {
+	pb = &Neighbor::half_multi_no_newton;
+      } 
     }
 
   } else if (rq->full) {
@@ -836,29 +859,77 @@
 
   else if (rq->half || rq->gran || rq->respaouter) {
     if (style == BIN) {
-      if (newton_pair == 0) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_bin_2d_no_newton;
-	else if (dimension == 3) sc = &Neighbor::stencil_half_bin_3d_no_newton;
-      } else if (triclinic == 0) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_bin_2d_newton;
-	else if (dimension == 3) sc = &Neighbor::stencil_half_bin_3d_newton;
-      } else if (triclinic == 1) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_bin_2d_newton_tri;
-	else if (dimension == 3) 
-	  sc = &Neighbor::stencil_half_bin_3d_newton_tri;
+      if (rq->newton == 0) {
+	if (newton_pair == 0) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_bin_2d_no_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_bin_3d_no_newton;
+	} else if (triclinic == 0) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_bin_2d_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_bin_3d_newton;
+	} else if (triclinic == 1) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_bin_2d_newton_tri;
+	  else if (dimension == 3) 
+	    sc = &Neighbor::stencil_half_bin_3d_newton_tri;
+	}
+      } else if (rq->newton == 1) {
+	if (triclinic == 0) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_bin_2d_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_bin_3d_newton;
+	} else if (triclinic == 1) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_bin_2d_newton_tri;
+	  else if (dimension == 3) 
+	    sc = &Neighbor::stencil_half_bin_3d_newton_tri;
+	}
+      } else if (rq->newton == 2) {
+	if (dimension == 2)
+	  sc = &Neighbor::stencil_half_bin_2d_no_newton;
+	else if (dimension == 3)
+	  sc = &Neighbor::stencil_half_bin_3d_no_newton;
       }
+
     } else if (style == MULTI) {
-      if (newton_pair == 0) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_multi_2d_no_newton;
+      if (rq->newton == 0) {
+	if (newton_pair == 0) {
+	  if (dimension == 2) 
+	    sc = &Neighbor::stencil_half_multi_2d_no_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_multi_3d_no_newton;
+	} else if (triclinic == 0) {
+	  if (dimension == 2) 
+	    sc = &Neighbor::stencil_half_multi_2d_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_multi_3d_newton;
+	} else if (triclinic == 1) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_multi_2d_newton_tri;
+	  else if (dimension == 3) 
+	    sc = &Neighbor::stencil_half_multi_3d_newton_tri;
+	}
+      } else if (rq->newton == 1) {
+	if (triclinic == 0) {
+	  if (dimension == 2) 
+	    sc = &Neighbor::stencil_half_multi_2d_newton;
+	  else if (dimension == 3)
+	    sc = &Neighbor::stencil_half_multi_3d_newton;
+	} else if (triclinic == 1) {
+	  if (dimension == 2)
+	    sc = &Neighbor::stencil_half_multi_2d_newton_tri;
+	  else if (dimension == 3) 
+	    sc = &Neighbor::stencil_half_multi_3d_newton_tri;
+	}
+      } else if (rq->newton == 2) {
+	if (dimension == 2) 
+	  sc = &Neighbor::stencil_half_multi_2d_no_newton;
 	else if (dimension == 3)
 	  sc = &Neighbor::stencil_half_multi_3d_no_newton;
-      } else if (triclinic == 0) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_multi_2d_newton;
-	else if (dimension == 3) sc = &Neighbor::stencil_half_multi_3d_newton;
-      } else if (triclinic == 1) {
-	if (dimension == 2) sc = &Neighbor::stencil_half_multi_2d_newton_tri;
-	else if (dimension == 3) 
-	  sc = &Neighbor::stencil_half_multi_3d_newton_tri;
       }
     }
 
diff -Naur lammps-29Jan09/src/pair.cpp lammps-12Feb09/src/pair.cpp
--- lammps-29Jan09/src/pair.cpp	2009-01-08 14:46:20.000000000 -0700
+++ lammps-12Feb09/src/pair.cpp	2009-02-12 13:42:48.000000000 -0700
@@ -285,11 +285,11 @@
     }
   }
 
-  // if vflag_global = 2
+  // if vflag_global = 2 and pair::compute() calls virial_compute()
   // compute global virial via (F dot r) instead of via pairwise summation
   // unset other flags as appropriate
 
-  if (vflag_global == 2) {
+  if (vflag_global == 2 && no_virial_compute == 0) {
     vflag_fdotr = 1;
     vflag_global = 0;
     if (vflag_atom == 0) vflag_either = 0;
diff -Naur lammps-29Jan09/src/pair_hybrid.cpp lammps-12Feb09/src/pair_hybrid.cpp
--- lammps-29Jan09/src/pair_hybrid.cpp	2009-01-05 15:26:08.000000000 -0700
+++ lammps-12Feb09/src/pair_hybrid.cpp	2009-02-12 13:42:48.000000000 -0700
@@ -71,14 +71,14 @@
 {
   int i,j,m,n;
 
-  // if no_virial_compute is set and global component of incoming vflag = 2,
-  // reset vflag as if it were 1
+  // if no_virial_compute is set and global component of incoming vflag = 2
+  // reset vflag as if global component were 1
   // necessary since one or more sub-styles cannot compute virial as F dot r
   
   if (no_virial_compute && vflag % 4 == 2) vflag = 1 + vflag/4 * 4;
 
   if (eflag || vflag) ev_setup(eflag,vflag);
-  else evflag = 0;
+  else evflag = vflag_fdotr = 0;
 
   // check if global component of incoming vflag = 2
   // if so, reset vflag passed to substyle as if it were 0
@@ -506,8 +506,7 @@
     if (j < neighbor->nrequest) irq->otherlist = j;
     else {
       int newrequest = neighbor->request(this);
-      neighbor->requests[newrequest]->copy_kind(irq);
-      neighbor->requests[newrequest]->dnum = irq->dnum;
+      neighbor->requests[newrequest]->copy_request(irq);
       irq->otherlist = newrequest;
     }
 
diff -Naur lammps-29Jan09/src/style.h lammps-12Feb09/src/style.h
--- lammps-29Jan09/src/style.h	2009-01-19 10:26:01.000000000 -0700
+++ lammps-12Feb09/src/style.h	2009-02-06 10:05:46.000000000 -0700
@@ -364,6 +364,7 @@
 #include "style_opt.h"
 #include "style_peri.h"
 #include "style_poems.h"
+#include "style_reax.h"
 #include "style_xtc.h"
 
 // user add-ons: individual classes and packages